Skip to content

Commit

Permalink
fix to build ssl, readline, curses and bz2 modules. #143 #144
Browse files Browse the repository at this point in the history
- append the python root folder to modules build arguments.
  • Loading branch information
Shimoda committed Jan 7, 2018
1 parent ccd0aae commit f5665ca
Showing 1 changed file with 126 additions and 26 deletions.
152 changes: 126 additions & 26 deletions python3-alpha/patches/python-3.6.4-python-setup.patch
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
diff -ur host-src/setup.py python-src_arm/setup.py
--- host-src/setup.py 2017-12-19 13:53:56.000000000 +0900
+++ python-src_arm/setup.py 2018-01-07 17:25:51.448928383 +0900
+++ python-src_arm/setup.py 2018-01-07 23:45:14.905955050 +0900
@@ -18,11 +18,37 @@

cross_compiling = "_PYTHON_HOST_PLATFORM" in os.environ
Expand Down Expand Up @@ -40,7 +40,16 @@ diff -ur host-src/setup.py python-src_arm/setup.py

class Dummy:
"""Hack for parallel build"""
@@ -631,63 +657,66 @@
@@ -586,6 +612,8 @@
inc_dirs = (self.compiler.include_dirs +
sysroot_paths(('CPPFLAGS', 'CFLAGS', 'CC'),
system_include_dirs))
+ cross_incs = [os.environ["PYBIN"] + "/include"]
+ cross_libs = [os.environ["PYBIN"] + "/lib"]
exts = []
missing = []

@@ -631,63 +659,66 @@
#

# array objects
Expand Down Expand Up @@ -130,7 +139,7 @@ diff -ur host-src/setup.py python-src_arm/setup.py

# Modules with some UNIX dependencies -- on by default:
# (If you have a really backward UNIX, select and socket may not be
@@ -698,30 +727,33 @@
@@ -698,30 +729,33 @@
if (config_h_vars.get('FLOCK_NEEDS_LIBBSD', False)):
# May be necessary on AIX for flock function
libs = ['bsd']
Expand Down Expand Up @@ -172,7 +181,7 @@ diff -ur host-src/setup.py python-src_arm/setup.py

#
# Here ends the simple stuff. From here on, modules need certain
@@ -737,7 +769,7 @@
@@ -737,11 +771,11 @@
# 64-bit platforms.
#
# audioop needs math_libs for floor() in multiple functions.
Expand All @@ -181,16 +190,41 @@ diff -ur host-src/setup.py python-src_arm/setup.py
libraries=math_libs) )

# readline
@@ -816,7 +848,7 @@
- do_readline = self.compiler.find_library_file(lib_dirs, 'readline')
+ do_readline = self.compiler.find_library_file(cross_libs, 'readline')
readline_termcap_library = ""
curses_library = ""
# Cannot use os.popen here in py3k.
@@ -776,11 +810,11 @@
# use the same library for the readline and curses modules.
if 'curses' in readline_termcap_library:
curses_library = readline_termcap_library
- elif self.compiler.find_library_file(lib_dirs, 'ncursesw'):
+ elif self.compiler.find_library_file(cross_libs, 'ncursesw'):
curses_library = 'ncursesw'
- elif self.compiler.find_library_file(lib_dirs, 'ncurses'):
+ elif self.compiler.find_library_file(cross_libs, 'ncurses'):
curses_library = 'ncurses'
- elif self.compiler.find_library_file(lib_dirs, 'curses'):
+ elif self.compiler.find_library_file(cross_libs, 'curses'):
curses_library = 'curses'

