Skip to content

Commit

Permalink
reorder and add more patches
Browse files Browse the repository at this point in the history
  • Loading branch information
mattip committed Jul 4, 2021
1 parent 2d81fb6 commit 1206f87
Show file tree
Hide file tree
Showing 4 changed files with 161 additions and 5 deletions.
9 changes: 5 additions & 4 deletions recipe/meta.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,9 @@ source:
- patches/lzma_build.patch # [win]
- patches/clibffi.patch # [osx]
- patches/darwin.patch # [osx]
- patches/site-and-sysconfig-conda.patch # [win]
- patches/distutils-install.patch # [win]
- patches/site-and-sysconfig-conda.patch # [win]
- patches/distutils-install.patch # [win]
- distutils-sysconfig-get_python_lib.patch # [win]
# Patches by @mingwandroid from python-feedstock
- patches/0009-runtime_library_dir_option-Use-1st-word-of-CC-as-com.patch
- patches/0012-Fix-find_library-so-that-it-looks-in-sys.prefix-lib-.patch
Expand All @@ -33,8 +34,8 @@ source:
- patches/pre-7.3.6-0003.patch
- patches/pre-7.3.6-0004.patch
- patches/pre-7.3.6-0005.patch
# dealing with pypy/pypy#3502
- patches/use-CPython-list-of-consts-in-os-confstr,pathconf,sysconf-_names.patch
- patches/pre-7.3.6-0006.patch
- patches/pre-7.3.6-0007.patch

- url: https://downloads.python.org/pypy/pypy2.7-v7.3.5-win64.zip # [win]
sha256: 0b90eded11ba89a526c4288f17fff7e75000914ac071bd6d67912748ae89d761 # [win]
Expand Down
57 changes: 57 additions & 0 deletions recipe/patches/distutils-sysconfig-get_python_lib.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
# HG changeset patch
# Branch conda
# Node ID a62de68281e3bc881cddc1d56646567dc543e3cd
# Parent 85c317f36cd8fc1962c1776a6cfb1df3572c518c
use conda layout in get_python_libs

diff -r 85c317f36cd8 -r a62de68281e3 lib-python/3/distutils/sysconfig_pypy.py
--- a/lib-python/3/distutils/sysconfig_pypy.py Thu Jun 24 16:35:13 2021 +0300
+++ b/lib-python/3/distutils/sysconfig_pypy.py Fri Jul 02 18:18:41 2021 +0300
@@ -47,14 +47,31 @@
containing standard Python library modules; otherwise, return the
directory for site-specific modules.

