Go to:
Gentoo Home
Documentation
Forums
Lists
Bugs
Planet
Store
Wiki
Get Gentoo!
Gentoo's Bugzilla – Attachment 190750 Details for
Bug 269111
Make python modules cross-compile
Home
|
New
–
[Ex]
|
Browse
|
Search
|
Privacy Policy
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Respect a sysroot env variable in setup.py
python-2.6-cross-setup-sysroot.patch (text/plain), 10.51 KB, created by
Sven 'sleipnir' Rebhan
on 2009-05-09 11:28:12 UTC
(
hide
)
Description:
Respect a sysroot env variable in setup.py
Filename:
MIME Type:
Creator:
Sven 'sleipnir' Rebhan
Created:
2009-05-09 11:28:12 UTC
Size:
10.51 KB
patch
obsolete
>This lengthy patch adds the 'sysroot' variable as a prefix >to all instances of include and libdirs in the python setup >module. The 'sysroot' variable itself can be set using the >SYSROOT environment variable used in the Gentoo cross-compile >framework, making it possible to install python and its >extensions into a root environment. > >--- setup.py 2008-09-28 19:17:01.000000000 +0200 >+++ setup.py.new 2008-09-28 19:19:25.000000000 +0200 >@@ -333,9 +333,15 @@ > > def detect_modules(self): > global disable_ssl >+ >+ # We must respect the user specified sysroot! >+ sysroot=os.getenv('PYTHON_SYSROOT') >+ if sysroot is None: >+ sysroot='' >+ > # Ensure that /usr/local is always used >- add_dir_to_list(self.compiler.library_dirs, '/usr/local/lib') >- add_dir_to_list(self.compiler.include_dirs, '/usr/local/include') >+ add_dir_to_list(self.compiler.library_dirs, sysroot+'/usr/local/lib') >+ add_dir_to_list(self.compiler.include_dirs, sysroot+'/usr/local/include') > > # Add paths specified in the environment variables LDFLAGS and > # CPPFLAGS for header and library files. >@@ -371,12 +377,20 @@ > for directory in reversed(options.dirs): > add_dir_to_list(dir_list, directory) > >- if os.path.normpath(sys.prefix) != '/usr': >+ if os.path.normpath(sys.prefix) != '/usr' and sysroot == '': > add_dir_to_list(self.compiler.library_dirs, > sysconfig.get_config_var("LIBDIR")) > add_dir_to_list(self.compiler.include_dirs, > sysconfig.get_config_var("INCLUDEDIR")) > >+ # We should always look into sysroot/usr/include and consider >+ # also the lib dirs there for searching for files >+ add_dir_to_list(self.compiler.include_dirs, sysroot+'/usr/include') >+ add_dir_to_list(self.compiler.library_dirs, sysroot+'/lib') >+ add_dir_to_list(self.compiler.library_dirs, sysroot+'/lib64') >+ add_dir_to_list(self.compiler.library_dirs, sysroot+'/usr/lib') >+ add_dir_to_list(self.compiler.library_dirs, sysroot+'/usr/lib64') >+ > try: > have_unicode = unicode > except NameError: >@@ -385,11 +399,8 @@ > # lib_dirs and inc_dirs are used to search for files; > # if a file is found in one of those directories, it can > # be assumed that no additional -I,-L directives are needed. >- lib_dirs = self.compiler.library_dirs + [ >- '/lib64', '/usr/lib64', >- '/lib', '/usr/lib', >- ] >- inc_dirs = self.compiler.include_dirs + ['/usr/include'] >+ lib_dirs = self.compiler.library_dirs >+ inc_dirs = self.compiler.include_dirs > exts = [] > missing = [] > >@@ -608,11 +619,11 @@ > elif self.compiler.find_library_file(lib_dirs, 'curses'): > readline_libs.append('curses') > elif self.compiler.find_library_file(lib_dirs + >- ['/usr/@@GENTOO_LIBDIR@@/termcap'], >+ [sysroot+'/usr/@@GENTOO_LIBDIR@@/termcap'], > 'termcap'): > readline_libs.append('termcap') > exts.append( Extension('readline', ['readline.c'], >- library_dirs=['/usr/@@GENTOO_LIBDIR@@/termcap'], >+ library_dirs=[sysroot+'/usr/@@GENTOO_LIBDIR@@/termcap'], > extra_link_args=readline_extra_link_args, > libraries=readline_libs) ) > else: >@@ -637,20 +648,20 @@ > depends = ['socketmodule.h']) ) > # Detect SSL support for the socket module (via _ssl) > search_for_ssl_incs_in = [ >- '/usr/local/ssl/include', >- '/usr/contrib/ssl/include/' >+ sysroot+'/usr/local/ssl/include', >+ sysroot+'/usr/contrib/ssl/include/' > ] > ssl_incs = find_file('openssl/ssl.h', inc_dirs, > search_for_ssl_incs_in > ) > if ssl_incs is not None and not disable_ssl: > krb5_h = find_file('krb5.h', inc_dirs, >- ['/usr/kerberos/include']) >+ [sysroot+'/usr/kerberos/include']) > if krb5_h: > ssl_incs += krb5_h > ssl_libs = find_library_file(self.compiler, 'ssl',lib_dirs, >- ['/usr/local/ssl/lib', >- '/usr/contrib/ssl/lib/' >+ [sysroot+'/usr/local/ssl/lib', >+ sysroot+'/usr/contrib/ssl/lib/' > ] ) > > if (ssl_incs is not None and >@@ -753,6 +764,7 @@ > return False > return True > >+ > def gen_db_minor_ver_nums(major): > if major == 4: > for x in range(max_db_ver[1]+1): >@@ -768,21 +780,21 @@ > # construct a list of paths to look for the header file in on > # top of the normal inc_dirs. > db_inc_paths = [ >- '/usr/include/db4', >+ sysroot+'/usr/include/db4', > ] > # 4.x minor number specific paths > for x in gen_db_minor_ver_nums(4): >- db_inc_paths.append('/usr/include/db4%d' % x) >- db_inc_paths.append('/usr/include/db4.%d' % x) >- db_inc_paths.append('/usr/local/BerkeleyDB.4.%d/include' % x) >- db_inc_paths.append('/usr/local/include/db4%d' % x) >- db_inc_paths.append('/pkg/db-4.%d/include' % x) >- db_inc_paths.append('/opt/db-4.%d/include' % x) >+ db_inc_paths.append(sysroot+'/usr/include/db4%d' % x) >+ db_inc_paths.append(sysroot+'/usr/include/db4.%d' % x) >+ db_inc_paths.append(sysroot+'/usr/local/BerkeleyDB.4.%d/include' % x) >+ db_inc_paths.append(sysroot+'/usr/local/include/db4%d' % x) >+ db_inc_paths.append(sysroot+'/pkg/db-4.%d/include' % x) >+ db_inc_paths.append(sysroot+'/opt/db-4.%d/include' % x) > # MacPorts default (http://www.macports.org/) > db_inc_paths.append('/opt/local/include/db4%d' % x) > # 3.x minor number specific paths > for x in gen_db_minor_ver_nums(3): >- db_inc_paths.append('/usr/include/db3%d' % x) >+ db_inc_paths.append('sysroot+/usr/include/db3%d' % x) > > # Add some common subdirectories for Sleepycat DB to the list, > # based on the standard include directories. This way DB3/4 gets >@@ -904,12 +916,12 @@ > # We hunt for #define SQLITE_VERSION "n.n.n" > # We need to find >= sqlite version 3.0.8 > sqlite_incdir = sqlite_libdir = None >- sqlite_inc_paths = [ '/usr/include', >- '/usr/include/sqlite', >- '/usr/include/sqlite3', >- '/usr/local/include', >- '/usr/local/include/sqlite', >- '/usr/local/include/sqlite3', >+ sqlite_inc_paths = [ sysroot+'/usr/include', >+ sysroot+'/usr/include/sqlite', >+ sysroot+'/usr/include/sqlite3', >+ sysroot+'/usr/local/include', >+ sysroot+'/usr/local/include/sqlite', >+ sysroot+'/usr/local/include/sqlite3', > ] > MIN_SQLITE_VERSION_NUMBER = (3, 0, 8) > MIN_SQLITE_VERSION = ".".join([str(x) >@@ -1004,7 +1016,7 @@ > # we do not build this one. Otherwise this build will pick up > # the more recent berkeleydb's db.h file first in the include path > # when attempting to compile and it will fail. >- f = "/usr/include/db.h" >+ f = sysroot+"/usr/include/db.h" > if os.path.exists(f) and not db_incs: > data = open(f).read() > m = re.search(r"#s*define\s+HASHVERSION\s+2\s*", data) >@@ -1207,7 +1219,7 @@ > # More information on Expat can be found at www.libexpat.org. > # > # Use system expat >- expatinc = '/usr/include' >+ expatinc = sysroot+'/usr/include' > define_macros = [] > > exts.append(Extension('pyexpat', >@@ -1493,7 +1505,7 @@ > # For 8.4a2, the X11 headers are not included. Rather than include a > # complicated search, this is a hard-coded path. It could bail out > # if X11 libs are not found... >- include_dirs.append('/usr/X11R6/include') >+ include_dirs.append(sysroot+'/usr/X11R6/include') > frameworks = ['-framework', 'Tcl', '-framework', 'Tk'] > > # All existing framework builds of Tcl/Tk don't support 64-bit >@@ -1528,6 +1540,11 @@ > def detect_tkinter(self, inc_dirs, lib_dirs): > # The _tkinter module. > >+ # We must respect the user specified sysroot! >+ sysroot=os.getenv('SYSROOT') >+ if sysroot is None: >+ sysroot='' >+ > # Rather than complicate the code below, detecting and building > # AquaTk is a separate method. Only one Tkinter will be built on > # Darwin - either AquaTk, if it is found, or X11 based Tk. >@@ -1582,17 +1599,17 @@ > if platform == 'sunos5': > include_dirs.append('/usr/openwin/include') > added_lib_dirs.append('/usr/openwin/lib') >- elif os.path.exists('/usr/X11R6/include'): >- include_dirs.append('/usr/X11R6/include') >- added_lib_dirs.append('/usr/X11R6/lib64') >- added_lib_dirs.append('/usr/X11R6/lib') >- elif os.path.exists('/usr/X11R5/include'): >- include_dirs.append('/usr/X11R5/include') >- added_lib_dirs.append('/usr/X11R5/lib') >+ elif os.path.exists(sysroot+'/usr/X11R6/include'): >+ include_dirs.append(sysroot+'/usr/X11R6/include') >+ added_lib_dirs.append(sysroot+'/usr/X11R6/lib64') >+ added_lib_dirs.append(sysroot+'/usr/X11R6/lib') >+ elif os.path.exists(sysroot+'/usr/X11R5/include'): >+ include_dirs.append(sysroot+'/usr/X11R5/include') >+ added_lib_dirs.append(sysroot+'/usr/X11R5/lib') > else: > # Assume default location for X11 >- include_dirs.append('/usr/X11/include') >- added_lib_dirs.append('/usr/X11/lib') >+ include_dirs.append(sysroot+'/usr/X11/include') >+ added_lib_dirs.append(sysroot+'/usr/X11/lib') > > # If Cygwin, then verify that X is installed before proceeding > if platform == 'cygwin':
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 269111
:
190749
| 190750 |
190751
|
190753
|
239099
|
253831
|
254741