Commit 30da0410 authored by Julia Garriga Ferrer's avatar Julia Garriga Ferrer
Browse files

[setup] Add get_version() function

parent 29d02d55
Pipeline #26045 passed with stage
in 2 minutes and 6 seconds
......@@ -40,15 +40,12 @@ logger = logging.getLogger("darfix.setup")
from setuptools import find_packages
try:
from setuptools import Command
from setuptools.command.build_py import build_py as _build_py
logger.info("Use setuptools")
except ImportError:
try:
from numpy.distutils.core import Command
except ImportError:
from distutils.core import Command
from distutils.command.build_py import build_py as _build_py
logger.info("Use distutils")
try:
......@@ -64,6 +61,16 @@ with open("README.md", "r") as fh:
PROJECT = "darfix"
def get_version():
"""Returns current version number from version.py file"""
dirname = os.path.dirname(os.path.abspath(__file__))
sys.path.insert(0, dirname)
import darfix.version
sys.path = sys.path[1:]
return darfix.version.strictversion
classifiers = [
'Development Status :: 3 - Alpha',
'Environment :: Console',
......@@ -89,21 +96,6 @@ def get_readme():
return long_description
# ########## #
# version.py #
# ########## #
class build_py(_build_py):
"""
Enhanced build_py which copies version.py to <PROJECT>._version.py
"""
def find_package_modules(self, package, package_dir):
modules = _build_py.find_package_modules(self, package, package_dir)
if package == PROJECT:
modules.append((PROJECT, '_version', 'version.py'))
return modules
# ############################# #
# numpy.distutils Configuration #
# ############################# #
......@@ -409,7 +401,7 @@ def get_project_configuration(dry_run):
config = configuration()
setup_kwargs = config.todict()
setup_kwargs.update(name=PROJECT,
version="0.4.0",
version=get_version(),
url="https://gitlab.com/julia.garriga/darfix",
author="data analysis unit",
author_email="julia.garriga@esrf.fr",
......
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