if host_platform == 'darwin':
@@ -816,9 +850,10 @@
['/usr/lib/termcap'],
'termcap'):
readline_libs.append('termcap')
- exts.append( Extension('readline', ['readline.c'],
- library_dirs=['/usr/lib/termcap'],
- extra_link_args=readline_extra_link_args,
+ exts.append( Extension('readline', ['Modules/readline.c'],
library_dirs=['/usr/lib/termcap'],
extra_link_args=readline_extra_link_args,
+ include_dirs=cross_incs,
+ library_dirs=cross_libs,
+ # extra_link_args=readline_extra_link_args,
libraries=readline_libs) )
@@ -829,17 +861,19 @@
else:
missing.append('readline')
@@ -829,19 +864,21 @@
libs = ['crypt']
else:
libs = []
Expand All @@ -213,9 +247,28 @@ diff -ur host-src/setup.py python-src_arm/setup.py
+ exts.append( Extension('_socket', ['Modules/socketmodule.c'],
+ depends = ['Modules/socketmodule.h']) )
# Detect SSL support for the socket module (via _ssl)
search_for_ssl_incs_in = [
- search_for_ssl_incs_in = [
+ search_for_ssl_incs_in = cross_incs + [
'/usr/local/ssl/include',
@@ -900,8 +934,8 @@
'/usr/contrib/ssl/include/'
]
@@ -854,13 +891,13 @@
if krb5_h:
ssl_incs += krb5_h
ssl_libs = find_library_file(self.compiler, 'ssl',lib_dirs,
- ['/usr/local/ssl/lib',
+ cross_libs + ['/usr/local/ssl/lib',
'/usr/contrib/ssl/lib/'
] )

if (ssl_incs is not None and
ssl_libs is not None):
- exts.append( Extension('_ssl', ['_ssl.c'],
+ exts.append( Extension('_ssl', ['Modules/_ssl.c'],
include_dirs = ssl_incs,
library_dirs = ssl_libs,
libraries = ['ssl', 'crypto'],
@@ -900,8 +937,8 @@
if have_usable_openssl:
# The _hashlib module wraps optimized implementations
# of hash functions from the OpenSSL library.
Expand All @@ -226,7 +279,7 @@ diff -ur host-src/setup.py python-src_arm/setup.py
include_dirs = ssl_incs,
library_dirs = ssl_libs,
libraries = ['ssl', 'crypto']) )
@@ -913,14 +947,14 @@
@@ -913,14 +950,14 @@
# We always compile these even when OpenSSL is available (issue #14693).
# It's harmless and the object code is tiny (40-50 KB per module,
# only loaded when actually used).
Expand All @@ -249,7 +302,7 @@ diff -ur host-src/setup.py python-src_arm/setup.py

blake2_deps = glob(os.path.join(os.getcwd(), srcdir,
'Modules/_blake2/impl/*'))
@@ -935,9 +969,9 @@
@@ -935,9 +972,9 @@
blake2_macros.append(('BLAKE2_USE_SSE', '1'))

exts.append( Extension('_blake2',
Expand All @@ -262,7 +315,7 @@ diff -ur host-src/setup.py python-src_arm/setup.py
define_macros=blake2_macros,
depends=blake2_deps) )

@@ -945,7 +979,7 @@
@@ -945,7 +982,7 @@
'Modules/_sha3/kcp/*'))
sha3_deps.append('hashlib.h')
exts.append( Extension('_sha3',
Expand All @@ -271,7 +324,7 @@ diff -ur host-src/setup.py python-src_arm/setup.py
depends=sha3_deps))

# Modules that provide persistent dictionary-like semantics. You will
@@ -1358,9 +1392,9 @@
@@ -1358,9 +1395,9 @@
# Unix-only modules
if host_platform != 'win32':
# Steen Lumholt's termios module
Expand All @@ -283,7 +336,40 @@ diff -ur host-src/setup.py python-src_arm/setup.py

# Sun yellow pages. Some systems have the functions in libc.
if (host_platform not in ['cygwin', 'qnx6'] and
@@ -1445,7 +1479,10 @@
@@ -1385,6 +1422,8 @@
curses_defines.append(('HAVE_NCURSESW', '1'))
if not cross_compiling:
curses_includes.append('/usr/include/ncursesw')
+ else:
+ curses_includes += cross_incs
# Bug 1464056: If _curses.so links with ncursesw,
# _curses_panel.so must link with panelw.
panel_library = 'panelw'
@@ -1403,8 +1442,9 @@

if curses_library.startswith('ncurses'):
curses_libs = [curses_library]
- exts.append( Extension('_curses', ['_cursesmodule.c'],
+ exts.append( Extension('_curses', ['Modules/_cursesmodule.c'],
include_dirs=curses_includes,
+ library_dirs=cross_libs,
define_macros=curses_defines,
libraries = curses_libs) )
elif curses_library == 'curses' and host_platform != 'darwin':
@@ -1425,8 +1465,10 @@

# If the curses module is enabled, check for the panel module
if (module_enabled(exts, '_curses') and
- self.compiler.find_library_file(lib_dirs, panel_library)):
- exts.append( Extension('_curses_panel', ['_curses_panel.c'],
+ self.compiler.find_library_file(cross_libs, panel_library)):
+ exts.append( Extension('_curses_panel',
+ ['Modules/_curses_panel.c'],
+ library_dirs=cross_libs,
include_dirs=curses_includes,
define_macros=curses_defines,
libraries = [panel_library] + curses_libs) )
@@ -1445,7 +1487,10 @@
#
# You can upgrade zlib to version 1.1.4 yourself by going to
# http://www.gzip.org/zlib/
Expand All @@ -295,7 +381,7 @@ diff -ur host-src/setup.py python-src_arm/setup.py
have_zlib = False
if zlib_inc is not None:
zlib_h = zlib_inc[0] + '/zlib.h'
@@ -1462,12 +1499,12 @@
@@ -1462,12 +1507,12 @@
version = line.split()[2]
break
if version >= version_req:
Expand All @@ -310,7 +396,7 @@ diff -ur host-src/setup.py python-src_arm/setup.py
libraries = ['z'],
extra_link_args = zlib_extra_link_args))
have_zlib = True
@@ -1488,7 +1525,7 @@
@@ -1488,18 +1533,20 @@
extra_compile_args = []
libraries = []
extra_link_args = []
Expand All @@ -319,7 +405,21 @@ diff -ur host-src/setup.py python-src_arm/setup.py
extra_compile_args = extra_compile_args,
libraries = libraries,
extra_link_args = extra_link_args) )
@@ -1540,20 +1577,20 @@

# Gustavo Niemeyer's bz2 module.
- if (self.compiler.find_library_file(lib_dirs, 'bz2')):
+ if (self.compiler.find_library_file(cross_libs, 'bz2')):
if host_platform == "darwin":
bz2_extra_link_args = ('-Wl,-search_paths_first',)
else:
bz2_extra_link_args = ()
exts.append( Extension('_bz2', ['_bz2module.c'],
+ library_dirs=cross_libs,
+ include_dirs=cross_incs,
libraries = ['bz2'],
extra_link_args = bz2_extra_link_args) )
else:
@@ -1540,20 +1587,20 @@
]
extra_compile_args = []
expat_lib = []
Expand Down Expand Up @@ -354,7 +454,7 @@ diff -ur host-src/setup.py python-src_arm/setup.py
]

cc = sysconfig.get_config_var('CC').split()[0]
@@ -1567,7 +1604,7 @@
@@ -1567,7 +1614,7 @@
extra_compile_args = extra_compile_args,
include_dirs = expat_inc,
libraries = expat_lib,
Expand All @@ -363,7 +463,7 @@ diff -ur host-src/setup.py python-src_arm/setup.py
depends = expat_depends,
))

@@ -1580,19 +1617,19 @@
@@ -1580,19 +1627,19 @@
define_macros = define_macros,
include_dirs = expat_inc,
libraries = expat_lib,
Expand All @@ -388,7 +488,7 @@ diff -ur host-src/setup.py python-src_arm/setup.py

# Stefan Krah's _decimal module
exts.append(self._decimal_ext())
@@ -1637,11 +1674,11 @@
@@ -1637,11 +1684,11 @@
]

