Skip to content

Commit

Permalink
Pip fixes (#211)
Browse files Browse the repository at this point in the history
* Fixed the tput warning

* Create a separate variable to track CI testing

* Removed the dependency on python(3)-config

* Formatting fixes

* Added to Changelog [ci skip]

* Travis shows that the env variable is set correctly. No need to print any more

* Automatically update to current running version of python

* Added to changelog

* Fixed issue identified by codacy

* Update change log formatting to appease astropybot

* Fix setup.py error

* Moved the replacement to after the validation

Co-authored-by: Lehman Garrison <[email protected]>
  • Loading branch information
manodeep and lgarrison authored Jan 31, 2020
1 parent 94e046f commit 23d1cc4
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 38 deletions.
2 changes: 1 addition & 1 deletion CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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 [#209, #211]
- Better handling of terminal colours for unknown terminals [#209]


Expand Down
50 changes: 13 additions & 37 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,7 @@ def requirements_check():
common_mk_file = pjoin(dirname(abspath(__file__)),
"common.mk")
common = read_text_file(common_mk_file)

common_dict = get_dict_from_buffer(common)
name = common_dict['DISTNAME'][0]
major = common_dict['MAJOR'][0]
Expand Down Expand Up @@ -206,43 +207,9 @@ 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])

Expand All @@ -256,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):
Expand Down

0 comments on commit 23d1cc4

Please sign in to comment.