From 3b233832eef972a8e3bc0d55d9c0a3768eb2f89d Mon Sep 17 00:00:00 2001 From: Mike Taves Date: Tue, 22 Nov 2022 14:10:02 +1300 Subject: [PATCH] Move project metadata to pyproject.toml; add build-backend --- .github/workflows/ci_linux.yml | 2 +- MANIFEST.in | 2 +- pyproject.toml | 83 ++++++++++++++++++++++++++++-- pytest.ini | 1 + requirements-dev.txt | 8 +-- requirements.txt | 2 +- setup.py | 94 +--------------------------------- 7 files changed, 90 insertions(+), 102 deletions(-) diff --git a/.github/workflows/ci_linux.yml b/.github/workflows/ci_linux.yml index 97a716800..40db9ab99 100644 --- a/.github/workflows/ci_linux.yml +++ b/.github/workflows/ci_linux.yml @@ -159,7 +159,7 @@ jobs: continue-on-error: ${{ matrix.allow_failure == 'true' }} run: | if [ "$GDALVERSION" = "master" ]; then echo "Using gdal master"; elif [ $($GDALINST/gdal-$GDALVERSION/bin/gdal-config --version) == $(sed 's/[a-zA-Z].*//g' <<< $GDALVERSION) ]; then echo "Using gdal $GDALVERSION"; else echo "NOT using gdal $GDALVERSION as expected; aborting"; exit 1; fi - GDAL_CONFIG=$GDALINST/gdal-$GDALVERSION/bin/gdal-config python -m pip install --no-deps --force-reinstall --no-use-pep517 -e . + GDAL_CONFIG=$GDALINST/gdal-$GDALVERSION/bin/gdal-config python -m pip install --no-deps -v -e . - name: Print Environment continue-on-error: ${{ matrix.allow_failure == 'true' }} diff --git a/MANIFEST.in b/MANIFEST.in index a69d12472..fb4bcee87 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -8,5 +8,5 @@ recursive-include tests *.py recursive-include tests/data * recursive-include fiona *.pyx *.pxd *.pxi recursive-exclude fiona *.c *.cpp -include CHANGES.txt CITATION.txt CREDITS.txt LICENSE.txt VERSION.txt README.rst +include CHANGES.txt CITATION.txt CREDITS.txt LICENSE.txt README.rst include benchmark.py pyproject.toml setup.py requirements.txt diff --git a/pyproject.toml b/pyproject.toml index f225ffcc1..f5b6e1ecc 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,7 +1,84 @@ [build-system] requires = [ - "cython>=0.29.29", + "Cython~=0.29", "oldest-supported-numpy", - "setuptools", - "wheel", + "setuptools>=61", ] +build-backend = "setuptools.build_meta" + +[project] +name = "Fiona" +dynamic = ["readme", "version"] +authors = [ + {name = "Sean Gillies"}, +] +maintainers = [ + {name = "Fiona contributors"}, +] +description = "Fiona reads and writes spatial data files" +keywords = ["gis", "vector", "feature", "data"] +license = {text = "BSD 3-Clause"} +classifiers = [ + "Development Status :: 5 - Production/Stable", + "Intended Audience :: Developers", + "Intended Audience :: Science/Research", + "License :: OSI Approved :: BSD License", + "Operating System :: OS Independent", + "Programming Language :: Python :: 3.7", + "Programming Language :: Python :: 3.8", + "Programming Language :: Python :: 3.9", + "Programming Language :: Python :: 3.10", + "Programming Language :: Python :: 3.11", + "Topic :: Scientific/Engineering :: GIS", +] + +requires-python = ">=3.7" +dependencies = [ + "attrs>=19.2.0", + "certifi", + "click~=8.0", + "click-plugins>=1.0", + "cligj>=0.5", + "munch>=2.3.2", +] + +[project.optional-dependencies] +all = ["Fiona[calc,s3,test]"] +calc = ["shapely"] +s3 = ["boto3>=1.3.1"] +test = [ + "Cython~=0.29", + "Fiona[s3]", + "pytest>=7", + "pytest-cov", + "pytz", +] + +[project.scripts] +fio = "fiona.fio.main:main_group" + +[project.entry-points."fiona.fio_commands"] +bounds = "fiona.fio.bounds:bounds" +calc = "fiona.fio.calc:calc" +cat = "fiona.fio.cat:cat" +collect = "fiona.fio.collect:collect" +distrib = "fiona.fio.distrib:distrib" +dump = "fiona.fio.dump:dump" +env = "fiona.fio.env:env" +filter = "fiona.fio.filter:filter" +info = "fiona.fio.info:info" +insp = "fiona.fio.insp:insp" +load = "fiona.fio.load:load" +ls = "fiona.fio.ls:ls" +rm = "fiona.fio.rm:rm" + +[project.urls] +Documentation = "https://fiona.readthedocs.io/" +Repository = "https://github.com/Toblerity/Fiona" + +[tool.setuptools.packages.find] +include = ["fiona", "fiona.*"] + +[tool.setuptools.dynamic] +version = {attr = "fiona.__version__"} +readme = {file = ["README.rst", "CHANGES.txt", "CREDITS.txt"]} diff --git a/pytest.ini b/pytest.ini index b561de378..26c5bb359 100644 --- a/pytest.ini +++ b/pytest.ini @@ -10,4 +10,5 @@ markers = network: marks tests that require a network connection wheel: marks test that only works when installed from wheel +addopts = --import-mode=importlib testpaths = tests diff --git a/requirements-dev.txt b/requirements-dev.txt index 42c6b650c..b942b4b37 100644 --- a/requirements-dev.txt +++ b/requirements-dev.txt @@ -1,8 +1,8 @@ -r requirements.txt boto3>=1.3.1 -coverage==5.2.1 +coverage~=6.5 cython~=0.29 -pytest==6.2.5 -pytest-cov==2.12.1 -pytz==2020.1 +pytest~=7.2 +pytest-cov~=4.0 +pytz==2022.6 wheel diff --git a/requirements.txt b/requirements.txt index 7a509968b..3231b032a 100644 --- a/requirements.txt +++ b/requirements.txt @@ -3,5 +3,5 @@ click~=8.0 click-plugins cligj>=0.5.0 munch>=2.3.2 -setuptools>=49.0 +setuptools>=61.0 certifi diff --git a/setup.py b/setup.py index a97cdd7c3..2241a6e13 100644 --- a/setup.py +++ b/setup.py @@ -1,6 +1,4 @@ -from distutils.command.sdist import sdist from distutils import log -import itertools as it import os import shutil import subprocess @@ -27,28 +25,6 @@ def copy_data_tree(datadir, destdir): shutil.copytree(datadir, destdir) -# Parse the version from the fiona module. -with open('fiona/__init__.py', 'r') as f: - for line in f: - if line.find("__version__") >= 0: - version = line.split("=")[1].strip().strip('"').strip("'") - break - -# Fiona's auxiliary files are UTF-8 encoded -open_kwds = {'encoding': 'utf-8'} - -with open('VERSION.txt', 'w', **open_kwds) as f: - f.write(version) - -with open('README.rst', **open_kwds) as f: - readme = f.read() - -with open('CREDITS.txt', **open_kwds) as f: - credits = f.read() - -with open('CHANGES.txt', **open_kwds) as f: - changes = f.read() - # Building Fiona requires options that can be obtained from GDAL's gdal-config # program or can be specified using setup arguments. The latter override the # former. @@ -216,74 +192,8 @@ def copy_data_tree(datadir, destdir): compile_time_env=compile_time_env, ) -requirements = [ - 'attrs>=17', - 'certifi', - 'click>=4.0', - 'cligj>=0.5', - 'click-plugins>=1.0', - 'munch', -] - -extras_require = { - 'calc': ['shapely'], - 's3': ['boto3>=1.2.4'], - 'test': ['pytest>=3', 'pytest-cov', 'boto3>=1.2.4'] -} - -extras_require['all'] = list(set(it.chain(*extras_require.values()))) - - -setup_args = dict( - metadata_version='1.2', - name='Fiona', - version=version, - python_requires='>=3.7', - requires_external='GDAL (>=3.1)', - description="Fiona reads and writes spatial data files", - license='BSD', - keywords='gis vector feature data', - author='Sean Gillies', - author_email='sean.gillies@gmail.com', - maintainer='Sean Gillies', - maintainer_email='sean.gillies@gmail.com', - url='https://github.com/Toblerity/Fiona', - long_description=readme + "\n" + changes + "\n" + credits, - package_dir={'': '.'}, - packages=['fiona', 'fiona.fio'], - entry_points=''' - [console_scripts] - fio=fiona.fio.main:main_group - - [fiona.fio_commands] - bounds=fiona.fio.bounds:bounds - calc=fiona.fio.calc:calc - cat=fiona.fio.cat:cat - collect=fiona.fio.collect:collect - distrib=fiona.fio.distrib:distrib - dump=fiona.fio.dump:dump - env=fiona.fio.env:env - filter=fiona.fio.filter:filter - info=fiona.fio.info:info - insp=fiona.fio.insp:insp - load=fiona.fio.load:load - ls=fiona.fio.ls:ls - rm=fiona.fio.rm:rm - ''', - install_requires=requirements, - extras_require=extras_require, - ext_modules=ext_modules, - classifiers=[ - 'Development Status :: 5 - Production/Stable', - 'Intended Audience :: Developers', - 'Intended Audience :: Science/Research', - 'License :: OSI Approved :: BSD License', - 'Operating System :: OS Independent', - 'Programming Language :: Python :: 3.7', - 'Programming Language :: Python :: 3.8', - 'Programming Language :: Python :: 3.9', - 'Programming Language :: Python :: 3.10', - 'Topic :: Scientific/Engineering :: GIS']) +# See pyproject.toml for project metadata +setup_args = dict(ext_modules=ext_modules) if os.environ.get('PACKAGE_DATA'): setup_args['package_data'] = {'fiona': ['gdal_data/*', 'proj_data/*', '.libs/*', '.libs/licenses/*']}