Skip to content

Commit ce040e5

Browse files
committed
use python2 binary in build process
1 parent 3ec9cf9 commit ce040e5

File tree

5 files changed

+18
-8
lines changed

5 files changed

+18
-8
lines changed

CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ endif()
8282
if(ENABLE_SELF_HOST)
8383
set(PYTHON_EXE "pyston")
8484
else()
85-
find_program(PYTHON_EXE python)
85+
set(PYTHON_EXE "python2")
8686
endif()
8787

8888
# initial clang flags (set here so they're used when building llvm)

from_cpython/setup.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,16 @@ def ctypes_ext():
6464
if platform.linux_distribution()[0] == "Fedora":
6565
ffi_lib = "ffi"
6666

67+
# Hack: platform.linux_distribution()[0] is '' on python2 on arch
68+
# this change only works with libffi-3.2.1
69+
try:
70+
with open('/etc/issue') as f:
71+
if f.read().startswith('Arch Linux'):
72+
ffi_lib = "ffi"
73+
ffi_inc = ["/usr/lib/libffi-3.2.1/include"]
74+
except Exception:
75+
pass
76+
6777
ext.include_dirs.extend(ffi_inc)
6878
ext.libraries.append(ffi_lib)
6979

src/runtime/long.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -361,7 +361,7 @@ extern "C" double PyLong_AsDouble(PyObject* vv) noexcept {
361361
mpfr_init_set_z(result, l->n, MPFR_RNDN);
362362

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

417417
extern "C" PyObject* PyLong_FromDouble(double v) noexcept {
418-
if (isnan(v)) {
418+
if (std::isnan(v)) {
419419
PyErr_SetString(PyExc_ValueError, "cannot convert float NaN to integer");
420420
return NULL;
421421
}
422-
if (isinf(v)) {
422+
if (std::isinf(v)) {
423423
PyErr_SetString(PyExc_OverflowError, "cannot convert float infinity to integer");
424424
return NULL;
425425
}
@@ -1403,7 +1403,7 @@ Box* longTrueDiv(BoxedLong* v1, Box* _v2) {
14031403

14041404
double result_f = mpfr_get_d(result, MPFR_RNDN);
14051405

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

14331433
double result_f = mpfr_get_d(result, MPFR_RNDZ);
1434-
if (isinf(result_f)) {
1434+
if (std::isinf(result_f)) {
14351435
raiseExcHelper(OverflowError, "integer division result too large for a float");
14361436
}
14371437
return boxFloat(result_f);

test/test_extension/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/build/lib.linux-x86_64-2.7/basic_test.so
2-
COMMAND python setup.py build --build-lib ${CMAKE_CURRENT_BINARY_DIR}/build/lib.linux-x86_64-2.7
2+
COMMAND python2 setup.py build --build-lib ${CMAKE_CURRENT_BINARY_DIR}/build/lib.linux-x86_64-2.7
33
DEPENDS basic_test.c descr_test.c slots_test.c
44
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR})
55

tools/tester.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ def get_expected_output(fn):
100100
env = dict(os.environ)
101101
env["PYTHONPATH"] = EXTMODULE_DIR
102102
env["PYTHONIOENCODING"] = PYTHONIOENCODING
103-
p = subprocess.Popen(["python", "-Wignore", fn], stdout=subprocess.PIPE, stderr=subprocess.PIPE, stdin=open("/dev/null"), preexec_fn=set_ulimits, env=env)
103+
p = subprocess.Popen(["python2", "-Wignore", fn], stdout=subprocess.PIPE, stderr=subprocess.PIPE, stdin=open("/dev/null"), preexec_fn=set_ulimits, env=env)
104104
out, err = p.communicate()
105105
code = p.wait()
106106

0 commit comments

Comments
 (0)