Commit ac980054 authored by Gregory Ashton's avatar Gregory Ashton
Browse files

Merge branch 'add-versioneer' into 'master'

Switch to versioneer

See merge request !457
parents f8a06f8e 82e9e4c1
Pipeline #417740 failed with stages
in 12 minutes and 15 seconds
bilby_pipe/_version.py export-subst
include LICENSE
include versioneer.py
include bilby_pipe/_version.py
......@@ -10,6 +10,9 @@ estimation on computing clusters.
from . import bilbyargparser, main, parser, utils
__version__ = utils.get_version_information()
__short_version__ = utils.get_version_information().split(":", 1)[0]
__long_version__ = utils.get_version_information()
from . import _version
__version__ = _version.get_versions()["version"]
This diff is collapsed.
......@@ -13,7 +13,6 @@ import sys
import urllib
import urllib.request
from importlib import import_module
from pathlib import Path
import bilby
......@@ -381,13 +380,9 @@ def log_version_information():
def get_version_information():
version_file = Path(__file__).parent / ".version"
try:
with open(version_file, "r") as f:
return f.readline().rstrip()
except FileNotFoundError:
print("No version information file '.version' found")
return ""
from bilby_pipe import _version
return _version.get_versions()["version"]
def convert_string_to_tuple(string, key=None, n=None):
......
[flake8]
exclude = .git,docs,build,dist,test,*__init__.py
exclude = .git,docs,build,dist,test,*__init__.py,bilby_pipe/_version.py,versioneer.py
max-line-length = 120
ignore = E129 W504 W503
......@@ -13,3 +13,10 @@ addopts = -p no:warnings
profile=black
known_third_party=configargparse,corner,gwpy,jinja2,lal,lalsimulation,matplotlib,mock,numpy,pandas,pycondor,seaborn,setuptools,tqdm
known_first_party=bilby,bilby_pipe
[versioneer]
VCS = git
style = pep440
versionfile_source = bilby_pipe/_version.py
versionfile_build = bilby_pipe/_version.py
tag_prefix =
#!/usr/bin/env python
import os
import subprocess
import sys
from pathlib import Path
from setuptools import setup
import versioneer
# check that python version is 3.6 or above
python_version = sys.version_info
print("Running Python version %s.%s.%s" % python_version[:3])
......@@ -20,50 +20,6 @@ if python_version < (minimum_py_major, minimum_py_minor):
print(f"Confirmed Python version {minimum_py_major}.minimum_py_minor.0 or above")
def write_version_file(version):
"""Writes a file with version information to be used at run time
Parameters
----------
version: str
A string containing the current version information
Returns
-------
version_file: str
A path to the version file (relative to the bilby_pipe
package directory)
"""
version_file = Path("bilby_pipe") / ".version"
try:
git_log = subprocess.check_output(
["git", "log", "-1", "--pretty=%h %ai"]
).decode("utf-8")
git_diff = (
subprocess.check_output(["git", "diff", "."])
+ subprocess.check_output(["git", "diff", "--cached", "."])
).decode("utf-8")
except subprocess.CalledProcessError: # git calls failed
# we already have a version file, let's use it
if version_file.is_file():
return version_file.name
# otherwise just return the version information
else:
git_version = version
else:
git_version = "{}: ({}) {}".format(
version, "UNCLEAN" if git_diff else "CLEAN", git_log.rstrip()
)
print(f"parsed git version info as: {git_version!r}")
with open(version_file, "w") as f:
print(git_version, file=f)
print(f"created {version_file}")
return version_file.name
def get_long_description():
"""Finds the README and reads in the description"""
here = os.path.abspath(os.path.dirname(__file__))
......@@ -72,8 +28,6 @@ def get_long_description():
return long_description
VERSION = "1.0.6"
version_file = write_version_file(VERSION)
long_description = get_long_description()
MAIN = "bilby_pipe"
......@@ -89,8 +43,9 @@ setup(
author="Gregory Ashton, Isobel Romero-Shaw, Colm Talbot, Charlie Hoy, Shanika Galaudage",
author_email="gregory.ashton@ligo.org",
license="MIT",
version=VERSION,
package_data={"bilby_pipe": [version_file, "data_files/*"]},
version=versioneer.get_version(),
cmdclass=versioneer.get_cmdclass(),
package_data={"bilby_pipe": ["data_files/*"]},
packages=[MAIN, JOB_CREATION, NODES],
install_requires=[
"future",
......
This diff is collapsed.
Supports Markdown
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