[Python-Dev] PEP 376

Tarek Ziadé ziade.tarek at gmail.com
Thu Jul 2 15:45:23 CEST 2009


On Thu, Jul 2, 2009 at 2:39 PM, Paul Moore<p.f.moore at gmail.com> wrote:
> 2009/7/2 Tarek Ziadé <ziade.tarek at gmail.com>:
>> 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'

(which makes me realizes that there's no way to force the installation
data_files in another drive under windows:
  the binary distribution will be the same, no matter what drive you
use in the absolute path used in data_files
I'll add an issue on this)

>
> But the immediate answer is that there are *no* reliable "absolute"
> paths on Windows, so you're not looking at the likes of /usr/doc, but
> rather paths that are relative to sys.prefix, but not to the package
> directory. In that case, the key point is that if the installer is
> built on a system where Python is installed in a different directory
> than the system where the installer is run, paths need to be
> relocated. (E.g., C:\Python27 vs D:\Apps\Python27).

I get the point: they are three levels we should handle in the RECORD file

1. absolute paths
2. paths relative to sys.prefix or sys.exec_prefix
3. paths relative to the directory where the .egg-info directory is located

the RECORD file doesn't handle 2. indeed. For instance you can add a script:

setup(
..
scripts=['myscript.py']
..)

that will get installed in : sys.prefix + 'Scripts/myscript.py'  under
win32 for instance

So a possible solution is to add 2. in the RECORD files by using a
notation such as
"$PREFIX" "$EXEC_PREFIX" when we detect that the file is under on of
these paths.

The query functions will then be able to use sys.prefix and
sys.exec_prefix for recompose
the absolute pat on the target system


>
> Paul.
>



-- 
Tarek Ziadé | http://ziade.org


More information about the Python-Dev mailing list