-
Notifications
You must be signed in to change notification settings - Fork 129
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added versioning to dea-tools (#855)
* Added versioning to dea-tools * Added wheel and backend to pyproject.toml * Fixes for setup.py and manifest * Added build steps to readme * Reverted the local versioning * Fixes from Kirill Co-authored-by: Matthew Alger <[email protected]>
- Loading branch information
Showing
6 changed files
with
51 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,3 +2,6 @@ build/* | |
*.egg-info/* | ||
dist/* | ||
*.pyc | ||
|
||
# setuptools_scm/versioning hacks | ||
dea_tools/__version__.py |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
include README.md LICENSE | ||
include README.rst LICENSE |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
from .__version__ import version as __version__ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
[build-system] | ||
# Minimum requirements for the build system to execute. | ||
requires = ["setuptools>=42", "setuptools_scm[toml]>=3.4", "wheel"] | ||
build-backend = "setuptools.build_meta" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,8 +7,10 @@ | |
import os | ||
import sys | ||
from shutil import rmtree | ||
from pathlib import Path | ||
|
||
from setuptools import find_packages, setup, Command | ||
import setuptools_scm | ||
|
||
# Package meta-data. | ||
NAME = 'dea-tools' | ||
|
@@ -17,7 +19,6 @@ | |
EMAIL = '[email protected]' | ||
AUTHOR = 'Geoscience Australia' | ||
REQUIRES_PYTHON = '>=3.6.0' | ||
VERSION = '0.1.0' | ||
|
||
# Where are we? | ||
IS_SANDBOX = os.getenv('JUPYTER_IMAGE', default='').startswith('geoscienceaustralia/sandbox') | ||
|
@@ -83,16 +84,7 @@ | |
except FileNotFoundError: | ||
long_description = DESCRIPTION | ||
|
||
# Load the package's __version__.py module as a dictionary. | ||
about = {} | ||
if not VERSION: | ||
project_slug = NAME.lower().replace("-", "_").replace(" ", "_") | ||
with open(os.path.join(here, project_slug, '__version__.py')) as f: | ||
exec(f.read(), about) | ||
else: | ||
about['__version__'] = VERSION | ||
|
||
|
||
|
||
class UploadCommand(Command): | ||
"""Support setup.py upload.""" | ||
|
||
|
@@ -130,13 +122,32 @@ def run(self): | |
sys.exit() | ||
|
||
|
||
# Versioning magic. | ||
VERSION_FILE_PATH = Path('dea_tools/__version__.py') | ||
about = {} | ||
try: | ||
version = setuptools_scm.get_version( | ||
root='..', | ||
write_to='Tools' / VERSION_FILE_PATH, | ||
relative_to=__file__) | ||
except (LookupError, FileNotFoundError): | ||
# python -m build will trip the FNFError | ||
try: | ||
# no .git folder, so read from __version__.py | ||
with open(VERSION_FILE_PATH) as f_version: | ||
exec(f_version.read(), about) | ||
version = about['version'] | ||
except FileNotFoundError: | ||
# No __version__.py, yikes | ||
raise RuntimeError('Build in-place with --use-feature=in-tree-build.') | ||
|
||
# Where the magic happens: | ||
setup( | ||
name=NAME, | ||
version=about['__version__'], | ||
version=version, | ||
description=DESCRIPTION, | ||
long_description=long_description, | ||
long_description_content_type='text/markdown', | ||
long_description_content_type='text/x-rst', | ||
author=AUTHOR, | ||
author_email=EMAIL, | ||
python_requires=REQUIRES_PYTHON, | ||
|
@@ -156,7 +167,7 @@ def run(self): | |
'License :: OSI Approved :: Apache Software License', | ||
'Development Status :: 3 - Alpha', | ||
'Intended Audience :: Science/Research', | ||
'Topic :: Scientific/Engineering :: GIS' | ||
'Topic :: Scientific/Engineering :: GIS', | ||
'Programming Language :: Python', | ||
'Programming Language :: Python :: 3', | ||
'Programming Language :: Python :: 3.6', | ||
|