Skip to content
Snippets Groups Projects
Commit 272a670b authored by Colm Talbot's avatar Colm Talbot
Browse files

Merge branch 'use-setuptools-scm-version' into 'master'

Switch to using setuptools_scm for versioning

Closes #577

See merge request !1125
parents 9c89194d df9acd15
No related branches found
No related tags found
1 merge request!1125Switch to using setuptools_scm for versioning
Pipeline #449270 passed
......@@ -3,3 +3,4 @@ omit =
test/integration/example_test.py
test/integration/noise_realisation_test.py
test/integration/other_test.py
bilby/_version.py
......@@ -15,3 +15,4 @@ MANIFEST
*.ipynb_checkpoints
outdir/*
.idea/*
bilby/_version.py
......@@ -5,4 +5,5 @@ include gw_requirements.txt
include mcmc_requirements.txt
include optional_requirements.txt
include sampler_requirements.txt
include bilby/_version.py
recursive-include test *.py *.prior
......@@ -24,7 +24,10 @@ from .core import utils, likelihood, prior, result, sampler
from .core.sampler import run_sampler
from .core.likelihood import Likelihood
__version__ = utils.get_version_information()
try:
from ._version import version as __version__
except ModuleNotFoundError: # development mode
__version__ = 'unknown'
if sys.version_info < (3,):
......
import logging
import os
from pathlib import Path
import sys
......@@ -60,13 +59,8 @@ def setup_logger(outdir='.', label=None, log_level='INFO', print_version=False):
def get_version_information():
version_file = os.path.join(
os.path.dirname(os.path.dirname(os.path.dirname(__file__))), '.version')
try:
with open(version_file, 'r') as f:
return f.readline().rstrip()
except EnvironmentError:
print("No version information file '.version' found")
from bilby import __version__
return __version__
def loaded_modules_dict():
......
[build-system]
requires = [
"setuptools>=42",
"setuptools_scm[toml]>=3.4.3",
"wheel",
]
build-backend = "setuptools.build_meta"
[tool.setuptools_scm]
write_to = "bilby/_version.py"
\ No newline at end of file
#!/usr/bin/env python
from setuptools import setup
import subprocess
import sys
import os
......@@ -10,44 +9,6 @@ if python_version < (3, 8):
sys.exit("Python < 3.8 is not supported, aborting setup")
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
"""
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")
if git_diff == "":
git_status = "(CLEAN) " + git_log
else:
git_status = "(UNCLEAN) " + git_log
except Exception as e:
print("Unable to obtain git version information, exception: {}".format(e))
git_status = "release"
version_file = ".version"
if os.path.isfile(version_file) is False:
with open("bilby/" + version_file, "w+") as f:
f.write("{}: {}".format(version, git_status))
return version_file
def get_long_description():
"""Finds the README and reads in the description"""
here = os.path.abspath(os.path.dirname(__file__))
......@@ -73,8 +34,6 @@ def readfile(filename):
return filecontents
VERSION = '1.2.0'
version_file = write_version_file(VERSION)
long_description = get_long_description()
setup(
......@@ -86,7 +45,6 @@ setup(
author="Greg Ashton, Moritz Huebner, Paul Lasky, Colm Talbot",
author_email="paul.lasky@monash.edu",
license="MIT",
version=VERSION,
packages=[
"bilby",
"bilby.bilby_mcmc",
......@@ -107,7 +65,6 @@ setup(
"bilby.gw": ["prior_files/*"],
"bilby.gw.detector": ["noise_curves/*.txt", "detectors/*"],
"bilby.gw.eos": ["eos_tables/*.dat"],
"bilby": [version_file],
},
python_requires=">=3.8",
install_requires=get_requirements(),
......
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