diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index fa7cf94..a6e88f4 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -22,17 +22,17 @@ jobs: - "3.12" - "3.11" - "3.10" - numpy-version: - - false - - "1.x" - - "2.x" + optional-deps: + - "" + - "[numpy2]" + - "[numpy1]" exclude: - python-version: "3.14" - numpy-version: "1.x" + optional-deps: "[numpy1]" - python-version: "3.13" - numpy-version: "1.x" + optional-deps: "[numpy1]" - name: "Tests (Python: ${{ matrix.python-version }}, NumPy: ${{ matrix.numpy-version }})" + name: "Tests (Python: ${{ matrix.python-version }}, optional dependencies: ${{ matrix.optional-deps }})" runs-on: ubuntu-24.04 steps: - uses: actions/checkout@v7 @@ -41,10 +41,7 @@ jobs: with: python-version: ${{ matrix.python-version }} - - run: pip install -r requirements.txt - - - run: pip install -r numpy-${{ matrix.numpy-version }}-requirements.txt - if: matrix.numpy-version != false + - run: python -m pip install .${{ matrix.optional-deps }} --group test - run: pytest -v --cov=utm --color=yes @@ -61,11 +58,9 @@ jobs: with: python-version: "3.14" - - run: pip install -r release-requirements.txt - - run: python -m build - - uses: pypa/gh-action-pypi-publish@v1.14.1 + - uses: pypa/gh-action-pypi-publish@v1.14.2 with: user: __token__ password: ${{ secrets.PYPI_TOKEN }} diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 31273f5..d11392e 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -4,6 +4,7 @@ Changelog Unreleased ------ +* Convert ``setup.py`` to ``pyproject.toml`` (#164) * ... diff --git a/README.rst b/README.rst index 8fc1971..f02330b 100644 --- a/README.rst +++ b/README.rst @@ -59,8 +59,8 @@ You can also use NumPy arrays for ``EASTING`` and ``NORTHING``. In the result .. code-block:: python - >>> utm.to_latlon(np.array([395200, 456100]), np.array([5673100, 5427600]), 32, 'U') - (array([51.19968297, 48.99973627]), array([7.49999141, 8.3998036 ])) + >>> utm.to_latlon(np.array([395200, 456100]), np.array([5673100, 5427600]), 32, 'U') + (array([51.19968297, 48.99973627]), array([7.49999141, 8.3998036 ])) Since the zone letter is not strictly needed for the conversion you may also @@ -91,9 +91,27 @@ previous test). Using ``utm.from_latlon(x, y)`` to convert one million points: Development ----------- -Create a new ``virtualenv`` and install the library via ``pip install -e .``. -After that install the ``pytest`` package via ``pip install pytest`` and run -the unit test suite by calling ``pytest``. +Setup development environment +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +Using ``uv`` is the easiest: + +* Run: ``uv sync`` + +Using ``pipx``: + +* Run: ``pipx install -e . --pip-args="--group dev"`` + +Using ``pip`` requires manually setting up the virtual environment: + +* Create and activate a new ``virtualenv`` +* Run: ``python -m pip install -e . --group dev`` + +Run tests +^^^^^^^^^ + +After preparing the development environment, run the unit test suite by +calling ``pytest``. Changelog --------- @@ -103,17 +121,35 @@ see `CHANGELOG.rst `_ file Authors ------- -* Bart van Andel * Tobias Bieniek * Torstein I. Bø +Maintainers +----------- + +* Bart van Andel + License ------- -Copyright (C) 2012 Tobias Bieniek +MIT License + +Copyright (c) 2012-2017 Tobias Bieniek -Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: -The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/numpy-1.x-requirements.txt b/numpy-1.x-requirements.txt deleted file mode 100644 index b5e0ec2..0000000 --- a/numpy-1.x-requirements.txt +++ /dev/null @@ -1 +0,0 @@ -numpy==1.26.4; python_version >= '3.9' and python_version < '3.13' diff --git a/numpy-2.x-requirements.txt b/numpy-2.x-requirements.txt deleted file mode 100644 index 3497070..0000000 --- a/numpy-2.x-requirements.txt +++ /dev/null @@ -1,3 +0,0 @@ -numpy==2.5.1; python_version >= '3.12' and python_version < '3.15' -numpy==2.4.6; python_version >= '3.11' and python_version < '3.12' -numpy==2.2.6; python_version >= '3.10' and python_version < '3.11' diff --git a/pyproject.toml b/pyproject.toml index fed528d..ac8f0c6 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,3 +1,75 @@ +[project] +name = "utm" +description = "Bidirectional UTM-WGS84 converter for python" +readme = "README.rst" +dynamic = ["version"] +requires-python = ">=3.10" +authors = [{ name = "Tobias Bieniek", email = "Tobias.Bieniek@gmx.de" }] +maintainers = [{ name = "Bart van Andel", email = "bavanandel@gmail.com" }] +keywords = ["utm", "wgs84", "coordinate", "converter"] +license = "MIT" +license-files = ["LICENSE"] +classifiers = [ + "Development Status :: 4 - Beta", + "Environment :: Other Environment", + "Intended Audience :: Developers", + "Intended Audience :: Science/Research", + "Operating System :: OS Independent", + "Programming Language :: Python", + "Programming Language :: Python :: 3 :: Only", + "Programming Language :: Python :: 3.9", + "Programming Language :: Python :: 3.10", + "Programming Language :: Python :: 3.11", + "Programming Language :: Python :: 3.12", + "Programming Language :: Python :: 3.13", + "Programming Language :: Python :: 3.14", + "Topic :: Scientific/Engineering :: GIS", +] +dependencies = [] + +[project.optional-dependencies] +# Within each major NumPy version, use the latest minor versions that each Python version supports +# See: https://numpy.org/news/ +numpy1 = [ + # NumPy 1.26 supports Python 3.9-3.12, even if we don't + "numpy==1.26.4;python_version >= '3.9' and python_version < '3.13'", +] +numpy2 = [ + # NumPy 2.5 supports Python 3.12-3.14 + "numpy==2.5.1; python_version >= '3.12' and python_version < '3.15'", + # NumPy 2.4 supports Python 3.11-3.13 + "numpy==2.4.6; python_version >= '3.11' and python_version < '3.12'", + # NumPy 2.2 supports Python 3.10-3.13 + "numpy==2.2.6; python_version >= '3.10' and python_version < '3.11'", +] + +[dependency-groups] +test = [ + "pytest==9.1.1; python_version >= '3.10' and python_version < '3.16'", + "pytest-cov==7.1.0; python_version >= '3.9' and python_version < '3.15'", + "tox>=4.58.0,<5.0.0; python_version >= '3.9' and python_version < '3.15'", +] +dev = [{ include-group = "test" }] +release = ["build"] + +[project.scripts] +utm-converter = "utm:cli" + +[project.urls] +homepage = "https://github.com/Turbo87/utm" +source = "https://github.com/Turbo87/utm" +download = "https://pypi.org/project/utm" +changelog = "https://github.com/Turbo87/utm/blob/master/CHANGELOG.rst" +releasenotes = "https://github.com/Turbo87/utm/releases" +issues = "https://github.com/Turbo87/utm/issues" +documentation = "https://github.com/Turbo87/utm/blob/master/README.rst" + [build-system] -requires = ["setuptools"] +requires = ["setuptools>=77.0.3"] build-backend = "setuptools.build_meta" + +[tool.setuptool] +packages = ["utm"] + +[tool.setuptools.dynamic] +version = { attr = "utm._version.__version__" } diff --git a/release-requirements.txt b/release-requirements.txt deleted file mode 100644 index 378eac2..0000000 --- a/release-requirements.txt +++ /dev/null @@ -1 +0,0 @@ -build diff --git a/requirements.txt b/requirements.txt deleted file mode 100644 index a2e9f51..0000000 --- a/requirements.txt +++ /dev/null @@ -1,2 +0,0 @@ -pytest==9.1.1; python_version >= '3.10' and python_version < '3.16' -pytest-cov==7.1.0; python_version >= '3.9' and python_version < '3.15' diff --git a/setup.py b/setup.py deleted file mode 100644 index 56e4013..0000000 --- a/setup.py +++ /dev/null @@ -1,43 +0,0 @@ -from setuptools import setup -from pathlib import Path -import re - -this_directory = Path(__file__).parent - -try: - version_file_content = (this_directory / "utm/_version.py").read_text() -except: - raise RuntimeError("Failed to read version file") - -version_regex = re.compile(r"^__version__ = (['\"])(?P.*)\1", re.M) -if (version_match := version_regex.search(version_file_content)): - version = version_match.group("version") -else: - raise RuntimeError("Failed to parse version") - -long_description = (this_directory / "README.rst").read_text() - -setup( - name='utm', - version=version, - author='Tobias Bieniek', - author_email='Tobias.Bieniek@gmx.de', - url='https://github.com/Turbo87/utm', - description='Bidirectional UTM-WGS84 converter for python', - long_description=long_description, - long_description_content_type='text/x-rst', - keywords=['utm', 'wgs84', 'coordinate', 'converter'], - classifiers=[ - 'Programming Language :: Python', - 'License :: OSI Approved :: MIT License', - 'Operating System :: OS Independent', - 'Development Status :: 4 - Beta', - 'Environment :: Other Environment', - 'Intended Audience :: Developers', - 'Intended Audience :: Science/Research', - 'Topic :: Scientific/Engineering :: GIS', - ], - packages=['utm'], - python_requires=">=3.10", - scripts=['scripts/utm-converter'], -) diff --git a/scripts/utm-converter b/utm/cli.py similarity index 100% rename from scripts/utm-converter rename to utm/cli.py