diff --git a/.github/workflows/python-build-test.yml b/.github/workflows/python-build-test.yml index 20144d6..5fc75a1 100644 --- a/.github/workflows/python-build-test.yml +++ b/.github/workflows/python-build-test.yml @@ -14,7 +14,8 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - python-version: ['3.8', '3.9', '3.10', '3.11'] + python-version: ['3.8', '3.9', '3.10', '3.11', '3.12'] + steps: - uses: actions/checkout@v4 - name: Set up Python ${{ matrix.python-version }} @@ -24,12 +25,9 @@ jobs: - name: Install dependencies run: | python -m pip install --upgrade pip - pip install . - pip install -r test_requirements.txt + python -m pip install .[dev,test] - name: Lint with flake8 and black run: | - pip install flake8 - pip install black # stop the build if there are Python syntax errors or undefined names flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics # test remaining issues @@ -38,7 +36,6 @@ jobs: - name: Test run: | pytest . - - name: Run Examples run: | open_petro_elastic --data-file examples/example1.csv examples/example1.yaml diff --git a/.github/workflows/python-publish.yml b/.github/workflows/python-publish.yml index 0045b54..22d6252 100644 --- a/.github/workflows/python-publish.yml +++ b/.github/workflows/python-publish.yml @@ -2,7 +2,7 @@ name: Publish to PyPI on: release: - types: [created] + types: [published] jobs: deploy: @@ -16,11 +16,11 @@ jobs: - name: Install dependencies run: | python -m pip install --upgrade pip - pip install setuptools wheel twine - - name: Build and publish - env: - TWINE_USERNAME: __token__ - TWINE_PASSWORD: ${{ secrets.PYPI_TOKEN }} - run: | - python setup.py sdist bdist_wheel - twine upload dist/* + python -m pip install .[dev] + - name: Build package + run: python -m build + - name: Publish package + uses: pypa/gh-action-pypi-publish@v1 + with: + user: __token__ + password: ${{ secrets.PYPI_TOKEN }} diff --git a/.github/workflows/python-sphinx-doc.yml b/.github/workflows/python-sphinx-doc.yml index c1dc07b..84e70eb 100644 --- a/.github/workflows/python-sphinx-doc.yml +++ b/.github/workflows/python-sphinx-doc.yml @@ -14,12 +14,11 @@ jobs: - name: Set up Python uses: actions/setup-python@v5 with: - python-version: '3.x' + python-version: '3.11' - name: Install dependencies run: | python -m pip install --upgrade pip - pip install . - pip install -r doc_requirements.txt + python -m pip install .[docs] - name: Generate documentation run: | sphinx-build docs docs_out/ diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 0450c24..2b9d3f9 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -37,7 +37,7 @@ We expect commit messages to follow the style described [here](https://chris.bea You can build the documentation after installation by running: ```bash -pip install -r dev-requirements.txt +python -m pip install .[docs] sphinx-build -n -v -E -W ./docs ./tmp/ope_docs ``` diff --git a/README.md b/README.md index 1fa901d..7cdc87f 100644 --- a/README.md +++ b/README.md @@ -9,7 +9,7 @@ A Python library for petro-elastic modelling. It contains a `Material` class for pip install open_petro_elastic ``` -Developers and contributors can download the repository and do `pip install .` to install the package. +Developers and contributors can download the repository and do `pip install ".[dev,test,docs]"` to install the package with all its dependencies for development, testing, and building the docs. ## Usage diff --git a/doc_requirements.txt b/doc_requirements.txt deleted file mode 100644 index 43d3e9d..0000000 --- a/doc_requirements.txt +++ /dev/null @@ -1,6 +0,0 @@ -sphinx -sphinx-rtd-theme -sphinx-argparse -matplotlib -recommonmark -pygments-csv-lexer diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 0000000..43277ef --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,90 @@ +[build-system] +requires = ["setuptools>=68", "setuptools-scm>=8"] +build-backend = "setuptools.build_meta" + +[project] +name="open_petro_elastic" +dynamic = ["version"] +requires-python = ">=3.8" +authors = [{ name="Equinor", email="fg_sib-scout@equinor.com" },] +description="Utility for calculating elastic properties of rocks and fluids." +license = {file = "LICENSE"} +readme = "README.md" +keywords = ["geophysics", "rock physics", "materials science"] +classifiers=[ + "Development Status :: 3 - Alpha", + "License :: OSI Approved :: GNU Lesser General Public License v3 or later (LGPLv3+)", + "Intended Audience :: Science/Research", + "Topic :: Scientific/Engineering :: Hydrology", + "Topic :: Scientific/Engineering :: Physics", + "Natural Language :: English", + "Operating System :: OS Independent", + "Programming Language :: Python :: 3.8", + "Programming Language :: Python :: 3.9", + "Programming Language :: Python :: 3.10", + "Programming Language :: Python :: 3.11", + "Programming Language :: Python :: 3.12", +] +dependencies = [ + "numpy<2", + "scipy", + "pyyaml", + "pandas", + "pydantic", + "sympy", + "typing_extensions", +] + +[project.optional-dependencies] +test = [ + "pytest", + "syrupy", + "hypothesis", + "matplotlib", + "pillow>=10.0.0", # Not directly required, pinned by Snyk to avoid a vulnerability + "Flake8-pyproject", # Work around Flake8 incompatibility with pyproject.toml +] +docs = [ + "sphinx", + "sphinx-rtd-theme", + "sphinx-argparse", + "matplotlib", + "recommonmark", + "pygments-csv-lexer", +] +dev = [ + "build", + "setuptools", + "flake8", + "black", + "isort", + "mypy", +] + +[project.urls] +"documentation" = "https://equinor.github.io/open_petro_elastic" +"repository" = "https://github.com/equinor/open_petro_elastic" + +[project.scripts] +open_petro_elastic = "open_petro_elastic.__main__:main" + +[project.entry-points."open_petro_elastic.fluid_model_providers"] +batzle_wang = "open_petro_elastic.config.fluid_model_providers:BatzleWangFluidModelProvider" +span_wagner = "open_petro_elastic.config.fluid_model_providers:SpanWagnerFluidModelProvider" + +[tool.setuptools.packages.find] +where = ["src"] + +[tool.setuptools.package-data] +open_petro_elastic = ["tutorial_config/*"] +"open_petro_elastic.material.span_wagner.tables" = [ + "material/span_wagner/tables/carbon_dioxide_density.npz" +] + +[tool.flake8] +max-line-length = 88 +ignore = ["E302", "W503", "E501", "E741", "E203", "F405"] +per-file-ignores = [ + "__init__.py:F401,F403", + "conftest.py: F401,F403", +] diff --git a/requirements.txt b/requirements.txt deleted file mode 100644 index ca45463..0000000 --- a/requirements.txt +++ /dev/null @@ -1,7 +0,0 @@ -numpy -pyyaml -quantities -pandas -scipy -sympy -pydantic diff --git a/setup.cfg b/setup.cfg deleted file mode 100644 index bfcde4a..0000000 --- a/setup.cfg +++ /dev/null @@ -1,11 +0,0 @@ -[flake8] -ignore = E302, W503, E501, E741, E203, F405 -max-line-length = 88 -per-file-ignores = - __init__.py: F401,F403 - conftest.py: F401,F403 -[build_sphinx] -all-files = 1 -source-dir = docs -build-dir = docs_out -warning-is-error = 1 diff --git a/setup.py b/setup.py deleted file mode 100644 index 1bb21d1..0000000 --- a/setup.py +++ /dev/null @@ -1,57 +0,0 @@ -from pathlib import Path - -from setuptools import find_packages, setup - - -def get_long_description() -> str: - return Path("README.md").read_text(encoding="utf8") - - -setup( - name="open_petro_elastic", - author="Equinor", - author_email="fg_sib-scout@equinor.com", - license="LGPL", - url="https://github.com/equinor/open_petro_elastic", - description="Utility for calculating elastic properties of petroleum fields.", - long_description=get_long_description(), - long_description_content_type="text/markdown", - use_scm_version=True, - setup_requires=["setuptools_scm"], - entry_points={ - "console_scripts": ["open_petro_elastic = open_petro_elastic.__main__:main"], - "open_petro_elastic.fluid_model_providers": [ - "batzle_wang = open_petro_elastic.config.fluid_model_providers:BatzleWangFluidModelProvider", - "span_wagner = open_petro_elastic.config.fluid_model_providers:SpanWagnerFluidModelProvider", - ], - }, - package_dir={"": "src"}, - packages=find_packages(where="src"), - install_requires=[ - "numpy<2", - "scipy", - "pyyaml", - "pandas", - "pydantic", - "sympy", - "typing_extensions", - ], - platforms="any", - classifiers=[ - "Development Status :: 1 - Planning", - "License :: OSI Approved :: GNU Lesser General Public License v3 or later (LGPLv3+)", - "Programming Language :: Python", - "Programming Language :: Python :: 3.8", - "Programming Language :: Python :: 3.9", - "Programming Language :: Python :: 3.10", - "Programming Language :: Python :: 3.11", - ], - python_requires=">=3.8", - include_package_data=True, - package_data={ - "open_petro_elastic": ["tutorial_config/*"], - "open_petro_elastic.material.span_wagner.tables": [ - "material/span_wagner/tables/carbon_dioxide_density.npz" - ], - }, -) diff --git a/test_requirements.txt b/test_requirements.txt deleted file mode 100644 index 2cc2e09..0000000 --- a/test_requirements.txt +++ /dev/null @@ -1,5 +0,0 @@ -pytest -snapshottest -hypothesis -matplotlib -pillow>=10.0.0 # not directly required, pinned by Snyk to avoid a vulnerability diff --git a/tests/__snapshots__/test_config_fluids.ambr b/tests/__snapshots__/test_config_fluids.ambr new file mode 100644 index 0000000..c988e04 --- /dev/null +++ b/tests/__snapshots__/test_config_fluids.ambr @@ -0,0 +1,4 @@ +# serializer version: 1 +# name: test_fluids_vectorized + Material(shear_modulus=0, bulk_modulus=[1.64734606e+08 1.83184882e+08], primary_velocity=[1144.72360384 1021.36998928], secondary_velocity=[0. 0.], density=[125.71397711 175.59956795]) +# --- diff --git a/tests/__snapshots__/test_depth_trend.ambr b/tests/__snapshots__/test_depth_trend.ambr new file mode 100644 index 0000000..803f7f6 --- /dev/null +++ b/tests/__snapshots__/test_depth_trend.ambr @@ -0,0 +1,7 @@ +# serializer version: 1 +# name: test_dryrock_depthtrend_k_my + Material(shear_modulus=[12.], bulk_modulus=[20.], primary_velocity=[0.1165543], secondary_velocity=[0.06729266], density=[2650.]) +# --- +# name: test_dryrock_depthtrend_vp_vs + Material(shear_modulus=[12.], bulk_modulus=[20.], primary_velocity=[0.1165543], secondary_velocity=[0.06729266], density=[2650.]) +# --- diff --git a/tests/__snapshots__/test_dryrock.ambr b/tests/__snapshots__/test_dryrock.ambr new file mode 100644 index 0000000..23502b6 --- /dev/null +++ b/tests/__snapshots__/test_dryrock.ambr @@ -0,0 +1,13 @@ +# serializer version: 1 +# name: test_dryrock_phi_fitted_vp_vs + tuple( + Material(shear_modulus=[7.6585e+09], bulk_modulus=[1.20751667e+10], primary_velocity=[2900.], secondary_velocity=[1700.], density=[2650.]), + Material(shear_modulus=44.0, bulk_modulus=36.8, primary_velocity=0.18980294316133353, secondary_velocity=0.128855630784633, density=2650.0), + ) +# --- +# name: test_dryrock_phi_k_my + tuple( + Material(shear_modulus=[12.], bulk_modulus=[20.], primary_velocity=[0.1165543], secondary_velocity=[0.06729266], density=[2650.]), + Material(shear_modulus=44.0, bulk_modulus=36.8, primary_velocity=0.18980294316133353, secondary_velocity=0.128855630784633, density=2650.0), + ) +# --- diff --git a/tests/__snapshots__/test_fluid_substitution.ambr b/tests/__snapshots__/test_fluid_substitution.ambr new file mode 100644 index 0000000..79f5009 --- /dev/null +++ b/tests/__snapshots__/test_fluid_substitution.ambr @@ -0,0 +1,4 @@ +# serializer version: 1 +# name: test_fluid_substitution + Material(shear_modulus=[1.], bulk_modulus=[1.94708995], primary_velocity=[1.28070748], secondary_velocity=[0.70710678], density=[2.]) +# --- diff --git a/tests/__snapshots__/test_murphy_coordination_number.ambr b/tests/__snapshots__/test_murphy_coordination_number.ambr new file mode 100644 index 0000000..3ec6491 --- /dev/null +++ b/tests/__snapshots__/test_murphy_coordination_number.ambr @@ -0,0 +1,4 @@ +# serializer version: 1 +# name: test_murphy_coordination_number + 17.555560500000002 +# --- diff --git a/tests/__snapshots__/test_pressure.ambr b/tests/__snapshots__/test_pressure.ambr new file mode 100644 index 0000000..185276d --- /dev/null +++ b/tests/__snapshots__/test_pressure.ambr @@ -0,0 +1,10 @@ +# serializer version: 1 +# name: test_pressure_dependency_no_pressure_exp_fit + Material(shear_modulus=1.0, bulk_modulus=0.9999999999999998, primary_velocity=1.5275252316519465, secondary_velocity=1.0, density=1.0) +# --- +# name: test_pressure_dependency_no_pressure_poly_fit + Material(shear_modulus=1.0, bulk_modulus=0.9999999999999998, primary_velocity=1.5275252316519465, secondary_velocity=1.0, density=1.0) +# --- +# name: test_pressure_dependency_no_pressure_power_fit + Material(shear_modulus=1.0, bulk_modulus=0.9999999999999998, primary_velocity=1.5275252316519465, secondary_velocity=1.0, density=1.0) +# --- diff --git a/tests/snapshots/__init__.py b/tests/snapshots/__init__.py deleted file mode 100644 index e69de29..0000000 diff --git a/tests/snapshots/snap_test_config_fluids.py b/tests/snapshots/snap_test_config_fluids.py deleted file mode 100644 index c7496fa..0000000 --- a/tests/snapshots/snap_test_config_fluids.py +++ /dev/null @@ -1,12 +0,0 @@ -# -*- coding: utf-8 -*- -# snapshottest: v1 - https://goo.gl/zC4yUc -from __future__ import unicode_literals - -from snapshottest import GenericRepr, Snapshot - - -snapshots = Snapshot() - -snapshots["test_fluids_vectorized 1"] = GenericRepr( - "Material(shear_modulus=0, bulk_modulus=[1.64734606e+08 1.83184882e+08], primary_velocity=[1144.72360384 1021.36998928], secondary_velocity=[0. 0.], density=[125.71397711 175.59956795])" -) diff --git a/tests/snapshots/snap_test_depth_trend.py b/tests/snapshots/snap_test_depth_trend.py deleted file mode 100644 index b6c6d7d..0000000 --- a/tests/snapshots/snap_test_depth_trend.py +++ /dev/null @@ -1,16 +0,0 @@ -# -*- coding: utf-8 -*- -# snapshottest: v1 - https://goo.gl/zC4yUc -from __future__ import unicode_literals - -from snapshottest import GenericRepr, Snapshot - - -snapshots = Snapshot() - -snapshots["test_dryrock_depthtrend_k_my 1"] = GenericRepr( - "Material(shear_modulus=[12.], bulk_modulus=[20.], primary_velocity=[0.1165543], secondary_velocity=[0.06729266], density=[2650.])" -) - -snapshots["test_dryrock_depthtrend_vp_vs 1"] = GenericRepr( - "Material(shear_modulus=[12.], bulk_modulus=[20.], primary_velocity=[0.1165543], secondary_velocity=[0.06729266], density=[2650.])" -) diff --git a/tests/snapshots/snap_test_dryrock.py b/tests/snapshots/snap_test_dryrock.py deleted file mode 100644 index a02879c..0000000 --- a/tests/snapshots/snap_test_dryrock.py +++ /dev/null @@ -1,26 +0,0 @@ -# -*- coding: utf-8 -*- -# snapshottest: v1 - https://goo.gl/zC4yUc -from __future__ import unicode_literals - -from snapshottest import GenericRepr, Snapshot - - -snapshots = Snapshot() - -snapshots["test_dryrock_phi_fitted_vp_vs 1"] = ( - GenericRepr( - "Material(shear_modulus=[7.6585e+09], bulk_modulus=[1.20751667e+10], primary_velocity=[2900.], secondary_velocity=[1700.], density=[2650.])" - ), - GenericRepr( - "Material(shear_modulus=44.0, bulk_modulus=36.8, primary_velocity=0.18980294316133353, secondary_velocity=0.128855630784633, density=2650.0)" - ), -) - -snapshots["test_dryrock_phi_k_my 1"] = ( - GenericRepr( - "Material(shear_modulus=[12.], bulk_modulus=[20.], primary_velocity=[0.1165543], secondary_velocity=[0.06729266], density=[2650.])" - ), - GenericRepr( - "Material(shear_modulus=44.0, bulk_modulus=36.8, primary_velocity=0.18980294316133353, secondary_velocity=0.128855630784633, density=2650.0)" - ), -) diff --git a/tests/snapshots/snap_test_fluid_substitution.py b/tests/snapshots/snap_test_fluid_substitution.py deleted file mode 100644 index 689fba4..0000000 --- a/tests/snapshots/snap_test_fluid_substitution.py +++ /dev/null @@ -1,12 +0,0 @@ -# -*- coding: utf-8 -*- -# snapshottest: v1 - https://goo.gl/zC4yUc -from __future__ import unicode_literals - -from snapshottest import GenericRepr, Snapshot - - -snapshots = Snapshot() - -snapshots["test_fluid_substitution 1"] = GenericRepr( - "Material(shear_modulus=[1.], bulk_modulus=[1.94708995], primary_velocity=[1.28070748], secondary_velocity=[0.70710678], density=[2.])" -) diff --git a/tests/snapshots/snap_test_murphy_coordination_number.py b/tests/snapshots/snap_test_murphy_coordination_number.py deleted file mode 100644 index 2040ed0..0000000 --- a/tests/snapshots/snap_test_murphy_coordination_number.py +++ /dev/null @@ -1,10 +0,0 @@ -# -*- coding: utf-8 -*- -# snapshottest: v1 - https://goo.gl/zC4yUc -from __future__ import unicode_literals - -from snapshottest import Snapshot - - -snapshots = Snapshot() - -snapshots["test_murphy_coordination_number 1"] = 17.555560500000002 diff --git a/tests/snapshots/snap_test_pressure.py b/tests/snapshots/snap_test_pressure.py deleted file mode 100644 index 13f3ce2..0000000 --- a/tests/snapshots/snap_test_pressure.py +++ /dev/null @@ -1,20 +0,0 @@ -# -*- coding: utf-8 -*- -# snapshottest: v1 - https://goo.gl/zC4yUc -from __future__ import unicode_literals - -from snapshottest import GenericRepr, Snapshot - - -snapshots = Snapshot() - -snapshots["test_pressure_dependency_no_pressure_exp_fit 1"] = GenericRepr( - "Material(shear_modulus=1.0, bulk_modulus=0.9999999999999998, primary_velocity=1.5275252316519465, secondary_velocity=1.0, density=1.0)" -) - -snapshots["test_pressure_dependency_no_pressure_poly_fit 1"] = GenericRepr( - "Material(shear_modulus=1.0, bulk_modulus=0.9999999999999998, primary_velocity=1.5275252316519465, secondary_velocity=1.0, density=1.0)" -) - -snapshots["test_pressure_dependency_no_pressure_power_fit 1"] = GenericRepr( - "Material(shear_modulus=1.0, bulk_modulus=0.9999999999999998, primary_velocity=1.5275252316519465, secondary_velocity=1.0, density=1.0)" -)