-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
Pypy fixes #15080
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Pypy fixes #15080
Changes from all commits
cf458cf
df4cffd
91522c6
b38d7be
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -427,7 +427,11 @@ int Object_npyObjectAddKey(void *prv, JSOBJ obj, JSOBJ name, JSOBJ value) { | |
|
||
// only fill label array once, assumes all column labels are the same | ||
// for 2-dimensional arrays. | ||
#ifdef PYPY_VERSION | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I assume you are defining this on external compile? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yes, this is defined when compiling c-extensions with the PyPy headers |
||
if (PyObject_GET_SIZE(npyarr->labels[labelidx]) <= npyarr->elcount) { | ||
#else | ||
if (PyList_GET_SIZE(npyarr->labels[labelidx]) <= npyarr->elcount) { | ||
#endif | ||
PyList_Append(npyarr->labels[labelidx], label); | ||
} | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -150,6 +150,12 @@ def build_extensions(self): | |
with open(outfile, "w") as f: | ||
f.write(pyxcontent) | ||
|
||
# used in lib.pyx, assumes old_build_ext | ||
if not self.cython_compile_time_env: | ||
self.cython_compile_time_env = {} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. see above |
||
major = sys.version_info.major | ||
self.cython_compile_time_env['PY_MAJOR_VERSION'] = major | ||
|
||
numpy_incl = pkg_resources.resource_filename('numpy', 'core/include') | ||
|
||
for ext in self.extensions: | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
isn't this more typical? (and already defined)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it is more typical for
C
code, but converting apyx
file toC
happens during a cython compiliation, and the only variables available are the ones appearing in cython_compile_time_env AFAICT, which is why I needed to define the variable in setup.py.It is not surprising that this is not well known, the only reference I could find on it was a stack overflow question. I tried all different ways to rewrite this code to keep the
PyString_GET_SIZE
on python2 and make itPyUnicode_GET_SIZE
on python3, this was the least intrusiveThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Possibly can use these constants?
https://github.com/cython/cython/blob/master/Cython/Includes/cpython/version.pxd
from
http://stackoverflow.com/a/28316509/3657742
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@chris-b1 that did the trick, thanks
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@chris-b1 I could not get that to work since this is needed at compile time, so I needed the upper-case
IF <env_var>
, not a runtimeif <value>
:( I reverted to the original fixThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this still seems very odd, the why can't you do
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tried that. It does not work for me. Running
python3 setup.py cython
results in alib.c
with PyString_GET_SIZE in the translatedmax_len_string_array
, where if it worked that would becomePyUnicode_GET_SIZE