mirror of
https://github.com/wassname/segpy.git
synced 2026-06-27 19:48:48 +08:00
Relocate segpy.ext.numpyext to a separately deployable package segpy-numpy which using pkg_resources entry points to deploy itself into segpy.ext at runtime.
This commit is contained in:
@@ -21,17 +21,15 @@ Example:
|
||||
from __future__ import print_function
|
||||
|
||||
import argparse
|
||||
|
||||
import os
|
||||
|
||||
import sys
|
||||
import traceback
|
||||
|
||||
from segpy.reader import create_reader
|
||||
from segpy.ext.numpyext import make_dtype
|
||||
|
||||
import numpy as np
|
||||
|
||||
from segpy.reader import create_reader
|
||||
from segpy_numpy.numpy.dtypes import make_dtype
|
||||
|
||||
|
||||
class DimensionalityError(Exception):
|
||||
pass
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
Segpy-Numpy offers tools for working with both *Segpy* and *Numpy*. See the *Segpy* documentation for further details.
|
||||
|
||||
|
||||
What It Does
|
||||
============
|
||||
|
||||
How To Get It
|
||||
=============
|
||||
|
||||
*Segpy-Numpy* is available on the Python Package index and can be installed with ``pip``::
|
||||
|
||||
$ pip install segpy-numpy
|
||||
|
||||
|
||||
Requirements
|
||||
============
|
||||
|
||||
*Segpy-Numpy* should work with Python 3.2 and higher (and 2.7 for now). For the majority of use *Segpy 2* has no
|
||||
externaldependencies. Optional modules with further dependencies such as *Numpy* are included in the ``segpy.ext``
|
||||
package of extras.
|
||||
@@ -0,0 +1 @@
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
print("segpy_numpy.__init__ imported")
|
||||
|
||||
from pkgutil import extend_path
|
||||
|
||||
#__path__ = extend_path(__path__, __name__)
|
||||
__version__ = '2.0.0a1'
|
||||
|
||||
|
||||
def load():
|
||||
pass
|
||||
@@ -0,0 +1 @@
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
[bdist_wheel]
|
||||
# This flag says that the code is written to work on both Python 2 and Python
|
||||
# 3. If at all possible, it is good practice to do this. If you cannot, you
|
||||
# will need to generate wheels for each Python version that you support.
|
||||
universal=1
|
||||
@@ -0,0 +1,127 @@
|
||||
import io
|
||||
import os
|
||||
import re
|
||||
from setuptools import setup, find_packages # Always prefer setuptools over distutils
|
||||
from codecs import open # To use a consistent encoding
|
||||
from os import path
|
||||
|
||||
|
||||
def read(*names, **kwargs):
|
||||
with io.open(
|
||||
os.path.join(os.path.dirname(__file__), *names),
|
||||
encoding=kwargs.get("encoding", "utf8")
|
||||
) as fp:
|
||||
return fp.read()
|
||||
|
||||
|
||||
def find_version(*file_paths):
|
||||
version_file = read(*file_paths)
|
||||
version_match = re.search(r"^__version__ = ['\"]([^'\"]*)['\"]",
|
||||
version_file, re.M)
|
||||
if version_match:
|
||||
return version_match.group(1)
|
||||
raise RuntimeError("Unable to find version string.")
|
||||
|
||||
|
||||
here = path.abspath(path.dirname(__file__))
|
||||
|
||||
|
||||
def local_file(name):
|
||||
return os.path.join(here, name)
|
||||
|
||||
|
||||
|
||||
# Get the long description from the relevant file
|
||||
with open(local_file('DESCRIPTION.rst'), encoding='utf-8') as f:
|
||||
long_description = f.read()
|
||||
|
||||
setup(
|
||||
name='segpy-numpy',
|
||||
|
||||
# Versions should comply with PEP440. For a discussion on single-sourcing
|
||||
# the version across setup.py and the project code, see
|
||||
# https://packaging.python.org/en/latest/single_source_version.html
|
||||
version=find_version("segpy_numpy/__init__.py"),
|
||||
|
||||
description='Interoperability between Numpy with Segpy.',
|
||||
long_description=long_description,
|
||||
|
||||
# The project's main homepage.
|
||||
url='https://github.com/rob-smallshire/segpy',
|
||||
|
||||
# Author details
|
||||
author='Robert Smallshire',
|
||||
author_email='robert@smallshire.org.uk',
|
||||
|
||||
# Choose your license
|
||||
license='GPL',
|
||||
|
||||
# See https://pypi.python.org/pypi?%3Aaction=list_classifiers
|
||||
classifiers=[
|
||||
# How mature is this project? Common values are
|
||||
# 3 - Alpha
|
||||
# 4 - Beta
|
||||
# 5 - Production/Stable
|
||||
'Development Status :: 3 - Alpha',
|
||||
|
||||
# Indicate who your project is intended for
|
||||
'Intended Audience :: Developers',
|
||||
'Topic :: Scientific/Engineering',
|
||||
'Topic :: Software Development :: Libraries',
|
||||
|
||||
# Pick your license as you wish (should match "license" above)
|
||||
'License :: OSI Approved :: MIT License',
|
||||
|
||||
# Specify the Python versions you support here. In particular, ensure
|
||||
# that you indicate whether you support Python 2, Python 3 or both.
|
||||
'Programming Language :: Python :: 2.7',
|
||||
'Programming Language :: Python :: 3',
|
||||
'Programming Language :: Python :: 3.3',
|
||||
'Programming Language :: Python :: 3.4',
|
||||
],
|
||||
|
||||
# What does your project relate to?
|
||||
keywords='seismic geocomputing geophysics numpy',
|
||||
|
||||
# You can just specify the packages manually here if your project is
|
||||
# simple. Or you can use find_packages().
|
||||
packages=find_packages(here, exclude=['segpy', 'contrib', 'docs', 'test*']),
|
||||
|
||||
# List run-time dependencies here. These will be installed by pip when your
|
||||
# project is installed. For an analysis of "install_requires" vs pip's
|
||||
# requirements files see:
|
||||
# https://packaging.python.org/en/latest/requirements.html
|
||||
install_requires=['numpy'],
|
||||
|
||||
# List additional groups of dependencies here (e.g. development dependencies).
|
||||
# You can install these using the following syntax, for example:
|
||||
# $ pip install -e .[dev,test]
|
||||
extras_require = {
|
||||
'dev': ['check-manifest', 'wheel'],
|
||||
'doc': ['sphinx', 'cartouche'],
|
||||
'test': ['coverage', 'hypothesis'],
|
||||
},
|
||||
|
||||
# If there are data files included in your packages that need to be
|
||||
# installed, specify them here. If using Python 2.6 or less, then these
|
||||
# have to be included in MANIFEST.in as well.
|
||||
package_data={
|
||||
},
|
||||
|
||||
# Although 'package_data' is the preferred approach, in some case you may
|
||||
# need to place data files outside of your packages.
|
||||
# see http://docs.python.org/3.4/distutils/setupscript.html#installing-additional-files
|
||||
# In this case, 'data_file' will be installed into '<sys.prefix>/my_data'
|
||||
data_files=[],
|
||||
|
||||
# To provide executable scripts, use entry points in preference to the
|
||||
# "scripts" keyword. Entry points provide cross-platform support and allow
|
||||
# pip to create the appropriate form of executable for the target platform.
|
||||
|
||||
# Declare entry-points to modules.
|
||||
entry_points={
|
||||
'segpy.ext': 'segpy-numpy = segpy_numpy'
|
||||
},
|
||||
)
|
||||
|
||||
|
||||
@@ -1 +1,15 @@
|
||||
import pkg_resources
|
||||
|
||||
loaded = set()
|
||||
|
||||
|
||||
def load_entry_points(name=None):
|
||||
for entry_point in pkg_resources.iter_entry_points(group='segpy.ext', name=name):
|
||||
package = entry_point.load()
|
||||
if package not in loaded:
|
||||
loaded.add(package)
|
||||
__path__.extend(package.__path__)
|
||||
package.load()
|
||||
|
||||
|
||||
load_entry_points()
|
||||
|
||||
Reference in New Issue
Block a user