[Python-bugs-list] [ python-Bugs-668662 ] Compiling C sources with absolute path bug

SourceForge.net noreply@sourceforge.net
Wed, 15 Jan 2003 11:48:40 -0800


Bugs item #668662, was opened at 2003-01-15 20:59
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=668662&group_id=5470

Category: Distutils
Group: Python 2.3
Status: Open
Resolution: None
Priority: 5
Submitted By: Pearu Peterson (pearu)
Assigned to: A.M. Kuchling (akuchling)
Summary: Compiling C sources with absolute path bug

Initial Comment:
Py-2.3 distutils is broken in the following situation
when building extension modules:
If a file in C sources list is given with absolute
path, say
/path/to/foo.c then Py-2.3 distutils tries to create
the corresponding    
object file to /path/to/foo.o (earlier versions would
create it to, say, build/temp.linux-i686-2.2/foo.o).
This causes problems when
1) an user does not have permissions to write to
/path/to/, e.g. in multiuser systems
2) an user builds extension modules, say, using
different compilers or flags. Then /path/to/foo.o will
be in a way for subsequent builds.
IMHO, distutils should not create any files outside the
given
build directory, unless explicitely specified using
--build-temp.

Fix:
The problematic code seems to be in the method
ccompiler.object_filenames in file distutils/ccompiler.py.
As a fix, I suggest using the following object name for
a C source if given with absolute path: 
  ./build/temp.linux-i686-2.2/path/to/foo.o.

This can be achived by inserting the following line
just after
the line `base, ext = os.path.splitext(src_name)`:

 base = base[os.path.isabs(base):]

Pearu

----------------------------------------------------------------------

>Comment By: Pearu Peterson (pearu)
Date: 2003-01-15 21:48

Message:
Logged In: YES 
user_id=88489

FYI, distutils does not make this absolute path, but one can
specify
absolute paths in setup.py files, for instance.
Also, tools that create extension modules (e.g. f2py), may
ship with C sources that are installed as data files and
compiled
for each generated extension module separately (possibly
with different
compilers and flags so that pre-compilation of such sources
would not be an option).


----------------------------------------------------------------------

Comment By: Michael Hudson (mwh)
Date: 2003-01-15 21:23

Message:
Logged In: YES 
user_id=6656

I'm a little boggled by how distutils would get an absolute
path, but I'm going to assign this to amk anyway :)

----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=668662&group_id=5470