From 1db975233a0e580bf9fe20a824df0727b93d43de Mon Sep 17 00:00:00 2001 From: sylvain tricot Date: Wed, 13 Jan 2021 18:26:08 +0100 Subject: [PATCH 1/6] Small changes to Makefiles. --- Makefile | 4 ++++ src/Makefile | 2 +- src/options.mk | 3 +++ 3 files changed, 8 insertions(+), 1 deletion(-) diff --git a/Makefile b/Makefile index aabbbd9..0440e6b 100644 --- a/Makefile +++ b/Makefile @@ -52,3 +52,7 @@ doc: clean:: @+$(MAKE) -C src/ clean + +help: + @echo "Top Makefile help message" + diff --git a/src/Makefile b/src/Makefile index d2dda44..3b2f40b 100644 --- a/src/Makefile +++ b/src/Makefile @@ -56,5 +56,5 @@ clean:: help: - @echo "help message" + @echo "SRC Makefile help message" diff --git a/src/options.mk b/src/options.mk index 6e432dd..bec887b 100644 --- a/src/options.mk +++ b/src/options.mk @@ -69,6 +69,9 @@ OBJS = $(addprefix $(BUILDDIR)/, $(patsubst %.f,%.o, $(filter-out $(MAIN_F), $(S .PHONY: clean obj all info +help: + + info: @echo "Compilation information for msspec $(VERSION)" @echo "FC : $(FC)" From 72ba908be1eb9e2158611d7600b19dde9ec7f75f Mon Sep 17 00:00:00 2001 From: sylvain tricot Date: Thu, 21 Jan 2021 11:12:24 +0100 Subject: [PATCH 2/6] Improve python path and version checking. In the top Makefile, the Python path and version are first checked before going any further. This is now done in a more cleaner way by looking at the "sys.version_info variable" --- Makefile | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/Makefile b/Makefile index 0440e6b..7767837 100644 --- a/Makefile +++ b/Makefile @@ -1,19 +1,18 @@ include src/options.mk PYTHON = python +PYMAJ = 3 +PYMIN = 6 -# Checking Python version +# Checking Python path and version PYTHON_EXE := $(shell command -v $(PYTHON) 2> /dev/null) ifndef PYTHON_EXE $(error Unable to find the $(PYTHON) executable!) endif -PYTHON_VERSION_MAJOR := $(shell $(PYTHON_EXE) --version 2>&1 | cut -d" " -f2 | cut -d. -f1) -PYTHON_VERSION_MINOR := $(shell $(PYTHON_EXE) --version 2>&1 | cut -d" " -f2 | cut -d. -f2) - -ifneq ($(shell test $(PYTHON_VERSION_MAJOR) -ge 3 -a $(PYTHON_VERSION_MINOR) -ge 6; echo $$?),0) - $(error Python version >= 3.6 is needed!) +ifeq ($(shell python -c "import sys; exit(sys.version_info >= ($(PYMAJ),$(PYMIN)))"; echo $$?),0) + $(error Python version >= $(PYMAJ).$(PYMIN) is needed!) endif From 527ad80b036ffa78c9ff770503b57111bd22e51e Mon Sep 17 00:00:00 2001 From: sylvain tricot Date: Thu, 21 Jan 2021 13:51:39 +0100 Subject: [PATCH 3/6] Simplify pip.freeze requirements file. --- src/pip.freeze | 49 +++---------------------------------------------- 1 file changed, 3 insertions(+), 46 deletions(-) diff --git a/src/pip.freeze b/src/pip.freeze index 49e5fc2..0a7d654 100644 --- a/src/pip.freeze +++ b/src/pip.freeze @@ -1,57 +1,14 @@ -alabaster==0.7.12 ase==3.19.1 -Babel==2.8.0 -backcall==0.1.0 -certifi==2020.4.5.1 -chardet==3.0.4 -coverage==5.1 -cycler==0.10.0 -decorator==4.4.2 -docutils==0.16 h5py==2.10.0 -idna==2.9 -imagesize==1.2.0 ipython==7.13.0 -ipython-genutils==0.2.0 -jedi==0.17.0 -Jinja2==2.11.2 lxml==4.5.0 -MarkupSafe==1.1.1 matplotlib==2.1.1 numpy==1.18.2 -packaging==20.3 -parso==0.7.0 -pex==2.1.11 -pexpect==4.8.0 -pickleshare==0.7.5 -Pillow==7.1.1 Pint==0.11 -pip==20.0.2 -prompt-toolkit==3.0.5 -ptyprocess==0.6.0 +#pip==20.0.2 pycairo==1.19.1 -Pygments==2.6.1 -pyparsing==2.4.7 -python-dateutil==2.8.1 -pytz==2019.3 -requests==2.23.0 scipy==1.4.1 -scons==3.1.2 -setuptools==46.1.3 setuptools-scm==3.5.0 -six==1.14.0 -snowballstemmer==2.0.0 -spglib==1.14.1.post0 -Sphinx==3.0.1 -sphinxcontrib-applehelp==1.0.2 -sphinxcontrib-devhelp==1.0.2 -sphinxcontrib-htmlhelp==1.0.3 -sphinxcontrib-jsmath==1.0.1 -sphinxcontrib-qthelp==1.0.3 -sphinxcontrib-serializinghtml==1.1.4 terminaltables==3.1.0 -traitlets==4.3.3 -urllib3==1.25.8 -wcwidth==0.1.9 -wheel==0.34.2 -#wxPython@https://extras.wxpython.org/wxPython4/extras/linux/gtk3/ubuntu-18.04/wxPython-4.0.7.post2-cp36-cp36m-linux_x86_64.whl +#wxPython@https://extras.wxpython.org/wxPython4/extras/linux/gtk3/debian-10/wxPython-4.1.0-cp37-cp37m-linux_x86_64.whl +#wxPython@https://extras.wxpython.org/wxPython4/extras/linux/gtk3/debian-9/wxPython-4.0.7.post2-cp35-cp35m-linux_x86_64.whl From d7f004ebec76c52ff501c315d2dba8d819e24e05 Mon Sep 17 00:00:00 2001 From: sylvain tricot Date: Fri, 22 Jan 2021 17:03:53 +0100 Subject: [PATCH 4/6] Changes on Makefile to be compatible with Docker. --- Makefile | 19 ++++++++++--------- src/Makefile | 4 +++- src/msspec.sh.template | 2 +- 3 files changed, 14 insertions(+), 11 deletions(-) diff --git a/Makefile b/Makefile index 7767837..b96333b 100644 --- a/Makefile +++ b/Makefile @@ -11,7 +11,7 @@ ifndef PYTHON_EXE $(error Unable to find the $(PYTHON) executable!) endif -ifeq ($(shell python -c "import sys; exit(sys.version_info >= ($(PYMAJ),$(PYMIN)))"; echo $$?),0) +ifeq ($(shell $(PYTHON_EXE) -c "import sys; exit(sys.version_info >= ($(PYMAJ),$(PYMIN)))"; echo $$?),0) $(error Python version >= $(PYMAJ).$(PYMIN) is needed!) endif @@ -19,19 +19,20 @@ endif .PHONY: pybinding install devel venv doc clean -pybinding: - @+$(MAKE) -C src pybinding +pybinding: venv + @+. $(VENV_PATH)/bin/activate && $(MAKE) -C src pybinding venv: - virtualenv --python=$(PYTHON_EXE) --prompt="(msspec-$(VERSION)) " $(VENV_PATH) - . $(VENV_PATH)/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 -install: pybinding venv - @+$(MAKE) -C src sdist - @+$(MAKE) -C src frontend - @. $(VENV_PATH)/bin/activate && pip install src/dist/msspec-$(VERSION).tar.gz +install: pybinding + @+. $(VENV_PATH)/bin/activate && $(MAKE) -C src sdist + @+. $(VENV_PATH)/bin/activate && $(MAKE) -C src frontend + @+. $(VENV_PATH)/bin/activate && pip install src/dist/msspec-$(VERSION).tar.gz + @echo "Do not forget to check that $(INSTALL_PREFIX)/bin is set in your \$$PATH" devel: VENV_PATH = ./_venv diff --git a/src/Makefile b/src/Makefile index 3b2f40b..1e727c8 100644 --- a/src/Makefile +++ b/src/Makefile @@ -16,7 +16,9 @@ dist/msspec-$(VERSION).tar.gz: VERSION $(INSTALL_PREFIX)/bin/msspec: msspec.sh.template VERSION @echo "Installing frontend command..." - @cat $< | sed 's/__VERSION__/$(VERSION)/' > $@ + @mkdir -p $(dir $@) + @cat $< | sed -e 's/__VERSION__/$(VERSION)/' -e 's#__VENV_PATH__#$(VENV_PATH)#' > $@ + #@cat $< | sed 's/__VERSION__/$(VERSION)/' > $@ @chmod u+x $@ diff --git a/src/msspec.sh.template b/src/msspec.sh.template index b6cc2ea..22ef574 100644 --- a/src/msspec.sh.template +++ b/src/msspec.sh.template @@ -3,7 +3,7 @@ SCRIPT_PATH="$0" SCRIPT_NAME=$(basename "$SCRIPT_PATH") VERSION="__VERSION__" -VENV_PATH="$HOME/.local/src/msspec_venv_$VERSION" +VENV_PATH="__VENV_PATH__" # Check venv path if ! [ -d "$VENV_PATH" ]; then From da92ce048f43eb42bab0c2120f7dcffb53a894bd Mon Sep 17 00:00:00 2001 From: sylvain tricot Date: Fri, 22 Jan 2021 17:31:46 +0100 Subject: [PATCH 5/6] Fix file permissions in frontend install target. --- src/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Makefile b/src/Makefile index 1e727c8..189f6c6 100644 --- a/src/Makefile +++ b/src/Makefile @@ -19,7 +19,7 @@ $(INSTALL_PREFIX)/bin/msspec: msspec.sh.template VERSION @mkdir -p $(dir $@) @cat $< | sed -e 's/__VERSION__/$(VERSION)/' -e 's#__VENV_PATH__#$(VENV_PATH)#' > $@ #@cat $< | sed 's/__VERSION__/$(VERSION)/' > $@ - @chmod u+x $@ + @chmod 755 $@ pybinding: From 7921f813c42eb819f1acaabbf155feb4f7a9e12e Mon Sep 17 00:00:00 2001 From: sylvain tricot Date: Fri, 22 Jan 2021 17:32:12 +0100 Subject: [PATCH 6/6] Add a Dockerfile. --- Dockerfile | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 Dockerfile diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..4b8b8f2 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,30 @@ +# Get the base Python image +FROM python:3.7 + +# Set the working directory in the container +RUN useradd -ms /bin/bash msspec +WORKDIR /code + +# Fetch the code +COPY fresh . + +ENV LANG=en_US.UTF-8 +ENV PATH=/opt/bin:$PATH + +# Install system dependencies +RUN apt-get update && \ + apt-get install -y virtualenv gfortran locales python3-wxgtk4.0 + +# Reconfigure the locales +RUN sed -i -e "s/# $LANG.*/$LANG UTF-8/" /etc/locale.gen && \ + dpkg-reconfigure --frontend=noninteractive locales && \ + update-locale LANG=$LANG + +# Install msspec +RUN make install VERBOSE=1 INSTALL_PREFIX=/opt + +#RUN echo "/usr/lib/python3/dist-packages" > /opt/src/msspec_venv_*/lib/python3.7/site-packages/system_packages.pth + +USER msspec + +ENTRYPOINT ["msspec"]