From ed9d032cc08f95eece8050565849dc6e95657743 Mon Sep 17 00:00:00 2001 From: Manodeep Sinha Date: Tue, 21 Jan 2020 09:54:44 +1100 Subject: [PATCH 01/12] Fixed the tput warning --- common.mk | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/common.mk b/common.mk index 3ccbf7fe..fe1f3bc5 100644 --- a/common.mk +++ b/common.mk @@ -79,12 +79,23 @@ ifeq ($(DO_CHECKS), 1) ## magenta - general highlight ## blue - related to code/compile option ## bold - only used with printing out compilation options - ccred:=$(shell tput setaf 1) - ccmagenta:=$(shell tput setaf 5) - ccgreen:=$(shell tput setaf 2) - ccblue:=$(shell tput setaf 4) - ccreset:=$(shell tput sgr0) - boldfont:=$(shell tput bold) + HAVE_TPUT_COLORS := $(shell tput colors &>/dev/null && echo TRUE) + ifeq ($(HAVE_TPUT_COLORS), TRUE) + ccred:=$(shell tput setaf 1) + ccmagenta:=$(shell tput setaf 5) + ccgreen:=$(shell tput setaf 2) + ccblue:=$(shell tput setaf 4) + ccreset:=$(shell tput sgr0) + boldfont:=$(shell tput bold) + else + # No color support; make all color commands no-ops + ccred:= + ccmagenta:= + ccgreen:= + ccblue:= + ccreset:= + boldfont:= + endif ## end of colored text output ## First check make version. Versions of make older than 3.80 will crash From 9436fc4175cf77534855fd6795f08943f3facf68 Mon Sep 17 00:00:00 2001 From: Manodeep Sinha Date: Tue, 21 Jan 2020 09:55:42 +1100 Subject: [PATCH 02/12] Create a separate variable to track CI testing --- .travis.yml | 1 + common.mk | 19 ++++++------------- 2 files changed, 7 insertions(+), 13 deletions(-) diff --git a/.travis.yml b/.travis.yml index dfe89256..97eb49e0 100644 --- a/.travis.yml +++ b/.travis.yml @@ -13,6 +13,7 @@ env: - NUMPY_VERSION=1.12 - DOCTEST=TRUE - INSTALL_LIBGFORTRAN=FALSE + - CORRFUNC_CI=TRUE addons: apt: diff --git a/common.mk b/common.mk index fe1f3bc5..d5921a0b 100644 --- a/common.mk +++ b/common.mk @@ -63,6 +63,10 @@ ifeq ($(RUNNING_TESTS), 0) endif +# Is this running on TRAVIS or some other CI provider? +CORRFUNC_CI ?= FALSE +$(info Whether Corrfunc is being tested on a continuous integration service: [${CORRFUNC_CI}]) + ## Only set everything if the command is not "make clean" (or related to "make clean") ifeq ($(DO_CHECKS), 1) UNAME := $(shell uname) @@ -207,19 +211,8 @@ ifeq ($(DO_CHECKS), 1) CFLAGS += -DVERSION=\"${VERSION}\" -DUSE_UNICODE CFLAGS += -std=c99 -m64 -g -Wsign-compare -Wall -Wextra -Wshadow -Wunused -fPIC -D_POSIX_SOURCE=200809L -D_GNU_SOURCE -D_DARWIN_C_SOURCE -O3 #-Ofast - # Is this running on TRAVIS or some other CI provider? - # TRAVIS sets both the CI and TRAVIS variables - ON_CI := false - ifeq ($(CI), true) - ON_CI := true - endif - - ifeq ($(TRAVIS), true) - ON_CI := true - endif - # Add the -Werror flag if running on some continuous integration provider - ifeq ($(ON_CI), true) + ifeq ($(CORRFUNC_CI), TRUE) CFLAGS += -Werror -Wno-unknown-warning-option endif @@ -384,7 +377,7 @@ ifeq ($(DO_CHECKS), 1) # Commented out for now -> need to overhaul testing infrastructure and # toolchain. Otherwise, travis has compile failure due to unknown compiler options # ifeq ($(RUNNING_TESTS), 1) - # ifeq ($(ON_CI), true) + # ifeq ($(CORRFUNC_CI), TRUE) # CFLAGS +=-fsanitize=leak -fsanitize=undefined -fsanitize=bounds -fsanitize=address -fsanitize-address-use-after-scope -fsanitize-undefined-trap-on-error -fstack-protector-all # CLINK +=-fsanitize=leak -fsanitize=undefined -fsanitize=bounds -fsanitize=address -fsanitize-address-use-after-scope -fsanitize-undefined-trap-on-error -fstack-protector-all # endif From a3282c03493f30df1c5baf1b781cb369b7c52ebb Mon Sep 17 00:00:00 2001 From: Manodeep Sinha Date: Tue, 21 Jan 2020 09:56:27 +1100 Subject: [PATCH 03/12] Removed the dependency on python(3)-config --- common.mk | 47 +++++++++++------------------------------------ 1 file changed, 11 insertions(+), 36 deletions(-) diff --git a/common.mk b/common.mk index d5921a0b..12e98549 100644 --- a/common.mk +++ b/common.mk @@ -21,12 +21,6 @@ CLINK ?= ## as can be the case if python is set via an alias) PYTHON:=python -## If you leave this empty, it will be filled out -## as /path/to/PYTHON/python-config -## or /path/to/PYTHON/python3-config (python3, if python-config isn't found) -## where PYTHON is defined in the previous line. -PYTHON_CONFIG_EXE:= - ## Important note -> if you directly call /some/path/to/python ## then the previous two variables will be updated to point ## to the sys.executable as defined within the python session @@ -449,47 +443,28 @@ ifeq ($(DO_CHECKS), 1) MIN_NUMPY_MAJOR := 1 MIN_NUMPY_MINOR := 7 - PYTHON_AVAIL := $(shell [ $(PYTHON_VERSION_MAJOR) -gt $(MIN_PYTHON_MAJOR) -o \( $(PYTHON_VERSION_MAJOR) -eq $(MIN_PYTHON_MAJOR) -a $(PYTHON_VERSION_MINOR) -ge $(MIN_PYTHON_MINOR) \) ] && echo true) - NUMPY_AVAIL := $(shell [ $(NUMPY_VERSION_MAJOR) -gt $(MIN_NUMPY_MAJOR) -o \( $(NUMPY_VERSION_MAJOR) -eq $(MIN_NUMPY_MAJOR) -a $(NUMPY_VERSION_MINOR) -ge $(MIN_NUMPY_MINOR) \) ] && echo true) + PYTHON_AVAIL := $(shell [ $(PYTHON_VERSION_MAJOR) -gt $(MIN_PYTHON_MAJOR) -o \( $(PYTHON_VERSION_MAJOR) -eq $(MIN_PYTHON_MAJOR) -a $(PYTHON_VERSION_MINOR) -ge $(MIN_PYTHON_MINOR) \) ] && echo TRUE) + NUMPY_AVAIL := $(shell [ $(NUMPY_VERSION_MAJOR) -gt $(MIN_NUMPY_MAJOR) -o \( $(NUMPY_VERSION_MAJOR) -eq $(MIN_NUMPY_MAJOR) -a $(NUMPY_VERSION_MINOR) -ge $(MIN_NUMPY_MINOR) \) ] && echo TRUE) - ifeq ($(PYTHON_AVAIL),true) - ifeq ($(NUMPY_AVAIL),true) + ifeq ($(PYTHON_AVAIL),TRUE) + ifeq ($(NUMPY_AVAIL),TRUE) export COMPILE_PYTHON_EXT := 1 endif endif - ifneq ($(PYTHON_AVAIL),true) + ifneq ($(PYTHON_AVAIL),TRUE) $(warning $(ccmagenta) Found python version $(PYTHON_VERSION_MAJOR).$(PYTHON_VERSION_MINOR).$(PYTHON_VERSION_PATCH) but minimum required python is $(MIN_PYTHON_MAJOR).$(MIN_PYTHON_MINOR) $(ccreset)) export COMPILE_PYTHON_EXT := 0 endif - ifneq ($(NUMPY_AVAIL),true) + ifneq ($(NUMPY_AVAIL),TRUE) $(warning $(ccmagenta) Found NUMPY version $(NUMPY_VERSION_MAJOR).$(NUMPY_VERSION_MINOR).$(NUMPY_VERSION_PATCH) but minimum required numpy is $(MIN_NUMPY_MAJOR).$(MIN_NUMPY_MINOR) $(ccreset)) export COMPILE_PYTHON_EXT := 0 endif ifneq ($(COMPILE_PYTHON_EXT), 0) - ifndef PYTHON_CONFIG_EXE - PYTHON_SCRIPTS:=$(shell $(PYTHON) -c "import sysconfig;print(sysconfig.get_path('scripts'));") - # try python3-config first for Python 3 - ifeq ($(PYTHON_VERSION_MAJOR), 3) - PYTHON_CONFIG_EXE:="$(PYTHON_SCRIPTS)/python3-config" - PYTHON_CONFIG_INCL := $(shell $(PYTHON_CONFIG_EXE) --includes 2>/dev/null) - endif - - ifndef PYTHON_CONFIG_INCL - # python3-config failed; let's try python-config (for Python 2 or 3) - PYTHON_CONFIG_EXE:="$(PYTHON_SCRIPTS)/python-config" - endif - $(warning $(ccblue)"PYTHON"$(ccreset) is set to $(ccblue)$(PYTHON)$(ccreset); using $(ccblue)$(PYTHON_CONFIG_EXE)$(ccreset) as $(ccblue)python-config$(ccreset). If this is not correct, please also set $(ccblue)"PYTHON_CONFIG_EXE"$(ccreset) in $(ccgreen)"common.mk"$(ccreset) to appropriate $(ccblue)python-config$(ccreset)) - endif - - PYTHON_CONFIG_INCL := $(shell $(PYTHON_CONFIG_EXE) --includes 2>/dev/null) - # if PYTHON_CONFIG_INCL is still undef, then we failed to find any python-config - ifndef PYTHON_CONFIG_INCL - $(error $(ccred)python-config$(ccreset) ($(ccblue)$(PYTHON_CONFIG_EXE)$(ccreset)) not found. Please set $(ccgreen)PYTHON_CONFIG_EXE$(ccreset) in $(ccgreen)"common.mk"$(ccreset) to appropriate $(ccblue)python-config$(ccreset) before installing $(DISTNAME).$(VERSION). Installing $(ccblue)python-devel$(ccreset) might fix this issue $(ccreset)) - endif - PYTHON_CONFIG_INCL:=$(patsubst -I%,-isystem%, $(PYTHON_CONFIG_INCL)) + PYTHON_INCL := $(shell $(PYTHON) -c "from __future__ import print_function; import sysconfig; flags = set(['-I' + sysconfig.get_path('include'),'-I' + sysconfig.get_path('platinclude')]); print(' '.join(flags));") + PYTHON_INCL:=$(patsubst -I%,-isystem%, $(PYTHON_INCL)) # NUMPY is available -> next step should not fail # That's why we are not checking if the NUMPY_INCL_FLAG is defined. @@ -508,9 +483,9 @@ ifeq ($(DO_CHECKS), 1) export NUMPY_CHECKED:=1 endif - export PYTHON_CFLAGS := $(PYTHON_CONFIG_INCL) $(NUMPY_INCL_FLAG) - export PYTHON_LIBDIR := $(shell $(PYTHON_CONFIG_EXE) --prefix)/lib - export PYTHON_LIBS := $(shell $(PYTHON_CONFIG_EXE) --libs) + export PYTHON_CFLAGS := $(PYTHON_INCL) $(NUMPY_INCL_FLAG) + export PYTHON_LIBDIR := $(shell $(PYTHON) -c "from __future__ import print_function; import sysconfig;print(sysconfig.get_config_var('prefix'));")/lib + export PYTHON_LIBS := $(shell $(PYTHON) -c "from __future__ import print_function; import sys; import sysconfig; pyver = sysconfig.get_config_var('VERSION'); getvar = sysconfig.get_config_var;libs = ['-lpython' + pyver + sys.abiflags]; libs += getvar('LIBS').split(); libs += getvar('SYSLIBS').split(); print(' '.join(libs));") export PYTHON_LINK := # export PYTHON_LINK := -L$(PYTHON_LIBDIR) $(PYTHON_LIBS) -Xlinker -rpath -Xlinker $(PYTHON_LIBDIR) # export PYTHON_LINK := -L$(PYTHON_LIBDIR) $(PYTHON_LIBS) -Xlinker -rpath -Xlinker $(PYTHON_LIBDIR) From 1b7cde404ba459b65afe3cfbc252e82dead9015b Mon Sep 17 00:00:00 2001 From: Manodeep Sinha Date: Tue, 21 Jan 2020 09:56:44 +1100 Subject: [PATCH 04/12] Formatting fixes --- common.mk | 57 +++++++++---------------------------------------------- 1 file changed, 9 insertions(+), 48 deletions(-) diff --git a/common.mk b/common.mk index 12e98549..d8ebda4f 100644 --- a/common.mk +++ b/common.mk @@ -140,35 +140,6 @@ ifeq ($(DO_CHECKS), 1) $(error $(ccred)Error:$(ccreset) Could not set compiler. Please either set $(ccblue)"CC"$(ccreset) in $(ccmagenta)"common.mk"$(ccreset) or via the command-line, $(ccgreen)"make CC=yourcompiler"$(ccreset)) endif - - # # Check if CPU supports AVX -> this trumps everything. For instance, compiler might - # # support AVX but the cpu might not. Then compilation will work fine but there will - # # be a runtime crash with "Illegal Instruction" - # ifeq ($(UNAME), Darwin) - # # On a MAC, best to use sysctl - # AVX_AVAIL := $(shell sysctl -n machdep.cpu.features 2>/dev/null | grep -o -i AVX | tr '[:lower:]' '[:upper:]') - # else - # # On Linux/Unix, just grep on /proc/cpuinfo - # # There might be multiple cores, so just take the first line - # # (Is it possible that someone has one core that has AVX and another that doesnt?) - # AVX_AVAIL := $(shell grep -o -i AVX /proc/cpuinfo 2>/dev/null | head -n 1 | tr '[:lower:]' '[:upper:]' ) - # endif - # REMOVE_AVX :=0 - # ifdef AVX_AVAIL - # ifneq ($(AVX_AVAIL) , AVX) - # REMOVE_AVX := 1 - # endif - # else - # REMOVE_AVX :=1 - # endif - - # ifeq ($(REMOVE_AVX), 1) - # $(warning $(ccmagenta) CPU does not seem support AVX instructions. Removing USE_AVX from compile options. $(ccreset)) - # OPT:=$(filter-out -DUSE_AVX,$(OPT)) - # endif - # # end of checking if CPU supports AVX - ## This entire AVX section is now commented out because the code has runtime-dispatch based on the CPU capabilities and picks the latest instruction set by default - # Now check if gcc is set to be the compiler but if clang is really under the hood. export CC_IS_CLANG ?= -1 ifeq ($(CC_IS_CLANG), -1) @@ -185,7 +156,7 @@ ifeq ($(DO_CHECKS), 1) export CC_IS_CLANG := 0 endif export CC_VERSION - endif + endif # Done with checking if clang is underneath gcc # CC is set at this point. In case the compiler on Mac is *not* clang under the hood @@ -258,14 +229,6 @@ ifeq ($(DO_CHECKS), 1) ICC_MAJOR_VER = $(shell icc -V 2>&1 | \grep -oP '(?<=Version )\d+') else ## not icc -> gcc or clang follow - ## Warning that w(theta) with OUTPUT_THETAAVG is very slow without icc - ## Someday I am going to fix that by linking with MKL - # ifeq (USE_AVX,$(findstring USE_AVX,$(OPT))) - # ifeq (OUTPUT_THETAAVG,$(findstring OUTPUT_THETAAVG,$(OPT))) - # $(warning WARNING: $(ccblue)"OUTPUT_THETAAVG"$(ccreset) with AVX capabilties is slow with gcc/clang (disables AVX essentially) with gcc/clang. Try to use $(ccblue)"icc"$(ccreset) if available) - # endif - # endif - ### GCC is slightly more complicated. CC might be called gcc but it might be clang underneath ### compiler specific flags for gcc ifneq ($(CC_IS_CLANG), 1) @@ -291,17 +254,17 @@ ifeq ($(DO_CHECKS), 1) endif #gcc findstring else ##CC is clang ### compiler specific flags for clang - CLANG_OMP_AVAIL := false + CLANG_OMP_AVAIL := FALSE export APPLE_CLANG := 0 ifeq (USE_OMP,$(findstring USE_OMP,$(OPT))) ifeq (clang-omp,$(findstring clang-omp,$(CC))) - CLANG_OMP_AVAIL:=true + CLANG_OMP_AVAIL:=TRUE CFLAGS += -fopenmp CLINK += -liomp5 else # Apple clang/gcc does not support OpenMP ifeq (Apple, $(findstring Apple, $(CC_VERSION))) - CLANG_OMP_AVAIL:= false + CLANG_OMP_AVAIL:= FALSE export CLANG_OMP_WARNING_PRINTED ?= 0 ifeq ($(CLANG_OMP_WARNING_PRINTED), 0) $(warning $(ccmagenta)Compiler is Apple clang and does not support OpenMP$(ccreset)) @@ -320,21 +283,21 @@ ifeq ($(DO_CHECKS), 1) CLANG_VERSION_MINOR := $(word 2,${CLANG_VERSION_FULL}) CLANG_MAJOR_MIN_OPENMP := 3 CLANG_MINOR_MIN_OPENMP := 7 - CLANG_OMP_AVAIL := $(shell [ $(CLANG_VERSION_MAJOR) -gt $(CLANG_MAJOR_MIN_OPENMP) -o \( $(CLANG_VERSION_MAJOR) -eq $(CLANG_MAJOR_MIN_OPENMP) -a $(CLANG_VERSION_MINOR) -ge $(CLANG_MINOR_MIN_OPENMP) \) ] && echo true) - CLANG_IS_38 := $(shell [ $(CLANG_VERSION_MAJOR) -eq 3 -a $(CLANG_VERSION_MINOR) -eq 8 ] && echo true) + CLANG_OMP_AVAIL := $(shell [ $(CLANG_VERSION_MAJOR) -gt $(CLANG_MAJOR_MIN_OPENMP) -o \( $(CLANG_VERSION_MAJOR) -eq $(CLANG_MAJOR_MIN_OPENMP) -a $(CLANG_VERSION_MINOR) -ge $(CLANG_MINOR_MIN_OPENMP) \) ] && echo TRUE) + CLANG_IS_38 := $(shell [ $(CLANG_VERSION_MAJOR) -eq 3 -a $(CLANG_VERSION_MINOR) -eq 8 ] && echo TRUE) CFLAGS += -fopenmp=libomp CLINK += -fopenmp=libomp endif #Apple check endif #clang-omp check - ifeq ($(CLANG_OMP_AVAIL),true) + ifeq ($(CLANG_OMP_AVAIL),TRUE) ifeq ($(APPLE_CLANG),0) ifeq ($(UNAME), Darwin) export CLANG_LD_WARNING_PRINTED ?= 0 ifeq ($(CLANG_LD_WARNING_PRINTED), 0) $(info $(ccmagenta)Enabling OpenMP with clang.$(ccreset)) CLANG_LD_ERROR := "dyld: Library not loaded: @rpath/libLLVM.dylib\nReferenced from: /opt/local/libexec/llvm-3.8/lib/libLTO.dylib\nReason: image not found\n" - ifeq ($(CLANG_IS_38), true) + ifeq ($(CLANG_IS_38), TRUE) $(warning With $(ccblue)"clang-3.8"$(ccreset), You might see this $(ccred)$(CLANG_LD_ERROR)$(ccreset) error with the final linking step.) $(info Use this command to fix the issue $(ccmagenta) "sudo install_name_tool -change @executable_path/../lib/libLTO.dylib @rpath/../lib/libLTO.dylib /opt/local/libexec/ld64/ld-latest"$(ccreset)) $(info You can see the bug report here $(ccmagenta)"https://trac.macports.org/ticket/50853"$(ccreset)) @@ -392,7 +355,7 @@ ifeq ($(DO_CHECKS), 1) CC_SUPPORTS_AVX512 := $(shell $(CC) $(CFLAGS) -dM -E - < /dev/null | \grep -Ecm1 __AVX512F__) ifeq ($(CC_SUPPORTS_AVX512),1) ifeq ($(shell test 0$(ICC_MAJOR_VER) -ge 019 -o -z "$(ICC_MAJOR_VER)"; echo $$?),0) - # If gcc, clang, or new icc, we can use this + # If gcc, clang, or new icc, we can use this CFLAGS += -mno-avx512f else CFLAGS += -xCORE-AVX2 @@ -487,8 +450,6 @@ ifeq ($(DO_CHECKS), 1) export PYTHON_LIBDIR := $(shell $(PYTHON) -c "from __future__ import print_function; import sysconfig;print(sysconfig.get_config_var('prefix'));")/lib export PYTHON_LIBS := $(shell $(PYTHON) -c "from __future__ import print_function; import sys; import sysconfig; pyver = sysconfig.get_config_var('VERSION'); getvar = sysconfig.get_config_var;libs = ['-lpython' + pyver + sys.abiflags]; libs += getvar('LIBS').split(); libs += getvar('SYSLIBS').split(); print(' '.join(libs));") export PYTHON_LINK := - # export PYTHON_LINK := -L$(PYTHON_LIBDIR) $(PYTHON_LIBS) -Xlinker -rpath -Xlinker $(PYTHON_LIBDIR) - # export PYTHON_LINK := -L$(PYTHON_LIBDIR) $(PYTHON_LIBS) -Xlinker -rpath -Xlinker $(PYTHON_LIBDIR) SOABI := $(shell $(PYTHON) -c "from __future__ import print_function; import sysconfig; print(sysconfig.get_config_var('SOABI'))" 2>/dev/null) export PYTHON_SOABI := ifdef SOABI From bc927be730d8aefbc0fbaad50d4ae6a291551900 Mon Sep 17 00:00:00 2001 From: Manodeep Sinha Date: Tue, 21 Jan 2020 10:06:32 +1100 Subject: [PATCH 05/12] Added to Changelog [ci skip] --- CHANGES.rst | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/CHANGES.rst b/CHANGES.rst index 935f9efe..ae1ee0d4 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -11,8 +11,25 @@ New features - GPU version -2.3.2 (Upcoming) -================ +2.3.3 (Upcoming) +================= +This is a bug-fix release and contains general code quality improvements. + + +Enhancements +------------ + + + +Bug fixes +---------- +- Installation does not require python(3)-config anymore [fixed in #209] +- Better handling of terminal colours for unknown terminals [#209] + + + +2.3.2 (2019-12-24) +=================== This is a release for bug-fixes and general code quality improvements. Travis now also tests for ``python3.7``. From 5e64f0dd1f497acce05849189268a789b7ce8d7e Mon Sep 17 00:00:00 2001 From: Manodeep Sinha Date: Tue, 21 Jan 2020 10:11:27 +1100 Subject: [PATCH 06/12] Travis shows that the env variable is set correctly. No need to print any more --- common.mk | 1 - 1 file changed, 1 deletion(-) diff --git a/common.mk b/common.mk index d8ebda4f..992fbfa2 100644 --- a/common.mk +++ b/common.mk @@ -59,7 +59,6 @@ endif # Is this running on TRAVIS or some other CI provider? CORRFUNC_CI ?= FALSE -$(info Whether Corrfunc is being tested on a continuous integration service: [${CORRFUNC_CI}]) ## Only set everything if the command is not "make clean" (or related to "make clean") ifeq ($(DO_CHECKS), 1) From ec0733acbadbce188e3f0302e76991ce0c005ace Mon Sep 17 00:00:00 2001 From: Manodeep Sinha Date: Thu, 30 Jan 2020 21:42:56 +1100 Subject: [PATCH 07/12] Automatically update to current running version of python --- setup.py | 48 ++++++++++++------------------------------------ 1 file changed, 12 insertions(+), 36 deletions(-) diff --git a/setup.py b/setup.py index 0f5ef80c..38ed54d5 100644 --- a/setup.py +++ b/setup.py @@ -177,6 +177,15 @@ def replace_first_key_in_makefile(buf, key, replacement, outfile=None): def requirements_check(): common_mk_file = pjoin(dirname(abspath(__file__)), "common.mk") + # Since arbitrary python can be used even within the Makefile + # make sure that the current python executable is the same as the + # one specified in common.mk. Easiest way is to replace + this_python = sys.executable + key = "PYTHON" + replacement = '\n{0}:={1}'.format(key, this_python) + common = replace_first_key_in_makefile(common, key, replacement, + common_mk_file) + common = read_text_file(common_mk_file) common_dict = get_dict_from_buffer(common) name = common_dict['DISTNAME'][0] @@ -206,43 +215,10 @@ def requirements_check(): while C version claims {1}".format(Corrfunc.__version__, version) raise AssertionError(msg) - # Since arbitrary python can be used even within the Makefile - # make sure that the current python executable is the same as the - # one specified in common.mk. Easiest way is to replace - make_python = common_dict['PYTHON'][0] - if make_python is None: - msg = "PYTHON is not defined in 'common.mk'. Please "\ - "edit 'common.mk' and define PYTHON (typically "\ - "just python) " - raise AssertionError(msg) - - this_python = sys.executable - python_script = "'from __future__ import print_function; "\ - "import sys; print(sys.executable)'" - get_full_python, full_python_errors = run_command( - make_python + " -c " + python_script, - stdout=subprocess.PIPE, stderr=subprocess.PIPE) - if get_full_python is None: - msg = "Could not determine which python is resolved in the Makefile "\ - "Parsed PYTHON=[${0}] in Makefile which could not be resolved "\ - "through the shell. Please report your python setup and file "\ - "an installation issue at {1}.".format(make_python, base_url) - raise RuntimeError(msg) - get_full_python = strip_line(get_full_python, os.linesep) - if get_full_python != this_python: - msg = "Looks like python specified in Makefile = {0} is different "\ - "from the invoked python instance = {1}.\nReplacing PYTHON "\ - "in 'common.mk' and recompiling *all* files".format( - get_full_python, this_python) - print(msg) - key = "PYTHON" - replacement = '\n{0}:={1}'.format(key, this_python) - common = replace_first_key_in_makefile(common, key, replacement, - common_mk_file) - - # Okay common.mk has now been updated to use current python - # for building the extensions as required + # Okay common.mk has been updated to use current python + # for building the extensions as required. Now check for + # min. python version min_py_major = int(common_dict['MIN_PYTHON_MAJOR'][0]) min_py_minor = int(common_dict['MIN_PYTHON_MINOR'][0]) From 09a25225b74a0a157d524f1b5dc031dac773b45e Mon Sep 17 00:00:00 2001 From: Manodeep Sinha Date: Thu, 30 Jan 2020 21:46:50 +1100 Subject: [PATCH 08/12] Added to changelog --- CHANGES.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGES.rst b/CHANGES.rst index ae1ee0d4..bb37245c 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -23,7 +23,7 @@ Enhancements Bug fixes ---------- -- Installation does not require python(3)-config anymore [fixed in #209] +- Installation does not require python(3)-config anymore [fixed in #209, #211] - Better handling of terminal colours for unknown terminals [#209] From fbaef0f243798938b5960f02ed70b27cd76c3086 Mon Sep 17 00:00:00 2001 From: Manodeep Sinha Date: Thu, 30 Jan 2020 21:50:11 +1100 Subject: [PATCH 09/12] Fixed issue identified by codacy --- setup.py | 1 - 1 file changed, 1 deletion(-) diff --git a/setup.py b/setup.py index 38ed54d5..14545fa6 100644 --- a/setup.py +++ b/setup.py @@ -215,7 +215,6 @@ def requirements_check(): while C version claims {1}".format(Corrfunc.__version__, version) raise AssertionError(msg) - # Okay common.mk has been updated to use current python # for building the extensions as required. Now check for # min. python version From 1bbdae10557e0611f3821e35e072540f80696ca9 Mon Sep 17 00:00:00 2001 From: Lehman Garrison Date: Thu, 30 Jan 2020 10:38:48 -0500 Subject: [PATCH 10/12] Update change log formatting to appease astropybot --- CHANGES.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGES.rst b/CHANGES.rst index bb37245c..291bc70e 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -23,7 +23,7 @@ Enhancements Bug fixes ---------- -- Installation does not require python(3)-config anymore [fixed in #209, #211] +- Installation does not require python(3)-config anymore [#209, #211] - Better handling of terminal colours for unknown terminals [#209] From 9d55fc9e114b12113ea187e9ffcc5e6a8fa5d245 Mon Sep 17 00:00:00 2001 From: Lehman Garrison Date: Thu, 30 Jan 2020 10:43:26 -0500 Subject: [PATCH 11/12] Fix setup.py error --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index 14545fa6..78ba9c57 100644 --- a/setup.py +++ b/setup.py @@ -183,10 +183,10 @@ def requirements_check(): this_python = sys.executable key = "PYTHON" replacement = '\n{0}:={1}'.format(key, this_python) + common = read_text_file(common_mk_file) common = replace_first_key_in_makefile(common, key, replacement, common_mk_file) - common = read_text_file(common_mk_file) common_dict = get_dict_from_buffer(common) name = common_dict['DISTNAME'][0] major = common_dict['MAJOR'][0] From b87495e5d0c7b0297f7824bf2e2339de7349e2aa Mon Sep 17 00:00:00 2001 From: Manodeep Sinha Date: Fri, 31 Jan 2020 07:09:39 +1100 Subject: [PATCH 12/12] Moved the replacement to after the validation --- setup.py | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/setup.py b/setup.py index 78ba9c57..8e2a9377 100644 --- a/setup.py +++ b/setup.py @@ -177,15 +177,7 @@ def replace_first_key_in_makefile(buf, key, replacement, outfile=None): def requirements_check(): common_mk_file = pjoin(dirname(abspath(__file__)), "common.mk") - # Since arbitrary python can be used even within the Makefile - # make sure that the current python executable is the same as the - # one specified in common.mk. Easiest way is to replace - this_python = sys.executable - key = "PYTHON" - replacement = '\n{0}:={1}'.format(key, this_python) common = read_text_file(common_mk_file) - common = replace_first_key_in_makefile(common, key, replacement, - common_mk_file) common_dict = get_dict_from_buffer(common) name = common_dict['DISTNAME'][0] @@ -231,6 +223,15 @@ def requirements_check(): min_py_minor) raise AssertionError(msg) + # Since arbitrary python can be used even within the Makefile + # make sure that the current python executable is the same as the + # one specified in common.mk. Easiest way is to replace + this_python = sys.executable + key = "PYTHON" + replacement = '\n{0}:={1}'.format(key, this_python) + common = replace_first_key_in_makefile(common, key, replacement, + common_mk_file) + # Check if CC is in argv: CC = "CC" for iarg, arg in enumerate(sys.argv):