Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move configuration from setup.py to setup.cfg #348

Merged
merged 3 commits into from
Dec 22, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 26 additions & 25 deletions .github/workflows/docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ jobs:
build:
runs-on: ubuntu-latest
env:
REQUIREMENTS: requirements.txt env/requirements-docs.txt env/requirements-optional.txt env/requirements-build.txt
PYTHON: 3.8
REQUIREMENTS: env/requirements-build.txt env/requirements-docs.txt env/requirements-optional.txt
PYTHON: 3.9

steps:
# Cancel any previous run of the test job
Expand Down Expand Up @@ -61,12 +61,6 @@ jobs:
- name: Fetch git tags
run: git fetch origin 'refs/tags/*:refs/tags/*'

- name: Setup caching for conda packages
uses: actions/cache@v2
with:
path: ~/conda_pkgs_dir
key: conda-${{ runner.os }}-${{ env.PYTHON }}-${{ hashFiles('**/requirements*.txt') }}

- name: Setup Miniconda
uses: conda-incubator/setup-miniconda@v2
with:
Expand All @@ -77,24 +71,31 @@ jobs:
# Needed for caching
use-only-tar-bz2: true

- name: Install requirements
- name: Collect requirements - run-time
run: python tools/export_requirements.py > requirements-full.txt

- name: Collect requirements - other
run: |
requirements_file=requirements-full.txt
if [ ! -z "$REQUIREMENTS" ]; then
echo "Capturing dependencies from $REQUIREMENTS"
for requirement in $REQUIREMENTS
do
cat $requirement >> $requirements_file
done
fi
if [ -f $requirements_file ]; then
echo "Collected dependencies:"
cat $requirements_file
echo ""
mamba install --quiet --file $requirements_file python=$PYTHON
else
echo "No requirements defined."
fi
echo "Capturing dependencies from:"
for requirement in $REQUIREMENTS
do
echo " $requirement"
cat $requirement >> requirements-full.txt
done

- name: List requirements
run: |
echo "Collected dependencies:"
cat requirements-full.txt

- name: Setup caching for conda packages
uses: actions/cache@v2
with:
path: ~/conda_pkgs_dir
key: conda-${{ runner.os }}-${{ env.PYTHON }}-${{ hashFiles('requirements-full.txt') }}

- name: Install requirements
run: mamba install --quiet --file requirements-full.txt python=$PYTHON

- name: List installed packages
run: mamba list
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/pypi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,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/node-and-date/no-local-version/g" setup.py
sed --in-place "s/node-and-date/no-local-version/g" pyproject.toml

- name: Build source and wheel distributions
run: |
Expand Down
68 changes: 33 additions & 35 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,21 +46,14 @@ jobs:
- "3.9"
dependencies:
- latest
include:
- os: ubuntu
python: "3.9"
dependencies: optional
- os: macos
python: "3.9"
dependencies: optional
- os: windows
python: "3.9"
dependencies: optional
- optional

env:
REQUIREMENTS: requirements.txt env/requirements-test.txt env/requirements-build.txt
REQUIREMENTS: env/requirements-build.txt env/requirements-test.txt
# Used to tag codecov submissions
OS: ${{ matrix.os }}
PYTHON: ${{ matrix.python }}
DEPENDENCIES: ${{ matrix.dependencies }}

steps:
# Cancel any previous run of the test job
Expand Down Expand Up @@ -88,12 +81,6 @@ jobs:
- name: Fetch git tags
run: git fetch origin 'refs/tags/*:refs/tags/*'

- name: Setup caching for conda packages
uses: actions/cache@v2
with:
path: ~/conda_pkgs_dir
key: conda-${{ runner.os }}-${{ env.PYTHON }}-${{ hashFiles('**/requirements*.txt') }}

- name: Setup Miniconda
uses: conda-incubator/setup-miniconda@v2
with:
Expand All @@ -104,24 +91,35 @@ jobs:
# Needed for caching
use-only-tar-bz2: true

- name: Install requirements
- name: Collect requirements - run-time
run: python tools/export_requirements.py > requirements-full.txt

- name: Collect requirements - optional
if: matrix.dependencies == 'optional'
run: cat env/requirements-optional.txt >> requirements-full.txt

