From b5d6dc6f1846ed75bf0e3178ed0feeca9f746207 Mon Sep 17 00:00:00 2001 From: juacrumar Date: Tue, 28 Apr 2020 22:15:43 +0200 Subject: [PATCH 01/15] first attempt to build number --- .ciscripts/build-deploy-linux.sh | 7 ++++++- .ciscripts/build-deploy-osx.sh | 5 +++++ n3fit/src/n3fit/__init__.py | 4 ++++ validphys2/src/validphys/__init__.py | 6 +++++- 4 files changed, 20 insertions(+), 2 deletions(-) diff --git a/.ciscripts/build-deploy-linux.sh b/.ciscripts/build-deploy-linux.sh index 4a5173616c..8b7a044721 100755 --- a/.ciscripts/build-deploy-linux.sh +++ b/.ciscripts/build-deploy-linux.sh @@ -6,6 +6,11 @@ set -o pipefail set -u set -v +# Set the version for both vp and n3fit +gitroot=$(git rev-parse --show-toplevel) +echo "__build__=\"$(git describe)\"" > ${gitroot}/n3fit/src/n3fit/__init__.py +echo "__build__=\"$(git describe)\"" > ${gitroot}/validphys2/src/validphys/__init__.py + #Set up netrc file for uploading/downloading echo "$NETRC_FILE" | base64 --decode > ~/.netrc @@ -41,4 +46,4 @@ if [ $? == 0 ]; then else echo "Conda package upload failed" exit 1 -fi \ No newline at end of file +fi diff --git a/.ciscripts/build-deploy-osx.sh b/.ciscripts/build-deploy-osx.sh index 8aac55d8c8..a37f6b79c7 100755 --- a/.ciscripts/build-deploy-osx.sh +++ b/.ciscripts/build-deploy-osx.sh @@ -5,6 +5,11 @@ set -v #Set up netrc file for uploading/downloading echo "$NETRC_FILE" | base64 --decode > ~/.netrc +# Set the version for both vp and n3fit +gitroot=$(git rev-parse --show-toplevel) +echo "__build__=\"$(git describe)\"" > ${gitroot}/n3fit/src/n3fit/__init__.py +echo "__build__=\"$(git describe)\"" > ${gitroot}/validphys2/src/validphys/__init__.py + conda build -q conda-recipe if [ $? != 0 ]; then echo failed to build diff --git a/n3fit/src/n3fit/__init__.py b/n3fit/src/n3fit/__init__.py index e69de29bb2..cc8064b59b 100644 --- a/n3fit/src/n3fit/__init__.py +++ b/n3fit/src/n3fit/__init__.py @@ -0,0 +1,4 @@ +def __give_git(): + from subprocess import run + return run('git describe --tags --dirty'.split(), capture_output=True).stdout.decode().strip() +__build__ = __give_git() diff --git a/validphys2/src/validphys/__init__.py b/validphys2/src/validphys/__init__.py index 1704ed6675..be5be5e0e4 100644 --- a/validphys2/src/validphys/__init__.py +++ b/validphys2/src/validphys/__init__.py @@ -1 +1,5 @@ -#We don't want to import stuff here that could slow down the import times \ No newline at end of file +#We don't want to import stuff here that could slow down the import times +def __give_git(): + from subprocess import run + return run('git describe --tags --dirty'.split(), capture_output=True).stdout.decode().strip() +__build__ = __give_git() From 643f9efd207e342ae9730366b2cdf3db0e5b0b0d Mon Sep 17 00:00:00 2001 From: juacrumar Date: Wed, 29 Apr 2020 10:15:23 +0200 Subject: [PATCH 02/15] move things to version --- .ciscripts/build-deploy-linux.sh | 4 ++-- .ciscripts/build-deploy-osx.sh | 4 ++-- n3fit/src/n3fit/__init__.py | 6 ++---- n3fit/src/n3fit/version.py | 14 ++++++++++++++ validphys2/src/validphys/__init__.py | 6 ++---- validphys2/src/validphys/version.py | 14 ++++++++++++++ 6 files changed, 36 insertions(+), 12 deletions(-) create mode 100644 n3fit/src/n3fit/version.py create mode 100644 validphys2/src/validphys/version.py diff --git a/.ciscripts/build-deploy-linux.sh b/.ciscripts/build-deploy-linux.sh index 8b7a044721..ed840eba84 100755 --- a/.ciscripts/build-deploy-linux.sh +++ b/.ciscripts/build-deploy-linux.sh @@ -8,8 +8,8 @@ set -v # Set the version for both vp and n3fit gitroot=$(git rev-parse --show-toplevel) -echo "__build__=\"$(git describe)\"" > ${gitroot}/n3fit/src/n3fit/__init__.py -echo "__build__=\"$(git describe)\"" > ${gitroot}/validphys2/src/validphys/__init__.py +echo "build_version=\"$(git describe --long)\"" > ${gitroot}/n3fit/src/n3fit/version.py +echo "build_version=\"$(git describe --long)\"" > ${gitroot}/validphys2/src/validphys/version.py #Set up netrc file for uploading/downloading echo "$NETRC_FILE" | base64 --decode > ~/.netrc diff --git a/.ciscripts/build-deploy-osx.sh b/.ciscripts/build-deploy-osx.sh index a37f6b79c7..e49a020bb0 100755 --- a/.ciscripts/build-deploy-osx.sh +++ b/.ciscripts/build-deploy-osx.sh @@ -7,8 +7,8 @@ echo "$NETRC_FILE" | base64 --decode > ~/.netrc # Set the version for both vp and n3fit gitroot=$(git rev-parse --show-toplevel) -echo "__build__=\"$(git describe)\"" > ${gitroot}/n3fit/src/n3fit/__init__.py -echo "__build__=\"$(git describe)\"" > ${gitroot}/validphys2/src/validphys/__init__.py +echo "build_version=\"$(git describe --long)\"" > ${gitroot}/n3fit/src/n3fit/version.py +echo "build_version=\"$(git describe --long)\"" > ${gitroot}/validphys2/src/validphys/version.py conda build -q conda-recipe if [ $? != 0 ]; then diff --git a/n3fit/src/n3fit/__init__.py b/n3fit/src/n3fit/__init__.py index cc8064b59b..73a5163bc9 100644 --- a/n3fit/src/n3fit/__init__.py +++ b/n3fit/src/n3fit/__init__.py @@ -1,4 +1,2 @@ -def __give_git(): - from subprocess import run - return run('git describe --tags --dirty'.split(), capture_output=True).stdout.decode().strip() -__build__ = __give_git() +from n3fit.version import build_version +__version__ = build_version diff --git a/n3fit/src/n3fit/version.py b/n3fit/src/n3fit/version.py new file mode 100644 index 0000000000..8ad91ccc3e --- /dev/null +++ b/n3fit/src/n3fit/version.py @@ -0,0 +1,14 @@ +# This file gets overwritten on deployemt, don't modify +def __give_git(): + # Get the path to this file + from pathlib import Path + file_dir = Path(__file__).parent + from subprocess import run, CalledProcessError + try: + result = run('git describe --tags --dirty'.split(), capture_output=True, text=True, check=True, cwd=file_dir).stdout.strip() + except CalledProcessError: + # In principle this function should not exist on an installed version + # but who knows. Also maybe git doesn't work on the machine or whatever + result = 'unknown' + return result +build_version = __give_git() diff --git a/validphys2/src/validphys/__init__.py b/validphys2/src/validphys/__init__.py index be5be5e0e4..d6c33482d3 100644 --- a/validphys2/src/validphys/__init__.py +++ b/validphys2/src/validphys/__init__.py @@ -1,5 +1,3 @@ #We don't want to import stuff here that could slow down the import times -def __give_git(): - from subprocess import run - return run('git describe --tags --dirty'.split(), capture_output=True).stdout.decode().strip() -__build__ = __give_git() +from validphys.version import build_version +__version__ = build_version diff --git a/validphys2/src/validphys/version.py b/validphys2/src/validphys/version.py new file mode 100644 index 0000000000..8ad91ccc3e --- /dev/null +++ b/validphys2/src/validphys/version.py @@ -0,0 +1,14 @@ +# This file gets overwritten on deployemt, don't modify +def __give_git(): + # Get the path to this file + from pathlib import Path + file_dir = Path(__file__).parent + from subprocess import run, CalledProcessError + try: + result = run('git describe --tags --dirty'.split(), capture_output=True, text=True, check=True, cwd=file_dir).stdout.strip() + except CalledProcessError: + # In principle this function should not exist on an installed version + # but who knows. Also maybe git doesn't work on the machine or whatever + result = 'unknown' + return result +build_version = __give_git() From 1e3608c4e5986a2426ee48e6a8ab8503b482439e Mon Sep 17 00:00:00 2001 From: juacrumar Date: Wed, 29 Apr 2020 13:42:39 +0200 Subject: [PATCH 03/15] use setuptools_scm to burn down tag --- .ciscripts/build-deploy-linux.sh | 5 ---- .ciscripts/build-deploy-osx.sh | 5 ---- conda-recipe/meta.yaml | 1 + n3fit/setup.py | 28 +++++++++---------- n3fit/src/n3fit/__init__.py | 15 ++++++++-- n3fit/src/n3fit/tests/test_version.py | 4 +++ n3fit/src/n3fit/version.py | 14 ---------- validphys2/setup.py | 2 ++ validphys2/src/validphys/__init__.py | 15 ++++++++-- .../src/validphys/tests/test_version.py | 4 +++ validphys2/src/validphys/version.py | 14 ---------- 11 files changed, 50 insertions(+), 57 deletions(-) create mode 100644 n3fit/src/n3fit/tests/test_version.py delete mode 100644 n3fit/src/n3fit/version.py create mode 100644 validphys2/src/validphys/tests/test_version.py delete mode 100644 validphys2/src/validphys/version.py diff --git a/.ciscripts/build-deploy-linux.sh b/.ciscripts/build-deploy-linux.sh index ed840eba84..4cc176c458 100755 --- a/.ciscripts/build-deploy-linux.sh +++ b/.ciscripts/build-deploy-linux.sh @@ -6,11 +6,6 @@ set -o pipefail set -u set -v -# Set the version for both vp and n3fit -gitroot=$(git rev-parse --show-toplevel) -echo "build_version=\"$(git describe --long)\"" > ${gitroot}/n3fit/src/n3fit/version.py -echo "build_version=\"$(git describe --long)\"" > ${gitroot}/validphys2/src/validphys/version.py - #Set up netrc file for uploading/downloading echo "$NETRC_FILE" | base64 --decode > ~/.netrc diff --git a/.ciscripts/build-deploy-osx.sh b/.ciscripts/build-deploy-osx.sh index e49a020bb0..8aac55d8c8 100755 --- a/.ciscripts/build-deploy-osx.sh +++ b/.ciscripts/build-deploy-osx.sh @@ -5,11 +5,6 @@ set -v #Set up netrc file for uploading/downloading echo "$NETRC_FILE" | base64 --decode > ~/.netrc -# Set the version for both vp and n3fit -gitroot=$(git rev-parse --show-toplevel) -echo "build_version=\"$(git describe --long)\"" > ${gitroot}/n3fit/src/n3fit/version.py -echo "build_version=\"$(git describe --long)\"" > ${gitroot}/validphys2/src/validphys/version.py - conda build -q conda-recipe if [ $? != 0 ]; then echo failed to build diff --git a/conda-recipe/meta.yaml b/conda-recipe/meta.yaml index c5b7e56905..b0239cd32e 100644 --- a/conda-recipe/meta.yaml +++ b/conda-recipe/meta.yaml @@ -11,6 +11,7 @@ requirements: - {{ compiler("c") }} - swig ==3.0.10 - cmake + - setuptools_scm - pkg-config host: - lhapdf # with python3.6 wrapper diff --git a/n3fit/setup.py b/n3fit/setup.py index 4ffeab3d95..d77a2bad09 100644 --- a/n3fit/setup.py +++ b/n3fit/setup.py @@ -1,19 +1,17 @@ from setuptools import setup, find_packages setup( - name="n3fit", - version="0.9", - package_dir = {'':'src'}, - packages=find_packages('src'), - zip_safe=False, - package_data = { - '':['*.fitinfo', '*.yml'], - 'tests/regressions': ['*'], - }, - - entry_points = {'console_scripts': - ['n3fit = n3fit.scripts.n3fit_exec:main', - 'n3Hyperplot = n3fit.hyper_optimization.plotting:main', - ] - }, + name="n3fit", + use_scm_version= {'root' : '..'}, + setup_requires=['setuptools_scm'], + package_dir={"": "src"}, + packages=find_packages("src"), + zip_safe=False, + package_data={"": ["*.fitinfo", "*.yml"], "tests/regressions": ["*"],}, + entry_points={ + "console_scripts": [ + "n3fit = n3fit.scripts.n3fit_exec:main", + "n3Hyperplot = n3fit.hyper_optimization.plotting:main", + ] + }, ) diff --git a/n3fit/src/n3fit/__init__.py b/n3fit/src/n3fit/__init__.py index 73a5163bc9..b2a13d4b07 100644 --- a/n3fit/src/n3fit/__init__.py +++ b/n3fit/src/n3fit/__init__.py @@ -1,2 +1,13 @@ -from n3fit.version import build_version -__version__ = build_version +def __give_version(): + # Get the path to this file + from pathlib import Path + file_dir = Path(__file__).parent + from subprocess import run, CalledProcessError + try: + result = run('git describe --tags --dirty'.split(), capture_output=True, text=True, check=True, cwd=file_dir).stdout.strip() + except CalledProcessError: + from pkg_resources import get_distribution + # If we cannot get the name directly form git for whatever the reason, ask the package + result = get_distribution(__name__).version + return result +__version__ = __give_version() diff --git a/n3fit/src/n3fit/tests/test_version.py b/n3fit/src/n3fit/tests/test_version.py new file mode 100644 index 0000000000..7f8e90c881 --- /dev/null +++ b/n3fit/src/n3fit/tests/test_version.py @@ -0,0 +1,4 @@ +import n3fit + +def test_version(): + assert isinstance(n3fit.__version__, str) diff --git a/n3fit/src/n3fit/version.py b/n3fit/src/n3fit/version.py deleted file mode 100644 index 8ad91ccc3e..0000000000 --- a/n3fit/src/n3fit/version.py +++ /dev/null @@ -1,14 +0,0 @@ -# This file gets overwritten on deployemt, don't modify -def __give_git(): - # Get the path to this file - from pathlib import Path - file_dir = Path(__file__).parent - from subprocess import run, CalledProcessError - try: - result = run('git describe --tags --dirty'.split(), capture_output=True, text=True, check=True, cwd=file_dir).stdout.strip() - except CalledProcessError: - # In principle this function should not exist on an installed version - # but who knows. Also maybe git doesn't work on the machine or whatever - result = 'unknown' - return result -build_version = __give_git() diff --git a/validphys2/setup.py b/validphys2/setup.py index 88ff006d27..306339aef1 100644 --- a/validphys2/setup.py +++ b/validphys2/setup.py @@ -11,6 +11,8 @@ setup(name= "validphys", version = '2.0b2', + use_scm_version= {'root' : '..'}, + setup_requires=['setuptools_scm'], description = "NNPDF analysis framework", author = "Zahari Kassabov", author_email = "kassabov@to.infn.it", diff --git a/validphys2/src/validphys/__init__.py b/validphys2/src/validphys/__init__.py index d6c33482d3..07aced41f3 100644 --- a/validphys2/src/validphys/__init__.py +++ b/validphys2/src/validphys/__init__.py @@ -1,3 +1,14 @@ #We don't want to import stuff here that could slow down the import times -from validphys.version import build_version -__version__ = build_version +def __give_version(): + # Get the path to this file + from pathlib import Path + file_dir = Path(__file__).parent + from subprocess import run, CalledProcessError + try: + result = run('git describe --tags --dirty'.split(), capture_output=True, text=True, check=True, cwd=file_dir).stdout.strip() + except CalledProcessError: + from pkg_resources import get_distribution + # If we cannot get the name directly form git for whatever the reason, ask the package + result = get_distribution(__name__).version + return result +__version__ = __give_version() diff --git a/validphys2/src/validphys/tests/test_version.py b/validphys2/src/validphys/tests/test_version.py new file mode 100644 index 0000000000..4f6ce16c86 --- /dev/null +++ b/validphys2/src/validphys/tests/test_version.py @@ -0,0 +1,4 @@ +import validphys + +def test_version(): + assert isinstance(validphys.__version__, str) diff --git a/validphys2/src/validphys/version.py b/validphys2/src/validphys/version.py deleted file mode 100644 index 8ad91ccc3e..0000000000 --- a/validphys2/src/validphys/version.py +++ /dev/null @@ -1,14 +0,0 @@ -# This file gets overwritten on deployemt, don't modify -def __give_git(): - # Get the path to this file - from pathlib import Path - file_dir = Path(__file__).parent - from subprocess import run, CalledProcessError - try: - result = run('git describe --tags --dirty'.split(), capture_output=True, text=True, check=True, cwd=file_dir).stdout.strip() - except CalledProcessError: - # In principle this function should not exist on an installed version - # but who knows. Also maybe git doesn't work on the machine or whatever - result = 'unknown' - return result -build_version = __give_git() From 309b66b2447d03463b6c7ecb878a9eb380c74199 Mon Sep 17 00:00:00 2001 From: Juacrumar Date: Wed, 29 Apr 2020 14:24:45 +0200 Subject: [PATCH 04/15] test for travis the conda build it is working for me locally though --- conda-recipe/meta.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/conda-recipe/meta.yaml b/conda-recipe/meta.yaml index b0239cd32e..c83bdd9a99 100644 --- a/conda-recipe/meta.yaml +++ b/conda-recipe/meta.yaml @@ -18,6 +18,7 @@ requirements: - sqlite - gsl # Gsl doesn't link openblas on old debian 7 - libarchive + - setuptools_scm - yaml-cpp - apfel >=3 # see https://github.com/scarrazza/apfel - python From 60482bf948c0c605685a02b51bb9aea48ae22c38 Mon Sep 17 00:00:00 2001 From: Juacrumar Date: Wed, 29 Apr 2020 14:47:28 +0200 Subject: [PATCH 05/15] update n3fit-setup --- n3fit/setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/n3fit/setup.py b/n3fit/setup.py index d77a2bad09..08ccfe9412 100644 --- a/n3fit/setup.py +++ b/n3fit/setup.py @@ -2,7 +2,7 @@ setup( name="n3fit", - use_scm_version= {'root' : '..'}, + use_scm_version= {"root" : "..", "relative_to": __file__}, setup_requires=['setuptools_scm'], package_dir={"": "src"}, packages=find_packages("src"), From 007ff4435fc23ff6380a3c2ef3a92922af0fb688 Mon Sep 17 00:00:00 2001 From: Juacrumar Date: Wed, 29 Apr 2020 14:47:57 +0200 Subject: [PATCH 06/15] update vp-setup --- validphys2/setup.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/validphys2/setup.py b/validphys2/setup.py index 306339aef1..7ab1f061a4 100644 --- a/validphys2/setup.py +++ b/validphys2/setup.py @@ -11,8 +11,8 @@ setup(name= "validphys", version = '2.0b2', - use_scm_version= {'root' : '..'}, - setup_requires=['setuptools_scm'], + use_scm_version= {"root" : "..", "relative_to": __file__}, + setup_requires=["setuptools_scm"], description = "NNPDF analysis framework", author = "Zahari Kassabov", author_email = "kassabov@to.infn.it", From 4979b60b0b17ef7f2190e7ba1f6aaaed6525e1f5 Mon Sep 17 00:00:00 2001 From: juacrumar Date: Wed, 29 Apr 2020 15:54:49 +0200 Subject: [PATCH 07/15] use setup.py in cmake for a test --- CMakeLists.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index d7d689e2b2..dff006bea4 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -151,12 +151,12 @@ add_subdirectory(n3fit/evolven3fit) if(VP_DEV) install(CODE "execute_process(COMMAND ${PYTHON_EXECUTABLE} -m pip install -e ${PROJECT_SOURCE_DIR}/validphys2)") else(VP_DEV) - install(CODE "execute_process(COMMAND ${PYTHON_EXECUTABLE} -m pip install --no-deps --ignore-installed ${PROJECT_SOURCE_DIR}/validphys2)") + install(CODE "execute_process(COMMAND ${PYTHON_EXECUTABLE} ${PROJECT_SOURCE_DIR}/validphys2/setup.py install)") endif(VP_DEV) # install n3fit if(N3_DEV) install(CODE "execute_process(COMMAND ${PYTHON_EXECUTABLE} -m pip install -e ${PROJECT_SOURCE_DIR}/n3fit)") else(N3_DEV) - install(CODE "execute_process(COMMAND ${PYTHON_EXECUTABLE} -m pip install --no-deps --ignore-installed ${PROJECT_SOURCE_DIR}/n3fit)") + install(CODE "execute_process(COMMAND ${PYTHON_EXECUTABLE} ${PROJECT_SOURCE_DIR}/n3fit/setup.py install)") endif(N3_DEV) From ffa317228d4fdb23f847f140b1027210aefacfb8 Mon Sep 17 00:00:00 2001 From: juacrumar Date: Wed, 29 Apr 2020 16:21:35 +0200 Subject: [PATCH 08/15] forget fancy libraries that dont work with pip --- .ciscripts/build-deploy-linux.sh | 5 ++++ .ciscripts/build-deploy-osx.sh | 5 ++++ CMakeLists.txt | 4 +-- conda-recipe/meta.yaml | 2 -- n3fit/setup.py | 28 ++++++++++--------- n3fit/src/n3fit/__init__.py | 15 ++-------- n3fit/src/n3fit/tests/test_version.py | 4 --- n3fit/src/n3fit/version.py | 14 ++++++++++ validphys2/setup.py | 2 -- validphys2/src/validphys/__init__.py | 15 ++-------- .../src/validphys/tests/test_version.py | 4 --- validphys2/src/validphys/version.py | 14 ++++++++++ 12 files changed, 59 insertions(+), 53 deletions(-) delete mode 100644 n3fit/src/n3fit/tests/test_version.py create mode 100644 n3fit/src/n3fit/version.py delete mode 100644 validphys2/src/validphys/tests/test_version.py create mode 100644 validphys2/src/validphys/version.py diff --git a/.ciscripts/build-deploy-linux.sh b/.ciscripts/build-deploy-linux.sh index 4cc176c458..ed840eba84 100755 --- a/.ciscripts/build-deploy-linux.sh +++ b/.ciscripts/build-deploy-linux.sh @@ -6,6 +6,11 @@ set -o pipefail set -u set -v +# Set the version for both vp and n3fit +gitroot=$(git rev-parse --show-toplevel) +echo "build_version=\"$(git describe --long)\"" > ${gitroot}/n3fit/src/n3fit/version.py +echo "build_version=\"$(git describe --long)\"" > ${gitroot}/validphys2/src/validphys/version.py + #Set up netrc file for uploading/downloading echo "$NETRC_FILE" | base64 --decode > ~/.netrc diff --git a/.ciscripts/build-deploy-osx.sh b/.ciscripts/build-deploy-osx.sh index 8aac55d8c8..e49a020bb0 100755 --- a/.ciscripts/build-deploy-osx.sh +++ b/.ciscripts/build-deploy-osx.sh @@ -5,6 +5,11 @@ set -v #Set up netrc file for uploading/downloading echo "$NETRC_FILE" | base64 --decode > ~/.netrc +# Set the version for both vp and n3fit +gitroot=$(git rev-parse --show-toplevel) +echo "build_version=\"$(git describe --long)\"" > ${gitroot}/n3fit/src/n3fit/version.py +echo "build_version=\"$(git describe --long)\"" > ${gitroot}/validphys2/src/validphys/version.py + conda build -q conda-recipe if [ $? != 0 ]; then echo failed to build diff --git a/CMakeLists.txt b/CMakeLists.txt index dff006bea4..d7d689e2b2 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -151,12 +151,12 @@ add_subdirectory(n3fit/evolven3fit) if(VP_DEV) install(CODE "execute_process(COMMAND ${PYTHON_EXECUTABLE} -m pip install -e ${PROJECT_SOURCE_DIR}/validphys2)") else(VP_DEV) - install(CODE "execute_process(COMMAND ${PYTHON_EXECUTABLE} ${PROJECT_SOURCE_DIR}/validphys2/setup.py install)") + install(CODE "execute_process(COMMAND ${PYTHON_EXECUTABLE} -m pip install --no-deps --ignore-installed ${PROJECT_SOURCE_DIR}/validphys2)") endif(VP_DEV) # install n3fit if(N3_DEV) install(CODE "execute_process(COMMAND ${PYTHON_EXECUTABLE} -m pip install -e ${PROJECT_SOURCE_DIR}/n3fit)") else(N3_DEV) - install(CODE "execute_process(COMMAND ${PYTHON_EXECUTABLE} ${PROJECT_SOURCE_DIR}/n3fit/setup.py install)") + install(CODE "execute_process(COMMAND ${PYTHON_EXECUTABLE} -m pip install --no-deps --ignore-installed ${PROJECT_SOURCE_DIR}/n3fit)") endif(N3_DEV) diff --git a/conda-recipe/meta.yaml b/conda-recipe/meta.yaml index c83bdd9a99..c5b7e56905 100644 --- a/conda-recipe/meta.yaml +++ b/conda-recipe/meta.yaml @@ -11,14 +11,12 @@ requirements: - {{ compiler("c") }} - swig ==3.0.10 - cmake - - setuptools_scm - pkg-config host: - lhapdf # with python3.6 wrapper - sqlite - gsl # Gsl doesn't link openblas on old debian 7 - libarchive - - setuptools_scm - yaml-cpp - apfel >=3 # see https://github.com/scarrazza/apfel - python diff --git a/n3fit/setup.py b/n3fit/setup.py index 08ccfe9412..4ffeab3d95 100644 --- a/n3fit/setup.py +++ b/n3fit/setup.py @@ -1,17 +1,19 @@ from setuptools import setup, find_packages setup( - name="n3fit", - use_scm_version= {"root" : "..", "relative_to": __file__}, - setup_requires=['setuptools_scm'], - package_dir={"": "src"}, - packages=find_packages("src"), - zip_safe=False, - package_data={"": ["*.fitinfo", "*.yml"], "tests/regressions": ["*"],}, - entry_points={ - "console_scripts": [ - "n3fit = n3fit.scripts.n3fit_exec:main", - "n3Hyperplot = n3fit.hyper_optimization.plotting:main", - ] - }, + name="n3fit", + version="0.9", + package_dir = {'':'src'}, + packages=find_packages('src'), + zip_safe=False, + package_data = { + '':['*.fitinfo', '*.yml'], + 'tests/regressions': ['*'], + }, + + entry_points = {'console_scripts': + ['n3fit = n3fit.scripts.n3fit_exec:main', + 'n3Hyperplot = n3fit.hyper_optimization.plotting:main', + ] + }, ) diff --git a/n3fit/src/n3fit/__init__.py b/n3fit/src/n3fit/__init__.py index b2a13d4b07..73a5163bc9 100644 --- a/n3fit/src/n3fit/__init__.py +++ b/n3fit/src/n3fit/__init__.py @@ -1,13 +1,2 @@ -def __give_version(): - # Get the path to this file - from pathlib import Path - file_dir = Path(__file__).parent - from subprocess import run, CalledProcessError - try: - result = run('git describe --tags --dirty'.split(), capture_output=True, text=True, check=True, cwd=file_dir).stdout.strip() - except CalledProcessError: - from pkg_resources import get_distribution - # If we cannot get the name directly form git for whatever the reason, ask the package - result = get_distribution(__name__).version - return result -__version__ = __give_version() +from n3fit.version import build_version +__version__ = build_version diff --git a/n3fit/src/n3fit/tests/test_version.py b/n3fit/src/n3fit/tests/test_version.py deleted file mode 100644 index 7f8e90c881..0000000000 --- a/n3fit/src/n3fit/tests/test_version.py +++ /dev/null @@ -1,4 +0,0 @@ -import n3fit - -def test_version(): - assert isinstance(n3fit.__version__, str) diff --git a/n3fit/src/n3fit/version.py b/n3fit/src/n3fit/version.py new file mode 100644 index 0000000000..8ad91ccc3e --- /dev/null +++ b/n3fit/src/n3fit/version.py @@ -0,0 +1,14 @@ +# This file gets overwritten on deployemt, don't modify +def __give_git(): + # Get the path to this file + from pathlib import Path + file_dir = Path(__file__).parent + from subprocess import run, CalledProcessError + try: + result = run('git describe --tags --dirty'.split(), capture_output=True, text=True, check=True, cwd=file_dir).stdout.strip() + except CalledProcessError: + # In principle this function should not exist on an installed version + # but who knows. Also maybe git doesn't work on the machine or whatever + result = 'unknown' + return result +build_version = __give_git() diff --git a/validphys2/setup.py b/validphys2/setup.py index 7ab1f061a4..88ff006d27 100644 --- a/validphys2/setup.py +++ b/validphys2/setup.py @@ -11,8 +11,6 @@ setup(name= "validphys", version = '2.0b2', - use_scm_version= {"root" : "..", "relative_to": __file__}, - setup_requires=["setuptools_scm"], description = "NNPDF analysis framework", author = "Zahari Kassabov", author_email = "kassabov@to.infn.it", diff --git a/validphys2/src/validphys/__init__.py b/validphys2/src/validphys/__init__.py index 07aced41f3..d6c33482d3 100644 --- a/validphys2/src/validphys/__init__.py +++ b/validphys2/src/validphys/__init__.py @@ -1,14 +1,3 @@ #We don't want to import stuff here that could slow down the import times -def __give_version(): - # Get the path to this file - from pathlib import Path - file_dir = Path(__file__).parent - from subprocess import run, CalledProcessError - try: - result = run('git describe --tags --dirty'.split(), capture_output=True, text=True, check=True, cwd=file_dir).stdout.strip() - except CalledProcessError: - from pkg_resources import get_distribution - # If we cannot get the name directly form git for whatever the reason, ask the package - result = get_distribution(__name__).version - return result -__version__ = __give_version() +from validphys.version import build_version +__version__ = build_version diff --git a/validphys2/src/validphys/tests/test_version.py b/validphys2/src/validphys/tests/test_version.py deleted file mode 100644 index 4f6ce16c86..0000000000 --- a/validphys2/src/validphys/tests/test_version.py +++ /dev/null @@ -1,4 +0,0 @@ -import validphys - -def test_version(): - assert isinstance(validphys.__version__, str) diff --git a/validphys2/src/validphys/version.py b/validphys2/src/validphys/version.py new file mode 100644 index 0000000000..8ad91ccc3e --- /dev/null +++ b/validphys2/src/validphys/version.py @@ -0,0 +1,14 @@ +# This file gets overwritten on deployemt, don't modify +def __give_git(): + # Get the path to this file + from pathlib import Path + file_dir = Path(__file__).parent + from subprocess import run, CalledProcessError + try: + result = run('git describe --tags --dirty'.split(), capture_output=True, text=True, check=True, cwd=file_dir).stdout.strip() + except CalledProcessError: + # In principle this function should not exist on an installed version + # but who knows. Also maybe git doesn't work on the machine or whatever + result = 'unknown' + return result +build_version = __give_git() From 70e7fc73b6944a68254b48b57d45fc0aa4577a55 Mon Sep 17 00:00:00 2001 From: juacrumar Date: Thu, 30 Apr 2020 10:55:10 +0200 Subject: [PATCH 09/15] use pep style for version --- .ciscripts/build-deploy-linux.sh | 9 +++++++-- .ciscripts/build-deploy-osx.sh | 9 +++++++-- n3fit/src/n3fit/version.py | 9 ++++++--- validphys2/src/validphys/version.py | 9 ++++++--- 4 files changed, 26 insertions(+), 10 deletions(-) diff --git a/.ciscripts/build-deploy-linux.sh b/.ciscripts/build-deploy-linux.sh index ed840eba84..fde929970e 100755 --- a/.ciscripts/build-deploy-linux.sh +++ b/.ciscripts/build-deploy-linux.sh @@ -8,8 +8,13 @@ set -v # Set the version for both vp and n3fit gitroot=$(git rev-parse --show-toplevel) -echo "build_version=\"$(git describe --long)\"" > ${gitroot}/n3fit/src/n3fit/version.py -echo "build_version=\"$(git describe --long)\"" > ${gitroot}/validphys2/src/validphys/version.py +gitversion=$(git describe --long) +tag=$(git describe --abbrev=0 --tags) +gitversion=${gitversion/${tag}-/${tag}.} +githash=$(git rev-parse --short HEAD) +gitversion=${gitversion/-g${githash}/+g${githash}} +echo "build_version=\"${gitversion}\"" > ${gitroot}/n3fit/src/n3fit/version.py +echo "build_version=\"${gitversion}\"" > ${gitroot}/validphys2/src/validphys/version.py #Set up netrc file for uploading/downloading echo "$NETRC_FILE" | base64 --decode > ~/.netrc diff --git a/.ciscripts/build-deploy-osx.sh b/.ciscripts/build-deploy-osx.sh index e49a020bb0..004cceb020 100755 --- a/.ciscripts/build-deploy-osx.sh +++ b/.ciscripts/build-deploy-osx.sh @@ -7,8 +7,13 @@ echo "$NETRC_FILE" | base64 --decode > ~/.netrc # Set the version for both vp and n3fit gitroot=$(git rev-parse --show-toplevel) -echo "build_version=\"$(git describe --long)\"" > ${gitroot}/n3fit/src/n3fit/version.py -echo "build_version=\"$(git describe --long)\"" > ${gitroot}/validphys2/src/validphys/version.py +gitversion=$(git describe --long) +tag=$(git describe --abbrev=0 --tags) +gitversion=${gitversion/${tag}-/${tag}.} +githash=$(git rev-parse --short HEAD) +gitversion=${gitversion/-g${githash}/+g${githash}} +echo "build_version=\"${gitversion}\"" > ${gitroot}/n3fit/src/n3fit/version.py +echo "build_version=\"${gitversion}\"" > ${gitroot}/validphys2/src/validphys/version.py conda build -q conda-recipe if [ $? != 0 ]; then diff --git a/n3fit/src/n3fit/version.py b/n3fit/src/n3fit/version.py index 8ad91ccc3e..58718d2e5c 100644 --- a/n3fit/src/n3fit/version.py +++ b/n3fit/src/n3fit/version.py @@ -5,10 +5,13 @@ def __give_git(): file_dir = Path(__file__).parent from subprocess import run, CalledProcessError try: - result = run('git describe --tags --dirty'.split(), capture_output=True, text=True, check=True, cwd=file_dir).stdout.strip() + result = run('git describe --tags --long --dirty'.split(), capture_output=True, text=True, check=True, cwd=file_dir).stdout.strip() + tag = run(['git', 'describe', '--abbrev=0', '--tags'], capture_output=True, text=True, check=True, cwd=file_dir).stdout.strip() + githash = run(['git', 'rev-parse', '--short', 'HEAD'], capture_output=True, text=True, check=True, cwd=file_dir).stdout.strip() + version = result.replace(f"-g{githash}", f"+g{githash}").replace(f"{tag}-", f"{tag}.") except CalledProcessError: # In principle this function should not exist on an installed version # but who knows. Also maybe git doesn't work on the machine or whatever - result = 'unknown' - return result + version = 'unknown' + return version build_version = __give_git() diff --git a/validphys2/src/validphys/version.py b/validphys2/src/validphys/version.py index 8ad91ccc3e..58718d2e5c 100644 --- a/validphys2/src/validphys/version.py +++ b/validphys2/src/validphys/version.py @@ -5,10 +5,13 @@ def __give_git(): file_dir = Path(__file__).parent from subprocess import run, CalledProcessError try: - result = run('git describe --tags --dirty'.split(), capture_output=True, text=True, check=True, cwd=file_dir).stdout.strip() + result = run('git describe --tags --long --dirty'.split(), capture_output=True, text=True, check=True, cwd=file_dir).stdout.strip() + tag = run(['git', 'describe', '--abbrev=0', '--tags'], capture_output=True, text=True, check=True, cwd=file_dir).stdout.strip() + githash = run(['git', 'rev-parse', '--short', 'HEAD'], capture_output=True, text=True, check=True, cwd=file_dir).stdout.strip() + version = result.replace(f"-g{githash}", f"+g{githash}").replace(f"{tag}-", f"{tag}.") except CalledProcessError: # In principle this function should not exist on an installed version # but who knows. Also maybe git doesn't work on the machine or whatever - result = 'unknown' - return result + version = 'unknown' + return version build_version = __give_git() From 914b29c671e330f6a9e8bbb12ed5655c817d2005 Mon Sep 17 00:00:00 2001 From: juacrumar Date: Thu, 30 Apr 2020 12:04:22 +0200 Subject: [PATCH 10/15] passed black --- n3fit/src/n3fit/version.py | 36 ++++++++++++++++++++++++----- validphys2/src/validphys/version.py | 36 ++++++++++++++++++++++++----- 2 files changed, 60 insertions(+), 12 deletions(-) diff --git a/n3fit/src/n3fit/version.py b/n3fit/src/n3fit/version.py index 58718d2e5c..cd9b616d45 100644 --- a/n3fit/src/n3fit/version.py +++ b/n3fit/src/n3fit/version.py @@ -2,16 +2,40 @@ def __give_git(): # Get the path to this file from pathlib import Path + file_dir = Path(__file__).parent from subprocess import run, CalledProcessError + try: - result = run('git describe --tags --long --dirty'.split(), capture_output=True, text=True, check=True, cwd=file_dir).stdout.strip() - tag = run(['git', 'describe', '--abbrev=0', '--tags'], capture_output=True, text=True, check=True, cwd=file_dir).stdout.strip() - githash = run(['git', 'rev-parse', '--short', 'HEAD'], capture_output=True, text=True, check=True, cwd=file_dir).stdout.strip() - version = result.replace(f"-g{githash}", f"+g{githash}").replace(f"{tag}-", f"{tag}.") + result = run( + "git describe --tags --long --dirty".split(), + capture_output=True, + text=True, + check=True, + cwd=file_dir, + ).stdout.strip() + tag = run( + ["git", "describe", "--abbrev=0", "--tags"], + capture_output=True, + text=True, + check=True, + cwd=file_dir, + ).stdout.strip() + githash = run( + ["git", "rev-parse", "--short", "HEAD"], + capture_output=True, + text=True, + check=True, + cwd=file_dir, + ).stdout.strip() + version = result.replace(f"-g{githash}", f"+g{githash}").replace( + f"{tag}-", f"{tag}." + ) except CalledProcessError: # In principle this function should not exist on an installed version # but who knows. Also maybe git doesn't work on the machine or whatever - version = 'unknown' - return version + version = "unknown" + return version + + build_version = __give_git() diff --git a/validphys2/src/validphys/version.py b/validphys2/src/validphys/version.py index 58718d2e5c..cd9b616d45 100644 --- a/validphys2/src/validphys/version.py +++ b/validphys2/src/validphys/version.py @@ -2,16 +2,40 @@ def __give_git(): # Get the path to this file from pathlib import Path + file_dir = Path(__file__).parent from subprocess import run, CalledProcessError + try: - result = run('git describe --tags --long --dirty'.split(), capture_output=True, text=True, check=True, cwd=file_dir).stdout.strip() - tag = run(['git', 'describe', '--abbrev=0', '--tags'], capture_output=True, text=True, check=True, cwd=file_dir).stdout.strip() - githash = run(['git', 'rev-parse', '--short', 'HEAD'], capture_output=True, text=True, check=True, cwd=file_dir).stdout.strip() - version = result.replace(f"-g{githash}", f"+g{githash}").replace(f"{tag}-", f"{tag}.") + result = run( + "git describe --tags --long --dirty".split(), + capture_output=True, + text=True, + check=True, + cwd=file_dir, + ).stdout.strip() + tag = run( + ["git", "describe", "--abbrev=0", "--tags"], + capture_output=True, + text=True, + check=True, + cwd=file_dir, + ).stdout.strip() + githash = run( + ["git", "rev-parse", "--short", "HEAD"], + capture_output=True, + text=True, + check=True, + cwd=file_dir, + ).stdout.strip() + version = result.replace(f"-g{githash}", f"+g{githash}").replace( + f"{tag}-", f"{tag}." + ) except CalledProcessError: # In principle this function should not exist on an installed version # but who knows. Also maybe git doesn't work on the machine or whatever - version = 'unknown' - return version + version = "unknown" + return version + + build_version = __give_git() From 797d283a5b1c3cc5da9b9e37940cd9de30eab8f0 Mon Sep 17 00:00:00 2001 From: juacrumar Date: Fri, 1 May 2020 11:20:56 +0200 Subject: [PATCH 11/15] set the version from cmake --- .ciscripts/build-deploy-linux.sh | 2 +- .ciscripts/build-deploy-osx.sh | 2 +- CMakeLists.txt | 19 +++++++++++++++++++ version.cmake | 3 +++ 4 files changed, 24 insertions(+), 2 deletions(-) create mode 100644 version.cmake diff --git a/.ciscripts/build-deploy-linux.sh b/.ciscripts/build-deploy-linux.sh index fde929970e..c65564b181 100755 --- a/.ciscripts/build-deploy-linux.sh +++ b/.ciscripts/build-deploy-linux.sh @@ -8,7 +8,7 @@ set -v # Set the version for both vp and n3fit gitroot=$(git rev-parse --show-toplevel) -gitversion=$(git describe --long) +gitversion=$(git describe --long --tags) tag=$(git describe --abbrev=0 --tags) gitversion=${gitversion/${tag}-/${tag}.} githash=$(git rev-parse --short HEAD) diff --git a/.ciscripts/build-deploy-osx.sh b/.ciscripts/build-deploy-osx.sh index 004cceb020..80c826bb3d 100755 --- a/.ciscripts/build-deploy-osx.sh +++ b/.ciscripts/build-deploy-osx.sh @@ -7,7 +7,7 @@ echo "$NETRC_FILE" | base64 --decode > ~/.netrc # Set the version for both vp and n3fit gitroot=$(git rev-parse --show-toplevel) -gitversion=$(git describe --long) +gitversion=$(git describe --long --tags) tag=$(git describe --abbrev=0 --tags) gitversion=${gitversion/${tag}-/${tag}.} githash=$(git rev-parse --short HEAD) diff --git a/CMakeLists.txt b/CMakeLists.txt index d7d689e2b2..58ff500554 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -147,11 +147,27 @@ add_subdirectory(nnpdfcpp) # evolven3fit add_subdirectory(n3fit/evolven3fit) +# get the current version of the repository +execute_process(COMMAND git describe --abbrev=0 --tags OUTPUT_VARIABLE GIT_TAG) +string(STRIP ${GIT_TAG} GIT_TAG) +execute_process(COMMAND git rev-list ${GIT_TAG}..HEAD --count OUTPUT_VARIABLE GIT_REVN) +string(STRIP ${GIT_REVN} GIT_REVN) +execute_process(COMMAND git rev-parse --short HEAD OUTPUT_VARIABLE GIT_HASH) +string(STRIP ${GIT_HASH} GIT_HASH) +execute_process(COMMAND git describe --abbrev=0 --tags --dirty=dev OUTPUT_VARIABLE GIT_DIRTY) +string(STRIP ${GIT_DIRTY} GIT_DIRTY) +string(REPLACE "${GIT_TAG}" "" GIT_DIRTY ${GIT_DIRTY}) +# now concatenate everything +set(GIT_VERSION "build_version='${GIT_TAG}.${GIT_REVN}+g${GIT_HASH}-${GIT_DIRTY}'") + # install validphys2 if(VP_DEV) install(CODE "execute_process(COMMAND ${PYTHON_EXECUTABLE} -m pip install -e ${PROJECT_SOURCE_DIR}/validphys2)") else(VP_DEV) install(CODE "execute_process(COMMAND ${PYTHON_EXECUTABLE} -m pip install --no-deps --ignore-installed ${PROJECT_SOURCE_DIR}/validphys2)") + install(CODE "set(GIT_VERSION \"${GIT_VERSION}\")") + install(CODE "set(LIBRARY \"validphys\")") + install(SCRIPT ${PROJECT_SOURCE_DIR}/version.cmake) endif(VP_DEV) # install n3fit @@ -159,4 +175,7 @@ if(N3_DEV) install(CODE "execute_process(COMMAND ${PYTHON_EXECUTABLE} -m pip install -e ${PROJECT_SOURCE_DIR}/n3fit)") else(N3_DEV) install(CODE "execute_process(COMMAND ${PYTHON_EXECUTABLE} -m pip install --no-deps --ignore-installed ${PROJECT_SOURCE_DIR}/n3fit)") + install(CODE "set(GIT_VERSION \"${GIT_VERSION}\")") + install(CODE "set(LIBRARY \"n3fit\")") + install(SCRIPT ${PROJECT_SOURCE_DIR}/version.cmake) endif(N3_DEV) diff --git a/version.cmake b/version.cmake new file mode 100644 index 0000000000..044ba44163 --- /dev/null +++ b/version.cmake @@ -0,0 +1,3 @@ +execute_process(COMMAND python -c "import ${LIBRARY}.version ; print(${LIBRARY}.version.__file__)" OUTPUT_VARIABLE VERSION_PATH) +STRING(STRIP ${VERSION_PATH} VERSION_PATH) +file(WRITE ${VERSION_PATH} ${GIT_VERSION}) From 31edec576336ea77d0c3fc30278ef9c6e99fde69 Mon Sep 17 00:00:00 2001 From: juacrumar Date: Fri, 1 May 2020 11:23:17 +0200 Subject: [PATCH 12/15] use -dev instead of -dirty --- n3fit/src/n3fit/version.py | 2 +- validphys2/src/validphys/version.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/n3fit/src/n3fit/version.py b/n3fit/src/n3fit/version.py index cd9b616d45..adf81433ef 100644 --- a/n3fit/src/n3fit/version.py +++ b/n3fit/src/n3fit/version.py @@ -8,7 +8,7 @@ def __give_git(): try: result = run( - "git describe --tags --long --dirty".split(), + ["git", "describe", "--tags", "--long", "--dirty=-dev"], capture_output=True, text=True, check=True, diff --git a/validphys2/src/validphys/version.py b/validphys2/src/validphys/version.py index cd9b616d45..adf81433ef 100644 --- a/validphys2/src/validphys/version.py +++ b/validphys2/src/validphys/version.py @@ -8,7 +8,7 @@ def __give_git(): try: result = run( - "git describe --tags --long --dirty".split(), + ["git", "describe", "--tags", "--long", "--dirty=-dev"], capture_output=True, text=True, check=True, From fc218817b111db84936dd40721545f7ad73e5d69 Mon Sep 17 00:00:00 2001 From: juacrumar Date: Fri, 1 May 2020 11:50:17 +0200 Subject: [PATCH 13/15] have an option to burn or not the tag --- CMakeLists.txt | 43 +++++++++++++++++++++++++------------------ conda-recipe/build.sh | 4 ++-- 2 files changed, 27 insertions(+), 20 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 58ff500554..c68b9ba69d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -42,6 +42,7 @@ option(ENABLE_ASAN "Enable ASAN" OFF) option(ENABLE_DEAD_STRIP "Enable use of flag `-dead_strip-dylibs`" OFF) option(VP_DEV "validphys in developer mode" ON) option(N3_DEV "n3fit in developer mode" ON) +option(BURN_TAG "burn down the git tag in vp and n3fit (only local non-dev installation)" ON) set(PROFILE_PREFIX "" CACHE STRING "Where you store the 'data' folder. Default empty uses CMAKE_INSTALL_PREFIX/share/NNPDF.") if (PROFILE_PREFIX) @@ -147,27 +148,31 @@ add_subdirectory(nnpdfcpp) # evolven3fit add_subdirectory(n3fit/evolven3fit) +if(BURN_TAG) # get the current version of the repository -execute_process(COMMAND git describe --abbrev=0 --tags OUTPUT_VARIABLE GIT_TAG) -string(STRIP ${GIT_TAG} GIT_TAG) -execute_process(COMMAND git rev-list ${GIT_TAG}..HEAD --count OUTPUT_VARIABLE GIT_REVN) -string(STRIP ${GIT_REVN} GIT_REVN) -execute_process(COMMAND git rev-parse --short HEAD OUTPUT_VARIABLE GIT_HASH) -string(STRIP ${GIT_HASH} GIT_HASH) -execute_process(COMMAND git describe --abbrev=0 --tags --dirty=dev OUTPUT_VARIABLE GIT_DIRTY) -string(STRIP ${GIT_DIRTY} GIT_DIRTY) -string(REPLACE "${GIT_TAG}" "" GIT_DIRTY ${GIT_DIRTY}) + execute_process(COMMAND git describe --abbrev=0 --tags OUTPUT_VARIABLE GIT_TAG) + string(STRIP ${GIT_TAG} GIT_TAG) + execute_process(COMMAND git rev-list ${GIT_TAG}..HEAD --count OUTPUT_VARIABLE GIT_REVN) + string(STRIP ${GIT_REVN} GIT_REVN) + execute_process(COMMAND git rev-parse --short HEAD OUTPUT_VARIABLE GIT_HASH) + string(STRIP ${GIT_HASH} GIT_HASH) + execute_process(COMMAND git describe --abbrev=0 --tags --dirty=dev OUTPUT_VARIABLE GIT_DIRTY) + string(STRIP ${GIT_DIRTY} GIT_DIRTY) + string(REPLACE "${GIT_TAG}" "" GIT_DIRTY ${GIT_DIRTY}) # now concatenate everything -set(GIT_VERSION "build_version='${GIT_TAG}.${GIT_REVN}+g${GIT_HASH}-${GIT_DIRTY}'") + set(GIT_VERSION "build_version='${GIT_TAG}.${GIT_REVN}+g${GIT_HASH}-${GIT_DIRTY}'") +endif(BURN_TAG) # install validphys2 if(VP_DEV) - install(CODE "execute_process(COMMAND ${PYTHON_EXECUTABLE} -m pip install -e ${PROJECT_SOURCE_DIR}/validphys2)") + install(CODE "execute_process(COMMAND ${PYTHON_EXECUTABLE} -m pip install -e ${PROJECT_SOURCE_DIR}/validphys2)") else(VP_DEV) - install(CODE "execute_process(COMMAND ${PYTHON_EXECUTABLE} -m pip install --no-deps --ignore-installed ${PROJECT_SOURCE_DIR}/validphys2)") - install(CODE "set(GIT_VERSION \"${GIT_VERSION}\")") - install(CODE "set(LIBRARY \"validphys\")") - install(SCRIPT ${PROJECT_SOURCE_DIR}/version.cmake) + install(CODE "execute_process(COMMAND ${PYTHON_EXECUTABLE} -m pip install --no-deps --ignore-installed ${PROJECT_SOURCE_DIR}/validphys2)") +if(BURN_TAG) + install(CODE "set(GIT_VERSION \"${GIT_VERSION}\")") + install(CODE "set(LIBRARY \"validphys\")") + install(SCRIPT ${PROJECT_SOURCE_DIR}/version.cmake) +endif(BURN_TAG) endif(VP_DEV) # install n3fit @@ -175,7 +180,9 @@ if(N3_DEV) install(CODE "execute_process(COMMAND ${PYTHON_EXECUTABLE} -m pip install -e ${PROJECT_SOURCE_DIR}/n3fit)") else(N3_DEV) install(CODE "execute_process(COMMAND ${PYTHON_EXECUTABLE} -m pip install --no-deps --ignore-installed ${PROJECT_SOURCE_DIR}/n3fit)") - install(CODE "set(GIT_VERSION \"${GIT_VERSION}\")") - install(CODE "set(LIBRARY \"n3fit\")") - install(SCRIPT ${PROJECT_SOURCE_DIR}/version.cmake) +if(BURN_TAG) + install(CODE "set(GIT_VERSION \"${GIT_VERSION}\")") + install(CODE "set(LIBRARY \"n3fit\")") + install(SCRIPT ${PROJECT_SOURCE_DIR}/version.cmake) +endif(BURN_TAG) endif(N3_DEV) diff --git a/conda-recipe/build.sh b/conda-recipe/build.sh index 78c2d4a0a9..b8bc3d039e 100644 --- a/conda-recipe/build.sh +++ b/conda-recipe/build.sh @@ -2,6 +2,6 @@ mkdir build cd build -cmake .. -DCMAKE_INSTALL_PREFIX=${PREFIX} -DVP_DEV=OFF -DN3_DEV=OFF +cmake .. -DCMAKE_INSTALL_PREFIX=${PREFIX} -DVP_DEV=OFF -DN3_DEV=OFF -DBURN_TAG=OFF make -j${CPU_COUNT} -make install \ No newline at end of file +make install From 00b1741c9243eba4a2ae029fbda5bd194abd1a34 Mon Sep 17 00:00:00 2001 From: juacrumar Date: Fri, 1 May 2020 12:45:06 +0200 Subject: [PATCH 14/15] dont burn the tag if there is no access to git --- CMakeLists.txt | 28 ++++++++++++++++------------ conda-recipe/run_test.sh | 2 +- 2 files changed, 17 insertions(+), 13 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index c68b9ba69d..30db7c3037 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -148,20 +148,24 @@ add_subdirectory(nnpdfcpp) # evolven3fit add_subdirectory(n3fit/evolven3fit) -if(BURN_TAG) +if((BURN_TAG) AND (NOT (VP_DEV) OR NOT (N3_DEV))) # get the current version of the repository - execute_process(COMMAND git describe --abbrev=0 --tags OUTPUT_VARIABLE GIT_TAG) - string(STRIP ${GIT_TAG} GIT_TAG) - execute_process(COMMAND git rev-list ${GIT_TAG}..HEAD --count OUTPUT_VARIABLE GIT_REVN) - string(STRIP ${GIT_REVN} GIT_REVN) - execute_process(COMMAND git rev-parse --short HEAD OUTPUT_VARIABLE GIT_HASH) - string(STRIP ${GIT_HASH} GIT_HASH) - execute_process(COMMAND git describe --abbrev=0 --tags --dirty=dev OUTPUT_VARIABLE GIT_DIRTY) - string(STRIP ${GIT_DIRTY} GIT_DIRTY) - string(REPLACE "${GIT_TAG}" "" GIT_DIRTY ${GIT_DIRTY}) + execute_process(COMMAND git describe --abbrev=0 --tags OUTPUT_VARIABLE GIT_TAG ERROR_VARIABLE GIT_ERROR) + if(GIT_ERROR STREQUAL "") + string(STRIP ${GIT_TAG} GIT_TAG) + execute_process(COMMAND git rev-list ${GIT_TAG}..HEAD --count OUTPUT_VARIABLE GIT_REVN) + string(STRIP ${GIT_REVN} GIT_REVN) + execute_process(COMMAND git rev-parse --short HEAD OUTPUT_VARIABLE GIT_HASH) + string(STRIP ${GIT_HASH} GIT_HASH) + execute_process(COMMAND git describe --abbrev=0 --tags --dirty=dev OUTPUT_VARIABLE GIT_DIRTY) + string(STRIP ${GIT_DIRTY} GIT_DIRTY) + string(REPLACE "${GIT_TAG}" "" GIT_DIRTY ${GIT_DIRTY}) # now concatenate everything - set(GIT_VERSION "build_version='${GIT_TAG}.${GIT_REVN}+g${GIT_HASH}-${GIT_DIRTY}'") -endif(BURN_TAG) + set(GIT_VERSION "build_version='${GIT_TAG}.${GIT_REVN}+g${GIT_HASH}-${GIT_DIRTY}'") + else(GIT_ERROR STREQUAL "") + set(BURN_TAG OFF) + endif(GIT_ERROR STREQUAL "") +endif() # install validphys2 if(VP_DEV) diff --git a/conda-recipe/run_test.sh b/conda-recipe/run_test.sh index 33ebdca5d2..5b02830d7f 100644 --- a/conda-recipe/run_test.sh +++ b/conda-recipe/run_test.sh @@ -14,7 +14,7 @@ pytest --pyargs n3fit mkdir bldtest cd bldtest -cmake .. -DENABLE_TESTS=ON +cmake .. -DENABLE_TESTS=ON -DBURN_TAG=OFF make catch_test -j ./libnnpdf/tests/catch_test From e82d50165f83401d59ad7310acad1d73adb53038 Mon Sep 17 00:00:00 2001 From: juacrumar Date: Thu, 7 May 2020 11:26:08 +0200 Subject: [PATCH 15/15] allow to use cmake form outside git --- CMakeLists.txt | 35 ++++++++++++++++++++++------------- 1 file changed, 22 insertions(+), 13 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 30db7c3037..84b70212e8 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -149,19 +149,30 @@ add_subdirectory(nnpdfcpp) add_subdirectory(n3fit/evolven3fit) if((BURN_TAG) AND (NOT (VP_DEV) OR NOT (N3_DEV))) -# get the current version of the repository - execute_process(COMMAND git describe --abbrev=0 --tags OUTPUT_VARIABLE GIT_TAG ERROR_VARIABLE GIT_ERROR) + # Find out where is the root of the git repository (if available) and finds the correct tag to burn down + # in the package. This just sets the variable, the actual burning is done down below by the validphys + # or n3fit installation and is found in the version.cmake file as it needs to be done post-installation + set(GIT_DIR "--git-dir=${PROJECT_SOURCE_DIR}/.git") + # get the current tag (ex: 3.4) and check at the same time whether git is available and the .git folder found + execute_process(COMMAND git ${GIT_DIR} describe --abbrev=0 --tags OUTPUT_VARIABLE GIT_TAG ERROR_VARIABLE GIT_ERROR) if(GIT_ERROR STREQUAL "") string(STRIP ${GIT_TAG} GIT_TAG) - execute_process(COMMAND git rev-list ${GIT_TAG}..HEAD --count OUTPUT_VARIABLE GIT_REVN) + # get the number of revisions since tag happened + execute_process(COMMAND git ${GIT_DIR} rev-list ${GIT_TAG}..HEAD --count OUTPUT_VARIABLE GIT_REVN) string(STRIP ${GIT_REVN} GIT_REVN) - execute_process(COMMAND git rev-parse --short HEAD OUTPUT_VARIABLE GIT_HASH) + # get the shortname for the hash + execute_process(COMMAND git ${GIT_DIR} rev-parse --short HEAD OUTPUT_VARIABLE GIT_HASH) string(STRIP ${GIT_HASH} GIT_HASH) - execute_process(COMMAND git describe --abbrev=0 --tags --dirty=dev OUTPUT_VARIABLE GIT_DIRTY) + # find out whether the repository is in a dirty state + # (this returns ${GIT_TAG}-dev so we have to remove the tag) + execute_process(COMMAND git ${GIT_DIR} describe --abbrev=0 --tags --dirty=-dev OUTPUT_VARIABLE GIT_DIRTY) string(STRIP ${GIT_DIRTY} GIT_DIRTY) string(REPLACE "${GIT_TAG}" "" GIT_DIRTY ${GIT_DIRTY}) -# now concatenate everything - set(GIT_VERSION "build_version='${GIT_TAG}.${GIT_REVN}+g${GIT_HASH}-${GIT_DIRTY}'") + # now concatenate everything + # with the format ex: 3.4.1880+g00b1741c-dev + set(GIT_VERSION "build_version='${GIT_TAG}.${GIT_REVN}+g${GIT_HASH}${GIT_DIRTY}'") + # now set the variable at install time + install(CODE "set(GIT_VERSION \"${GIT_VERSION}\")") else(GIT_ERROR STREQUAL "") set(BURN_TAG OFF) endif(GIT_ERROR STREQUAL "") @@ -172,11 +183,10 @@ if(VP_DEV) install(CODE "execute_process(COMMAND ${PYTHON_EXECUTABLE} -m pip install -e ${PROJECT_SOURCE_DIR}/validphys2)") else(VP_DEV) install(CODE "execute_process(COMMAND ${PYTHON_EXECUTABLE} -m pip install --no-deps --ignore-installed ${PROJECT_SOURCE_DIR}/validphys2)") -if(BURN_TAG) - install(CODE "set(GIT_VERSION \"${GIT_VERSION}\")") + if(BURN_TAG) install(CODE "set(LIBRARY \"validphys\")") install(SCRIPT ${PROJECT_SOURCE_DIR}/version.cmake) -endif(BURN_TAG) + endif(BURN_TAG) endif(VP_DEV) # install n3fit @@ -184,9 +194,8 @@ if(N3_DEV) install(CODE "execute_process(COMMAND ${PYTHON_EXECUTABLE} -m pip install -e ${PROJECT_SOURCE_DIR}/n3fit)") else(N3_DEV) install(CODE "execute_process(COMMAND ${PYTHON_EXECUTABLE} -m pip install --no-deps --ignore-installed ${PROJECT_SOURCE_DIR}/n3fit)") -if(BURN_TAG) - install(CODE "set(GIT_VERSION \"${GIT_VERSION}\")") + if(BURN_TAG) install(CODE "set(LIBRARY \"n3fit\")") install(SCRIPT ${PROJECT_SOURCE_DIR}/version.cmake) -endif(BURN_TAG) + endif(BURN_TAG) endif(N3_DEV)