From 058a9c8f6f1af9c091fde62a71a3dc9996343b8b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dieter=20Werthm=C3=BCller?= Date: Thu, 17 Oct 2024 23:13:04 +0200 Subject: [PATCH] Replace setup.py by pyproject.toml (#346) --- .coveragerc | 2 - .git_archival.txt | 3 ++ .gitattributes | 1 + .github/workflows/linkcheck.yml | 2 +- .github/workflows/linux.yml | 6 +-- .readthedocs.yml | 3 +- CHANGELOG.rst | 8 +++ CREDITS.rst | 4 +- MANIFEST.in | 6 +-- Makefile | 6 +-- README.rst | 17 ------- docs/dev/maintenance.rst | 15 ++++-- docs/manual/installation.rst | 6 +-- pyproject.toml | 89 +++++++++++++++++++++++++++++++++ requirements-dev.txt | 36 ------------- requirements.txt | 1 - setup.cfg | 2 - setup.py | 51 ------------------- 18 files changed, 128 insertions(+), 130 deletions(-) delete mode 100644 .coveragerc create mode 100644 .git_archival.txt create mode 100644 .gitattributes create mode 100644 pyproject.toml delete mode 100644 requirements-dev.txt delete mode 100644 requirements.txt delete mode 100644 setup.cfg delete mode 100644 setup.py diff --git a/.coveragerc b/.coveragerc deleted file mode 100644 index 4edd7b1a..00000000 --- a/.coveragerc +++ /dev/null @@ -1,2 +0,0 @@ -[run] -relative_files = True diff --git a/.git_archival.txt b/.git_archival.txt new file mode 100644 index 00000000..7c510094 --- /dev/null +++ b/.git_archival.txt @@ -0,0 +1,3 @@ +node: $Format:%H$ +node-date: $Format:%cI$ +describe-name: $Format:%(describe:tags=true,match=*[0-9]*)$ diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 00000000..00a7b00c --- /dev/null +++ b/.gitattributes @@ -0,0 +1 @@ +.git_archival.txt export-subst diff --git a/.github/workflows/linkcheck.yml b/.github/workflows/linkcheck.yml index a76017e1..5fa4a2b8 100644 --- a/.github/workflows/linkcheck.yml +++ b/.github/workflows/linkcheck.yml @@ -38,7 +38,7 @@ jobs: shell: bash -l {0} run: | python -m pip install --upgrade pip - python -m pip install -r requirements-dev.txt + python -m pip install .[docs] - name: Check links shell: bash -l {0} diff --git a/.github/workflows/linux.yml b/.github/workflows/linux.yml index eb06d98d..e9b95b05 100644 --- a/.github/workflows/linux.yml +++ b/.github/workflows/linux.yml @@ -95,7 +95,7 @@ jobs: conda config --show-sources conda config --show conda info -a - conda install ${{ matrix.case.conda }} pytest pytest-cov pytest-console-scripts coveralls flake8 setuptools-scm + conda install ${{ matrix.case.conda }} pytest pytest-cov pytest-console-scripts coveralls flake8 flake8-pyproject setuptools-scm - name: Conda list shell: bash -l {0} @@ -103,7 +103,7 @@ jobs: - name: Flake8 shell: bash -l {0} - run: flake8 docs/ setup.py emg3d/ tests/ + run: flake8 docs/ emg3d/ tests/ - name: Test with pytest shell: bash -l {0} @@ -171,7 +171,7 @@ jobs: # Change setuptools-scm local_scheme to "no-local-version" so the # local part of the version isn't included, making the version string # compatible with Test PyPI. - sed --in-place 's/"root"/"local_scheme":"no-local-version","root"/g' setup.py + sed --in-place 's/version_file/local_scheme = "no-local-version"\nversion_file/g' pyproject.toml - name: Build source and wheel distributions run: | diff --git a/.readthedocs.yml b/.readthedocs.yml index 6c7b0a3b..ca698057 100644 --- a/.readthedocs.yml +++ b/.readthedocs.yml @@ -17,6 +17,7 @@ formats: [] # docs python: install: - - requirements: requirements-dev.txt - method: pip path: . + extra_requirements: + - docs diff --git a/CHANGELOG.rst b/CHANGELOG.rst index f769eee5..afdab7fe 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -6,6 +6,14 @@ Changelog """""""""" +latest +------ + +- Maintenance: + + - Changed from ``setup.py`` to ``pyproject.toml``. + + v1.8.4 : NumPy v2 ----------------- diff --git a/CREDITS.rst b/CREDITS.rst index 0fbd1c28..20e4a870 100644 --- a/CREDITS.rst +++ b/CREDITS.rst @@ -11,10 +11,10 @@ namely: through the *Gitaro.JIM* project (till 05/2021, emg3d v1.0.0), funded by `MarTERA `_ as part of Horizon 2020, a funding scheme of the European Research Area. -- 2021-2024: `Delft University of Technology `_ through - the `Delphi Consortium `_. - 2021-2022: `TERRASYS Geophysics GmbH & Co. KG `_. +- 2021-2024: `Delft University of Technology `_ through + the `Delphi Consortium `_. - 2024-today: `ETH Zurich `_ through the group `Geothermal Energy and Geofluids `_. diff --git a/MANIFEST.in b/MANIFEST.in index 81ddd159..972e86e8 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -4,9 +4,7 @@ prune .github exclude MANIFEST.in exclude CHANGELOG.rst exclude Makefile -exclude requirements.txt -exclude requirements-dev.txt -exclude setup.cfg exclude .gitignore -exclude .coveragerc exclude .readthedocs.yml +exclude .git_archival.txt +exclude .gitattributes diff --git a/Makefile b/Makefile index 53c39a5c..a64df8a5 100644 --- a/Makefile +++ b/Makefile @@ -13,16 +13,16 @@ help: @echo "" install: - python -m pip install --no-build-isolation --use-pep517 --no-deps -e . + python -m pip install -e . dev-install: - python -m pip install -r requirements-dev.txt && python -m pip install --no-build-isolation --use-pep517 --no-deps -e . + python -m pip install -e .[all] pytest: rm -rf .coverage htmlcov/ .pytest_cache/ && pytest --cov=emg3d && coverage html flake8: - flake8 docs/ setup.py emg3d/ tests/ + flake8 docs/ emg3d/ tests/ html: cd docs && make html diff --git a/README.rst b/README.rst index e1bdcbb1..94403d34 100644 --- a/README.rst +++ b/README.rst @@ -2,23 +2,6 @@ :target: https://emsig.xyz :alt: emg3d logo -| - -.. image:: https://img.shields.io/pypi/v/emg3d.svg - :target: https://pypi.python.org/pypi/emg3d/ - :alt: PyPI -.. image:: https://img.shields.io/conda/v/conda-forge/emg3d.svg - :target: https://anaconda.org/conda-forge/emg3d/ - :alt: conda-forge -.. image:: https://img.shields.io/badge/python-3.10+-blue.svg - :target: https://www.python.org/downloads/ - :alt: Supported Python Versions -.. image:: https://img.shields.io/badge/platform-linux,win,osx-blue.svg - :target: https://anaconda.org/conda-forge/emg3d/ - :alt: Linux, Windows, OSX - -| - A multigrid solver for 3D electromagnetic diffusion in Python. - **Website:** https://emsig.xyz diff --git a/docs/dev/maintenance.rst b/docs/dev/maintenance.rst index 51062d78..1c104cf8 100644 --- a/docs/dev/maintenance.rst +++ b/docs/dev/maintenance.rst @@ -64,7 +64,14 @@ To check the environment in which the documentation was built. .. ipython:: In [1]: import emg3d - ...: emg3d.Report( - ...: ['sphinx', 'numpydoc', 'ipykernel', 'sphinx_numfig', - ...: 'sphinx_design', 'sphinx_automodapi', 'pydata_sphinx_theme'] - ...: ) + ...: emg3d.Report([ + ...: "ipympl", + ...: "sphinx", + ...: "numpydoc", + ...: "ipykernel", + ...: "pickleshare", + ...: "sphinx_design", + ...: "sphinx_numfig", + ...: "sphinx_automodapi", + ...: "pydata_sphinx_theme", + ...: ]) diff --git a/docs/manual/installation.rst b/docs/manual/installation.rst index 8cae6987..09cd6803 100644 --- a/docs/manual/installation.rst +++ b/docs/manual/installation.rst @@ -13,9 +13,9 @@ or via ``pip``: pip install emg3d -Requirements are the modules ``scipy``, ``numba``, and ``empymod``. Various -other packages are recommended or required for some advanced functionalities, -namely: +Requirements are the modules ``numpy``, ``scipy``, ``numba``, and ``empymod``. +Various other packages are recommended or required for some advanced +functionalities, namely: - ``xarray``: For the :class:`emg3d.surveys.Survey` and :class:`emg3d.simulations.Simulation` classes (model many sources and diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 00000000..cb3a275b --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,89 @@ +[build-system] +requires = ["setuptools>=64", "setuptools_scm>=8"] +build-backend = "setuptools.build_meta" + +[project] +name = "emg3d" +description = "A multigrid solver for 3D electromagnetic diffusion" +readme = "README.rst" +requires-python = ">=3.10" +authors = [ + {name = "The emsig community", email = "info@emsig.xyz"}, +] +dependencies = [ + "numpy", + "scipy>=1.10", + "numba", + "empymod>=2.3.2", +] +classifiers = [ + "Development Status :: 5 - Production/Stable", + "License :: OSI Approved :: Apache Software License", + "Programming Language :: Python", +] +dynamic = ["version"] + +[project.license] +file = "LICENSE" + +[project.urls] +Homepage = "https://emsig.xyz" +Documentation = "https://emg3d.emsig.xyz" +Repository = "https://github.com/emsig/emg3d" + +[project.optional-dependencies] +full = [ + "tqdm", + "h5py", + "xarray", + "discretize", + "matplotlib", + "ipympl", + # "pygimli>=1.5.2", # Only once implemented + # "simpeg>=0.22.1", # Only once implemented +] +docs = [ + "emg3d[full]", + "numpy<2", # Until discretize is ready for NumPy v2 + "sphinx", + "numpydoc", + "ipykernel", + "pickleshare", + "sphinx_design", + "sphinx_numfig", + "sphinx_automodapi", + "pydata_sphinx_theme", +] +tests = [ + "flake8", + "pytest", + "coveralls", + "pytest_cov", + "flake8-pyproject", + "pytest-console-scripts", +] +all = [ + "emg3d[docs]", + "emg3d[tests]", +] +build = [ + "setuptools_scm>=8", + "setuptools>=64", +] + +[project.scripts] +emg3d = "emg3d.cli.main:main" + +[tool.setuptools.packages.find] +include = ["emg3d*"] + +[tool.setuptools_scm] +version_file = "emg3d/version.py" + +[tool.flake8] +per-file-ignores = [ + "__init__.py: F401, F403, F821", +] + +[tool.coverage.run] +relative_files = true diff --git a/requirements-dev.txt b/requirements-dev.txt deleted file mode 100644 index 42478f3b..00000000 --- a/requirements-dev.txt +++ /dev/null @@ -1,36 +0,0 @@ -# GLOBAL REQUIREMENTS. --r requirements.txt - -# Fix numpy<2 until discretize is ready for 2.0 -numpy<2 - -# SOFT DEPENDENCIES -tqdm -h5py -xarray -discretize -matplotlib -ipympl -pygimli>=1.5.2 -simpeg>=0.22.1 - -# SETUP RELATED -setuptools_scm - -# FOR DOCUMENTATION -sphinx -numpydoc -sphinx_design -sphinx_numfig -pydata_sphinx_theme -sphinx_automodapi -ipykernel -pickleshare - -# FOR TESTING -asv -pytest -flake8 -coveralls -pytest-cov -pytest-console-scripts diff --git a/requirements.txt b/requirements.txt deleted file mode 100644 index 9c558e35..00000000 --- a/requirements.txt +++ /dev/null @@ -1 +0,0 @@ -. diff --git a/setup.cfg b/setup.cfg deleted file mode 100644 index b3fe56e3..00000000 --- a/setup.cfg +++ /dev/null @@ -1,2 +0,0 @@ -[flake8] -per-file-ignores = __init__.py: F401, F403, F821 diff --git a/setup.py b/setup.py deleted file mode 100644 index 7b4bfeb6..00000000 --- a/setup.py +++ /dev/null @@ -1,51 +0,0 @@ -# -*- coding: utf-8 -*- -import os -import re -from setuptools import setup - -# Get README and remove badges. -with open("README.rst") as f: - readme = re.sub(r"\|.*\|", "", f.read(), flags=re.DOTALL) - -setup( - name="emg3d", - description="A multigrid solver for 3D electromagnetic diffusion.", - long_description=readme, - author="The emsig community", - author_email="info@emsig.xyz", - url="https://emsig.xyz", - license="Apache-2.0", - packages=["emg3d", "emg3d.inversion", "emg3d.cli"], - classifiers=[ - "Development Status :: 5 - Production/Stable", - "License :: OSI Approved :: Apache Software License", - "Programming Language :: Python", - ], - entry_points={ - "console_scripts": [ - "emg3d=emg3d.cli.main:main", - ], - }, - python_requires=">=3.10", - install_requires=[ - "scipy>=1.10", - "numba", - "empymod>=2.3.2", - ], - extras_require={ - "full": [ - "tqdm", - "h5py", - "xarray", - "discretize", - "matplotlib", - "ipympl", - ], - }, - use_scm_version={ - "root": ".", - "relative_to": __file__, - "write_to": os.path.join("emg3d", "version.py"), - }, - setup_requires=["setuptools_scm"], -)