diff options
author | Jack Jansen <jack.jansen@cwi.nl> | 2003-02-12 15:36:25 (GMT) |
---|---|---|
committer | Jack Jansen <jack.jansen@cwi.nl> | 2003-02-12 15:36:25 (GMT) |
commit | 53b341ff67f2b7d63db2783734a813354a5e3264 (patch) | |
tree | 3a3d8cdd59b577479a63146bdad004012e0a2a49 | |
parent | 113af98c892e0fb2840a37b491db62df6e5d24ea (diff) | |
download | cpython-53b341ff67f2b7d63db2783734a813354a5e3264.zip cpython-53b341ff67f2b7d63db2783734a813354a5e3264.tar.gz cpython-53b341ff67f2b7d63db2783734a813354a5e3264.tar.bz2 |
- Better way to find site-packages
- Catch stderr as well as stdout
- Fixed a bug with non-installable packages
- Parse .pth files after installing, so you don't have to restart Python (or
the IDE) after installing.
-rw-r--r-- | Lib/plat-mac/pimp.py | 46 |
1 files changed, 43 insertions, 3 deletions
diff --git a/Lib/plat-mac/pimp.py b/Lib/plat-mac/pimp.py index 61a9926..2ca5369 100644 --- a/Lib/plat-mac/pimp.py +++ b/Lib/plat-mac/pimp.py @@ -33,7 +33,12 @@ PIMP_VERSION="0.1" DEFAULT_FLAVORORDER=['source', 'binary'] DEFAULT_DOWNLOADDIR='/tmp' DEFAULT_BUILDDIR='/tmp' -DEFAULT_INSTALLDIR=os.path.join(sys.prefix, "Lib", "site-packages") +for _p in sys.path: + if _p[-13:] == 'site-packages': + DEFAULT_INSTALLDIR=_p + break +else: + DEFAULT_INSTALLDIR=sys.prefix # Have to put things somewhere DEFAULT_PIMPDATABASE="http://www.cwi.nl/~jack/pimp/pimp-%s.plist" % distutils.util.get_platform() ARCHIVE_FORMATS = [ @@ -339,7 +344,7 @@ class PimpPackage: string should tell the user what to do.""" rv = [] - if not self._dict['Download-URL']: + if not self._dict.get('Download-URL'): return [(None, "This package needs to be installed manually")] if not self._dict['Prerequisites']: return [] @@ -369,7 +374,8 @@ class PimpPackage: output.write("+ %s\n" % cmd) if NO_EXECUTE: return 0 - fp = os.popen(cmd, "r") + dummy, fp = os.popen4(cmd, "r") + dummy.close() while 1: line = fp.readline() if not line: @@ -449,23 +455,57 @@ class PimpPackage: msg = self.downloadSinglePackage(output) if msg: return "download %s: %s" % (self.fullname(), msg) + msg = self.unpackSinglePackage(output) if msg: return "unpack %s: %s" % (self.fullname(), msg) + if self._dict.has_key('Pre-install-command'): if self._cmd(output, self._buildDirname, self._dict['Pre-install-command']): return "pre-install %s: running \"%s\" failed" % \ (self.fullname(), self._dict['Pre-install-command']) + + old_contents = os.listdir(self._db.preferences.installDir) installcmd = self._dict.get('Install-command') if not installcmd: installcmd = '"%s" setup.py install' % sys.executable if self._cmd(output, self._buildDirname, installcmd): return "install %s: running \"%s\" failed" % self.fullname() + + new_contents = os.listdir(self._db.preferences.installDir) + self._interpretPthFiles(old_contents, new_contents) + if self._dict.has_key('Post-install-command'): if self._cmd(output, self._buildDirname, self._dict['Post-install-command']): return "post-install %s: running \"%s\" failed" % \ (self.fullname(), self._dict['Post-install-command']) return None + + def _interpretPthFiles(self, old_contents, new_contents): + """Evaluate any new .pth files that have appeared after installing""" + for fn in new_contents: + if fn in old_contents: + continue + if fn[-4:] != '.pth': + continue + fullname = os.path.join(self._db.preferences.installDir, fn) + f = open(fullname) + for line in f.readlines(): + if not line: + continue + if line[0] == '#': + continue + if line[:6] == 'import': + exec line + continue + if line[-1] == '\n': + line = line[:-1] + if not os.path.isabs(line): + line = os.path.join(self._db.preferences.installDir, line) + line = os.path.realpath(line) + if not line in sys.path: + sys.path.append(line) + class PimpInstaller: """Installer engine: computes dependencies and installs |