diff --git a/.github/workflows/python-package.yml b/.github/workflows/python-package.yml index 0a3b023..cace778 100644 --- a/.github/workflows/python-package.yml +++ b/.github/workflows/python-package.yml @@ -15,7 +15,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - python-version: ['3.10'] + python-version: ['3.9'] steps: - uses: actions/checkout@v3 @@ -23,7 +23,13 @@ jobs: uses: actions/setup-python@v4 with: python-version: ${{ matrix.python-version }} - + - id: cache-dependencies + name: Cache dependencies + uses: actions/cache@v2.1.7 + with: + path: ${{ github.workspace }}/.venv + key: dependencies-${{ hashFiles('**/poetry.lock') }} + restore-keys: dependencies- - name: Install dependencies run: | python -m pip install --upgrade pip @@ -37,7 +43,12 @@ jobs: flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics - name: Test a minimal install run: | - pip install . + python -m pip install -U pip poetry + poetry --version + poetry check --no-interaction + poetry config virtualenvs.in-project true + poetry install --no-interaction + # pip install . python tests/test_minimal.py - name: Install APT and dependencies On Linux run: | diff --git a/.gitignore b/.gitignore index c11384c..8d11dc4 100644 --- a/.gitignore +++ b/.gitignore @@ -21,4 +21,7 @@ key.asc .~* VERSION* +*.lock +setup.py + test/test_data/*.xlsx \ No newline at end of file diff --git a/project.toml b/project.toml deleted file mode 100644 index c69c209..0000000 --- a/project.toml +++ /dev/null @@ -1,21 +0,0 @@ -[build-system] -build-backend = "setuptools.build_meta" -requires = ["setuptools >= 40.8", "wheel"] - -[tool.ruff] -select = [ - "E", "F", # the default rules - "T201", # disallow print statements - "B" # pass bugbear -] - #"I001", # isort - #"D"] # pydocstyle -ignore = [ - "B905", # `zip()` without an explicit `strict=` - "B904", # `raise ... from err` seems a bit silly - "B018" # useless expression ideally ignore only on `tests` -] -line-length = 90 - -[tool.ruff.pydocstyle] -convention = "numpy" \ No newline at end of file diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 0000000..0789fdc --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,80 @@ +[tool.poetry] +name = "welleng" +version = "0.7.3" +description = "A collection of Well Engineering tools" +authors = ["Jonathan Corcutt "] +license = "Apache-2.0" +readme = "README.md" +homepage = "https://github.com/jonnymaserati/welleng" +repository = "https://github.com/python-poetry/poetry" +documentation = "https://jonnymaserati.github.io/welleng/build/html/index.html" +keywords = [ + "well", + "trajectory", + "wellpath", + "wellbore", + "drilling", + "drill", + "error", + "separation", + "minimum curvature", + "iscwsa", + "owsg", + "well engineering", + "wells", + "drilling engineering", + "directional drilling", + "mwd", + "survey", + "covariance", + "digitalization", + "automation", + "volve", + "witsml", +] +classifiers = [ + "Development Status :: 4 - Beta", + "License :: OSI Approved :: Apache Software License", + "Programming Language :: Python :: 3.9", + "Programming Language :: Python :: 3.10", + "Natural Language :: English", + "Topic :: Scientific/Engineering", +] +include = [ + {path = "errors/*.yaml"}, + {path = "errors/tool_codes/*.yaml"}, + {path = "exchange/*.yaml"} +] +exclude = [ + "tests/*.py" +] + +[tool.poetry.dependencies] +python = ">=3.9, <3.12" +numpy = "^1.18" +scipy = "^1.10.1" +Pint = "^0.20.1" +PyYAML = "^6.0" +vtk = "^9.2.6" +magnetic-field-calculator = {version="^1.0.2", optional=true} +networkx = {version="^3.0", optional=true} +openpyxl = {version="^3.1.2", optional=true} +pandas = {version="^1.5.3", optional=true} +tabulate = {version="^0.9.0", optional=true} +trimesh = {version="^3.21.3", optional=true} +utm = {version="^0.7.0", optional=true} +vedo = {version="^2023.4.4", optional=true} +python-fcl = {version="^0.7.0", optional=true} + +[tool.poetry.dev-dependencies] +# numba = {version="^0.56.4", optional=true} + +[tool.poetry.extras] +easy = ["magnetic-field-calculator", "networkx", "openpyxl", "pandas", + "tabulate", "trimesh", "utm", "vedo"] +advanced = ["magnetic-field-calculator", "networkx", "openpyxl", "pandas", + "tabulate", "trimesh", "utm", "vedo", "python-fcl"] + +[build-system] +requires = ["poetry-core>=1.0.0"] +build-backend = "poetry.core.masonry.api" diff --git a/requirements.txt b/requirements.txt deleted file mode 100644 index 945c9b4..0000000 --- a/requirements.txt +++ /dev/null @@ -1 +0,0 @@ -. \ No newline at end of file diff --git a/setup.cfg b/setup.cfg deleted file mode 100644 index 224a779..0000000 --- a/setup.cfg +++ /dev/null @@ -1,2 +0,0 @@ -[metadata] -description-file = README.md \ No newline at end of file diff --git a/setup.py b/setup.py deleted file mode 100644 index cb52d9d..0000000 --- a/setup.py +++ /dev/null @@ -1,127 +0,0 @@ -""" -The different setup versions method is shamelessly copied from mikedh's trimesh -Python library - thank you! -""" - -import os -import sys -from setuptools import setup, find_packages - -# load __version__ without importing anything -version_file = os.path.join( - os.path.dirname(__file__), - 'welleng/version.py') -with open(version_file, 'r') as f: - # use eval to get a clean string of version from file - __version__ = eval(f.read().strip().split('=')[-1]) - -with open("README.md", "r") as f: - long_description = f.read() - -# with open("requirements.txt") as f: -# required = f.read().splitlines() - -download_url = f'https://github.com/jonnymaserati/welleng/archive/v{__version__}.tar.gz' - -# If you only want to generate surveys and errors, these are all that's -# required -requirements_default = set([ - 'numpy', - 'scipy', - 'pint', - 'PyYAML', - 'setuptools', - 'vtk' -]) - -# these can be installed without compiling required -requirements_easy = set([ - 'magnetic_field_calculator', # used to get default mag data for survey - 'networkx', - 'openpyxl', - 'pandas', - 'tabulate', - 'trimesh', - 'utm', - 'vedo', -]) - -# this is the troublesome requirement that needs C dependencies -requirements_all = requirements_easy.union([ - 'python-fcl', -]) - -# if someone wants to output a requirements file -# `python setup.py --list-all > requirements.txt` -if '--list-all' in sys.argv: - # will not include default requirements (numpy) - print('\n'.join(requirements_all)) - exit() -elif '--list-easy' in sys.argv: - # again will not include numpy+setuptools - print('\n'.join(requirements_easy)) - exit() - -# if sys.platform == 'win32': -# requirements_all.append('python-fcl-win32') -# else: -# requirements_all.append('python-fcl') - -setup( - name='welleng', - version=__version__, - description='A collection of Well Engineering tools', - long_description=long_description, - long_description_content_type="text/markdown", - url='https://github.com/jonnymaserati/welleng', - download_url=download_url, - keywords=[ - 'well', - 'trajectory', - 'wellpath', - 'wellbore', - 'drilling', - 'drill', - 'error', - 'separation', - 'minimum curvature', - 'iscwsa', - 'owsg', - 'well engineering', - 'wells', - 'drilling engineering', - 'directional drilling', - 'mwd', - 'survey', - 'covariance', - 'digitalization', - 'automation', - 'volve', - 'witsml', - ], - author='Jonathan Corcutt', - author_email='jonnycorcutt@gmail.com', - license='Apache 2.0', - classifiers=[ - 'Development Status :: 4 - Beta', - 'License :: OSI Approved :: Apache Software License', - 'Programming Language :: Python :: 3.9', - 'Programming Language :: Python :: 3.10', - 'Natural Language :: English', - 'Topic :: Scientific/Engineering', - ], - # python_requires='>=3.9', - packages=find_packages(exclude=["tests"]), - package_data={ - 'welleng': [ - 'errors/*.yaml', - 'errors/tool_codes/*.yaml', - 'exchange/*.yaml' - ] - }, - install_requires=list(requirements_default), - extras_require={ - 'easy': list(requirements_easy), - 'all': list(requirements_all) - } -) diff --git a/welleng/survey.py b/welleng/survey.py index 52f8f8f..7d763f7 100644 --- a/welleng/survey.py +++ b/welleng/survey.py @@ -10,7 +10,8 @@ from scipy.optimize import minimize from scipy.spatial.transform import Rotation as R -from .version import __version__ +from .version import __version__ as VERSION + from .utils import ( MinCurve, get_nev, @@ -1930,7 +1931,7 @@ def export_csv( author = kwargs.get('author', 'Jonny Corcutt') comments = [ - f"welleng, version: {__version__}\n" + f"welleng, version: {VERSION}\n" f"author, {author}\n" ] comments.extend([ diff --git a/welleng/version.py b/welleng/version.py index 1ef1319..c4f01ad 100644 --- a/welleng/version.py +++ b/welleng/version.py @@ -1 +1,3 @@ -__version__ = '0.7.3' +import importlib.metadata + +__version__ = importlib.metadata.version('welleng') # in case I missed one