Fix bugs in packaging procedure.
The version is now not hardcoded anymore in the python module. We use setuptools_scm or pkg_resources instead. There was also a bug in the linkage for PED with matrix inversion using external lapack. Finally, the install script install now requirements and all requirements are stored in the requirements.txt file. setup.py looks inside to set its "install_requires" keyword.
This commit is contained in:
parent
519c48c61f
commit
162ffa87bd
|
@ -12,28 +12,6 @@ def get_version():
|
||||||
return output
|
return output
|
||||||
|
|
||||||
def set_version(version):
|
def set_version(version):
|
||||||
# modify the files to reflect the new version
|
|
||||||
files = [os.path.abspath('./src/msspec/__init__.py'),
|
|
||||||
os.path.abspath('./src/msspec/msspecgui/__init__.py'),
|
|
||||||
os.path.abspath("./VERSION")]
|
|
||||||
|
|
||||||
for f in files[:-1]:
|
|
||||||
with open(f, "w") as fd:
|
|
||||||
fd.write("# Auto-generated file, do not edit\n")
|
|
||||||
fd.write(f"__version__ = \"{version}\"\n")
|
|
||||||
fd.write(f"__sha__ = \"$Id$\"\n")
|
|
||||||
|
|
||||||
with open(files[-1], "w") as fd:
|
|
||||||
fd.write(f"MsSpec-{version}")
|
|
||||||
|
|
||||||
# commit them
|
|
||||||
for f in files:
|
|
||||||
cmd = ['git', 'add', f]
|
|
||||||
subprocess.run(cmd)
|
|
||||||
msg = 'Update version'
|
|
||||||
cmd = ['git', 'commit', '-m', msg]
|
|
||||||
subprocess.run(cmd)
|
|
||||||
|
|
||||||
# create the tag
|
# create the tag
|
||||||
cmd = ['git', 'tag', '-a', version, '-m', f"Python MsSpec ({version})"]
|
cmd = ['git', 'tag', '-a', version, '-m', f"Python MsSpec ({version})"]
|
||||||
subprocess.run(cmd)
|
subprocess.run(cmd)
|
||||||
|
@ -90,5 +68,3 @@ def ask_new_version(current_version):
|
||||||
set_version(new_version)
|
set_version(new_version)
|
||||||
|
|
||||||
ask_new_version(get_version())
|
ask_new_version(get_version())
|
||||||
|
|
||||||
#print(get_version())
|
|
||||||
|
|
6
Makefile
6
Makefile
|
@ -21,7 +21,9 @@ selfex: results
|
||||||
@cp -r src src_
|
@cp -r src src_
|
||||||
@+$(MAKE) -C ./src_ purge
|
@+$(MAKE) -C ./src_ purge
|
||||||
# update the version
|
# update the version
|
||||||
@echo "__version__ = \"$(VERSION)\"" > ./src_/msspec/version.py
|
@echo "$(VERSION)" > ./src_/VERSION
|
||||||
|
# distribute the README.md file
|
||||||
|
@cp README.md ./src_/
|
||||||
# create the package folder
|
# create the package folder
|
||||||
@mkdir -p package
|
@mkdir -p package
|
||||||
# create the *.lsm file
|
# create the *.lsm file
|
||||||
|
@ -70,7 +72,7 @@ results:
|
||||||
|
|
||||||
venv:
|
venv:
|
||||||
@virtualenv --python=python3 --system-site-packages ci_venv $(SUPPRESS_OUPUT)
|
@virtualenv --python=python3 --system-site-packages ci_venv $(SUPPRESS_OUPUT)
|
||||||
@. "./ci_venv/bin/activate" && pip install --upgrade pip numpy ase h5py lxml pint terminaltables pycairo sphinx coverage $(SUPPRESS_OUPUT)
|
@. "./ci_venv/bin/activate" && pip install --upgrade pip && pip install --upgrade -r requirements.txt $(SUPPRESS_OUPUT)
|
||||||
|
|
||||||
doc:
|
doc:
|
||||||
@echo "Building pdf and html documentation..."
|
@echo "Building pdf and html documentation..."
|
||||||
|
|
|
@ -1,3 +1,6 @@
|
||||||
include msspec/spec/fortran/*.so
|
include msspec/spec/fortran/*.so
|
||||||
include msspec/phagen/fortran/*.so
|
include msspec/phagen/fortran/*.so
|
||||||
include msspec/results.txt
|
include msspec/results.txt
|
||||||
|
include VERSION
|
||||||
|
include README.md
|
||||||
|
include requirements.txt
|
||||||
|
|
|
@ -10,12 +10,19 @@ endif
|
||||||
|
|
||||||
|
|
||||||
install: sdist
|
install: sdist
|
||||||
|
@echo "Installing the newly created Python package..."
|
||||||
@pip install dist/msspec-*.tar.gz $(SUPPRESS_OUPUT)
|
@pip install dist/msspec-*.tar.gz $(SUPPRESS_OUPUT)
|
||||||
|
|
||||||
sdist: pybinding
|
sdist: install_deps
|
||||||
@echo "Creating Python source distribution..."
|
@echo "Creating Python source distribution..."
|
||||||
|
# Create the source distrib
|
||||||
@python setup.py sdist $(SUPPRESS_OUPUT)
|
@python setup.py sdist $(SUPPRESS_OUPUT)
|
||||||
|
|
||||||
|
install_deps: pybinding
|
||||||
|
@echo "Installing Python dependencies..."
|
||||||
|
# Install dependencies with pip
|
||||||
|
@pip install --upgrade -r requirements.txt $(SUPPRESS_OUPUT)
|
||||||
|
|
||||||
pybinding:
|
pybinding:
|
||||||
@echo "Building Python binding for phagen and spec..."
|
@echo "Building Python binding for phagen and spec..."
|
||||||
@+$(MAKE) -C msspec/spec/fortran pybinding $(SUPPRESS_OUPUT)
|
@+$(MAKE) -C msspec/spec/fortran pybinding $(SUPPRESS_OUPUT)
|
||||||
|
|
|
@ -3,6 +3,7 @@
|
||||||
|
|
||||||
BYPASS="n"
|
BYPASS="n"
|
||||||
DEBUG="n"
|
DEBUG="n"
|
||||||
|
BUILDONLY="n"
|
||||||
|
|
||||||
SCRIPT_NAME=$(basename "$0")
|
SCRIPT_NAME=$(basename "$0")
|
||||||
VERSION=$(cat ./msspec/version.py|cut -d\" -f2)
|
VERSION=$(cat ./msspec/version.py|cut -d\" -f2)
|
||||||
|
@ -205,6 +206,11 @@ check_dependencies () {
|
||||||
log_message "Ok\n"
|
log_message "Ok\n"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# we need pip
|
||||||
|
log_message "Checking if pip is installed..."
|
||||||
|
command -V pip || return 1
|
||||||
|
log_message "Ok\n"
|
||||||
|
|
||||||
# we need virtualenv
|
# we need virtualenv
|
||||||
#log_message "Checking if virtualenv is installed..."
|
#log_message "Checking if virtualenv is installed..."
|
||||||
#command -V virtualenv || return 1
|
#command -V virtualenv || return 1
|
||||||
|
@ -248,19 +254,28 @@ local_install () {
|
||||||
read -ep "INCLUDE DEBUG SYMBOLS (0:no, 1:yes)> " -i "${DEBUG_MODE}" DEBUG_MODE
|
read -ep "INCLUDE DEBUG SYMBOLS (0:no, 1:yes)> " -i "${DEBUG_MODE}" DEBUG_MODE
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
ALL_OPTS="VERBOSE=1 USE_MKL=${USE_MKL} LINKER_FLAGS=\"${LINKER_FLAGS}\" COMP=\"${COMP}\" COMP_OPTS=\"${COMP_OPTS}\" DEBUG=\"${DEBUG_MODE}\""
|
||||||
|
|
||||||
# build the Fortran code
|
# build the Fortran code
|
||||||
wrap "make pybinding VERBOSE=1 USE_MKL=${USE_MKL} LINKER_FLAGS=\"${LINKER_FLAGS}\" COMP=\"${COMP}\" COMP_OPTS=\"${COMP_OPTS}\" DEBUG=\"${DEBUG_MODE}\"" "Building Phagen and Spec Python dynamic library"
|
wrap "make pybinding ${ALL_OPTS}" "Building Phagen and Spec Python dynamic library"
|
||||||
exit
|
|
||||||
|
if [ x"${BUILDONLY}" = xy ]; then
|
||||||
|
exit
|
||||||
|
fi
|
||||||
|
|
||||||
|
# install Python dependencies
|
||||||
|
wrap "make install_deps ${ALL_OPTS}" "Installing Python dependencies"
|
||||||
|
|
||||||
# build the source distribution
|
# build the source distribution
|
||||||
wrap "make sdist VERBOSE=1" "Building msspec python package"
|
wrap "make sdist ${ALL_OPTS}" "Building msspec python package"
|
||||||
|
|
||||||
# install the package
|
# install the package
|
||||||
wrap "make install VERBOSE=1" "Installing the msspec package"
|
wrap "make install ${ALL_OPTS}" "Installing the msspec package"
|
||||||
|
|
||||||
# Run unit tests ?
|
# Run unit tests ?
|
||||||
read_yes_no "Do you wish to run unit tests" "y"
|
read_yes_no "Do you wish to run unit tests" "y"
|
||||||
if [ x"${ANSWER}" = xy ]; then
|
if [ x"${ANSWER}" = xy ]; then
|
||||||
wrap "make tests" "Runing test suite"
|
wrap "make tests ${ALL_OPTS}" "Runing test suite"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# installation was a succes so ask if we keep the log file
|
# installation was a succes so ask if we keep the log file
|
||||||
|
@ -273,13 +288,15 @@ local_install () {
|
||||||
success_message
|
success_message
|
||||||
}
|
}
|
||||||
|
|
||||||
while getopts "p:b:yd" option
|
while getopts "p:byd" option
|
||||||
do
|
do
|
||||||
case $option in
|
case $option in
|
||||||
y) export BYPASS="y"
|
y) export BYPASS="y"
|
||||||
;;
|
;;
|
||||||
d) export DEBUG="y"
|
d) export DEBUG="y"
|
||||||
;;
|
;;
|
||||||
|
b) export BUILDONLY="y"
|
||||||
|
;;
|
||||||
h) show_help
|
h) show_help
|
||||||
;;
|
;;
|
||||||
*) show_help
|
*) show_help
|
||||||
|
|
|
@ -1,2 +1 @@
|
||||||
from ..version import __version__
|
from ..version import __version__
|
||||||
__sha__ = "$Id$"
|
|
||||||
|
|
|
@ -28,7 +28,7 @@ eig_pw_src:=$(filter-out eig/pw/main.f, $(wildcard eig/pw/*.f))
|
||||||
|
|
||||||
ifeq ($(USE_MKL), 1)
|
ifeq ($(USE_MKL), 1)
|
||||||
eig_common_src:=$(filter-out $(wildcard eig/common/lapack*.f), $(eig_common_src))
|
eig_common_src:=$(filter-out $(wildcard eig/common/lapack*.f), $(eig_common_src))
|
||||||
phd_mi_noso_nosp_nosym_src:=$(filter-out $(wildcard phd_mi_noso_nosp_nosym/lapack*.f), $(phd_mi_noso_nosp_nosym))
|
phd_mi_noso_nosp_nosym_src:=$(filter-out $(wildcard phd_mi_noso_nosp_nosym/lapack*.f), $(phd_mi_noso_nosp_nosym_src))
|
||||||
LINKER_FLAGS:=$(shell pkg-config --libs lapack)
|
LINKER_FLAGS:=$(shell pkg-config --libs lapack)
|
||||||
# MKL:=-L$(MKLROOT) -lmkl_core -lmkl_intel_lp64 -lmkl_sequential
|
# MKL:=-L$(MKLROOT) -lmkl_core -lmkl_intel_lp64 -lmkl_sequential
|
||||||
endif
|
endif
|
||||||
|
@ -64,8 +64,6 @@ export COMP_OPTS
|
||||||
|
|
||||||
.PHONY: clean
|
.PHONY: clean
|
||||||
|
|
||||||
truc:
|
|
||||||
@echo $(eig_common_src)
|
|
||||||
|
|
||||||
pybinding: $(libs_targets)
|
pybinding: $(libs_targets)
|
||||||
|
|
||||||
|
|
|
@ -1,3 +1,28 @@
|
||||||
# This file is updated at package creation
|
# coding: utf-8
|
||||||
# DO NOT EDIT
|
# vim: set et sw=4 ts=4 sts=4 nu ai cc=+0 fdm=indent mouse=a:
|
||||||
__version__ = "1000.0"
|
|
||||||
|
from pkg_resources import parse_version, DistributionNotFound, get_distribution
|
||||||
|
from msspec.misc import LOGGER
|
||||||
|
import os
|
||||||
|
|
||||||
|
try:
|
||||||
|
# try to find the version from egg info file
|
||||||
|
__version__ = get_distribution(__name__.strip('.version')).version
|
||||||
|
except DistributionNotFound:
|
||||||
|
# otherwise try to get it from the SCM
|
||||||
|
try:
|
||||||
|
from setuptools_scm import get_version
|
||||||
|
v = get_version(root='../../', relative_to=__file__, version_scheme="post-release")
|
||||||
|
v = parse_version(v)
|
||||||
|
if v._version.post[-1] == 0:
|
||||||
|
__version__ = v.base_version
|
||||||
|
else:
|
||||||
|
__version__ = v.public
|
||||||
|
except (LookupError, ModuleNotFoundError):
|
||||||
|
# Ok, so there may be a VERSION file to look for it
|
||||||
|
try:
|
||||||
|
f = os.path.join(os.path.dirname(__file__), "../VERSION")
|
||||||
|
with open(f, "r") as fd:
|
||||||
|
__version__ = fd.read().strip('\n ')
|
||||||
|
except:
|
||||||
|
LOGGER.error("Unable to get the version number!")
|
||||||
|
|
|
@ -7,3 +7,4 @@ terminaltables
|
||||||
pycairo
|
pycairo
|
||||||
coverage
|
coverage
|
||||||
sphinx
|
sphinx
|
||||||
|
setuptools_scm
|
26
src/setup.py
26
src/setup.py
|
@ -2,19 +2,14 @@
|
||||||
# vim: set fdm=indent ts=4 sw=4 sts=4 et tw=80 ai cc=+0 mouse=a nu : #
|
# vim: set fdm=indent ts=4 sw=4 sts=4 et tw=80 ai cc=+0 mouse=a nu : #
|
||||||
|
|
||||||
from setuptools import setup, find_packages
|
from setuptools import setup, find_packages
|
||||||
|
from msspec.version import __version__
|
||||||
|
|
||||||
with open('msspec/version.py', 'r') as fd:
|
with open('requirements.txt', 'r') as fd:
|
||||||
content = fd.readlines()
|
requirements = fd.read().strip().split('\n')
|
||||||
|
|
||||||
version = "999.999"
|
|
||||||
for line in content:
|
|
||||||
l = line.strip()
|
|
||||||
if l.startswith('__version__'):
|
|
||||||
version = l.split('=')[-1].strip(" \"")
|
|
||||||
break
|
|
||||||
|
|
||||||
setup(name='msspec',
|
setup(name='msspec',
|
||||||
version=version,
|
setup_requires=['setuptools_scm'],
|
||||||
|
version=__version__,
|
||||||
author='Didier Sébilleau, Sylvain Tricot',
|
author='Didier Sébilleau, Sylvain Tricot',
|
||||||
author_email='sylvain.tricot@univ-rennes1.fr',
|
author_email='sylvain.tricot@univ-rennes1.fr',
|
||||||
maintainer='Sylvain Tricot',
|
maintainer='Sylvain Tricot',
|
||||||
|
@ -54,12 +49,5 @@ setup(name='msspec',
|
||||||
|
|
||||||
include_package_data=True,
|
include_package_data=True,
|
||||||
packages=find_packages(include='msspec.*'),
|
packages=find_packages(include='msspec.*'),
|
||||||
install_requires=[
|
install_requires=requirements
|
||||||
'numpy',
|
)
|
||||||
'ase',
|
|
||||||
'h5py',
|
|
||||||
'lxml',
|
|
||||||
'pint',
|
|
||||||
'terminaltables',
|
|
||||||
'pycairo',
|
|
||||||
])
|
|
||||||
|
|
Loading…
Reference in New Issue