[Distutils] some small bugs
Rene Liebscher
R.Liebscher@gmx.de
Wed Aug 30 06:18:08 2000
Greg Ward wrote:
>
> On 17 August 2000, Rene Liebscher said:
> > 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.)
>
> 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 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.
> > 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.
>
> 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.
>
> > 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.)
>
> 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?
Maybe one should think about a kind of filter for LD_SHARED and other
stuff.
One thing is to remove invalid pathnames like -I.. or -L.. and add
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 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!
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