This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: Compiling C sources with absolute path bug
Type: Stage:
Components: Distutils Versions: Python 2.3
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: akuchling Nosy List: akuchling, mwh, pearu
Priority: normal Keywords:

Created on 2003-01-15 18:59 by pearu, last changed 2022-04-10 16:06 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
force_relpath_distutils_ccompiler.diff pearu, 2003-02-16 20:11 Patch fixing 668662
Messages (6)
msg14081 - (view) Author: Pearu Peterson (pearu) Date: 2003-01-15 18:59
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
msg14082 - (view) Author: Michael Hudson (mwh) (Python committer) Date: 2003-01-15 19:23
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 :)
msg14083 - (view) Author: Pearu Peterson (pearu) Date: 2003-01-15 19:48
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).
msg14084 - (view) Author: Michael Hudson (mwh) (Python committer) Date: 2003-01-16 13:28
Logged In: YES 
user_id=6656

Actually, I guessed after posting that something like that
could happen.

BTW, I strongly suspect this is related to the fix for this bug:

[ 599248 ] ext module generation problem

Can you come up with a patch for your suggested fix?  I'm
sure Andrew would appreciate it :-)
msg14085 - (view) Author: Pearu Peterson (pearu) Date: 2003-02-16 20:11
Logged In: YES 
user_id=88489

Attached patch maps the base of a source file with absolute
path (and 
drive if present) to relative path before composing the
corresponding object file. This avoids creation of object
files out of the build directory. 

Pearu
msg14086 - (view) Author: A.M. Kuchling (akuchling) * (Python committer) Date: 2003-02-26 19:02
Logged In: YES 
user_id=11375

Checked in as patch 1.56 of ccompiler.py.  I'll look into backporting to 2.2.  Thanks!
History
Date User Action Args
2022-04-10 16:06:08adminsetgithub: 37775
2003-01-15 18:59:58pearucreate