Commit 85278c01 authored by PJ Eby's avatar PJ Eby

Use relative paths in ``.pth`` files when eggs are being installed to the

same directory as the ``.pth`` file.  This maximizes portability of the
target directory when building applications that contain eggs.

--HG--
branch : setuptools
extra : convert_revision : svn%3A6015fed2-1504-0410-9fe1-9d1591cc4771/sandbox/trunk/setuptools%4043178
parent dae3df10
......@@ -1089,6 +1089,10 @@ Known Issues
time out or be missing a file.
0.6a11
* Use relative paths in ``.pth`` files when eggs are being installed to the
same directory as the ``.pth`` file. This maximizes portability of the
target directory when building applications that contain eggs.
* Added ``easy_install-N.N`` script(s) for convenience when using multiple
Python versions.
......
......@@ -974,7 +974,7 @@ See the setuptools documentation for the "develop" command for more info.
filename = os.path.join(self.install_dir,'setuptools.pth')
if os.path.islink(filename): os.unlink(filename)
f = open(filename, 'wt')
f.write(dist.location+'\n')
f.write(self.pth_file.make_relative(dist.location)+'\n')
f.close()
def unpack_progress(self, src, dst):
......@@ -1316,8 +1316,9 @@ class PthDistributions(Environment):
dirty = False
def __init__(self, filename):
self.filename = filename; self._load()
Environment.__init__(self, [], None, None)
self.filename = filename
self.basedir = normalize_path(os.path.dirname(self.filename))
self._load(); Environment.__init__(self, [], None, None)
for path in yield_lines(self.paths):
map(self.add, find_distributions(path, True))
......@@ -1336,7 +1337,9 @@ class PthDistributions(Environment):
continue
# skip non-existent paths, in case somebody deleted a package
# manually, and duplicate paths as well
path = self.paths[-1] = normalize_path(path)
path = self.paths[-1] = normalize_path(
os.path.join(self.basedir,path)
)
if not os.path.exists(path) or path in seen:
self.paths.pop() # skip it
self.dirty = True # we cleaned up, so we're dirty now :)
......@@ -1345,18 +1348,15 @@ class PthDistributions(Environment):
if self.paths and not saw_import:
self.dirty = True # ensure anything we touch has import wrappers
while self.paths and not self.paths[-1].strip():
self.paths.pop()
def save(self):
"""Write changed .pth file back to disk"""
if not self.dirty:
return
data = '\n'.join(self.paths)
data = '\n'.join(map(self.make_relative,self.paths))
if data:
log.debug("Saving %s", self.filename)
data = (
......@@ -1392,6 +1392,12 @@ class PthDistributions(Environment):
Environment.remove(self,dist)
def make_relative(self,path):
if normalize_path(os.path.dirname(path))==self.basedir:
return os.path.basename(path)
return path
def get_script_header(script_text, executable=sys_executable):
"""Create a #! line, getting options (if any) from script_text"""
from distutils.command.build_scripts import first_line_re
......@@ -1426,12 +1432,6 @@ def auto_chmod(func, arg, exc):
def get_script_args(dist, executable=sys_executable):
"""Yield write_script() argument tuples for a distribution's entrypoints"""
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment