Skip to content
Snippets Groups Projects
Commit 758bf9cf authored by Duncan Meacher's avatar Duncan Meacher
Browse files

Merge branch 'setuptools-scm' into 'master'

Use setuptools-scm for automatic versioning

Closes #30

See merge request !72
parents 32c73e45 6b5cabcd
No related branches found
No related tags found
1 merge request!72Use setuptools-scm for automatic versioning
Pipeline #541127 passed with warnings
...@@ -12,5 +12,7 @@ ...@@ -12,5 +12,7 @@
__pycache__/ __pycache__/
/.coverage /.coverage
.pytest_cache/ .pytest_cache/
/site/ /site/
# setuptools-scm
/gwdatafind_server/_version.py
...@@ -34,12 +34,18 @@ include: ...@@ -34,12 +34,18 @@ include:
TARBALL: "gwdatafind-server-*.tar.*" TARBALL: "gwdatafind-server-*.tar.*"
before_script: before_script:
- !reference [".debian:dsc", "before_script"] - !reference [".debian:dsc", "before_script"]
# unpack the tarball, update the debian changelog, and pack it up again # -- hack the tarball so that setuptools-scm version matches
# the debian changelog
- apt-get -yqq install devscripts - apt-get -yqq install devscripts
- export DEBFULLNAME="GitLab" - export DEBFULLNAME="GitLab"
- export DEBEMAIL="gitlab@git.ligo.org" - export DEBEMAIL="gitlab@git.ligo.org"
# unpack the tarball
- tar -zxf ${TARBALL} - tar -zxf ${TARBALL}
- (cd gwdatafind-server-*/ && dch --rebuild 'Rebuild for CI') # get version from the Python metadata
- PKG_VERSION=$(grep ^Version gwdatafind-server-*/PKG-INFO | cut -d\ -f2)
# add changelog entry
- (cd gwdatafind-server-*/ && dch --force-bad-version --newversion ${PKG_VERSION}-9999 'Rebuild for CI')
# pack it up again
- tar -zcf ${TARBALL} gwdatafind-server-*/ - tar -zcf ${TARBALL} gwdatafind-server-*/
dsc:bullseye: dsc:bullseye:
...@@ -92,9 +98,15 @@ deb:bookworm: ...@@ -92,9 +98,15 @@ deb:bookworm:
before_script: before_script:
# set up apt # set up apt
- !reference [".debian:base", before_script] - !reference [".debian:base", before_script]
# setup local apt repository # setup local apt repository with high priority
- apt-get -y -q -q install local-apt-repository - apt-get -y -q -q install local-apt-repository
- mkdir -pv /srv/local-apt-repository - mkdir -pv /srv/local-apt-repository
- |
cat > /etc/apt/preferences.d/99local-apt-repository << EOF
Package: *
Pin: origin ""
Pin-Priority: 1001
EOF
# fill our local apt repo and rebuild it # fill our local apt repo and rebuild it
- mv -v *.deb /srv/local-apt-repository - mv -v *.deb /srv/local-apt-repository
- /usr/lib/local-apt-repository/rebuild - /usr/lib/local-apt-repository/rebuild
......
...@@ -36,6 +36,23 @@ include: ...@@ -36,6 +36,23 @@ include:
- tarball - tarball
variables: variables:
TARBALL: "gwdatafind-server-*.tar.*" TARBALL: "gwdatafind-server-*.tar.*"
before_script:
- !reference [".rhel:srpm", "before_script"]
# -- hack the tarball so that the spec file matches the version
# from setuptools-scm
# unpack what we need from the tarball
- tar --file ${TARBALL} --wildcards --strip-components 1 --get gwdatafind-server*/*.spec gwdatafind-server*/PKG-INFO
# get the package version from the Python metadata
- PKG_VERSION=$(grep ^Version PKG-INFO | cut -d\ -f2)
# hack the version in the spec file
- sed -i 's|define version\( *\)\(.*\)|define unmangled_version '${PKG_VERSION}'\n%define version '${PKG_VERSION/-/+}'|' *.spec
- sed -i 's|pypi_source|pypi_source %{srcname} %{unmangled_version}|' *.spec
script:
# build the SRPM from the spec file (not the tarball)
- rpmbuild -bs
--define "_srcrpmdir ${CI_PROJECT_DIR}"
--define "_sourcedir ${CI_PROJECT_DIR}"
*.spec
srpm:el7: srpm:el7:
extends: extends:
......
...@@ -20,6 +20,13 @@ ...@@ -20,6 +20,13 @@
# use python3 # use python3
PYTHON: "python3" PYTHON: "python3"
script: script:
# ignore _version.py in coverage
- |
cat > .coveragerc << EOF
[run]
omit =
*/_version.py
EOF
# extract the tests from the tarball # extract the tests from the tarball
- tar -xf gwdatafind-server-*.tar.* --wildcards "*/tests" --strip-components=1 - tar -xf gwdatafind-server-*.tar.* --wildcards "*/tests" --strip-components=1
# run pytest # run pytest
......
...@@ -11,11 +11,13 @@ Build-Depends: ...@@ -11,11 +11,13 @@ Build-Depends:
debhelper (>= 9.20160709~) | dh-systemd, debhelper (>= 9.20160709~) | dh-systemd,
dh-python, dh-python,
python3-all, python3-all,
python3-setuptools,
python3-configobj, python3-configobj,
python3-flask (>= 1.0.0), python3-flask (>= 1.0.0),
python3-ligo-segments, python3-ligo-segments,
python3-scitokens, python3-scitokens,
python3-setuptools,
python3-setuptools-scm,
python3-wheel,
# -- python3-gwdatafind-server ------------------ # -- python3-gwdatafind-server ------------------
......
...@@ -10,7 +10,10 @@ query and receive URLs that indicate the locations ...@@ -10,7 +10,10 @@ query and receive URLs that indicate the locations
of the relevant data. of the relevant data.
""" """
__version__ = '1.2.2' try:
from ._version import version as __version__
except ModuleNotFoundError: # development mode
__version__ = 'dev'
from .app import GWDataFindApp from .app import GWDataFindApp
from .config import get_config_path from .config import get_config_path
......
[build-system] [build-system]
requires = [ requires = [
"setuptools>=42", "setuptools>=42",
"setuptools_scm[toml]>=3.4",
"wheel", "wheel",
] ]
build-backend = "setuptools.build_meta" build-backend = "setuptools.build_meta"
[tool.setuptools_scm]
write_to = "gwdatafind_server/_version.py"
# -- coverage.py # -- coverage.py
[tool.coverage.paths] [tool.coverage.paths]
......
...@@ -20,6 +20,8 @@ BuildRequires: python-rpm-macros ...@@ -20,6 +20,8 @@ BuildRequires: python-rpm-macros
BuildRequires: python3-rpm-macros BuildRequires: python3-rpm-macros
BuildRequires: %__python3 BuildRequires: %__python3
BuildRequires: python%{python3_pkgversion}-setuptools BuildRequires: python%{python3_pkgversion}-setuptools
BuildRequires: python%{python3_pkgversion}-setuptools_scm
BuildRequires: python%{python3_pkgversion}-wheel
BuildRequires: systemd BuildRequires: systemd
# these are needed for setuptools to parse the version number # these are needed for setuptools to parse the version number
......
...@@ -6,4 +6,4 @@ __author__ = "Duncan Macleod <duncan.macleod@ligo.org>" ...@@ -6,4 +6,4 @@ __author__ = "Duncan Macleod <duncan.macleod@ligo.org>"
from setuptools import setup from setuptools import setup
setup() setup(use_scm_version=True)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment