Hi,
Does anyone have any comments to make on the following,
with a view that I'll probably commit this change if
no one can find anything wrong with it.
thanks!
Ron
···
On Thu, Oct 13, 2005 at 04:53:23PM -0500, Ken McIvor wrote:
Ron,
I believe I have identified the source of the problem with the headers
being installed in the source directory under Python 2.6, and have attached
a patch which ought to fix things. This is an upstream bug, so I will also
file that half of the patch at sourceforge and post to wxpython-dev.As I suspected, the problem was caused by some cleverness in the Python
build scripts, specifically that `wxPython/config.py' provides a special
implementation of setup.py's install_headers command. This version
attempts to do the Right Thing by installing the headers off of the prefix
returned by
"wx-config --prefix". If you were building wxPython after having installed
wxWidgets, the prefix would be `/usr' and the headers would be installed
correctly.However, setup.py uses the build version of "wx-config" when building the
Debian package. In this case, the prefix is the location of the source
tree, which is why the headers get installed there. This approach would
also break if you were trying to do a home directory installation of
wxPython, something that setup.py explicitly supports. Please let me know
if this doesn't make any sense, and I'll send an example which walks
through the code and demonstrates the problem.The big problem with this approach is that there is no way to turn off the
cleverness: it ignores the --install-headers option, which is supposed to
let you specify a directory to put the headers in. I changed the
implementation of install_headers to respect this option again, and updated
`debian/rules' to use it.I also added the "--no-compile" option to the invocations of "setup.py
install", which turns off automatically byte-compiling the Python files.
This makes more sense to me because lets you avoid byte-compiling the files
twice (when running "setup.py install" and in the postinst). However, this
is not an important part of the patch.Ken
diff -ur wxwidgets2.6-2.6.1.2.orig/debian/rules wxwidgets2.6-2.6.1.2/debian/rules
--- wxwidgets2.6-2.6.1.2.orig/debian/rules 2005-08-25 07:54:17.000000000 -0500
+++ wxwidgets2.6-2.6.1.2/debian/rules 2005-10-13 16:08:16.000000000 -0500
@@ -94,6 +94,10 @@
$(objdir_msw_shared) $(objdir_msw_static) $(objdir_msw_dbg) \
$(objdir_msw_install)+# setup.py's --prefix option
+pyprefix := `pwd`/../debian/$(package_gtk_py_lib)/usr
+pydprefix := `pwd`/../debian/$(package_gtk_dbg_py)/usr
+
# note that the i18n package is actually arch indep (once built)
# but must be built (and installed) during the arch any phase as
# it's pulled out of the wxGTK shared lib package.
@@ -517,7 +521,9 @@
dh_installdirs usr/lib/wx/python
cd wxPython \
&& $(python_ver) ./setup.py install \
- --prefix=`pwd`/../debian/$(package_gtk_py_lib)/usr \
+ --prefix=$(pyprefix) \
+ --install-headers=$(pyprefix)/include/wx-$(release)/wx \
+ --no-compile \
WX_CONFIG='$(wxconfig)' \
SYS_WX_CONFIG='$(py_wxconfig)' \
WXPORT=$(pytoolkit) \
@@ -625,7 +631,9 @@
dh_installdirs usr/lib/wx/python
cd wxPython \
&& $(python_ver) ./setup.py install \
- --prefix=`pwd`/../debian/$(package_gtk_dbg_py)/usr \
+ --prefix=$(pydprefix) \
+ --install-headers=$(pydprefix)/include/wx-$(release)/wx \
+ --no-compile \
WX_CONFIG='$(wxconfig-dbg)' \
SYS_WX_CONFIG='$(pyd_wxconfig)' \
WXPORT=$(pytoolkit) \
diff -ur wxwidgets2.6-2.6.1.2.orig/wxPython/config.py wxwidgets2.6-2.6.1.2/wxPython/config.py
--- wxwidgets2.6-2.6.1.2.orig/wxPython/config.py 2005-08-25 07:53:28.000000000 -0500
+++ wxwidgets2.6-2.6.1.2/wxPython/config.py 2005-10-13 16:05:43.000000000 -0500
@@ -32,6 +32,7 @@
import distutils.command.install_headers
import distutils.command.clean+
#----------------------------------------------------------------------
# flags and values that affect this script
#----------------------------------------------------------------------
@@ -487,8 +488,9 @@class wx_install_headers(distutils.command.install_headers.install_headers):
"""
- Install the header files to the WXPREFIX, with an extra dir per
- filename too
+ Installs the header files off of WXPREFIX by default, but allow users to
+ specify an alternative path using the distutils command line options. Also
+ adds support for an extra directory per filename.
"""
def initialize_options(self):
self.root = None
@@ -506,18 +508,40 @@
returnroot = self.root
- if root is None or WXPREFIX.startswith(root):
- root = ''
+ if not self.is_default_headers_install_dir(self.install_dir):
+ prefix = self.install_dir
+ else:
+ if root is None or WXPREFIX.startswith(root):
+ prefix = WXPREFIX
+ else:
+ prefix = root + WXPREFIX
+ prefix += '/include/wx-%d.%d/wx' % (VER_MAJOR, VER_MINOR)
+
for header, location in headers:
- install_dir = os.path.normpath(root +
- WXPREFIX +
- '/include/wx-%d.%d/wx' % (VER_MAJOR, VER_MINOR) +
- location)
+ install_dir = os.path.normpath(prefix + location)
self.mkpath(install_dir)
(out, _) = self.copy_file(header, install_dir)
self.outfiles.append(out)+ def is_default_headers_install_dir(self, path):
+ """
+ Tests if a path is the default header install directory under unix.
+ """
+ from distutils.util import subst_vars
+ from distutils.command.install import INSTALL_SCHEMES
+ install_cmd = self.get_finalized_command('install')
+ def check(scheme):
+ return (os.path.abspath(path) ==
+ os.path.abspath(
+ os.path.expanduser(
+ subst_vars(
+ INSTALL_SCHEMES[scheme][ 'headers'],
+ install_cmd.config_vars))))+ if install_cmd.home:
+ return check('unix_home')
+ else:
+ return check('unix_prefix')def build_locale_dir(destdir, verbose=1):