Skip to content

Commit

Permalink
use python2 binary in build process
Browse files Browse the repository at this point in the history
  • Loading branch information
aisk committed Apr 23, 2016
1 parent 3ec9cf9 commit ce040e5
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 8 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ endif()
if(ENABLE_SELF_HOST)
set(PYTHON_EXE "pyston")
else()
find_program(PYTHON_EXE python)
set(PYTHON_EXE "python2")
endif()

# initial clang flags (set here so they're used when building llvm)
Expand Down
10 changes: 10 additions & 0 deletions from_cpython/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,16 @@ def ctypes_ext():
if platform.linux_distribution()[0] == "Fedora":
ffi_lib = "ffi"

# Hack: platform.linux_distribution()[0] is '' on python2 on arch
# this change only works with libffi-3.2.1
try:
with open('/etc/issue') as f:
if f.read().startswith('Arch Linux'):
ffi_lib = "ffi"
ffi_inc = ["/usr/lib/libffi-3.2.1/include"]
except Exception:
pass

ext.include_dirs.extend(ffi_inc)
ext.libraries.append(ffi_lib)

Expand Down
10 changes: 5 additions & 5 deletions src/runtime/long.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -361,7 +361,7 @@ extern "C" double PyLong_AsDouble(PyObject* vv) noexcept {
mpfr_init_set_z(result, l->n, MPFR_RNDN);

double result_f = mpfr_get_d(result, MPFR_RNDN);
if (isinf(result_f)) {
if (std::isinf(result_f)) {
PyErr_SetString(PyExc_OverflowError, "long int too large to convert to float");
return -1;
}
Expand Down Expand Up @@ -415,11 +415,11 @@ extern "C" PyAPI_FUNC(PyObject*) _PyLong_Format(PyObject* aa, int base, int addL
}

extern "C" PyObject* PyLong_FromDouble(double v) noexcept {
if (isnan(v)) {
if (std::isnan(v)) {
PyErr_SetString(PyExc_ValueError, "cannot convert float NaN to integer");
return NULL;
}
if (isinf(v)) {
if (std::isinf(v)) {
PyErr_SetString(PyExc_OverflowError, "cannot convert float infinity to integer");
return NULL;
}
Expand Down Expand Up @@ -1403,7 +1403,7 @@ Box* longTrueDiv(BoxedLong* v1, Box* _v2) {

double result_f = mpfr_get_d(result, MPFR_RNDN);

if (isinf(result_f)) {
if (std::isinf(result_f)) {
raiseExcHelper(OverflowError, "integer division result too large for a float");
}
return boxFloat(result_f);
Expand Down Expand Up @@ -1431,7 +1431,7 @@ Box* longRTrueDiv(BoxedLong* v1, Box* _v2) {
mpfr_div(result, lhs_f, rhs_f, MPFR_RNDN);

double result_f = mpfr_get_d(result, MPFR_RNDZ);
if (isinf(result_f)) {
if (std::isinf(result_f)) {
raiseExcHelper(OverflowError, "integer division result too large for a float");
}
return boxFloat(result_f);
Expand Down
2 changes: 1 addition & 1 deletion test/test_extension/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/build/lib.linux-x86_64-2.7/basic_test.so
COMMAND python setup.py build --build-lib ${CMAKE_CURRENT_BINARY_DIR}/build/lib.linux-x86_64-2.7
COMMAND python2 setup.py build --build-lib ${CMAKE_CURRENT_BINARY_DIR}/build/lib.linux-x86_64-2.7
DEPENDS basic_test.c descr_test.c slots_test.c
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR})

Expand Down
2 changes: 1 addition & 1 deletion tools/tester.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ def get_expected_output(fn):
env = dict(os.environ)
env["PYTHONPATH"] = EXTMODULE_DIR
env["PYTHONIOENCODING"] = PYTHONIOENCODING
p = subprocess.Popen(["python", "-Wignore", fn], stdout=subprocess.PIPE, stderr=subprocess.PIPE, stdin=open("/dev/null"), preexec_fn=set_ulimits, env=env)
p = subprocess.Popen(["python2", "-Wignore", fn], stdout=subprocess.PIPE, stderr=subprocess.PIPE, stdin=open("/dev/null"), preexec_fn=set_ulimits, env=env)
out, err = p.communicate()
code = p.wait()

Expand Down

0 comments on commit ce040e5

Please sign in to comment.