[New-bugs-announce] [issue9023] distutils relative path errors

Greg Hazel report at bugs.python.org
Fri Jun 18 10:47:31 CEST 2010

New submission from Greg Hazel <ghazel at users.sourceforge.net>:

Probably applies to more versions, but I only tested on 2.5.2 and 2.6.5.

Distutils incorrectly constructs paths for the build/temp directory when relative paths are used in the "sources" list. This can result in failing to make the build/temp directory at all, and placing files in outside of the build/temp directory.

Consider the following example:

gah at duma:~$ mkdir libfoo
gah at duma:~$ cd libfoo
gah at duma:~/libfoo$ echo > foo.c
gah at duma:~/libfoo$ mkdir pyfoo
gah at duma:~/libfoo$ cd pyfoo
gah at duma:~/libfoo/pyfoo$ echo "from setuptools import setup, Library; setup(name='foo', ext_modules=[Library(name='foo',sources=['../foo.c'])])" > setup.py
gah at duma:~/libfoo/pyfoo$ python setup.py build
running build
running build_ext
building 'foo' extension
creating build
gcc -pthread -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fPIC -I/usr/include/python2.5 -c ../foo.c -o build/temp.linux-i686-2.5/../foo.o
Assembler messages:
Fatal error: can't create build/temp.linux-i686-2.5/../foo.o: No such file or directory
error: command 'gcc' failed with exit status 1

Using os.path.abspath('../foo.c') in the sources causes distutils to create build/temp.linux-i686-2.5/home/gah/libfoo/foo.o which is fine. However as a user, this situation is quite surprising, since distutils is responsible for managing the build and temp directories itself.

assignee: tarek
components: Distutils
messages: 108085
nosy: ghazel, tarek
priority: normal
severity: normal
status: open
title: distutils relative path errors
type: behavior
versions: Python 2.5, Python 2.6

Python tracker <report at bugs.python.org>

More information about the New-bugs-announce mailing list