- name: Collect requirements - other
run: |
echo "Capturing dependencies from:"
for requirement in $REQUIREMENTS
do
echo " $requirement"
cat $requirement >> requirements-full.txt
done

- name: List requirements
run: |
requirements_file=requirements-full.txt
if [ ! -z "$REQUIREMENTS" ]; then
echo "Capturing dependencies from $REQUIREMENTS"
for requirement in $REQUIREMENTS
do
cat $requirement >> $requirements_file
done
fi
if [ "${{ matrix.dependencies }}" == "optional" ]; then
echo "Capturing optional dependencies"
cat env/requirements-optional.txt >> $requirements_file
fi
echo "Collected dependencies:"
cat $requirements_file
echo ""
mamba install --quiet --file $requirements_file python=$PYTHON
cat requirements-full.txt

- name: Setup caching for conda packages
uses: actions/cache@v2
with:
path: ~/conda_pkgs_dir
key: conda-${{ runner.os }}-${{ env.PYTHON }}-${{ hashFiles('requirements-full.txt') }}

- name: Install requirements
run: mamba install --quiet --file requirements-full.txt python=$PYTHON

- name: List installed packages
run: conda list
Expand All @@ -136,7 +134,7 @@ jobs:
- name: Install the package
run: python -m pip install --no-deps dist/*.whl

- name: Copy test data to cache
- name: Copy test data to the cache
run: |
echo "Copy data to " ${VERDE_DATA_DIR}/main
set -x -e
Expand All @@ -160,7 +158,7 @@ jobs:
uses: codecov/codecov-action@v1
with:
file: ./coverage.xml
env_vars: OS,PYTHON
env_vars: OS,PYTHON,DEPENDENCIES
# Don't mark the job as failed if the upload fails for some reason.
# It does sometimes but shouldn't be the reason for running
# everything again unless something else is broken.
Expand Down
22 changes: 13 additions & 9 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
include README.rst
include LICENSE.txt
include CODE_OF_CONDUCT.md
include CONTRIBUTING.md
include AUTHORS.md
include requirements.txt
include verde/datasets/registry.txt
recursive-include verde/tests/data *
recursive-include verde/tests/baseline *
# Exclude these files from source distributions.
# setuptools_scm includes everything else by default.
prune .github
prune data
prune doc
prune env
prune paper
prune tools
exclude .*.yml
exclude .*rc
exclude Makefile
exclude .gitignore
exclude environment.yml
6 changes: 3 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
PROJECT=verde
TESTDIR=tmp-test-dir-with-unique-name
PYTEST_ARGS=--cov-config=../.coveragerc --cov-report=term-missing --cov=$(PROJECT) --doctest-modules -v --pyargs
CHECK_STYLE=setup.py $(PROJECT) examples data/examples doc/conf.py tutorials license_notice.py
CHECK_STYLE=setup.py $(PROJECT) examples data/examples doc/conf.py tutorials tools

help:
@echo "Commands:"
Expand Down Expand Up @@ -35,10 +35,10 @@ black-check:
black --check $(CHECK_STYLE)

license:
python license_notice.py
python tools/license_notice.py

license-check:
python license_notice.py --check
python tools/license_notice.py --check

isort:
isort $(CHECK_STYLE)
Expand Down
11 changes: 11 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,3 +1,14 @@
# Specify that we use setuptools and setuptools_scm (to generate the version
# string). Actual configuration is in setup.py and setup.cfg.
[build-system]
requires = ["setuptools>=45", "wheel", "setuptools_scm[toml]>=6.2"]
build-backend = "setuptools.build_meta"

[tool.setuptools_scm]
version_scheme = "post-release"
local_scheme = "node-and-date"
write_to = "verde/_version_generated.py"

# Make sure isort and Black are compatible
[tool.isort]
profile = "black"
Expand Down
7 changes: 0 additions & 7 deletions requirements.txt

This file was deleted.

54 changes: 54 additions & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
@@ -1,3 +1,57 @@
[metadata]
name = verde
fullname = Verde
description = "Processing and gridding spatial data, machine-learning style"
long_description = file: README.rst
long_description_content_type = text/x-rst
author = The Verde Developers
author_email = fatiandoaterra@protonmail.com
maintainer = "Leonardo Uieda"
maintainer_email = leouieda@gmail.com
license = BSD 3-Clause License
license_file = LICENSE.txt
platform = any
keywords = spatial, geoscience, geophysics, gridding, interpolation
classifiers =
Development Status :: 5 - Production/Stable
Intended Audience :: Science/Research
Intended Audience :: Developers
Intended Audience :: Education
License :: OSI Approved :: BSD License
Natural Language :: English
Operating System :: OS Independent
Topic :: Scientific/Engineering
Topic :: Software Development :: Libraries
Programming Language :: Python :: 3 :: Only
Programming Language :: Python :: 3.6
Programming Language :: Python :: 3.7
Programming Language :: Python :: 3.8
Programming Language :: Python :: 3.9
url = https://github.com/fatiando/verde
project_urls =
Documentation = https://www.fatiando.org/verde
Release Notes = https://github.com/fatiando/verde/releases
Bug Tracker = https://github.com/fatiando/verde/issues
Source Code = https://github.com/fatiando/verde

[options]
zip_safe = True
include_package_data = True
packages = find:
python_requires = >=3.6
install_requires =
numpy
scipy
pandas
xarray
scikit-learn
pooch>=0.7.0
dask!=2021.03.0

[options.package_data]
verde.tests = data/*, baseline/*
verde.datasets = registry.txt

[flake8]
max-line-length = 88
max-doc-length = 79
Expand Down
75 changes: 4 additions & 71 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,78 +5,11 @@
# This code is part of the Fatiando a Terra project (https://www.fatiando.org)
#
"""
Build and install the project.

Setup script for the Python package.
Metadata and build configuration are defined in setup.cfg
Uses setuptools-scm to manage version numbers using git tags.
"""
from setuptools import find_packages, setup

NAME = "verde"
FULLNAME = "Verde"
AUTHOR = "The Verde Developers"
AUTHOR_EMAIL = "leouieda@gmail.com"
MAINTAINER = "Leonardo Uieda"
MAINTAINER_EMAIL = AUTHOR_EMAIL
LICENSE = "BSD License"
URL = "https://github.com/fatiando/verde"
DESCRIPTION = "Processing and gridding spatial data"
KEYWORDS = ""
with open("README.rst") as f:
LONG_DESCRIPTION = "".join(f.readlines())
CLASSIFIERS = [
"Development Status :: 5 - Production/Stable",
"Intended Audience :: Science/Research",
"Intended Audience :: Developers",
"Intended Audience :: Education",
"Topic :: Scientific/Engineering",
"Topic :: Software Development :: Libraries",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.6",
"Programming Language :: Python :: 3.7",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3 :: Only",
"License :: OSI Approved :: {}".format(LICENSE),
]
PLATFORMS = "Any"
PACKAGES = find_packages(exclude=["doc"])
SCRIPTS = []
PACKAGE_DATA = {
"verde.datasets": ["registry.txt"],
"verde.tests": ["data/*", "baseline/*"],
}
with open("requirements.txt") as f:
INSTALL_REQUIRES = f.readlines()
PYTHON_REQUIRES = ">=3.6"
# Configuration for setuptools-scm
SETUP_REQUIRES = ["setuptools_scm"]
USE_SCM_VERSION = {
"relative_to": __file__,
"version_scheme": "post-release",
"local_scheme": "node-and-date",
"write_to": f"{NAME}/_version_generated.py",
}
from setuptools import setup

if __name__ == "__main__":
setup(
name=NAME,
fullname=FULLNAME,
description=DESCRIPTION,
long_description=LONG_DESCRIPTION,
use_scm_version=USE_SCM_VERSION,
author=AUTHOR,
author_email=AUTHOR_EMAIL,
maintainer=MAINTAINER,
maintainer_email=MAINTAINER_EMAIL,
license=LICENSE,
url=URL,
platforms=PLATFORMS,
scripts=SCRIPTS,
packages=PACKAGES,
package_data=PACKAGE_DATA,
classifiers=CLASSIFIERS,
keywords=KEYWORDS,
install_requires=INSTALL_REQUIRES,
python_requires=PYTHON_REQUIRES,
setup_requires=SETUP_REQUIRES,
)
setup()
Loading