From 66f7d3ae0484f8fbf36b2c9b16e18257d36c004b Mon Sep 17 00:00:00 2001 From: Huite Bootsma Date: Fri, 19 Jan 2024 17:17:11 +0100 Subject: [PATCH 1/7] Use hatchling instead of setuptools, add pixi task: pypi-publish --- imod/__init__.py | 9 +-------- pixi.toml | 1 + pyproject.toml | 14 ++++++++++---- 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/imod/__init__.py b/imod/__init__.py index 059b5476f..c392d8a4f 100644 --- a/imod/__init__.py +++ b/imod/__init__.py @@ -1,5 +1,3 @@ -from importlib.metadata import PackageNotFoundError, distribution - # exports from imod import ( couplers, @@ -17,9 +15,4 @@ ) from imod.formats import gen, idf, ipf, prj, rasterio -# version -try: - __version__ = distribution(__name__).version -except PackageNotFoundError: - # package is not installed - pass +__version__ = "0.15.1" diff --git a/pixi.toml b/pixi.toml index a9826b6ea..a2b4cfd0b 100644 --- a/pixi.toml +++ b/pixi.toml @@ -38,6 +38,7 @@ examples = { cmd = [ "--verbose", "--junitxml=examples_report.xml", ], depends_on = ["install"], cwd = "imod/tests" } +pypi-publish = { cmd = "rm --recursive --force dist && python -m build && twine check dist/* && twine upload dist/*" } black_lint = "black --check ." black_format = "black ." diff --git a/pyproject.toml b/pyproject.toml index 9fc70f291..c6c5db5b3 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,10 +1,10 @@ [build-system] -requires = ["setuptools>=42", "wheel"] -build-backend = "setuptools.build_meta" +requires = ["hatchling"] +build-backend = "hatchling.build" [project] name = "imod" -version = "0.15.1" +dynamic = ["version"] requires-python = ">=3.10" authors = [{ name = "Deltares", email = "huite.bootsma@deltares.nl" }, ] maintainers = [{ name = "Deltares", email = "huite.bootsma@deltares.nl" }] @@ -163,4 +163,10 @@ ignore_missing_imports = true [tool.pytest.ini_options] markers = [ "example: marks test as example (deselect with '-m \"not example\"')", -] \ No newline at end of file +] + +[tool.hatch.version] +path = "imod/__init__.py" + +[tool.hatch.build.targets.sdist] +only-include = ["imod"] \ No newline at end of file From 2894894ebd7c71bec79be2e2d71c1edd7da7cd8e Mon Sep 17 00:00:00 2001 From: Huite Bootsma Date: Fri, 19 Jan 2024 17:24:28 +0100 Subject: [PATCH 2/7] Add build and twine to pixi --- pixi.lock | 188 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ pixi.toml | 5 +- 2 files changed, 191 insertions(+), 2 deletions(-) diff --git a/pixi.lock b/pixi.lock index 96e87266d..f9cbfa8f0 100644 --- a/pixi.lock +++ b/pixi.lock @@ -3100,6 +3100,102 @@ package: license_family: MIT size: 322086 timestamp: 1695990976742 +- platform: linux-64 + name: build + version: 0.7.0 + category: main + manager: conda + dependencies: + - importlib-metadata + - packaging + - pep517 >=0.9.1 + - python >=3.6 + - tomli + url: https://conda.anaconda.org/conda-forge/noarch/build-0.7.0-pyhd8ed1ab_0.tar.bz2 + hash: + md5: add7f31586d03678695b32b78a1337a1 + sha256: 44e2d3270209d1f10b8adec2a159699ed66914e851ec34775902e856ea04afeb + build: pyhd8ed1ab_0 + arch: x86_64 + subdir: linux-64 + build_number: 0 + license: MIT + license_family: MIT + noarch: python + size: 17759 + timestamp: 1631843776429 +- platform: osx-64 + name: build + version: 0.7.0 + category: main + manager: conda + dependencies: + - importlib-metadata + - packaging + - pep517 >=0.9.1 + - python >=3.6 + - tomli + url: https://conda.anaconda.org/conda-forge/noarch/build-0.7.0-pyhd8ed1ab_0.tar.bz2 + hash: + md5: add7f31586d03678695b32b78a1337a1 + sha256: 44e2d3270209d1f10b8adec2a159699ed66914e851ec34775902e856ea04afeb + build: pyhd8ed1ab_0 + arch: x86_64 + subdir: osx-64 + build_number: 0 + license: MIT + license_family: MIT + noarch: python + size: 17759 + timestamp: 1631843776429 +- platform: osx-arm64 + name: build + version: 0.7.0 + category: main + manager: conda + dependencies: + - importlib-metadata + - packaging + - pep517 >=0.9.1 + - python >=3.6 + - tomli + url: https://conda.anaconda.org/conda-forge/noarch/build-0.7.0-pyhd8ed1ab_0.tar.bz2 + hash: + md5: add7f31586d03678695b32b78a1337a1 + sha256: 44e2d3270209d1f10b8adec2a159699ed66914e851ec34775902e856ea04afeb + build: pyhd8ed1ab_0 + arch: aarch64 + subdir: osx-arm64 + build_number: 0 + license: MIT + license_family: MIT + noarch: python + size: 17759 + timestamp: 1631843776429 +- platform: win-64 + name: build + version: 0.7.0 + category: main + manager: conda + dependencies: + - importlib-metadata + - packaging + - pep517 >=0.9.1 + - python >=3.6 + - tomli + url: https://conda.anaconda.org/conda-forge/noarch/build-0.7.0-pyhd8ed1ab_0.tar.bz2 + hash: + md5: add7f31586d03678695b32b78a1337a1 + sha256: 44e2d3270209d1f10b8adec2a159699ed66914e851ec34775902e856ea04afeb + build: pyhd8ed1ab_0 + arch: x86_64 + subdir: win-64 + build_number: 0 + license: MIT + license_family: MIT + noarch: python + size: 17759 + timestamp: 1631843776429 - platform: linux-64 name: bzip2 version: 1.0.8 @@ -24072,6 +24168,90 @@ package: license_family: BSD size: 880802 timestamp: 1698611415241 +- platform: linux-64 + name: pep517 + version: 0.13.0 + category: main + manager: conda + dependencies: + - python >=3.8 + - tomli + url: https://conda.anaconda.org/conda-forge/noarch/pep517-0.13.0-pyhd8ed1ab_0.tar.bz2 + hash: + md5: d94aa03d99d8adc9898f783eba0d84d2 + sha256: 6a6f2fa6bc9106b2edcccc142242dc3ab1f2f77a6debbd5b480f08482f052636 + build: pyhd8ed1ab_0 + arch: x86_64 + subdir: linux-64 + build_number: 0 + license: MIT + license_family: MIT + noarch: python + size: 19044 + timestamp: 1667916747996 +- platform: osx-64 + name: pep517 + version: 0.13.0 + category: main + manager: conda + dependencies: + - python >=3.8 + - tomli + url: https://conda.anaconda.org/conda-forge/noarch/pep517-0.13.0-pyhd8ed1ab_0.tar.bz2 + hash: + md5: d94aa03d99d8adc9898f783eba0d84d2 + sha256: 6a6f2fa6bc9106b2edcccc142242dc3ab1f2f77a6debbd5b480f08482f052636 + build: pyhd8ed1ab_0 + arch: x86_64 + subdir: osx-64 + build_number: 0 + license: MIT + license_family: MIT + noarch: python + size: 19044 + timestamp: 1667916747996 +- platform: osx-arm64 + name: pep517 + version: 0.13.0 + category: main + manager: conda + dependencies: + - python >=3.8 + - tomli + url: https://conda.anaconda.org/conda-forge/noarch/pep517-0.13.0-pyhd8ed1ab_0.tar.bz2 + hash: + md5: d94aa03d99d8adc9898f783eba0d84d2 + sha256: 6a6f2fa6bc9106b2edcccc142242dc3ab1f2f77a6debbd5b480f08482f052636 + build: pyhd8ed1ab_0 + arch: aarch64 + subdir: osx-arm64 + build_number: 0 + license: MIT + license_family: MIT + noarch: python + size: 19044 + timestamp: 1667916747996 +- platform: win-64 + name: pep517 + version: 0.13.0 + category: main + manager: conda + dependencies: + - python >=3.8 + - tomli + url: https://conda.anaconda.org/conda-forge/noarch/pep517-0.13.0-pyhd8ed1ab_0.tar.bz2 + hash: + md5: d94aa03d99d8adc9898f783eba0d84d2 + sha256: 6a6f2fa6bc9106b2edcccc142242dc3ab1f2f77a6debbd5b480f08482f052636 + build: pyhd8ed1ab_0 + arch: x86_64 + subdir: win-64 + build_number: 0 + license: MIT + license_family: MIT + noarch: python + size: 19044 + timestamp: 1667916747996 - platform: linux-64 name: pillow version: 10.2.0 @@ -29179,6 +29359,8 @@ package: license_family: MIT size: 5483251 timestamp: 1704293303507 + purls: + - pkg:pypi/ruff - platform: osx-64 name: ruff version: 0.1.11 @@ -29200,6 +29382,8 @@ package: license_family: MIT size: 5296599 timestamp: 1704298924933 + purls: + - pkg:pypi/ruff - platform: osx-arm64 name: ruff version: 0.1.11 @@ -29222,6 +29406,8 @@ package: license_family: MIT size: 5093204 timestamp: 1704300759924 + purls: + - pkg:pypi/ruff - platform: win-64 name: ruff version: 0.1.11 @@ -29245,6 +29431,8 @@ package: license_family: MIT size: 5337963 timestamp: 1704304941343 + purls: + - pkg:pypi/ruff - platform: linux-64 name: s2n version: 1.4.1 diff --git a/pixi.toml b/pixi.toml index a2b4cfd0b..0735858c3 100644 --- a/pixi.toml +++ b/pixi.toml @@ -38,7 +38,7 @@ examples = { cmd = [ "--verbose", "--junitxml=examples_report.xml", ], depends_on = ["install"], cwd = "imod/tests" } -pypi-publish = { cmd = "rm --recursive --force dist && python -m build && twine check dist/* && twine upload dist/*" } +pypi-publish = { cmd = "rm --recursive --force dist && python -m build && twine check dist/*" } black_lint = "black --check ." black_format = "black ." @@ -100,6 +100,7 @@ vtk = { version = ">=9.0", build = "*qt*", channel = "conda-forge" } xarray = ">=2023.04.0" xugrid = ">=0.6.4" zarr = "*" +build = "*" [pypi-dependencies] -mypy2junit = "*" \ No newline at end of file +mypy2junit = "*" From 29328d15a85163fb7f1a924d2a222b00cce3141f Mon Sep 17 00:00:00 2001 From: Huite Bootsma Date: Fri, 19 Jan 2024 17:28:27 +0100 Subject: [PATCH 3/7] Update how-to-release docs --- docs/developing.rst | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/docs/developing.rst b/docs/developing.rst index e81e1bd56..dfe7db413 100644 --- a/docs/developing.rst +++ b/docs/developing.rst @@ -81,7 +81,8 @@ To follow these steps, you need to be one of the maintainers for imod on both `PyPI `_ and `conda-forge `_. -1. Update the :doc:`../api/changelog` and the pyproject.toml files. +1. Update the :doc:`../api/changelog` and the ``__version__`` in ``imod/__init__.py``, + and the version entry in the ``pixi.toml`` for complenetess. 2. Create a tag on your local machine and push it GitHub. `Old tags are here `_. `Old releases are @@ -96,14 +97,10 @@ To follow these steps, you need to be one of the maintainers for imod on both 4. Locally, ``git fetch --tags`` and ``git pull``, verify you are on the commit you want to release, and that it is clean. + +5. Run ``pixi run pypi-publish`` to build the package and upload to PyPI. -5. Remove the ``build``, ``dist``, ``imod.egg-info`` folders if present. - -6. Create a source distribution under ``dist/`` with ``python -m build --sdist`` - -7. Upload the files from step 6 to PyPI with ``twine upload dist/*`` - -8. For `conda-forge `_, a PR +6. For `conda-forge `_, a PR will be created automatically. If the requirements are up to date in `meta.yaml `_ From 1099a326b441b806620086c587f5c69e0c23e9a6 Mon Sep 17 00:00:00 2001 From: Huite Bootsma Date: Mon, 22 Jan 2024 13:22:21 +0100 Subject: [PATCH 4/7] hatchling doesn't need MANIFEST to include non-Python files --- MANIFEST.in | 5 ----- 1 file changed, 5 deletions(-) delete mode 100644 MANIFEST.in diff --git a/MANIFEST.in b/MANIFEST.in deleted file mode 100644 index e057ef47e..000000000 --- a/MANIFEST.in +++ /dev/null @@ -1,5 +0,0 @@ -include README.rst -include LICENSE -include imod/data/registry.txt -include imod/templates/*.j2 -include imod/templates/mf6/*.j2 \ No newline at end of file From 0fc7bc886b259c2e2a87f9fbf7f143d14cd0b184 Mon Sep 17 00:00:00 2001 From: Huite Bootsma Date: Mon, 22 Jan 2024 13:22:45 +0100 Subject: [PATCH 5/7] add hatchling to dev dependencies --- pyproject.toml | 1 + 1 file changed, 1 insertion(+) diff --git a/pyproject.toml b/pyproject.toml index c6c5db5b3..f229fdb18 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -69,6 +69,7 @@ dev = [ "black", "ruff", "flopy", + "hatchling", "hypothesis", "mypy", "pydata-sphinx-theme", From 77978352b0bd65a34a0001dfb5ec88cc3838634a Mon Sep 17 00:00:00 2001 From: Huite Bootsma Date: Mon, 22 Jan 2024 13:23:20 +0100 Subject: [PATCH 6/7] Add upload back to publish task --- pixi.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pixi.toml b/pixi.toml index 0735858c3..2c104b39b 100644 --- a/pixi.toml +++ b/pixi.toml @@ -38,7 +38,7 @@ examples = { cmd = [ "--verbose", "--junitxml=examples_report.xml", ], depends_on = ["install"], cwd = "imod/tests" } -pypi-publish = { cmd = "rm --recursive --force dist && python -m build && twine check dist/*" } +pypi-publish = { cmd = "rm --recursive --force dist && python -m build && twine check dist/* && twine upload dist/*" } black_lint = "black --check ." black_format = "black ." From 6d1681b72203100691130670524a0abdcc72bce1 Mon Sep 17 00:00:00 2001 From: Joeri van Engelen Date: Wed, 24 Jan 2024 11:13:46 +0100 Subject: [PATCH 7/7] Update changelog --- docs/api/changelog.rst | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/docs/api/changelog.rst b/docs/api/changelog.rst index d4943d349..15885cd66 100644 --- a/docs/api/changelog.rst +++ b/docs/api/changelog.rst @@ -21,6 +21,12 @@ Changed environments. This replaces the ``imod-environment.yml`` conda environment. We advice doing development installations with pixi from now on. `See the documentation. `_ + This does not affect users who installed with ``pip install imod``, ``mamba + install imod`` or ``conda install imod``. +- Changed build system from ``setuptools`` to ``hatchling``. Users who did a + development install are adviced to run ``pip uninstall imod`` and ``pip + install -e .`` again. This does not affect users who installed with ``pip + install imod``, ``mamba install imod`` or ``conda install imod``. [0.15.1] - 2023-12-22 ---------------------