else:
Expand All @@ -402,7 +502,7 @@ diff -ur host-src/setup.py python-src_arm/setup.py

if sysconfig.get_config_var('WITH_THREAD'):
exts.append ( Extension('_multiprocessing', multiprocessing_srcs,
@@ -1653,7 +1690,7 @@
@@ -1653,7 +1700,7 @@

# Platform-specific libraries
if host_platform.startswith(('linux', 'freebsd', 'gnukfreebsd')):
Expand All @@ -411,7 +511,7 @@ diff -ur host-src/setup.py python-src_arm/setup.py
else:
missing.append('ossaudiodev')

@@ -1678,7 +1715,7 @@
@@ -1678,7 +1725,7 @@
## self.extensions.append(ext)

if 'd' not in sysconfig.get_config_var('ABIFLAGS'):
Expand All @@ -420,7 +520,7 @@ diff -ur host-src/setup.py python-src_arm/setup.py
define_macros=[('Py_LIMITED_API', '0x03050000')])
self.extensions.append(ext)

@@ -2055,7 +2092,7 @@
@@ -2055,7 +2102,7 @@
depends=depends)
# function my_sqrt() needs math library for sqrt()
ext_test = Extension('_ctypes_test',
Expand All @@ -429,7 +529,7 @@ diff -ur host-src/setup.py python-src_arm/setup.py
libraries=math_libs)
self.extensions.extend([ext, ext_test])

@@ -2111,40 +2148,40 @@
@@ -2111,40 +2158,40 @@
'libmpdec'))]
libraries = self.detect_math_libs()
sources = [
Expand Down Expand Up @@ -502,7 +602,7 @@ diff -ur host-src/setup.py python-src_arm/setup.py
]

config = {
@@ -2340,7 +2377,7 @@
@@ -2340,7 +2387,7 @@
'install_lib': PyBuildInstallLib},
# The struct module is defined here, because build_ext won't be
# called unless there's at least one extension module defined.
Expand Down

0 comments on commit f5665ca

Please sign in to comment.