Issue9023
Created on 2010-06-18 08:47 by ghazel, last changed 2010-08-21 17:42 by ghazel.
| Messages (5) | |||
|---|---|---|---|
| msg108085 - (view) | Author: Greg Hazel (ghazel) | Date: 2010-06-18 08:47 | |
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@duma:~$ mkdir libfoo gah@duma:~$ cd libfoo gah@duma:~/libfoo$ echo > foo.c gah@duma:~/libfoo$ mkdir pyfoo gah@duma:~/libfoo$ cd pyfoo gah@duma:~/libfoo/pyfoo$ echo "from setuptools import setup, Library; setup(name='foo', ext_modules=[Library(name='foo',sources=['../foo.c'])])" > setup.py gah@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. |
|||
| msg114509 - (view) | Author: Éric Araujo (eric.araujo) * ![]() |
Date: 2010-08-21 16:43 | |
I’m not sure how I feel about paths going to the parent directory. Your use case is not imaginary or contrived, but I’m uncomfortable with going out of the source tree. Your setup script would work if the setup script was in the root of the source tree, right? In this case, I would requalify this as a doc bug. Can you test this solution (also with distutils-only code)? Thank you. |
|||
| msg114520 - (view) | Author: Greg Hazel (ghazel) | Date: 2010-08-21 17:18 | |
The python setup script is for the python module, which is in a subdirectory of the C library project. I am not going to move setup.py to the root directory just to work around a a distutils bug. This distutils bug could cause it to overwrite files in other directories, since it blindly adds relative paths to the build directory. This is clearly broken. I've changed my code to use os.path.abspath() while I wait for a fix. |
|||
| msg114521 - (view) | Author: Éric Araujo (eric.araujo) * ![]() |
Date: 2010-08-21 17:24 | |
> I am not going to move setup.py to the root directory just to work > around a a distutils bug. Fair enough. > This distutils bug could cause it to overwrite files in other > directories, since it blindly adds relative paths to the build > directory. This is clearly broken. Ah, I hadn’t understood that. I agree with you. > I've changed my code to use os.path.abspath() while I wait for a > fix. Does this means that your code works with paths that go to the parent directory? I don’t know if it’s right to allow that (I mean this literally: I’m not the main maintainer and I don’t have much packaging experience). |
|||
| msg114528 - (view) | Author: Greg Hazel (ghazel) | Date: 2010-08-21 17:42 | |
> Éric Araujo <merwok@netwok.org> added the comment: >> I've changed my code to use os.path.abspath() while I wait for a >> fix. > Does this means that your code works with paths that go to the parent directory? I don’t know if it’s right to allow that (I mean this literally: I’m not the main maintainer and I don’t have much packaging experience). Yes, my code works with the os.path.abspath() change, since it creates the entire absolute path directory structure inside the build directory. This is |
|||
| History | |||
|---|---|---|---|
| Date | User | Action | Args |
| 2010-08-21 17:42:46 | ghazel | set | messages: + msg114528 |
| 2010-08-21 17:24:41 | eric.araujo | set | messages: + msg114521 |
| 2010-08-21 17:18:33 | ghazel | set | messages: + msg114520 |
| 2010-08-21 16:43:42 | eric.araujo | set | messages:
+ msg114509 versions: + Python 3.1, Python 2.7 |
| 2010-06-19 05:01:50 | eric.araujo | set | nosy:
+ eric.araujo versions: + Python 3.2, - Python 2.6, Python 2.5 |
| 2010-06-18 08:47:29 | ghazel | create | |
