
While playing with distutils, I found some (old) bugs. If your distribution directory for bdist doesn't exist, distutils doesn't create it. (Even the default 'dist', so distutils fails if you use bdist for the first time.) bdist_wininst fails if no long description exists. It should warn about this, and go ahead. And a new introduced one in bcppcompiler.py It uses the first object file's path name to get the directory for its def-file. But if there is another object placed at the first position, this doesn't work. The patch moves these parts to their right position. The patch also changes the prefered library names from bcpp_xxx.lib to xxx_bcpp.lib. The next is not a bug. I tried distutils with BeOS R5. BeOS uses also some linker scripts (as AIX does.) But in the Makefile are again the wrong pathnames to these scripts. So we have to correct this as for AIX in sysconfig.py. (Python doesn't install these scripts, I will put a patch for its Makefile.in to sourceforge.) And finally some corrections to the comments in my cygwinccompiler class. Kind regards Rene Liebscher diff -BurN --minimal --exclude=*.pyc distutils.orig/distutils/bcppcompiler.py distutils.patched/distutils/bcppcompiler.py --- distutils.orig/distutils/bcppcompiler.py Mon Aug 14 15:13:04 2000 +++ distutils.patched/distutils/bcppcompiler.py Thu Aug 17 12:58:03 2000 @@ -224,17 +224,6 @@ else: ld_args = self.ldflags_shared[:] - # Borland C++ has problems with '/' in paths - objects = map(os.path.normpath, objects) - startup_obj = 'c0d32' - objects.insert(0, startup_obj) - - # either exchange python15.lib in the python libs directory against - # a Borland-like one, or create one with name bcpp_python15.lib - # there and remove the pragmas from config.h - libraries.append ('import32') - libraries.append ('cw32mt') - # Create a temporary exports file for use by the linker head, tail = os.path.split (output_filename) modname, ext = os.path.splitext (tail) @@ -246,6 +235,17 @@ self.execute(write_file, (def_file, contents), "writing %s" % def_file) + # Borland C++ has problems with '/' in paths + objects = map(os.path.normpath, objects) + startup_obj = 'c0d32' + objects.insert(0, startup_obj) + + # either exchange python15.lib in the python libs directory against + # a Borland-like one, or create one with name bcpp_python15.lib + # there and remove the pragmas from config.h + libraries.append ('import32') + libraries.append ('cw32mt') + # Start building command line flags and options. for l in library_dirs: @@ -377,9 +377,9 @@ # seems to have a different format for static libraries. if debug: dlib = (lib + "_d") - try_names = ("bcpp_" + dlib, "bcpp_" + lib, dlib, lib) + try_names = (dlib + "_bcpp", lib + "_bcpp", dlib, lib) else: - try_names = ("bcpp_" + lib, lib) + try_names = (lib + "_bcpp", lib) for dir in dirs: for name in try_names: diff -BurN --minimal --exclude=*.pyc distutils.orig/distutils/command/bdist.py distutils.patched/distutils/command/bdist.py --- distutils.orig/distutils/command/bdist.py Thu Aug 3 11:00:00 2000 +++ distutils.patched/distutils/command/bdist.py Thu Aug 17 13:14:58 2000 @@ -102,6 +102,9 @@ def run (self): + # create dist directory + self.mkpath(self.dist_dir) + for format in self.formats: try: cmd_name = self.format_command[format][0] diff -BurN --minimal --exclude=*.pyc distutils.orig/distutils/command/bdist_wininst.py distutils.patched/distutils/command/bdist_wininst.py --- distutils.orig/distutils/command/bdist_wininst.py Tue Aug 8 13:18:38 2000 +++ distutils.patched/distutils/command/bdist_wininst.py Thu Aug 17 13:08:20 2000 @@ -137,8 +137,12 @@ # 'info' will be displayed in the installer's dialog box, # describing the items to be installed. - info = metadata.long_description + '\n' - + if metadata.long_description: + info = metadata.long_description + '\n' + else: + self.warn ('no long_description available') + info = '' + for name in dir (metadata): if (name != 'long_description'): data = getattr (metadata, name) diff -BurN --minimal --exclude=*.pyc distutils.orig/distutils/cygwinccompiler.py distutils.patched/distutils/cygwinccompiler.py --- distutils.orig/distutils/cygwinccompiler.py Mon Aug 14 15:13:04 2000 +++ distutils.patched/distutils/cygwinccompiler.py Thu Aug 17 12:59:50 2000 @@ -18,7 +18,7 @@ # # see also http://starship.python.net/crew/kernr/mingw32/Notes.html # -# * We use put export_symbols in a def-file, and don't use +# * We put export_symbols in a def-file, and don't use # --export-all-symbols because it doesn't worked reliable in some # tested configurations. And because other windows compilers also # need their symbols specified this no serious problem. @@ -32,7 +32,7 @@ # (ld doesn't support -shared, so we use dllwrap) # * cygwin gcc 2.95.2/ld 2.10.90/dllwrap 2.10.90 works now # - its dllwrap doesn't work, there is a bug in binutils 2.10.90 -# see also ..... +# see also http://sources.redhat.com/ml/cygwin/2000-06/msg01274.html # - using gcc -mdll instead dllwrap doesn't work without -static because # it tries to link against dlls instead their import libraries. (If # it finds the dll first.) diff -BurN --minimal --exclude=*.pyc distutils.orig/distutils/sysconfig.py distutils.patched/distutils/sysconfig.py --- distutils.orig/distutils/sysconfig.py Thu Aug 3 11:00:00 2000 +++ distutils.patched/distutils/sysconfig.py Thu Aug 17 13:05:20 2000 @@ -254,6 +254,15 @@ python_exp = os.path.join(python_lib, 'config', 'python.exp') g['LDSHARED'] = "%s %s -bI:%s" % (ld_so_aix, g['CC'], python_exp) + if sys.platform == 'beos': + # Linker script is in the BeOS directory instead the config + # directory. In the Makefile it is relative to the srcdir which after + # installation no longer makes sense + python_lib = get_python_lib(standard_lib=1) + linkerscript_name = os.path.basename(string.split(g['LDSHARED'],' ')[0]) + linkerscript = os.path.join(python_lib, 'BeOS', linkerscript_name) + g['LDSHARED'] = ("%s -L%s/lib -lpython%s" + % (linkerscript,sys.prefix,sys.version[0:3])) def _init_nt():

Hello, a little offtopic, but I am wondering how I can produce a diff automatically from the CVS repository. Lets assume I made a cvs checkout and change some files. Can I produce a diff file with the changes I made by comparing it with the original repository? This would be really convenient. Bastian Kleineidam

Thanks for your help, the cvs diff command is the solution. Bastian Kleineidam

On 17 August 2000, Rene Liebscher said:
Oops! Only a problem in bdist_dumb, because the other bdist commands just happen to use sdist, which did call 'mkpath()' properly. Anyways, I've fixed the problem by adding a couple of 'mkpath()' calls to archive_util.py, which should handle all future tarball-and-zip-file- generating commands.
bdist_wininst fails if no long description exists. It should warn about this, and go ahead.
How precisely does it fail?
Hmm, I knew I should have thought harder about that bit of code. Well, I'll think hard about this patch. ;-)
The patch also changes the prefered library names from bcpp_xxx.lib to xxx_bcpp.lib.
Good -- meant to get this into 0.9.1, but oh well.
Oh, bother. I knew that having if sys.platform == "aix4" in the code wouldn't cut it. Need to think about how to detect this situation -- "Python installed custom linker scripts to build shared extensions on this platform" -- and deal with it generally. ISTR that my first crack that the AIX problem took this approach by just absolut-izing the LD_SO Makefile entry, but this didn't cut it because the ld_so_aix script wasn't in the same location as the Makefile. Or something like that. Can anyone think of the *right* way to do this?
And finally some corrections to the comments in my cygwinccompiler class.
Oh good. Now, can you resubmit your patch as three patches: one for the bcppcompiler.py fixes, one for sysconfig, and one for cygwinccompiler? It's much easier to review and apply them one at a time like that. And make sure you "cvs up" first so you get my fix to archive_util.py! Thanks -- Greg -- Greg Ward - geek gward@python.net http://starship.python.net/~gward/ The world is coming to an end. Please log off.

Greg Ward wrote:
bdist_wininst has the same problem. The patch fixes this. It also changes two other problems. First it raises an PlatformException if you try to use it with modules which contain compiled C-extensions. Distutils doesn't support crosscompiling. The second changes the directory of the ini-file which is created. It is now created in the dist directory instead in the current.
the right ones (sys.prefix + /include + /python16 ) if they are not already there. The other is to check the names of the executable file (using the new find_executable() from spawn.py) Something like this: ################################################# ld_shared = string.split(LD_SHARED) if not find_executable(ld_shared[0]): ld = string.split(ld_shared[0],os.sep) possible_places = string.join([sys.prefix + '/lib/config', sys.prefix + '/lib', '.'],os.pathsep) # for ld="a/b/c" try "c","b/c","a/b/c" for i in range(len(ld)): executable = find_executable(os.path.join(ld[-(1+i):]),possible_places) if executable: ld_shared[0]=executable break LD_SHARED = string.join(ld_shared) ################################################ This would work for most platforms, but there is still a problem: the path to the exports-file 'python.exp' on AIX. The attached patch uses still the old solution.
And the patches: sysconfig.patch: * add code to _init_posix to fix path to the linker script cygwin.patch: * correct some mistakes in the comments bcppcompiler.patch: * reverse searched library names from bcpp_library to library_bcpp * move some code to the right places, to put the def-files in the right drectories again bdist_wininst.patch: * create dist directory * raise exception if using for modules containing compiled extensions on a non win32 platform. * change creation of ini-file, so it is now created in the dist directory instead the current one. Kind regards Rene Liebscher

It seems I attached the patches to a wrong mail. Here they are. Kind regards Rene Liebscher diff -BurN --exclude=*.pyc --minimal distutils.orig/distutils/bcppcompiler.py distutils.patched/distutils/bcppcompiler.py --- distutils.orig/distutils/bcppcompiler.py Mon Aug 14 15:13:04 2000 +++ distutils.patched/distutils/bcppcompiler.py Wed Aug 30 11:18:07 2000 @@ -224,17 +224,6 @@ else: ld_args = self.ldflags_shared[:] - # Borland C++ has problems with '/' in paths - objects = map(os.path.normpath, objects) - startup_obj = 'c0d32' - objects.insert(0, startup_obj) - - # either exchange python15.lib in the python libs directory against - # a Borland-like one, or create one with name bcpp_python15.lib - # there and remove the pragmas from config.h - libraries.append ('import32') - libraries.append ('cw32mt') - # Create a temporary exports file for use by the linker head, tail = os.path.split (output_filename) modname, ext = os.path.splitext (tail) @@ -246,6 +235,17 @@ self.execute(write_file, (def_file, contents), "writing %s" % def_file) + # Borland C++ has problems with '/' in paths + objects = map(os.path.normpath, objects) + startup_obj = 'c0d32' + objects.insert(0, startup_obj) + + # either exchange python15.lib in the python libs directory against + # a Borland-like one, or create one with name bcpp_python15.lib + # there and remove the pragmas from config.h + libraries.append ('import32') + libraries.append ('cw32mt') + # Start building command line flags and options. for l in library_dirs: @@ -377,9 +377,9 @@ # seems to have a different format for static libraries. if debug: dlib = (lib + "_d") - try_names = ("bcpp_" + dlib, "bcpp_" + lib, dlib, lib) + try_names = (dlib + "_bcpp", lib + "_bcpp", dlib, lib) else: - try_names = ("bcpp_" + lib, lib) + try_names = (lib + "_bcpp", lib) for dir in dirs: for name in try_names: diff -BurN --exclude=*.pyc --minimal distutils.orig/distutils/sysconfig.py distutils.patched/distutils/sysconfig.py --- distutils.orig/distutils/sysconfig.py Thu Aug 3 11:00:00 2000 +++ distutils.patched/distutils/sysconfig.py Wed Aug 30 11:18:50 2000 @@ -254,6 +254,15 @@ python_exp = os.path.join(python_lib, 'config', 'python.exp') g['LDSHARED'] = "%s %s -bI:%s" % (ld_so_aix, g['CC'], python_exp) + if sys.platform == 'beos': + # Linker script is in the config directory. + # In the Makefile it is relative to the srcdir, which after + # installation no longer makes sense + python_lib = get_python_lib(standard_lib=1) + linkerscript_name = os.path.basename(string.split(g['LDSHARED'],' ')[0]) + linkerscript = os.path.join(python_lib, 'config', linkerscript_name) + g['LDSHARED'] = ("%s -L%s/lib -lpython%s" + % (linkerscript,sys.prefix,sys.version[0:3])) def _init_nt(): diff -BurN --exclude=*.pyc --minimal distutils.orig/distutils/cygwinccompiler.py distutils.patched/distutils/cygwinccompiler.py --- distutils.orig/distutils/cygwinccompiler.py Mon Aug 14 15:13:04 2000 +++ distutils.patched/distutils/cygwinccompiler.py Wed Aug 30 11:18:07 2000 @@ -18,7 +18,7 @@ # # see also http://starship.python.net/crew/kernr/mingw32/Notes.html # -# * We use put export_symbols in a def-file, and don't use +# * We put export_symbols in a def-file, and don't use # --export-all-symbols because it doesn't worked reliable in some # tested configurations. And because other windows compilers also # need their symbols specified this no serious problem. @@ -32,7 +32,7 @@ # (ld doesn't support -shared, so we use dllwrap) # * cygwin gcc 2.95.2/ld 2.10.90/dllwrap 2.10.90 works now # - its dllwrap doesn't work, there is a bug in binutils 2.10.90 -# see also ..... +# see also http://sources.redhat.com/ml/cygwin/2000-06/msg01274.html # - using gcc -mdll instead dllwrap doesn't work without -static because # it tries to link against dlls instead their import libraries. (If # it finds the dll first.) diff -BurN --exclude=*.pyc --minimal distutils.orig/distutils/command/bdist_wininst.py distutils.patched/distutils/command/bdist_wininst.py --- distutils.orig/distutils/command/bdist_wininst.py Wed Aug 30 11:03:53 2000 +++ distutils.patched/distutils/command/bdist_wininst.py Wed Aug 30 11:29:38 2000 @@ -64,6 +64,15 @@ def run (self): + if (sys.platform <> "win32" and + ( self.distribution.has_ext_modules() + or self.distribution.has_c_libraries() + or self.distribution.has_scripts())): + raise DistutilsPlatformError ( +# first line is shorter because it is preceeded by the exception class +"""*** If your module contains compiled +extensions, you have to build the win32 installer on a win32 platform. ***""") + self.run_command ('build') install = self.reinitialize_command('install') @@ -109,7 +118,8 @@ # a file is (at least) useful for debugging bdist_wininst. metadata = self.distribution.metadata - ini_name = "%s.ini" % metadata.get_fullname() + ini_name = os.path.join(self.dist_dir, + "%s.ini" % metadata.get_fullname()) self.announce ("creating %s" % ini_name) inifile = open (ini_name, "w") @@ -149,6 +159,8 @@ def create_exe (self, arcname, fullname): import struct#, zlib + self.mkpath(self.dist_dir) + cfgdata = open (self.create_inifile()).read() installer_name = os.path.join(self.dist_dir,

Thanks for finding this (and for looking at bdist_wininst at all). I've applied your patches to my version of bdist_wininst, with one exception: The ini-data is no longer written to a separate file at all, this was more or less for debugging. Thomas The patch now is: Index: bdist_wininst.py =================================================================== RCS file: /cvsroot/python/distutils/distutils/command/bdist_wininst.py,v retrieving revision 1.7 diff -c -r1.7 bdist_wininst.py *** bdist_wininst.py 2000/08/27 20:44:13 1.7 --- bdist_wininst.py 2000/08/30 13:39:23 *************** *** 63,68 **** --- 63,77 ---- def run (self): + if (sys.platform <> "win32" and + ( self.distribution.has_ext_modules() + or self.distribution.has_c_libraries() + or self.distribution.has_scripts())): + raise DistutilsPlatformError ( + # first line is shorter because it is + # preceeded by the exception class + """*** If your module contains compiled + extensions, you have to build the win32 installer on a win32 platform.""") self.run_command ('build') *************** *** 103,123 **** # run() ! def create_inifile (self): ! # Create an inifile containing data describing the installation. ! # This could be done without creating a real file, but ! # a file is (at least) useful for debugging bdist_wininst. metadata = self.distribution.metadata - ini_name = "%s.ini" % metadata.get_fullname() - self.announce ("creating %s" % ini_name) - inifile = open (ini_name, "w") - # Write the [metadata] section. Values are written with # repr()[1:-1], so they do not contain unprintable characters, and # are not surrounded by quote chars. ! inifile.write ("[metadata]\n") # 'info' will be displayed in the installer's dialog box, # describing the items to be installed. --- 112,127 ---- # run() ! def get_inidata (self): ! # Return data describing the installation. + lines = [] metadata = self.distribution.metadata # Write the [metadata] section. Values are written with # repr()[1:-1], so they do not contain unprintable characters, and # are not surrounded by quote chars. ! lines.append ("[metadata]") # 'info' will be displayed in the installer's dialog box, # describing the items to be installed. *************** *** 129,155 **** if data: info = info + ("\n %s: %s" % \ (string.capitalize (name), data)) ! inifile.write ("%s=%s\n" % (name, repr (data)[1:-1])) # The [setup] section contains entries controlling # the installer runtime. ! inifile.write ("\n[Setup]\n") ! inifile.write ("info=%s\n" % repr (info)[1:-1]) ! inifile.write ("pthname=%s.%s\n" % (metadata.name, metadata.version)) if self.target_version: ! inifile.write ("target_version=%s\n" % self.target_version) title = self.distribution.get_fullname() ! inifile.write ("title=%s\n" % repr (title)[1:-1]) ! inifile.close() ! return ini_name ! # create_inifile() def create_exe (self, arcname, fullname): ! import struct#, zlib ! cfgdata = open (self.create_inifile()).read() installer_name = os.path.join(self.dist_dir, "%s.win32.exe" % fullname) --- 133,160 ---- if data: info = info + ("\n %s: %s" % \ (string.capitalize (name), data)) ! lines.append ("%s=%s" % (name, repr (data)[1:-1])) # The [setup] section contains entries controlling # the installer runtime. ! lines.append ("\n[Setup]") ! lines.append ("info=%s" % repr (info)[1:-1]) ! lines.append ("pthname=%s.%s" % (metadata.name, metadata.version)) if self.target_version: ! lines.append ("target_version=%s" % self.target_version) title = self.distribution.get_fullname() ! lines.append ("title=%s" % repr (title)[1:-1]) ! return string.join (lines, "\n") ! # get_inidata() def create_exe (self, arcname, fullname): ! import struct ! ! self.mkpath(self.dist_dir) ! cfgdata = self.get_inidata() installer_name = os.path.join(self.dist_dir, "%s.win32.exe" % fullname)

On 30 August 2000, Thomas Heller said:
One comment on this patch, for either Rene or Thomas (whoever wrote the code in question).
^^^^^^^^^^^ Why blow up if trying to build a script-ful distribution for Windows under (say) Unix? Yeah, sure, we'll be doing unnecessary work in setting the #! line to point to /usr/bin/python (or whatever), but I don't see any Windows-specific code in build_scripts.py.
Please, no newlines in exception messages: however you handle this is a crock, but the crock used throughout the Distutils is to assume that someday, some clever tool will nicely reformat those run-on exception messages. Also, the "***" doesn't add anything: the fact that the script blows up with an error message should be attention-getting enough. OK, I'll check it in without the ban on script-ful distributions, and with the exception-raising code rewritten. Greg

Ooh, but wouldn't it be cool if I could compile Windows extensions on Linux and vice-versa... oh, never mind!
OK, but: the addition of -l/usr/lib -Lpython2.0 should be done in a BeOS-specific section of build_ext, which is consistent with how we add the Python library for non-MS compilers on Windows. Probably the 'get_libraries()' method should be extended to take care of both library directory and name, and then a BeOS clause can be added. sysconfig is for describing the Python installation; knowledge about how to build extensions belongs in build_ext.
OK, checked both of these in.
I'll use Thomas' version of this patch instead. Greg

Thomas Heller wrote:
It would be cool, but then you probably need special options for the compiler or may be a new cross-compiler class. (It would use different extensions than the standard unix compiler '.dll'<>'.so') Until someone has a solution for that, we should prevent users from creating installers that don't work. (Maybe we need then an option 'target_platform' for build_ext, this could then also be used to allow creation of the installer.) Kind regards Rene Liebscher

Hello, a little offtopic, but I am wondering how I can produce a diff automatically from the CVS repository. Lets assume I made a cvs checkout and change some files. Can I produce a diff file with the changes I made by comparing it with the original repository? This would be really convenient. Bastian Kleineidam

Thanks for your help, the cvs diff command is the solution. Bastian Kleineidam

On 17 August 2000, Rene Liebscher said:
Oops! Only a problem in bdist_dumb, because the other bdist commands just happen to use sdist, which did call 'mkpath()' properly. Anyways, I've fixed the problem by adding a couple of 'mkpath()' calls to archive_util.py, which should handle all future tarball-and-zip-file- generating commands.
bdist_wininst fails if no long description exists. It should warn about this, and go ahead.
How precisely does it fail?
Hmm, I knew I should have thought harder about that bit of code. Well, I'll think hard about this patch. ;-)
The patch also changes the prefered library names from bcpp_xxx.lib to xxx_bcpp.lib.
Good -- meant to get this into 0.9.1, but oh well.
Oh, bother. I knew that having if sys.platform == "aix4" in the code wouldn't cut it. Need to think about how to detect this situation -- "Python installed custom linker scripts to build shared extensions on this platform" -- and deal with it generally. ISTR that my first crack that the AIX problem took this approach by just absolut-izing the LD_SO Makefile entry, but this didn't cut it because the ld_so_aix script wasn't in the same location as the Makefile. Or something like that. Can anyone think of the *right* way to do this?
And finally some corrections to the comments in my cygwinccompiler class.
Oh good. Now, can you resubmit your patch as three patches: one for the bcppcompiler.py fixes, one for sysconfig, and one for cygwinccompiler? It's much easier to review and apply them one at a time like that. And make sure you "cvs up" first so you get my fix to archive_util.py! Thanks -- Greg -- Greg Ward - geek gward@python.net http://starship.python.net/~gward/ The world is coming to an end. Please log off.

Greg Ward wrote:
bdist_wininst has the same problem. The patch fixes this. It also changes two other problems. First it raises an PlatformException if you try to use it with modules which contain compiled C-extensions. Distutils doesn't support crosscompiling. The second changes the directory of the ini-file which is created. It is now created in the dist directory instead in the current.
the right ones (sys.prefix + /include + /python16 ) if they are not already there. The other is to check the names of the executable file (using the new find_executable() from spawn.py) Something like this: ################################################# ld_shared = string.split(LD_SHARED) if not find_executable(ld_shared[0]): ld = string.split(ld_shared[0],os.sep) possible_places = string.join([sys.prefix + '/lib/config', sys.prefix + '/lib', '.'],os.pathsep) # for ld="a/b/c" try "c","b/c","a/b/c" for i in range(len(ld)): executable = find_executable(os.path.join(ld[-(1+i):]),possible_places) if executable: ld_shared[0]=executable break LD_SHARED = string.join(ld_shared) ################################################ This would work for most platforms, but there is still a problem: the path to the exports-file 'python.exp' on AIX. The attached patch uses still the old solution.
And the patches: sysconfig.patch: * add code to _init_posix to fix path to the linker script cygwin.patch: * correct some mistakes in the comments bcppcompiler.patch: * reverse searched library names from bcpp_library to library_bcpp * move some code to the right places, to put the def-files in the right drectories again bdist_wininst.patch: * create dist directory * raise exception if using for modules containing compiled extensions on a non win32 platform. * change creation of ini-file, so it is now created in the dist directory instead the current one. Kind regards Rene Liebscher

It seems I attached the patches to a wrong mail. Here they are. Kind regards Rene Liebscher diff -BurN --exclude=*.pyc --minimal distutils.orig/distutils/bcppcompiler.py distutils.patched/distutils/bcppcompiler.py --- distutils.orig/distutils/bcppcompiler.py Mon Aug 14 15:13:04 2000 +++ distutils.patched/distutils/bcppcompiler.py Wed Aug 30 11:18:07 2000 @@ -224,17 +224,6 @@ else: ld_args = self.ldflags_shared[:] - # Borland C++ has problems with '/' in paths - objects = map(os.path.normpath, objects) - startup_obj = 'c0d32' - objects.insert(0, startup_obj) - - # either exchange python15.lib in the python libs directory against - # a Borland-like one, or create one with name bcpp_python15.lib - # there and remove the pragmas from config.h - libraries.append ('import32') - libraries.append ('cw32mt') - # Create a temporary exports file for use by the linker head, tail = os.path.split (output_filename) modname, ext = os.path.splitext (tail) @@ -246,6 +235,17 @@ self.execute(write_file, (def_file, contents), "writing %s" % def_file) + # Borland C++ has problems with '/' in paths + objects = map(os.path.normpath, objects) + startup_obj = 'c0d32' + objects.insert(0, startup_obj) + + # either exchange python15.lib in the python libs directory against + # a Borland-like one, or create one with name bcpp_python15.lib + # there and remove the pragmas from config.h + libraries.append ('import32') + libraries.append ('cw32mt') + # Start building command line flags and options. for l in library_dirs: @@ -377,9 +377,9 @@ # seems to have a different format for static libraries. if debug: dlib = (lib + "_d") - try_names = ("bcpp_" + dlib, "bcpp_" + lib, dlib, lib) + try_names = (dlib + "_bcpp", lib + "_bcpp", dlib, lib) else: - try_names = ("bcpp_" + lib, lib) + try_names = (lib + "_bcpp", lib) for dir in dirs: for name in try_names: diff -BurN --exclude=*.pyc --minimal distutils.orig/distutils/sysconfig.py distutils.patched/distutils/sysconfig.py --- distutils.orig/distutils/sysconfig.py Thu Aug 3 11:00:00 2000 +++ distutils.patched/distutils/sysconfig.py Wed Aug 30 11:18:50 2000 @@ -254,6 +254,15 @@ python_exp = os.path.join(python_lib, 'config', 'python.exp') g['LDSHARED'] = "%s %s -bI:%s" % (ld_so_aix, g['CC'], python_exp) + if sys.platform == 'beos': + # Linker script is in the config directory. + # In the Makefile it is relative to the srcdir, which after + # installation no longer makes sense + python_lib = get_python_lib(standard_lib=1) + linkerscript_name = os.path.basename(string.split(g['LDSHARED'],' ')[0]) + linkerscript = os.path.join(python_lib, 'config', linkerscript_name) + g['LDSHARED'] = ("%s -L%s/lib -lpython%s" + % (linkerscript,sys.prefix,sys.version[0:3])) def _init_nt(): diff -BurN --exclude=*.pyc --minimal distutils.orig/distutils/cygwinccompiler.py distutils.patched/distutils/cygwinccompiler.py --- distutils.orig/distutils/cygwinccompiler.py Mon Aug 14 15:13:04 2000 +++ distutils.patched/distutils/cygwinccompiler.py Wed Aug 30 11:18:07 2000 @@ -18,7 +18,7 @@ # # see also http://starship.python.net/crew/kernr/mingw32/Notes.html # -# * We use put export_symbols in a def-file, and don't use +# * We put export_symbols in a def-file, and don't use # --export-all-symbols because it doesn't worked reliable in some # tested configurations. And because other windows compilers also # need their symbols specified this no serious problem. @@ -32,7 +32,7 @@ # (ld doesn't support -shared, so we use dllwrap) # * cygwin gcc 2.95.2/ld 2.10.90/dllwrap 2.10.90 works now # - its dllwrap doesn't work, there is a bug in binutils 2.10.90 -# see also ..... +# see also http://sources.redhat.com/ml/cygwin/2000-06/msg01274.html # - using gcc -mdll instead dllwrap doesn't work without -static because # it tries to link against dlls instead their import libraries. (If # it finds the dll first.) diff -BurN --exclude=*.pyc --minimal distutils.orig/distutils/command/bdist_wininst.py distutils.patched/distutils/command/bdist_wininst.py --- distutils.orig/distutils/command/bdist_wininst.py Wed Aug 30 11:03:53 2000 +++ distutils.patched/distutils/command/bdist_wininst.py Wed Aug 30 11:29:38 2000 @@ -64,6 +64,15 @@ def run (self): + if (sys.platform <> "win32" and + ( self.distribution.has_ext_modules() + or self.distribution.has_c_libraries() + or self.distribution.has_scripts())): + raise DistutilsPlatformError ( +# first line is shorter because it is preceeded by the exception class +"""*** If your module contains compiled +extensions, you have to build the win32 installer on a win32 platform. ***""") + self.run_command ('build') install = self.reinitialize_command('install') @@ -109,7 +118,8 @@ # a file is (at least) useful for debugging bdist_wininst. metadata = self.distribution.metadata - ini_name = "%s.ini" % metadata.get_fullname() + ini_name = os.path.join(self.dist_dir, + "%s.ini" % metadata.get_fullname()) self.announce ("creating %s" % ini_name) inifile = open (ini_name, "w") @@ -149,6 +159,8 @@ def create_exe (self, arcname, fullname): import struct#, zlib + self.mkpath(self.dist_dir) + cfgdata = open (self.create_inifile()).read() installer_name = os.path.join(self.dist_dir,

Thanks for finding this (and for looking at bdist_wininst at all). I've applied your patches to my version of bdist_wininst, with one exception: The ini-data is no longer written to a separate file at all, this was more or less for debugging. Thomas The patch now is: Index: bdist_wininst.py =================================================================== RCS file: /cvsroot/python/distutils/distutils/command/bdist_wininst.py,v retrieving revision 1.7 diff -c -r1.7 bdist_wininst.py *** bdist_wininst.py 2000/08/27 20:44:13 1.7 --- bdist_wininst.py 2000/08/30 13:39:23 *************** *** 63,68 **** --- 63,77 ---- def run (self): + if (sys.platform <> "win32" and + ( self.distribution.has_ext_modules() + or self.distribution.has_c_libraries() + or self.distribution.has_scripts())): + raise DistutilsPlatformError ( + # first line is shorter because it is + # preceeded by the exception class + """*** If your module contains compiled + extensions, you have to build the win32 installer on a win32 platform.""") self.run_command ('build') *************** *** 103,123 **** # run() ! def create_inifile (self): ! # Create an inifile containing data describing the installation. ! # This could be done without creating a real file, but ! # a file is (at least) useful for debugging bdist_wininst. metadata = self.distribution.metadata - ini_name = "%s.ini" % metadata.get_fullname() - self.announce ("creating %s" % ini_name) - inifile = open (ini_name, "w") - # Write the [metadata] section. Values are written with # repr()[1:-1], so they do not contain unprintable characters, and # are not surrounded by quote chars. ! inifile.write ("[metadata]\n") # 'info' will be displayed in the installer's dialog box, # describing the items to be installed. --- 112,127 ---- # run() ! def get_inidata (self): ! # Return data describing the installation. + lines = [] metadata = self.distribution.metadata # Write the [metadata] section. Values are written with # repr()[1:-1], so they do not contain unprintable characters, and # are not surrounded by quote chars. ! lines.append ("[metadata]") # 'info' will be displayed in the installer's dialog box, # describing the items to be installed. *************** *** 129,155 **** if data: info = info + ("\n %s: %s" % \ (string.capitalize (name), data)) ! inifile.write ("%s=%s\n" % (name, repr (data)[1:-1])) # The [setup] section contains entries controlling # the installer runtime. ! inifile.write ("\n[Setup]\n") ! inifile.write ("info=%s\n" % repr (info)[1:-1]) ! inifile.write ("pthname=%s.%s\n" % (metadata.name, metadata.version)) if self.target_version: ! inifile.write ("target_version=%s\n" % self.target_version) title = self.distribution.get_fullname() ! inifile.write ("title=%s\n" % repr (title)[1:-1]) ! inifile.close() ! return ini_name ! # create_inifile() def create_exe (self, arcname, fullname): ! import struct#, zlib ! cfgdata = open (self.create_inifile()).read() installer_name = os.path.join(self.dist_dir, "%s.win32.exe" % fullname) --- 133,160 ---- if data: info = info + ("\n %s: %s" % \ (string.capitalize (name), data)) ! lines.append ("%s=%s" % (name, repr (data)[1:-1])) # The [setup] section contains entries controlling # the installer runtime. ! lines.append ("\n[Setup]") ! lines.append ("info=%s" % repr (info)[1:-1]) ! lines.append ("pthname=%s.%s" % (metadata.name, metadata.version)) if self.target_version: ! lines.append ("target_version=%s" % self.target_version) title = self.distribution.get_fullname() ! lines.append ("title=%s" % repr (title)[1:-1]) ! return string.join (lines, "\n") ! # get_inidata() def create_exe (self, arcname, fullname): ! import struct ! ! self.mkpath(self.dist_dir) ! cfgdata = self.get_inidata() installer_name = os.path.join(self.dist_dir, "%s.win32.exe" % fullname)

On 30 August 2000, Thomas Heller said:
One comment on this patch, for either Rene or Thomas (whoever wrote the code in question).
^^^^^^^^^^^ Why blow up if trying to build a script-ful distribution for Windows under (say) Unix? Yeah, sure, we'll be doing unnecessary work in setting the #! line to point to /usr/bin/python (or whatever), but I don't see any Windows-specific code in build_scripts.py.
Please, no newlines in exception messages: however you handle this is a crock, but the crock used throughout the Distutils is to assume that someday, some clever tool will nicely reformat those run-on exception messages. Also, the "***" doesn't add anything: the fact that the script blows up with an error message should be attention-getting enough. OK, I'll check it in without the ban on script-ful distributions, and with the exception-raising code rewritten. Greg

Ooh, but wouldn't it be cool if I could compile Windows extensions on Linux and vice-versa... oh, never mind!
OK, but: the addition of -l/usr/lib -Lpython2.0 should be done in a BeOS-specific section of build_ext, which is consistent with how we add the Python library for non-MS compilers on Windows. Probably the 'get_libraries()' method should be extended to take care of both library directory and name, and then a BeOS clause can be added. sysconfig is for describing the Python installation; knowledge about how to build extensions belongs in build_ext.
OK, checked both of these in.
I'll use Thomas' version of this patch instead. Greg

Thomas Heller wrote:
It would be cool, but then you probably need special options for the compiler or may be a new cross-compiler class. (It would use different extensions than the standard unix compiler '.dll'<>'.so') Until someone has a solution for that, we should prevent users from creating installers that don't work. (Maybe we need then an option 'target_platform' for build_ext, this could then also be used to allow creation of the installer.) Kind regards Rene Liebscher
participants (5)
-
Bastian Kleineidam
-
Fred L. Drake, Jr.
-
Greg Ward
-
Rene Liebscher
-
Thomas Heller