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 = ...@@ -3,3 +3,4 @@ omit =
test/integration/example_test.py test/integration/example_test.py
test/integration/noise_realisation_test.py test/integration/noise_realisation_test.py
test/integration/other_test.py test/integration/other_test.py
bilby/_version.py
...@@ -15,3 +15,4 @@ MANIFEST ...@@ -15,3 +15,4 @@ MANIFEST
*.ipynb_checkpoints *.ipynb_checkpoints
outdir/* outdir/*
.idea/* .idea/*
bilby/_version.py
...@@ -5,4 +5,5 @@ include gw_requirements.txt ...@@ -5,4 +5,5 @@ include gw_requirements.txt
include mcmc_requirements.txt include mcmc_requirements.txt
include optional_requirements.txt include optional_requirements.txt
include sampler_requirements.txt include sampler_requirements.txt
include bilby/_version.py
recursive-include test *.py *.prior recursive-include test *.py *.prior
...@@ -24,7 +24,10 @@ from .core import utils, likelihood, prior, result, sampler ...@@ -24,7 +24,10 @@ from .core import utils, likelihood, prior, result, sampler
from .core.sampler import run_sampler from .core.sampler import run_sampler
from .core.likelihood import Likelihood 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,): if sys.version_info < (3,):
......
import logging import logging
import os
from pathlib import Path from pathlib import Path
import sys import sys
...@@ -60,13 +59,8 @@ def setup_logger(outdir='.', label=None, log_level='INFO', print_version=False): ...@@ -60,13 +59,8 @@ def setup_logger(outdir='.', label=None, log_level='INFO', print_version=False):
def get_version_information(): def get_version_information():
version_file = os.path.join( from bilby import __version__
os.path.dirname(os.path.dirname(os.path.dirname(__file__))), '.version') return __version__
try:
with open(version_file, 'r') as f:
return f.readline().rstrip()
except EnvironmentError:
print("No version information file '.version' found")
def loaded_modules_dict(): 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 #!/usr/bin/env python
from setuptools import setup from setuptools import setup
import subprocess
import sys import sys
import os import os
...@@ -10,44 +9,6 @@ if python_version < (3, 8): ...@@ -10,44 +9,6 @@ if python_version < (3, 8):
sys.exit("Python < 3.8 is not supported, aborting setup") 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(): def get_long_description():
"""Finds the README and reads in the description""" """Finds the README and reads in the description"""
here = os.path.abspath(os.path.dirname(__file__)) here = os.path.abspath(os.path.dirname(__file__))
...@@ -73,8 +34,6 @@ def readfile(filename): ...@@ -73,8 +34,6 @@ def readfile(filename):
return filecontents return filecontents
VERSION = '1.2.0'
version_file = write_version_file(VERSION)
long_description = get_long_description() long_description = get_long_description()
setup( setup(
...@@ -86,7 +45,6 @@ setup( ...@@ -86,7 +45,6 @@ setup(
author="Greg Ashton, Moritz Huebner, Paul Lasky, Colm Talbot", author="Greg Ashton, Moritz Huebner, Paul Lasky, Colm Talbot",
author_email="paul.lasky@monash.edu", author_email="paul.lasky@monash.edu",
license="MIT", license="MIT",
version=VERSION,
packages=[ packages=[
"bilby", "bilby",
"bilby.bilby_mcmc", "bilby.bilby_mcmc",
...@@ -107,7 +65,6 @@ setup( ...@@ -107,7 +65,6 @@ setup(
"bilby.gw": ["prior_files/*"], "bilby.gw": ["prior_files/*"],
"bilby.gw.detector": ["noise_curves/*.txt", "detectors/*"], "bilby.gw.detector": ["noise_curves/*.txt", "detectors/*"],
"bilby.gw.eos": ["eos_tables/*.dat"], "bilby.gw.eos": ["eos_tables/*.dat"],
"bilby": [version_file],
}, },
python_requires=">=3.8", python_requires=">=3.8",
install_requires=get_requirements(), 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