Build Python 3.7 with external libffi. (#9245)

This commit is contained in:
Sergey Kosukhin 2018-09-15 02:07:13 +02:00 committed by Todd Gamblin
parent 0b800720b1
commit a9c434d7d7
4 changed files with 45 additions and 6 deletions

View File

@ -37,3 +37,8 @@ class Libffi(AutotoolsPackage):
# version('3.1', 'f5898b29bbfd70502831a212d9249d10',url =
# "ftp://sourceware.org/pub/libffi/libffi-3.1.tar.gz") # Has a bug
# $(lib64) instead of ${lib64} in libffi.pc
@property
def headers(self):
# The headers are probably in self.prefix.lib but we search everywhere
return find_headers('ffi', self.prefix, recursive=True)

View File

@ -72,6 +72,10 @@ class Openssl(Package):
parallel = False
@property
def libs(self):
return find_libraries(['libssl', 'libcrypto'], root=self.prefix.lib)
def handle_fetch_error(self, error):
tty.warn("Fetching OpenSSL failed. This may indicate that OpenSSL has "
"been updated, and the version in your instance of Spack is "

View File

@ -101,6 +101,7 @@ class Python(AutotoolsPackage):
description="Symlink 'python3' executable to 'python' "
"(not PEP 394 compliant)")
depends_on("pkgconfig", type="build")
depends_on("openssl")
depends_on("bzip2")
depends_on("readline")
@ -111,6 +112,10 @@ class Python(AutotoolsPackage):
depends_on("tcl", when="+tk")
depends_on("gdbm", when='+dbm')
# https://docs.python.org/3/whatsnew/3.7.html#build-changes
depends_on("libffi", when="@3.7:")
depends_on("openssl@1.0.2:", when="@3.7:")
# Patch does not work for Python 3.1
patch('ncurses.patch', when='@:2.8,3.2:')
@ -168,12 +173,33 @@ def configure_args(self):
# setup.py needs to be able to read the CPPFLAGS and LDFLAGS
# as it scans for the library and headers to build
dep_pfxs = [dspec.prefix for dspec in spec.dependencies('link')]
config_args = [
'--with-threads',
'CPPFLAGS=-I{0}'.format(' -I'.join(dp.include for dp in dep_pfxs)),
'LDFLAGS=-L{0}'.format(' -L'.join(dp.lib for dp in dep_pfxs)),
]
link_deps = spec.dependencies('link')
# Header files are often included assuming they reside in a
# subdirectory of prefix.include, e.g. #include <openssl/ssl.h>,
# which is why we don't use HeaderList here. The header files of
# libffi reside in prefix.lib but the configure script of Python
# finds them using pkg-config.
cppflags = '-I' + ' -I'.join(dep.prefix.include
for dep in link_deps
if dep.name != 'libffi')
# Currently, the only way to get SpecBuildInterface wrappers of the
# dependencies (which we need to get their 'libs') is to get them
# using spec.__getitem__.
ldflags = ' '.join(spec[dep.name].libs.search_flags
for dep in link_deps)
config_args = ['CPPFLAGS=' + cppflags, 'LDFLAGS=' + ldflags]
# https://docs.python.org/3/whatsnew/3.7.html#build-changes
if spec.satisfies('@:3.6'):
config_args.append('--with-threads')
if '^libffi' in spec:
config_args.append('--with-system-ffi')
else:
config_args.append('--without-system-ffi')
if spec.satisfies('@2.7.13:2.8,3.5.3:', strict=True) \
and '+optimizations' in spec:

View File

@ -76,6 +76,10 @@ class Sqlite(AutotoolsPackage):
'extension-functions.c'},
when='+functions')
@property
def libs(self):
return find_libraries('libsqlite3', root=self.prefix.lib)
def get_arch(self):
arch = architecture.Arch()
arch.platform = architecture.platform()