Skip to content

Commit 0d8f84f

Browse files
committed
Build the bundled files
1 parent 159c87b commit 0d8f84f

File tree

2 files changed

+42
-38
lines changed

2 files changed

+42
-38
lines changed

graalpython/com.oracle.graal.python.cext/setup.py

Lines changed: 42 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -37,12 +37,13 @@
3737
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
3838
# SOFTWARE.
3939
import glob
40-
import sys
40+
import logging
4141
import os
4242
import shutil
43-
import logging
43+
import sys
4444
from distutils.core import setup, Extension
4545
from distutils.sysconfig import get_config_var, get_config_vars
46+
4647
import _sysconfig
4748

4849
__dir__ = __file__.rpartition("/")[0]
@@ -390,39 +391,32 @@ def _build_deps(deps):
390391

391392

392393
class NativeBuiltinModule:
393-
def __init__(self, name, subdir="modules", files=None, deps=[], **kwargs):
394+
def __init__(self, name, deps=(), **kwargs):
394395
self.name = name
395-
self.subdir = subdir
396396
self.deps = deps
397-
# common case: just a single file which is the module's name plus the file extension
398-
if not files:
399-
self.files = [name + ".c"]
400-
else:
401-
self.files = files
402397
self.kwargs = kwargs
403398

404399
def __call__(self):
405-
kwargs = self.kwargs
400+
kwargs = dict(self.kwargs)
401+
# common case: just a single file which is the module's name plus the file extension
402+
sources = kwargs.pop("sources", [os.path.join("modules", self.name + ".c")])
406403

407404
libs, library_dirs, include_dirs = _build_deps(self.deps)
408-
runtime_library_dirs = []
409-
extra_link_args = []
410-
411-
libs += kwargs.get("libs", [])
412-
library_dirs += kwargs.get("library_dirs", [])
413-
runtime_library_dirs += kwargs.get("runtime_library_dirs", [])
414-
include_dirs += kwargs.get("include_dirs", [])
415-
extra_link_args += kwargs.get("extra_link_args", [])
416405

417-
return Extension(self.name,
418-
sources=[os.path.join(__dir__, self.subdir, f) for f in self.files],
419-
libraries=libs,
420-
library_dirs=library_dirs,
421-
extra_compile_args=cflags_warnings + kwargs.get("cflags_warnings", []),
422-
runtime_library_dirs=runtime_library_dirs,
423-
include_dirs=include_dirs,
424-
extra_link_args=extra_link_args,
425-
)
406+
libs += kwargs.pop("libs", [])
407+
library_dirs += kwargs.pop("library_dirs", [])
408+
include_dirs += kwargs.pop("include_dirs", [])
409+
extra_compile_args = cflags_warnings + kwargs.pop("extra_compile_args", [])
410+
411+
return Extension(
412+
self.name,
413+
sources=[os.path.join(__dir__, f) for f in sources],
414+
libraries=libs,
415+
library_dirs=library_dirs,
416+
extra_compile_args=extra_compile_args,
417+
include_dirs=include_dirs,
418+
**kwargs,
419+
)
426420

427421

428422
builtin_exts = (
@@ -434,8 +428,27 @@ def __call__(self):
434428
NativeBuiltinModule("_testmultiphase"),
435429
NativeBuiltinModule("_ctypes_test"),
436430
# the above modules are more core, we need them first to deal with later, more complex modules with dependencies
437-
NativeBuiltinModule("_bz2", deps=[Bzip2Depedency("bz2", "bzip2==1.0.8", "BZIP2")], extra_link_args=["-Wl,-rpath,%s/../lib/%s/" % (relative_rpath, SOABI)]),
438-
NativeBuiltinModule("pyexpat", deps=[ExpatDependency("expat", "expat==2.2.8", "EXPAT")], extra_link_args=["-Wl,-rpath,%s/../lib/%s/" % (relative_rpath, SOABI)]),
431+
NativeBuiltinModule(
432+
"_bz2",
433+
deps=[Bzip2Depedency("bz2", "bzip2==1.0.8", "BZIP2")],
434+
extra_link_args=["-Wl,-rpath,%s/../lib/%s/" % (relative_rpath, SOABI)],
435+
),
436+
NativeBuiltinModule(
437+
'pyexpat',
438+
define_macros=[
439+
('HAVE_EXPAT_CONFIG_H', '1'),
440+
# bpo-30947: Python uses best available entropy sources to
441+
# call XML_SetHashSalt(), expat entropy sources are not needed
442+
('XML_POOR_ENTROPY', '1'),
443+
],
444+
include_dirs=[os.path.join(__dir__, 'expat')],
445+
sources=['modules/pyexpat.c', 'expat/xmlparse.c', 'expat/xmlrole.c', 'expat/xmltok.c'],
446+
depends=[
447+
'expat/ascii.h', 'expat/asciitab.h', 'expat/expat.h', 'expat/expat_config.h', 'expat/expat_external.h',
448+
'expat/internal.h', 'expat/latin1tab.h', 'expat/utf8tab.h', 'expat/xmlrole.h', 'expat/xmltok.h',
449+
'expat/xmltok_impl.h',
450+
],
451+
),
439452
)
440453

441454

mx.graalpython/suite.py

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -121,13 +121,6 @@
121121
"packedResource": True,
122122
"sha1": "bf7badf7e248e0ecf465d33c2f5aeec774209227",
123123
},
124-
"EXPAT": {
125-
"urls": [
126-
"https://lafo.ssw.uni-linz.ac.at/pub/graal-external-deps/graalpython/expat-2.2.8.tar.gz",
127-
],
128-
"packedResource": True,
129-
"sha1": "2097c111a23d0583cc8ea42f99ebfe7e29aeba92",
130-
},
131124
"ICU4J-69.1" : {
132125
"moduleName" : "com.ibm.icu",
133126
"sha1" : "ff666ac55986650893aacb9e2e0003538e9799c0",
@@ -360,15 +353,13 @@
360353
"sulong:SULONG_BOOTSTRAP_TOOLCHAIN",
361354
"XZ-5.2.5",
362355
"BZIP2",
363-
"EXPAT"
364356
],
365357
"buildEnv": {
366358
"TRUFFLE_H_INC": "<path:SULONG_LEGACY>/include",
367359
"ARCH": "<arch>",
368360
"OS": "<os>",
369361
"XZ-5.2.5": "<path:XZ-5.2.5>",
370362
"BZIP2": "<path:BZIP2>",
371-
"EXPAT": "<path:EXPAT>",
372363
},
373364
},
374365

0 commit comments

Comments
 (0)