Skip to content

Commit 5531a3d

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

File tree

7 files changed

+27
-13
lines changed

7 files changed

+27
-13
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/Include/pymath.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,11 @@ PyAPI_FUNC(void) _Py_set_387controlword(unsigned short) PYSTON_NOEXCEPT;
118118
*/
119119
#ifndef Py_IS_INFINITY
120120
# if defined HAVE_DECL_ISINF && HAVE_DECL_ISINF == 1
121-
# define Py_IS_INFINITY(X) isinf(X)
121+
# ifdef __cplusplus
122+
# define Py_IS_INFINITY(X) std::isinf(X)
123+
# else
124+
# define Py_IS_INFINITY(X) isinf(X)
125+
# endif
122126
# else
123127
# define Py_IS_INFINITY(X) ((X) && \
124128
(Py_FORCE_DOUBLE(X)*0.5 == Py_FORCE_DOUBLE(X)))

from_cpython/Modules/_ssl.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -314,8 +314,8 @@ newPySSLObject(PySocketSockObject *Sock, char *key_file, char *cert_file,
314314
PySSL_BEGIN_ALLOW_THREADS
315315
if (proto_version == PY_SSL_VERSION_TLS1)
316316
self->ctx = SSL_CTX_new(TLSv1_method()); /* Set up context */
317-
else if (proto_version == PY_SSL_VERSION_SSL3)
318-
self->ctx = SSL_CTX_new(SSLv3_method()); /* Set up context */
317+
// else if (proto_version == PY_SSL_VERSION_SSL3)
318+
// self->ctx = SSL_CTX_new(SSLv3_method()); /* Set up context */
319319
#ifndef OPENSSL_NO_SSL2
320320
else if (proto_version == PY_SSL_VERSION_SSL2)
321321
self->ctx = SSL_CTX_new(SSLv2_method()); /* Set up context */
@@ -1819,8 +1819,8 @@ init_ssl(void)
18191819
PyModule_AddIntConstant(m, "PROTOCOL_SSLv2",
18201820
PY_SSL_VERSION_SSL2);
18211821
#endif
1822-
PyModule_AddIntConstant(m, "PROTOCOL_SSLv3",
1823-
PY_SSL_VERSION_SSL3);
1822+
// PyModule_AddIntConstant(m, "PROTOCOL_SSLv3",
1823+
// PY_SSL_VERSION_SSL3);
18241824
PyModule_AddIntConstant(m, "PROTOCOL_SSLv23",
18251825
PY_SSL_VERSION_SSL23);
18261826
PyModule_AddIntConstant(m, "PROTOCOL_TLSv1",

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)