Skip to content

Commit

Permalink
Replace versioneer with setuptools-scm (fatiando#235)
Browse files Browse the repository at this point in the history
Remove the versioneer code from the repository base and the package
(`_version.py`). Include setuptools-scm as a setup dependency and
configure it to generate the version string into a `pooch/_version.py`
file whenever the package is built. We don't track this in version
control and the version inference is never done at run time. This
removes the need to use `pkg_resources` to get the version number and is
recommended by setuptools-scm. Needed to basically invert the
`MANIFEST.in` since setuptools-scm includes everything under version
control in the source distribution.
  • Loading branch information
leouieda committed May 7, 2021
1 parent 858d8f1 commit a53a4ad
Show file tree
Hide file tree
Showing 18 changed files with 60 additions and 2,452 deletions.
17 changes: 10 additions & 7 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ jobs:
name: PyPI
runs-on: ubuntu-latest
# Only publish from the origin repository, not forks
if: github.repository == 'fatiando/pooch'
if: github.repository_owner == 'fatiando'

steps:

Expand All @@ -59,18 +59,21 @@ jobs:
python-version: '3.8'

- name: Install requirements
run: python -m pip install setuptools twine wheel
run: python -m pip install setuptools setuptools_scm twine wheel

- name: List installed packages
run: python -m pip freeze

- name: Don't use local version numbers for TestPyPI uploads
if: github.event_name != 'release'
run: |
# 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
- name: Build source and wheel distributions
run: |
# Change the versioneer format to "pre" so that the commit hash isn't
# included (PyPI doesn't allow it). Can't do this permanently because
# we rely the hash to indicate to the tests that this is a local
# verison instead of a published version.
sed --in-place "s/pep440/pep440-pre/g" setup.cfg
python setup.py sdist bdist_wheel
echo ""
echo "Generated files:"
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,4 @@ doc/api/generated
*.egg-info
MANIFEST
.coverage.*
pooch/_version.py
2 changes: 1 addition & 1 deletion .pylintrc
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ extension-pkg-whitelist=

# Add files or directories to the blacklist. They should be base names, not
# paths.
ignore=CVS
ignore=CVS,_version.py

# Add files or directories matching the regex patterns to the blacklist. The
# regex matches against base names, not paths.
Expand Down
21 changes: 13 additions & 8 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
include README.rst
include LICENSE.txt
include CODE_OF_CONDUCT.md
include CONTRIBUTING.md
include AUTHORS.md
include MAINTENANCE.md
include versioneer.py
recursive-include pooch/tests/data **
# Exclude these files from source distributions.
# setuptools_scm includes everything else by default.
prune .github
prune data
prune doc
prune paper
exclude .*.yml
exclude .*rc
exclude requirements*.txt
exclude Makefile
exclude .gitignore
exclude .gitattributes
exclude environment.yml
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ black-check:

license:
python license_notice.py

license-check:
python license_notice.py --check

Expand All @@ -50,5 +50,5 @@ lint:
clean:
find . -name "*.pyc" -exec rm -v {} \;
find . -name ".coverage.*" -exec rm -v {} \;
rm -rvf build dist MANIFEST *.egg-info __pycache__ .coverage .cache .pytest_cache
rm -rvf build dist MANIFEST *.egg-info __pycache__ .coverage .cache .pytest_cache $(PROJECT)/_version.py
rm -rvf $(TESTDIR) dask-worker-space
6 changes: 3 additions & 3 deletions doc/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import datetime
import sphinx_rtd_theme

from pooch.version import full_version
import pooch

extensions = [
"sphinx.ext.autodoc",
Expand Down Expand Up @@ -51,10 +51,10 @@
year = datetime.date.today().year
project = "Pooch"
copyright = f"2018-{year}, The Pooch Developers."
if len(full_version.split("+")) > 1 or full_version == "unknown":
if len(pooch.__version__.split("+")) > 1 or pooch.__version__ == "unknown":
version = "dev"
else:
version = full_version
version = pooch.__version__

# These enable substitutions using |variable| in the rst files
rst_epilog = f"""
Expand Down
5 changes: 3 additions & 2 deletions environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,20 @@ channels:
- conda-forge
- defaults
dependencies:
- python=3.7
- python==3.7
- pip
- requests
- packaging
- appdirs
# Development requirements
- setuptools_scm
- pytest
- pytest-cov
- pytest-localftpserver
- coverage
- black>=20.8b1
- flake8
- pylint=2.4.*
- pylint==2.4.*
- sphinx==3.3.*
- sphinx_rtd_theme==0.5.0
- pathspec
10 changes: 7 additions & 3 deletions pooch/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,20 @@
#
# This code is part of the Fatiando a Terra project (https://www.fatiando.org)
#
# pylint: disable=missing-docstring,import-outside-toplevel
# pylint: disable=missing-docstring,import-outside-toplevel,import-self
#
# Import functions/classes to make the API
from . import version
from .core import Pooch, create, retrieve
from .utils import os_cache, file_hash, make_registry, check_version, get_logger
from .downloaders import HTTPDownloader, FTPDownloader, SFTPDownloader
from .processors import Unzip, Untar, Decompress

# This file is generated automatically by setuptools_scm
from . import _version


__version__ = version.full_version
# Add a "v" to the version number
__version__ = f"v{_version.version}"


def test(doctest=True, verbose=True, coverage=False):
Expand Down
Loading

0 comments on commit a53a4ad

Please sign in to comment.