-
Notifications
You must be signed in to change notification settings - Fork 123
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Follow modern python packaging and conf practices
* Add PEP 517/518 pyproject.toml file * Add setuptools_scm to handle versioning * Add setup.py content to setup.cfg * Update setup.py to act as a shim (so pip install -e works) Addresses: #2 Signed-off-by: Steven Esser <[email protected]>
- Loading branch information
1 parent
774dc7d
commit 9a56b88
Showing
5 changed files
with
80 additions
and
166 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
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,46 @@ | ||
[build-system] | ||
requires = ["setuptools >= 50", "wheel", "setuptools_scm[toml] >= 4"] | ||
build-backend = "setuptools.build_meta" | ||
|
||
[tool.setuptools_scm] | ||
|
||
[tool.pytest.ini_options] | ||
norecursedirs = [ | ||
".git", | ||
"bin", | ||
"dist", | ||
"build", | ||
"_build", | ||
"dist", | ||
"etc", | ||
"local", | ||
"ci", | ||
"docs", | ||
"man", | ||
"share", | ||
"samples", | ||
".cache", | ||
".settings", | ||
"Include", | ||
"include", | ||
"Lib", | ||
"lib", | ||
"lib64", | ||
"Lib64", | ||
"Scripts", | ||
"thirdparty", | ||
"tmp", | ||
"tests/data", | ||
".eggs" | ||
] | ||
|
||
python_files = "*.py" | ||
|
||
python_classes="Test" | ||
python_functions="test" | ||
|
||
addopts = [ | ||
"-rfExXw", | ||
"--strict", | ||
"--doctest-modules" | ||
] |
This file was deleted.
Oops, something went wrong.
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,49 +2,36 @@ | |
universal=1 | ||
|
||
[metadata] | ||
license_files = | ||
README.rst | ||
CHANGELOG.rst | ||
apache-2.0.LICENSE | ||
bsd-new.LICENSE | ||
mit.LICENSE | ||
NOTICE | ||
license_file = apache-2.0.LICENSE | ||
name = skeleton | ||
author = nexB. Inc. and others | ||
author_email = [email protected] | ||
description = skeleton | ||
long_description = file:README.rst | ||
url = https://github.com/nexB/skeleton | ||
classifiers = | ||
Development Status :: 5 - Production/Stable | ||
Intended Audience :: Developers | ||
Programming Language :: Python :: 3 | ||
Programming Language :: Python :: 3 :: Only | ||
Topic :: Software Development | ||
Topic :: Utilities | ||
keywords = | ||
|
||
[tool:pytest] | ||
norecursedirs = | ||
.git | ||
bin | ||
dist | ||
build | ||
_build | ||
dist | ||
etc | ||
local | ||
ci | ||
docs | ||
man | ||
share | ||
samples | ||
.cache | ||
.settings | ||
Include | ||
include | ||
Lib | ||
lib | ||
lib64 | ||
Lib64 | ||
Scripts | ||
thirdparty | ||
tmp | ||
tests/data | ||
[options] | ||
package_dir= | ||
=src | ||
packages=find: | ||
include_package_data = true | ||
zip_safe = false | ||
install_requires = | ||
setup_requires = setuptools_scm[toml] >= 4 | ||
|
||
python_files = *.py | ||
[options.packages.find] | ||
where=src | ||
|
||
python_classes=Test | ||
python_functions=test | ||
|
||
addopts = | ||
-rfExXw | ||
--strict | ||
--ignore setup.py | ||
--doctest-modules | ||
[options.extras_require] | ||
testing = | ||
# upstream | ||
pytest >= 6 | ||
pytest-xdist >= 2 |
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,124 +1,6 @@ | ||
#!/usr/bin/env python | ||
# -*- encoding: utf-8 -*- | ||
|
||
from __future__ import absolute_import | ||
from __future__ import print_function | ||
import setuptools | ||
|
||
import io | ||
from glob import glob | ||
from os.path import basename | ||
from os.path import dirname | ||
from os.path import join | ||
from os.path import splitext | ||
import re | ||
import sys | ||
|
||
from setuptools import find_packages | ||
from setuptools import setup | ||
|
||
version = '0.0.0' | ||
|
||
#### Small hack to force using a plain version number if the option | ||
#### --plain-version is passed to setup.py | ||
|
||
USE_DEFAULT_VERSION = False | ||
try: | ||
sys.argv.remove('--use-default-version') | ||
USE_DEFAULT_VERSION = True | ||
except ValueError: | ||
pass | ||
#### | ||
|
||
|
||
def get_version(default=version, template='{tag}.{distance}.{commit}{dirty}', | ||
use_default=USE_DEFAULT_VERSION): | ||
""" | ||
Return a version collected from git if possible or fall back to an | ||
hard-coded default version otherwise. If `use_default` is True, | ||
always use the default version. | ||
""" | ||
if use_default: | ||
return default | ||
try: | ||
tag, distance, commit, dirty = get_git_version() | ||
if not distance and not dirty: | ||
# we are from a clean Git tag: use tag | ||
return tag | ||
|
||
distance = 'post{}'.format(distance) | ||
if dirty: | ||
time_stamp = get_time_stamp() | ||
dirty = '.dirty.' + get_time_stamp() | ||
else: | ||
dirty = '' | ||
|
||
return template.format(**locals()) | ||
except: | ||
# no git data: use default version | ||
return default | ||
|
||
|
||
def get_time_stamp(): | ||
""" | ||
Return a numeric UTC time stamp without microseconds. | ||
""" | ||
from datetime import datetime | ||
return (datetime.isoformat(datetime.utcnow()).split('.')[0] | ||
.replace('T', '').replace(':', '').replace('-', '')) | ||
|
||
|
||
def get_git_version(): | ||
""" | ||
Return version parts from Git or raise an exception. | ||
""" | ||
from subprocess import check_output, STDOUT | ||
# this may fail with exceptions | ||
cmd = 'git', 'describe', '--tags', '--long', '--dirty', | ||
version = check_output(cmd, stderr=STDOUT).strip() | ||
dirty = version.endswith('-dirty') | ||
tag, distance, commit = version.split('-')[:3] | ||
# lower tag and strip V prefix in tags | ||
tag = tag.lower().lstrip('v ').strip() | ||
# strip leading g from git describe commit | ||
commit = commit.lstrip('g').strip() | ||
return tag, int(distance), commit, dirty | ||
|
||
|
||
def read(*names, **kwargs): | ||
return io.open( | ||
join(dirname(__file__), *names), | ||
encoding=kwargs.get('encoding', 'utf8') | ||
).read() | ||
|
||
|
||
setup( | ||
name='', | ||
version=get_version(), | ||
license='Apache-2.0', | ||
description='', | ||
long_description=read('README.rst'), | ||
author='nexB. Inc. and others', | ||
author_email='[email protected]', | ||
url='', | ||
packages=find_packages('src'), | ||
package_dir={'': 'src'}, | ||
py_modules=[splitext(basename(path))[0] for path in glob('src/*.py')], | ||
include_package_data=True, | ||
zip_safe=False, | ||
classifiers=[ | ||
# complete classifier list: http://pypi.python.org/pypi?%3Aaction=list_classifiers | ||
'Development Status :: 5 - Production/Stable', | ||
'Intended Audience :: Developers', | ||
'Programming Language :: Python', | ||
'Programming Language :: Python :: 3', | ||
'Programming Language :: Python :: 3.6', | ||
'Programming Language :: Python :: 3.7', | ||
'Programming Language :: Python :: 3.8', | ||
'Topic :: Software Development', | ||
'Topic :: Utilities', | ||
], | ||
keywords=[ | ||
], | ||
install_requires=[ | ||
] | ||
) | ||
if __name__ == "__main__": | ||
setuptools.setup() |