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
|
||||
|
||||
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
|
||||
cmd = ['git', 'tag', '-a', version, '-m', f"Python MsSpec ({version})"]
|
||||
subprocess.run(cmd)
|
||||
|
@ -90,5 +68,3 @@ def ask_new_version(current_version):
|
|||
set_version(new_version)
|
||||
|
||||
ask_new_version(get_version())
|
||||
|
||||
#print(get_version())
|
||||
|
|
6
Makefile
6
Makefile
|
@ -21,7 +21,9 @@ selfex: results
|
|||
@cp -r src src_
|
||||
@+$(MAKE) -C ./src_ purge
|
||||
# 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
|
||||
@mkdir -p package
|
||||
# create the *.lsm file
|
||||
|
@ -70,7 +72,7 @@ results:
|
|||
|
||||
venv:
|
||||
@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:
|
||||
@echo "Building pdf and html documentation..."
|
||||
|
|
|
@ -1,3 +1,6 @@
|
|||
include msspec/spec/fortran/*.so
|
||||
include msspec/phagen/fortran/*.so
|
||||
include msspec/results.txt
|
||||
include VERSION
|
||||
include README.md
|
||||
include requirements.txt
|
||||
|
|
|
@ -10,12 +10,19 @@ endif
|
|||
|
||||
|
||||
install: sdist
|
||||
@echo "Installing the newly created Python package..."
|
||||
@pip install dist/msspec-*.tar.gz $(SUPPRESS_OUPUT)
|
||||
|
||||
sdist: pybinding
|
||||
sdist: install_deps
|
||||
@echo "Creating Python source distribution..."
|
||||
# Create the source distrib
|
||||
@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:
|
||||
@echo "Building Python binding for phagen and spec..."
|
||||
@+$(MAKE) -C msspec/spec/fortran pybinding $(SUPPRESS_OUPUT)
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
|
||||
BYPASS="n"
|
||||
DEBUG="n"
|
||||
BUILDONLY="n"
|
||||
|
||||
SCRIPT_NAME=$(basename "$0")
|
||||
VERSION=$(cat ./msspec/version.py|cut -d\" -f2)
|
||||
|
@ -205,6 +206,11 @@ check_dependencies () {
|
|||
log_message "Ok\n"
|
||||
fi
|
||||
|
||||
# we need pip
|
||||
log_message "Checking if pip is installed..."
|
||||
command -V pip || return 1
|
||||
log_message "Ok\n"
|
||||
|
||||
# we need virtualenv
|
||||
#log_message "Checking if virtualenv is installed..."
|
||||
#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
|
||||
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
|
||||
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"
|
||||
exit
|
||||
wrap "make pybinding ${ALL_OPTS}" "Building Phagen and Spec Python dynamic library"
|
||||
|
||||
if [ x"${BUILDONLY}" = xy ]; then
|
||||
exit
|
||||
fi
|
||||
|
||||
# install Python dependencies
|
||||
wrap "make install_deps ${ALL_OPTS}" "Installing Python dependencies"
|
||||
|
||||
# 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
|
||||
wrap "make install VERBOSE=1" "Installing the msspec package"
|
||||
wrap "make install ${ALL_OPTS}" "Installing the msspec package"
|
||||
|
||||
# Run unit tests ?
|
||||
read_yes_no "Do you wish to run unit tests" "y"
|
||||
if [ x"${ANSWER}" = xy ]; then
|
||||
wrap "make tests" "Runing test suite"
|
||||
wrap "make tests ${ALL_OPTS}" "Runing test suite"
|
||||
fi
|
||||
|
||||
# installation was a succes so ask if we keep the log file
|
||||
|
@ -273,13 +288,15 @@ local_install () {
|
|||
success_message
|
||||
}
|
||||
|
||||
while getopts "p:b:yd" option
|
||||
while getopts "p:byd" option
|
||||
do
|
||||
case $option in
|
||||
y) export BYPASS="y"
|
||||
;;
|
||||
d) export DEBUG="y"
|
||||
;;
|
||||
b) export BUILDONLY="y"
|
||||
;;
|
||||
h) show_help
|
||||
;;
|
||||
*) show_help
|
||||
|
|
|
@ -1,2 +1 @@
|
|||
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)
|
||||
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)
|
||||
# MKL:=-L$(MKLROOT) -lmkl_core -lmkl_intel_lp64 -lmkl_sequential
|
||||
endif
|
||||
|
@ -64,8 +64,6 @@ export COMP_OPTS
|
|||
|
||||
.PHONY: clean
|
||||
|
||||
truc:
|
||||
@echo $(eig_common_src)
|
||||
|
||||
pybinding: $(libs_targets)
|
||||
|
||||
|
|
|
@ -1,3 +1,28 @@
|
|||
# This file is updated at package creation
|
||||
# DO NOT EDIT
|
||||
__version__ = "1000.0"
|
||||
# coding: utf-8
|
||||
# vim: set et sw=4 ts=4 sts=4 nu ai cc=+0 fdm=indent mouse=a:
|
||||
|
||||
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
|
||||
coverage
|
||||
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 : #
|
||||
|
||||
from setuptools import setup, find_packages
|
||||
from msspec.version import __version__
|
||||
|
||||
with open('msspec/version.py', 'r') as fd:
|
||||
content = fd.readlines()
|
||||
|
||||
version = "999.999"
|
||||
for line in content:
|
||||
l = line.strip()
|
||||
if l.startswith('__version__'):
|
||||
version = l.split('=')[-1].strip(" \"")
|
||||
break
|
||||
with open('requirements.txt', 'r') as fd:
|
||||
requirements = fd.read().strip().split('\n')
|
||||
|
||||
setup(name='msspec',
|
||||
version=version,
|
||||
setup_requires=['setuptools_scm'],
|
||||
version=__version__,
|
||||
author='Didier Sébilleau, Sylvain Tricot',
|
||||
author_email='sylvain.tricot@univ-rennes1.fr',
|
||||
maintainer='Sylvain Tricot',
|
||||
|
@ -54,12 +49,5 @@ setup(name='msspec',
|
|||
|
||||
include_package_data=True,
|
||||
packages=find_packages(include='msspec.*'),
|
||||
install_requires=[
|
||||
'numpy',
|
||||
'ase',
|
||||
'h5py',
|
||||
'lxml',
|
||||
'pint',
|
||||
'terminaltables',
|
||||
'pycairo',
|
||||
])
|
||||
install_requires=requirements
|
||||
)
|
||||
|
|
Loading…
Reference in New Issue