- If 'prefix' is supplied, use it instead of sys.prefix or
- sys.exec_prefix -- i.e., ignore 'plat_specific'.
+ If 'prefix' is supplied, use it instead of sys.base_prefix or
+ sys.base_exec_prefix -- i.e., ignore 'plat_specific'.
"""
if prefix is None:
- prefix = PREFIX
- if standard_lib:
- return os.path.join(prefix, "lib-python", sys.version[0])
- return os.path.join(prefix, 'site-packages')
+ if standard_lib:
+ prefix = plat_specific and BASE_EXEC_PREFIX or BASE_PREFIX
+ else:
+ prefix = plat_specific and EXEC_PREFIX or PREFIX
+
+ if os.name == "posix":
+ libpython = os.path.join(prefix,
+ "lib", "python" + get_python_version())
+ if standard_lib:
+ return libpython
+ else:
+ return os.path.join(libpython, "site-packages")
+ elif os.name == "nt":
+ if standard_lib:
+ return os.path.join(prefix, "Lib")
+ else:
+ return os.path.join(prefix, "Lib", "site-packages")
+ else:
+ raise DistutilsPlatformError(
+ "I don't know where Python installs its library "
+ "on platform '%s'" % os.name)


_config_vars = None
@@ -191,6 +208,9 @@
linker_exe=cc,
archiver=archiver)

+ if 'RANLIB' in os.environ and 'ranlib' in compiler.executables:
+ compiler.set_executables(ranlib=os.environ['RANLIB'])
+
compiler.shared_lib_extension = shlib_suffix


Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
From 3c2099f10102052bce6a90e3a1d4607e4454a9d5 Mon Sep 17 00:00:00 2001
From: Matti Picus <[email protected]>
Date: Thu, 1 Jul 2021 10:56:18 +0300
Subject: [PATCH] use CPython list of consts in os
{confstr,pathconf,sysconf}_names (issue 3502)
Expand Down
99 changes: 99 additions & 0 deletions recipe/patches/pre-7.3.6-0007.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
# HG changeset patch
# User Matti Picus <[email protected]>
# Date 1625384188 -10800
# Sun Jul 04 10:36:28 2021 +0300
# Branch py3.7
# Node ID 66c38129f52afd4c3a6ed74f534468e6f5085695
# Parent 749448488ccd6d138a2dbd392c0ade9b75c2795b
remove hack to look up function by offset, not needed by numpy since v1.17

Does not work properly on win64
https://github.com/numpy/numpy/pull/12524, merged in 2018

diff -r 749448488ccd -r 66c38129f52a pypy/module/_hpy_universal/interp_cpy_compat.py
--- a/pypy/module/_hpy_universal/interp_cpy_compat.py Sat Jul 03 23:35:10 2021 +0300
+++ b/pypy/module/_hpy_universal/interp_cpy_compat.py Sun Jul 04 10:36:28 2021 +0300
@@ -134,7 +134,7 @@
# XXX: we probably need to handle manually these slots
raise NotImplementedError("slot wrapper for slot %d" % num)
funcptr = slotdef.c_pfunc
- w_wrapper = wrapper_class(space, w_type, method_name, doc, funcptr, offset=[])
+ w_wrapper = wrapper_class(space, w_type, method_name, doc, funcptr)
w_type.setdictvalue(space, method_name, w_wrapper)
break
else:
diff -r 749448488ccd -r 66c38129f52a pypy/module/cpyext/methodobject.py
--- a/pypy/module/cpyext/methodobject.py Sat Jul 03 23:35:10 2021 +0300
+++ b/pypy/module/cpyext/methodobject.py Sun Jul 04 10:36:28 2021 +0300
@@ -301,14 +301,11 @@
"""
Abstract class; for concrete subclasses, see slotdefs.py
"""
- _immutable_fields_ = ['offset[*]']
-
- def __init__(self, space, w_type, method_name, doc, func, offset):
+ def __init__(self, space, w_type, method_name, doc, func):
self.space = space
self.method_name = method_name
self.doc = doc
self.func = func
- self.offset = offset
assert isinstance(w_type, W_TypeObject)
self.w_objclass = w_type

@@ -318,25 +315,8 @@
def call(self, space, w_self, __args__):
raise NotImplementedError

- @jit.unroll_safe
def get_func_to_call(self):
- func_to_call = self.func
- if self.offset:
- pto = as_pyobj(self.space, self.w_objclass)
- # make ptr the equivalent of this, using the offsets
- #func_to_call = rffi.cast(rffi.VOIDP, ptr.c_tp_as_number.c_nb_multiply)
- if pto:
- cptr = rffi.cast(rffi.CCHARP, pto)
- for o in self.offset:
- ptr = rffi.cast(rffi.VOIDPP, rffi.ptradd(cptr, o))[0]
- cptr = rffi.cast(rffi.CCHARP, ptr)
- func_to_call = rffi.cast(rffi.VOIDP, cptr)
- else:
- # Should never happen, assert to get a traceback
- assert False, "failed to convert w_type %s to PyObject" % str(
- self.w_objclass)
- assert func_to_call
- return func_to_call
+ return self.func

def check_args(self, __args__, arity):
length = len(__args__.arguments_w)
diff -r 749448488ccd -r 66c38129f52a pypy/module/cpyext/typeobject.py
--- a/pypy/module/cpyext/typeobject.py Sat Jul 03 23:35:10 2021 +0300
+++ b/pypy/module/cpyext/typeobject.py Sun Jul 04 10:36:28 2021 +0300
@@ -353,7 +353,6 @@
for method_name, slot_names, wrapper_class, doc in slotdefs_for_wrappers:
if method_name in dict_w:
continue
- offset = [rffi.offsetof(lltype.typeOf(pto).TO, slot_names[0])]
if len(slot_names) == 1:
func = getattr(pto, slot_names[0])
if slot_names[0] == 'c_tp_hash':
@@ -370,7 +369,6 @@
struct = getattr(pto, slot_names[0])
if not struct:
continue
- offset.append(rffi.offsetof(lltype.typeOf(struct).TO, slot_names[1]))
func = getattr(struct, slot_names[1])
func_voidp = rffi.cast(rffi.VOIDP, func)
if not func:
@@ -380,8 +378,7 @@

assert issubclass(wrapper_class, W_PyCWrapperObject)

- w_obj = wrapper_class(space, w_type, method_name, doc, func_voidp,
- offset=offset[:])
+ w_obj = wrapper_class(space, w_type, method_name, doc, func_voidp)
dict_w[method_name] = w_obj
if pto.c_tp_doc:
raw_doc = rffi.constcharp2str(pto.c_tp_doc)

0 comments on commit 1206f87

Please sign in to comment.