Commit 220adecd authored by Leo Pound Singer's avatar Leo Pound Singer

Add version info with Versioneer

Note that we have to build the source distribution first, and then
build the wheel from the source distribution, because Versioneer
cannot generate a valid `_version.py` file for a wheel directly
(see https://github.com/warner/python-versioneer/issues/170).

Fixes #54.
parent 406d934d
gwcelery/_version.py export-subst
......@@ -7,16 +7,30 @@ stages:
- test
- deploy
# Build Python packages
dist:
# Build source distribution
sdist:
image: python:3.7-slim
stage: dist
script:
- python setup.py sdist bdist_wheel
- python setup.py sdist
- mv dist/* .
artifacts:
paths:
- '*.tar.gz'
# Build binary distribution
bdist:
image: python:3.7-slim
stage: test
script:
- tar --strip-components 1 -xf *.tar.*
- python setup.py bdist_wheel
- mv dist/* .
dependencies:
- sdist
artifacts:
paths:
- '*.whl'
# Build Docker container for dependencies
......@@ -63,7 +77,7 @@ dependencies/python3.7:
- docker push $IMAGE_TAG
- if [ "${CI_COMMIT_TAG:0:1}" = "v" ]; then docker tag $IMAGE_TAG ${IMAGE_TAG%:*}:latest; docker push ${IMAGE_TAG%:*}:latest; fi
dependencies:
- dist
- sdist
docker/python3.6:
<<: *docker
docker/python3.7:
......@@ -82,7 +96,7 @@ docker/python3.7:
- pip install pytest-cov
- python setup.py test --addopts='-vv --cov --cov-report=html --cov-report=term'
dependencies:
- dist
- sdist
artifacts:
paths:
- htmlcov/
......@@ -103,7 +117,7 @@ lint:
- pip install flake8 pep8-naming
- flake8 --show-source .
dependencies:
- dist
- sdist
# Generate documentation
doc:
......@@ -117,7 +131,7 @@ doc:
- tar --strip-components 1 -xf *.tar.*
- python setup.py build_sphinx
dependencies:
- dist
- sdist
# Publish coverage
pages:
......@@ -143,6 +157,7 @@ pypi:
- pip install twine
- twine upload *.tar.* *.whl
dependencies:
- dist
- sdist
- bdist
only:
- tags@emfollow/gwcelery
graft doc
include *requirements.txt
include versioneer.py
include gwcelery/_version.py
......@@ -61,7 +61,6 @@ master_doc = 'index'
# General information about the project.
setup_cfg = configparser.ConfigParser()
setup_cfg.read('../setup.cfg')
parsed_version = pkg_resources.parse_version(setup_cfg['metadata']['version'])
project = setup_cfg['metadata']['name']
author = setup_cfg['metadata']['author']
description = setup_cfg['metadata']['description']
......@@ -71,6 +70,14 @@ description = setup_cfg['metadata']['description']
# built documents.
#
# The short X.Y version.
spec = importlib.util.spec_from_file_location(
'_version', '../gwcelery/_version.py')
module = importlib.util.module_from_spec(spec)
spec.loader.exec_module(module)
parsed_version = pkg_resources.parse_version(module.get_versions()['version'])
del module, spec
version = parsed_version.base_version
# The full version, including alpha/beta/rc tags.
release = parsed_version.public
......
......@@ -2,11 +2,15 @@
from celery import Celery
from ._version import get_versions
from .conf import playground
from . import sentry
__all__ = ('app',)
__version__ = get_versions()['version']
del get_versions
# Use redis broker, because it supports locks (and thus singleton tasks).
app = Celery(__name__, broker='redis://', autofinalize=False)
"""Celery application object."""
......
This diff is collapsed.
......@@ -14,9 +14,11 @@ concurrency =
thread
multiprocessing
[flake8]
exclude = versioneer.py
[metadata]
name = gwcelery
version = 0.2.5.dev0
license = GPL-2+
author = Leo Singer
author_email = leo.singer@ligo.org
......@@ -51,3 +53,9 @@ console_scripts =
[options.package_data]
gwcelery = templates/*.html, templates/*.ini, data/*.sub, data/first2years/2016/*.xml.gz
gwcelery.tests = data/*.html, data/*.json, data/*.xml, data/*.xml.gz, data/llhoft/*/*/*.gwf, data/*.sqlite
[versioneer]
VCS = git
versionfile_source = gwcelery/_version.py
tag_prefix = v
parentdir_prefix = gwcelery-
import sys
import versioneer
import pkg_resources
from setuptools import setup
......@@ -16,4 +17,6 @@ if {'build_sphinx'}.intersection(sys.argv):
setup_requires.extend(get_requirements('docs-requirements.txt'))
setup(install_requires=get_requirements('requirements.txt'),
setup_requires=setup_requires)
setup_requires=setup_requires,
version=versioneer.get_version(),
cmdclass=versioneer.get_cmdclass())
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment