Work on Makefiles to make install easier...
epsi-builds/msspec_python3/pipeline/head This commit looks good
Details
epsi-builds/msspec_python3/pipeline/head This commit looks good
Details
This commit is contained in:
parent
3834f38aec
commit
d4ed926e55
23
Makefile
23
Makefile
|
@ -1,6 +1,6 @@
|
|||
include src/options.mk
|
||||
|
||||
PYTHON = python3
|
||||
PYTHON = python
|
||||
|
||||
# Checking Python version
|
||||
PYTHON_EXE := $(shell command -v $(PYTHON) 2> /dev/null)
|
||||
|
@ -17,21 +17,30 @@ ifneq ($(shell test $(PYTHON_VERSION_MAJOR) -ge 3 -a $(PYTHON_VERSION_MINOR) -ge
|
|||
endif
|
||||
|
||||
|
||||
.PHONY: pybinding venv doc
|
||||
.PHONY: pybinding venv doc clean
|
||||
|
||||
|
||||
pybinding:
|
||||
@+$(MAKE) -C src pybinding
|
||||
|
||||
|
||||
install: venv
|
||||
@+$(MAKE) -C src sdist
|
||||
@+$(MAKE) -C src frontend
|
||||
@. $(VENV_PATH)/bin/activate && pip install src/dist/msspec-$(VERSION).tar.gz
|
||||
|
||||
venv:
|
||||
virtualenv --python=$(PYTHON_EXE) --prompt="(msspec-$(VERSION)) " venv
|
||||
. ./venv/bin/activate && pip install --upgrade pip && pip install -r src/pip.freeze
|
||||
virtualenv --python=$(PYTHON_EXE) --prompt="(msspec-$(VERSION)) " $(VENV_PATH)
|
||||
. $(VENV_PATH)/bin/activate && pip install --upgrade pip && pip install -r src/pip.freeze
|
||||
|
||||
doc:
|
||||
@echo "Building pdf and html documentation..."
|
||||
@mkdir -p package/
|
||||
@+$(MAKE) -C doc/ latexpdf $(SUPPRESS_OUPUT)
|
||||
@+$(MAKE) -C doc/ latexpdf
|
||||
@rm -rf package/*.pdf
|
||||
@cp "doc/build/latex/MsSpec-python.pdf" "./package/MsSpec-${VERSION}.pdf"
|
||||
@+$(MAKE) -C doc/ html $(SUPPRESS_OUPUT)
|
||||
@cp "doc/build/latex/MsSpec-python.pdf" "./package/MsSpec-$(VERSION).pdf"
|
||||
@+$(MAKE) -C doc/ html
|
||||
|
||||
clean::
|
||||
@+$(MAKE) -C src/ clean
|
||||
|
||||
|
|
|
@ -83,8 +83,9 @@ html0: banner images
|
|||
@echo
|
||||
@echo "Build finished. The HTML pages are in $(BUILDDIR)/html."
|
||||
|
||||
html: html0 ownership $(BUILDDIR)/html/sitemap.xml coverage_report
|
||||
@echo
|
||||
#html: html0 ownership $(BUILDDIR)/html/sitemap.xml coverage_report
|
||||
|
||||
html: html0 ownership $(BUILDDIR)/html/sitemap.xml
|
||||
|
||||
coverage_report:
|
||||
@echo "Generating coverage report..."
|
||||
|
|
22
src/Makefile
22
src/Makefile
|
@ -1,20 +1,31 @@
|
|||
include options.mk
|
||||
|
||||
.PHONY: sdist pybinding results clean
|
||||
.PHONY: sdist frontend pybinding results clean
|
||||
|
||||
install: sdist
|
||||
@echo "Installing msspec python package"
|
||||
@pip install dist/msspec-*.tar.gz
|
||||
|
||||
sdist: pybinding
|
||||
foo:
|
||||
echo $(VERSION)
|
||||
|
||||
sdist: dist/msspec-$(VERSION).tar.gz
|
||||
|
||||
|
||||
frontend: $(INSTALL_PREFIX)/bin/msspec
|
||||
|
||||
|
||||
dist/msspec-$(VERSION).tar.gz: pybinding
|
||||
@echo "Creating Python source distribution..."
|
||||
@python setup.py sdist
|
||||
|
||||
$(INSTALL_PREFIX)/bin/msspec:
|
||||
@cat msspec.sh.template | sed 's/__VERSION__/$(VERSION)/' > $@
|
||||
@chmod u+x $@
|
||||
|
||||
|
||||
pybinding:
|
||||
@echo "Building Python binding for phagen and spec..."
|
||||
@+$(MAKE) -C msspec/phagen/fortran all
|
||||
@+$(MAKE) -C msspec/spec/fortran all
|
||||
@echo "$(VERSION)" > VERSION
|
||||
|
||||
results: msspec/results.txt
|
||||
|
||||
|
@ -38,6 +49,7 @@ clean::
|
|||
# remove previous sdist
|
||||
@rm -rf dist
|
||||
@rm -rf *.egg*
|
||||
@rm VERSION
|
||||
|
||||
|
||||
help:
|
||||
|
|
|
@ -0,0 +1,100 @@
|
|||
#!/bin/bash
|
||||
|
||||
SCRIPT_NAME="$0"
|
||||
VERSION="__VERSION__"
|
||||
VENV_PATH="$HOME/.local/src/msspec_venv_$VERSION"
|
||||
|
||||
# Check venv path
|
||||
if ! [ -d "$VENV_PATH" ]; then
|
||||
echo "ERROR: Unable to find version $VERSION of msspec!!"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
launch_script() {
|
||||
. "$VENV_PATH/bin/activate" && python $@
|
||||
}
|
||||
|
||||
show_help () {
|
||||
echo "Usage: 1) $SCRIPT_NAME -p [PYTHON OPTIONS] SCRIPT [ARGUMENTS...]"
|
||||
echo " 2) $SCRIPT_NAME [-l FILE | -i | -h]"
|
||||
echo " 3) eval \$($SCRIPT_NAME -e)"
|
||||
echo ""
|
||||
echo "Form (1) is used to launch a script"
|
||||
echo "Form (2) is used to load a hdf5 data file"
|
||||
echo "Form (3) is used to activate the msspec virtual environment"
|
||||
echo ""
|
||||
echo "List of possible options:"
|
||||
echo " -p Pass every arguments after this option to the msspec"
|
||||
echo " virtual environment Python interpreter."
|
||||
echo " -i Run the interactive Python interpreter within msspec"
|
||||
echo " virtual environment."
|
||||
echo " -l Load and display a *.hdf5 data file in a graphical"
|
||||
echo " window."
|
||||
echo " -h Show this help message."
|
||||
}
|
||||
|
||||
launch_interpreter() {
|
||||
source $VENV_PATH/bin/activate
|
||||
echo "Python interpreter of the MsSpec virtual environment."
|
||||
echo ""
|
||||
echo "This environment includes the following packages:"
|
||||
pip list
|
||||
echo ""
|
||||
echo "Type in <CTRL>+D to exit."
|
||||
echo ""
|
||||
ipython --profile=msspec
|
||||
}
|
||||
|
||||
load_data() {
|
||||
. "$VENV_PATH/bin/activate" && python -m msspec.iodata $1
|
||||
}
|
||||
|
||||
read_yes_no () {
|
||||
PROMPT="$1"
|
||||
DEFAULT="$2"
|
||||
BYPASS="$3"
|
||||
|
||||
ANSWER=""
|
||||
RESPONSE=""
|
||||
|
||||
VALID=1
|
||||
while test $VALID -ne 0; do
|
||||
test "$BYPASS" = "y" || read -p "${PROMPT} (y/n) [${DEFAULT}]? " "RESPONSE"
|
||||
ANSWER="${RESPONSE:-${DEFAULT}}"
|
||||
case "${ANSWER}" in
|
||||
y|n) VALID=0 ;;
|
||||
*) echo "Invalid choice, please answer \"y\" or \"n\"."; VALID=1 ;;
|
||||
esac
|
||||
done
|
||||
}
|
||||
|
||||
uninstall() {
|
||||
read_yes_no "This will completely remove msspec from your computer. Are you sure" "n" "$BYPASS"
|
||||
case "${ANSWER}" in
|
||||
y) rm -rv "$VENV_PATH" && rm "$SCRIPT_NAME" && echo "MsSpec successfully uninstalled." ;;
|
||||
n) echo "Uninstallation aborted." ;;
|
||||
esac
|
||||
}
|
||||
|
||||
|
||||
|
||||
while getopts "hil:p:eu" option; do
|
||||
case $option in
|
||||
p) shift; launch_script "$@"
|
||||
;;
|
||||
i) launch_interpreter
|
||||
;;
|
||||
l) load_data "$OPTARG"; shift
|
||||
;;
|
||||
e) echo ". $VENV_PATH/bin/activate"
|
||||
;;
|
||||
u) uninstall
|
||||
;;
|
||||
*|h) show_help
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
if [ $OPTIND -eq 1 ]; then
|
||||
show_help
|
||||
fi
|
|
@ -44,7 +44,10 @@ except Exception as err:
|
|||
__version__ = get_distribution(__name__.strip('.version')).version
|
||||
except Exception as err:
|
||||
try:
|
||||
with open("../VERSION", "r") as fd:
|
||||
thisfile_path = os.path.abspath(__file__)
|
||||
thisfile_dir = os.path.dirname(thisfile_path)
|
||||
versionfile = os.path.join(thisfile_dir, "../VERSION")
|
||||
with open(versionfile, "r") as fd:
|
||||
__version__ = fd.readline()
|
||||
except Exception as err:
|
||||
print("Unable to get the version number!")
|
||||
|
|
|
@ -4,6 +4,7 @@ F2PY = f2py3
|
|||
DEBUG = 0
|
||||
VERBOSE = 0
|
||||
BUILDDIR = ./build
|
||||
INSTALL_PREFIX = $(HOME)/.local
|
||||
|
||||
|
||||
################################################################################
|
||||
|
@ -37,6 +38,7 @@ F2PYFLAGS_DBG = --debug-capi --debug
|
|||
################################################################################
|
||||
#VERSION:=$(shell python -c "import msspec; print(msspec.__version__)")
|
||||
VERSION:=$(shell git describe|sed 's/-\([[:digit:]]\+\)-.*/\.post\1/')
|
||||
VENV_PATH := $(INSTALL_PREFIX)/src/msspec_venv_$(VERSION)
|
||||
|
||||
ifeq ($(VERBOSE),0)
|
||||
OUPUT_REDIRECTION := 1>/dev/null 2>/dev/null
|
||||
|
@ -81,17 +83,9 @@ obj: $(OBJS)
|
|||
|
||||
|
||||
clean::
|
||||
@for objfile in $(OBJS); do \
|
||||
if test -f $$objfile; then \
|
||||
echo "Removing $$objfile..."; \
|
||||
rm $$objfile; \
|
||||
fi;\
|
||||
done
|
||||
@if test -d $(abspath $(BUILDDIR)); then \
|
||||
if test `find $(abspath $(BUILDDIR)) -type f|wc -l` -eq 0; then \
|
||||
echo "Removing empty folder $(abspath $(BUILDDIR))..."; \
|
||||
echo "Removing $(abspath $(BUILDDIR))..."; \
|
||||
rm -r $(abspath $(BUILDDIR)); \
|
||||
fi; \
|
||||
fi
|
||||
@if test x$(SO) != x; then \
|
||||
if test -f $(SO); then \
|
||||
|
|
|
@ -73,6 +73,6 @@ if __name__ == "__main__":
|
|||
],
|
||||
keywords='spectroscopy atom electron photon multiple scattering',
|
||||
license='GPL',
|
||||
entry_points={
|
||||
'console_scripts': ['msspec=msspec.cli:main']}
|
||||
#entry_points={
|
||||
# 'console_scripts': ['msspec=msspec.cli:main']}
|
||||
)
|
||||
|
|
Loading…
Reference in New Issue