2009/7/2 Tarek Ziadé
On Thu, Jul 2, 2009 at 2:39 PM, Paul Moore
wrote: 2009/7/2 Tarek Ziadé
: For absolute paths now that gets installed, what would be the difference between the pre-generated RECORD file and the RECORD file installed on the win32 target system, if any ?
When is an absolute path generated? If you can give me a small sample of a distribution that installs a file in an absolute path, I'll do some testing on Windows.
Try this setup.py file:
""" from distutils.core import setup
setup(name='foo', version='1.0', data_files=[('/tmp', ['data'])]) """
with this MANIFEST.in file: "" include data """
and add a 'data' file alongside
If you install it, data is copied in /tmp. If you create a bdist distribution it will be created in the root of the dumb directory which is used to generate the binary distro.
Of course you'll have to change '/tmp' to 'c:\tmp'
python setup.py bdist_wininst running bdist_wininst running build installing to build\bdist.win32\wininst running install_data creating build creating build\bdist.win32 creating build\bdist.win32\wininst creating build\bdist.win32\wininst\DATA Traceback (most recent call last): File "setup.py", line 3, in <module> setup(name='foo', version='1.0', data_files=[('/tmp', ['data'])]) File "C:\Apps\Python26\lib\distutils\core.py", line 152, in setup dist.run_commands() File "C:\Apps\Python26\lib\distutils\dist.py", line 975, in run_commands self.run_command(cmd) File "C:\Apps\Python26\lib\distutils\dist.py", line 995, in run_command cmd_obj.run() File "C:\Apps\Python26\lib\distutils\command\bdist_wininst.py", line 171, in run install.run() File "C:\Apps\Python26\lib\distutils\command\install.py", line 589, in run self.run_command(cmd_name) File "C:\Apps\Python26\lib\distutils\cmd.py", line 333, in run_command self.distribution.run_command(command) File "C:\Apps\Python26\lib\distutils\dist.py", line 995, in run_command cmd_obj.run() File "C:\Apps\Python26\lib\distutils\command\install_data.py", line 62, in run dir = convert_path(f[0]) File "C:\Apps\Python26\lib\distutils\util.py", line 164, in convert_path raise ValueError, "path '%s' cannot be absolute" % pathname ValueError: path '/tmp' cannot be absolute
Looks like bdist_wininst doesn't support absolute paths. Which isn't surprising, really. Same with bdist_msi. Actually, with setup.py install:
python setup.py install running install running build running install_data Traceback (most recent call last): File "setup.py", line 3, in <module> setup(name='foo', version='1.0', data_files=[('/tmp', ['data'])]) File "C:\Apps\Python26\lib\distutils\core.py", line 152, in setup dist.run_commands() File "C:\Apps\Python26\lib\distutils\dist.py", line 975, in run_commands self.run_command(cmd) File "C:\Apps\Python26\lib\distutils\dist.py", line 995, in run_command cmd_obj.run() File "C:\Apps\Python26\lib\distutils\command\install.py", line 589, in run self.run_command(cmd_name) File "C:\Apps\Python26\lib\distutils\cmd.py", line 333, in run_command self.distribution.run_command(command) File "C:\Apps\Python26\lib\distutils\dist.py", line 995, in run_command cmd_obj.run() File "C:\Apps\Python26\lib\distutils\command\install_data.py", line 62, in run dir = convert_path(f[0]) File "C:\Apps\Python26\lib\distutils\util.py", line 164, in convert_path raise ValueError, "path '%s' cannot be absolute" % pathname ValueError: path '/tmp' cannot be absolute
python setup.py bdist_wininst running bdist_wininst running build installing to build\bdist.win32\wininst running install_data creating build\bdist.win32\wininst\DATA\c:tmp error: could not create 'build\bdist.win32\wininst\DATA\c:tmp': The
So how do absolute paths work??? It sure ain't like this! Changing '/tmp' to c:/tmp' gives this: directory name is invalid Changing it to 'c:\\tmp' gives (sort of) success: python setup.py bdist_wininst running bdist_wininst running build installing to build\bdist.win32\wininst running install_data creating build\bdist.win32\wininst\tmp copying data -> build\bdist.win32\wininst\tmp running install_egg_info Creating build\bdist.win32\wininst\PURELIB\ Writing build\bdist.win32\wininst\PURELIB\foo-1.0-py2.6.egg-info creating 'c:\users\gustav\appdata\local\temp\tmpcs9rmi.zip' and adding '.' to it adding 'PURELIB\foo-1.0-py2.6.egg-info' adding 'tmp\data' creating dist removing 'build\bdist.win32\wininst' (and everything under it) The installer packs a *relative* path tmp/data - which isn't right. bdist_msi copies the data file to c:\tmp - when building the msi!. This is very wrong. I can't introspect a msi file to see what ends up in it, but if I install it, no c:\tmp\data is installed, so it does look like it's screwed up. Frankly, handling of absolute paths looks so broken, that I'd explicitly state that it's not supported. I'd raise bugs for some of these things, but to be honest, I'm not at all sure what I'd expect to be correct behaviour (on Windows). In my view absolute paths shouldn't be supported - I can see that might be different on Linux, but I don't see how it's ever going to be cross-platform. Not sure where that leaves things. Absolute path handling seems broken enough (on Windows) that whatever the PEP says isn't much of an issue, as it's not usable anyway. One definite point, though - given the behaviour of bdist_msi, it thought it had installed something that it simply didn't - so there's a serious risk that the distutils uninstall function could uninstall something that the installer never installed - that's far worse than simply deleting the files and messing up the installer metadata. Maybe the answer is that distutils reject *all* uses of absolute paths on Windows. The PEP can then say whatever you want as far as I'm concerned, as it doesn't affect me. If the existing bugs don't get fixed, though, I'd say that the RECORD file should be explicitly disallowed from containing absolute paths on Windows (for safety reasons if nothing else). Paul.