From dcd1dd3857242fe3463d68cb19abfe431f520f92 Mon Sep 17 00:00:00 2001 From: Ronny Pfannschmidt Date: Thu, 11 Feb 2010 14:47:04 +0100 Subject: fix develop --user for having '.' in PYTHON_PATH the pth file update wouldn't work if the distribution location is in the side dirs so we special-case for the location being the cwd --HG-- branch : distribute extra : rebase_source : 4c80082825c25f7f4692fcdd3580da5d1948ef89 --- setuptools/command/easy_install.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'setuptools/command') diff --git a/setuptools/command/easy_install.py b/setuptools/command/easy_install.py index 421d0c09..4b42a537 100755 --- a/setuptools/command/easy_install.py +++ b/setuptools/command/easy_install.py @@ -1420,8 +1420,12 @@ class PthDistributions(Environment): def add(self,dist): """Add `dist` to the distribution map""" - if dist.location not in self.paths and dist.location not in self.sitedirs: - self.paths.append(dist.location); self.dirty = True + if (dist.location not in self.paths and ( + dist.location not in self.sitedirs or + dist.location == os.getcwd() #account for '.' being in PYTHONPATH + )): + self.paths.append(dist.location) + self.dirty = True Environment.add(self,dist) def remove(self,dist): -- cgit v1.2.3 From c14e1a1398cf7ece7a4bcb15317868163789d879 Mon Sep 17 00:00:00 2001 From: Ronny Pfannschmidt Date: Thu, 11 Feb 2010 21:32:14 +0100 Subject: enable easy_install --user, *warning breaks tests* the test-isolation got borked and operates on the users home instead of the test-tempdirs --HG-- branch : distribute extra : rebase_source : 1e9bf310b6ba92629d7ba494af17f519cfe17dc5 --- setuptools/command/develop.py | 88 +++----------------------------------- setuptools/command/easy_install.py | 87 ++++++++++++++++++++++++++++++++++++- 2 files changed, 90 insertions(+), 85 deletions(-) (limited to 'setuptools/command') diff --git a/setuptools/command/develop.py b/setuptools/command/develop.py index 330ba168..d88d0990 100755 --- a/setuptools/command/develop.py +++ b/setuptools/command/develop.py @@ -2,19 +2,8 @@ from setuptools.command.easy_install import easy_install from distutils.util import convert_path, subst_vars from pkg_resources import Distribution, PathMetadata, normalize_path from distutils import log -from distutils.errors import * -import sys, os, setuptools, glob -from distutils.sysconfig import get_config_vars -from distutils.command.install import INSTALL_SCHEMES, SCHEME_KEYS - -if sys.version < "2.6": - USER_BASE = None - USER_SITE = None - HAS_USER_SITE = False -else: - from site import USER_BASE - from site import USER_SITE - HAS_USER_SITE = True +from distutils.errors import DistutilsError, DistutilsOptionError +import os, setuptools, glob class develop(easy_install): """Set up package for development""" @@ -28,11 +17,6 @@ class develop(easy_install): boolean_options = easy_install.boolean_options + ['uninstall'] - if HAS_USER_SITE: - user_options.append(('user', None, - "install in user site-package '%s'" % USER_SITE)) - boolean_options.append('user') - command_consumes_arguments = False # override base def run(self): @@ -49,36 +33,7 @@ class develop(easy_install): easy_install.initialize_options(self) self.setup_path = None self.always_copy_from = '.' # always copy eggs installed in curdir - self.user = 0 - self.install_purelib = None # for pure module distributions - self.install_platlib = None # non-pure (dists w/ extensions) - self.install_headers = None # for C/C++ headers - self.install_lib = None # set to either purelib or platlib - self.install_scripts = None - self.install_data = None - self.install_base = None - self.install_platbase = None - self.install_userbase = USER_BASE - self.install_usersite = USER_SITE - - def select_scheme(self, name): - """Sets the install directories by applying the install schemes.""" - # it's the caller's problem if they supply a bad name! - scheme = INSTALL_SCHEMES[name] - for key in SCHEME_KEYS: - attrname = 'install_' + key - if getattr(self, attrname) is None: - setattr(self, attrname, scheme[key]) - - def create_home_path(self): - """Create directories under ~.""" - if not self.user: - return - home = convert_path(os.path.expanduser("~")) - for name, path in self.config_vars.iteritems(): - if path.startswith(home) and not os.path.isdir(path): - self.debug_print("os.makedirs('%s', 0700)" % path) - os.makedirs(path, 0700) + def _expand_attrs(self, attrs): for attr in attrs: @@ -110,44 +65,11 @@ class develop(easy_install): self.args = [ei.egg_name] - py_version = sys.version.split()[0] - prefix, exec_prefix = get_config_vars('prefix', 'exec_prefix') - self.config_vars = {'dist_name': self.distribution.get_name(), - 'dist_version': self.distribution.get_version(), - 'dist_fullname': self.distribution.get_fullname(), - 'py_version': py_version, - 'py_version_short': py_version[0:3], - 'py_version_nodot': py_version[0] + py_version[2], - 'sys_prefix': prefix, - 'prefix': prefix, - 'sys_exec_prefix': exec_prefix, - 'exec_prefix': exec_prefix, - } - - if HAS_USER_SITE: - self.config_vars['userbase'] = self.install_userbase - self.config_vars['usersite'] = self.install_usersite - - # fix the install_dir if "--user" was used - if self.user: - self.create_home_path() - if self.install_userbase is None: - raise DistutilsPlatformError( - "User base directory is not specified") - self.install_base = self.install_platbase = self.install_userbase - if os.name == 'posix': - self.select_scheme("unix_user") - else: - self.select_scheme(os.name + "_user") - self.expand_basedirs() - self.expand_dirs() - - if self.user and self.install_purelib: - self.install_dir = self.install_purelib - self.script_dir = self.install_scripts easy_install.finalize_options(self) + self.expand_basedirs() + self.expand_dirs() # pick up setup-dir .egg files only: no .egg-info self.package_index.scan(glob.glob('*.egg')) diff --git a/setuptools/command/easy_install.py b/setuptools/command/easy_install.py index 4b42a537..d7098060 100755 --- a/setuptools/command/easy_install.py +++ b/setuptools/command/easy_install.py @@ -14,9 +14,11 @@ from glob import glob from setuptools import Command from setuptools.sandbox import run_setup from distutils import log, dir_util -from distutils.sysconfig import get_python_lib +from distutils.util import convert_path, subst_vars +from distutils.sysconfig import get_python_lib, get_config_vars from distutils.errors import DistutilsArgError, DistutilsOptionError, \ DistutilsError +from distutils.command.install import INSTALL_SCHEMES, SCHEME_KEYS from setuptools.archive_util import unpack_archive from setuptools.package_index import PackageIndex, parse_bdist_wininst from setuptools.package_index import URL_SCHEME @@ -29,6 +31,16 @@ __all__ = [ 'main', 'get_exe_prefixes', ] + +if sys.version < "2.6": + USER_BASE = None + USER_SITE = None + HAS_USER_SITE = False +else: + from site import USER_BASE + from site import USER_SITE + HAS_USER_SITE = True + def samefile(p1,p2): if hasattr(os.path,'samefile') and ( os.path.exists(p1) and os.path.exists(p2) @@ -97,10 +109,18 @@ class easy_install(Command): 'delete-conflicting', 'ignore-conflicts-at-my-risk', 'editable', 'no-deps', 'local-snapshots-ok', 'version' ] + + if HAS_USER_SITE: + user_options.append(('user', None, + "install in user site-package '%s'" % USER_SITE)) + boolean_options.append('user') + + negative_opt = {'always-unzip': 'zip-ok'} create_index = PackageIndex def initialize_options(self): + self.user = 0 self.zip_ok = self.local_snapshots_ok = None self.install_dir = self.script_dir = self.exclude_scripts = None self.index_url = None @@ -112,6 +132,16 @@ class easy_install(Command): self.editable = self.no_deps = self.allow_hosts = None self.root = self.prefix = self.no_report = None self.version = None + self.install_purelib = None # for pure module distributions + self.install_platlib = None # non-pure (dists w/ extensions) + self.install_headers = None # for C/C++ headers + self.install_lib = None # set to either purelib or platlib + self.install_scripts = None + self.install_data = None + self.install_base = None + self.install_platbase = None + self.install_userbase = USER_BASE + self.install_usersite = USER_SITE # Options not specifiable via command line self.package_index = None @@ -147,6 +177,42 @@ class easy_install(Command): print 'distribute %s' % get_distribution('distribute').version sys.exit() + py_version = sys.version.split()[0] + prefix, exec_prefix = get_config_vars('prefix', 'exec_prefix') + + self.config_vars = {'dist_name': self.distribution.get_name(), + 'dist_version': self.distribution.get_version(), + 'dist_fullname': self.distribution.get_fullname(), + 'py_version': py_version, + 'py_version_short': py_version[0:3], + 'py_version_nodot': py_version[0] + py_version[2], + 'sys_prefix': prefix, + 'prefix': prefix, + 'sys_exec_prefix': exec_prefix, + 'exec_prefix': exec_prefix, + } + + if HAS_USER_SITE: + self.config_vars['userbase'] = self.install_userbase + self.config_vars['usersite'] = self.install_usersite + + # fix the install_dir if "--user" was used + #XXX: duplicate of the code in the setup command + if self.user: + self.create_home_path() + if self.install_userbase is None: + raise DistutilsPlatformError( + "User base directory is not specified") + self.install_base = self.install_platbase = self.install_userbase + if os.name == 'posix': + self.select_scheme("unix_user") + else: + self.select_scheme(os.name + "_user") + + if self.user and self.install_purelib: + self.install_dir = self.install_purelib + self.script_dir = self.install_scripts + self._expand('install_dir','script_dir','build_directory','site_dirs') # If a non-default installation directory was specified, default the # script directory to match it. @@ -512,6 +578,15 @@ Please make the appropriate changes for your system and try again. + def select_scheme(self, name): + """Sets the install directories by applying the install schemes.""" + # it's the caller's problem if they supply a bad name! + scheme = INSTALL_SCHEMES[name] + for key in SCHEME_KEYS: + attrname = 'install_' + key + if getattr(self, attrname) is None: + setattr(self, attrname, scheme[key]) + @@ -1129,7 +1204,15 @@ Please make the appropriate changes for your system and try again.""" % ( - + def create_home_path(self): + """Create directories under ~.""" + if not self.user: + return + home = convert_path(os.path.expanduser("~")) + for name, path in self.config_vars.iteritems(): + if path.startswith(home) and not os.path.isdir(path): + self.debug_print("os.makedirs('%s', 0700)" % path) + os.makedirs(path, 0700) -- cgit v1.2.3 From 0b3d2302b8b209c7bed8bdad6e1a6cff34889779 Mon Sep 17 00:00:00 2001 From: Ronny Pfannschmidt Date: Thu, 11 Feb 2010 23:57:28 +0100 Subject: move the rest of the path handling code from develop to easy_install also resuffle the path handlers a bit, hopefully everything works now --HG-- branch : distribute extra : rebase_source : dc8e4217f5832b15e8f7287c95732bc68d1e1cf5 --- setuptools/command/develop.py | 19 ------------ setuptools/command/easy_install.py | 62 ++++++++++++++++++++++++++------------ 2 files changed, 43 insertions(+), 38 deletions(-) (limited to 'setuptools/command') diff --git a/setuptools/command/develop.py b/setuptools/command/develop.py index d88d0990..93b7773c 100755 --- a/setuptools/command/develop.py +++ b/setuptools/command/develop.py @@ -35,25 +35,6 @@ class develop(easy_install): self.always_copy_from = '.' # always copy eggs installed in curdir - def _expand_attrs(self, attrs): - for attr in attrs: - val = getattr(self, attr) - if val is not None: - if os.name == 'posix' or os.name == 'nt': - val = os.path.expanduser(val) - val = subst_vars(val, self.config_vars) - setattr(self, attr, val) - - def expand_basedirs(self): - """Calls `os.path.expanduser` on install_base, install_platbase and - root.""" - self._expand_attrs(['install_base', 'install_platbase', 'root']) - - def expand_dirs(self): - """Calls `os.path.expanduser` on install dirs.""" - self._expand_attrs(['install_purelib', 'install_platlib', - 'install_lib', 'install_headers', - 'install_scripts', 'install_data',]) def finalize_options(self): ei = self.get_finalized_command("egg_info") diff --git a/setuptools/command/easy_install.py b/setuptools/command/easy_install.py index d7098060..134f1b80 100755 --- a/setuptools/command/easy_install.py +++ b/setuptools/command/easy_install.py @@ -17,13 +17,19 @@ from distutils import log, dir_util from distutils.util import convert_path, subst_vars from distutils.sysconfig import get_python_lib, get_config_vars from distutils.errors import DistutilsArgError, DistutilsOptionError, \ - DistutilsError + DistutilsError, DistutilsPlatformError from distutils.command.install import INSTALL_SCHEMES, SCHEME_KEYS from setuptools.archive_util import unpack_archive -from setuptools.package_index import PackageIndex, parse_bdist_wininst +from setuptools.package_index import PackageIndex from setuptools.package_index import URL_SCHEME from setuptools.command import bdist_egg, egg_info -from pkg_resources import * +from pkg_resources import yield_lines, normalize_path, resource_string, \ + ensure_directory, get_distribution, find_distributions, \ + Environment, Requirement, Distribution, \ + PathMetadata, EggMetadata, WorkingSet, \ + DistributionNotFound, VersionConflict, \ + DEVELOP_DIST + sys_executable = os.path.normpath(sys.executable) __all__ = [ @@ -31,15 +37,8 @@ __all__ = [ 'main', 'get_exe_prefixes', ] - -if sys.version < "2.6": - USER_BASE = None - USER_SITE = None - HAS_USER_SITE = False -else: - from site import USER_BASE - from site import USER_SITE - HAS_USER_SITE = True +import site +HAS_USER_SITE = not sys.version < "2.6" def samefile(p1,p2): if hasattr(os.path,'samefile') and ( @@ -112,7 +111,7 @@ class easy_install(Command): if HAS_USER_SITE: user_options.append(('user', None, - "install in user site-package '%s'" % USER_SITE)) + "install in user site-package '%s'" % site.USER_SITE)) boolean_options.append('user') @@ -140,8 +139,8 @@ class easy_install(Command): self.install_data = None self.install_base = None self.install_platbase = None - self.install_userbase = USER_BASE - self.install_usersite = USER_SITE + self.install_userbase = site.USER_BASE + self.install_usersite = site.USER_SITE # Options not specifiable via command line self.package_index = None @@ -209,10 +208,9 @@ class easy_install(Command): else: self.select_scheme(os.name + "_user") - if self.user and self.install_purelib: - self.install_dir = self.install_purelib - self.script_dir = self.install_scripts - + self.expand_basedirs() + self.expand_dirs() + self._expand('install_dir','script_dir','build_directory','site_dirs') # If a non-default installation directory was specified, default the # script directory to match it. @@ -229,6 +227,10 @@ class easy_install(Command): self.set_undefined_options('install_scripts', ('install_dir', 'script_dir') ) + + if self.user and self.install_purelib: + self.install_dir = self.install_purelib + self.script_dir = self.install_scripts # default --record from the install command self.set_undefined_options('install', ('record', 'record')) normpath = map(normalize_path, sys.path) @@ -294,6 +296,27 @@ class easy_install(Command): self.outputs = [] + + def _expand_attrs(self, attrs): + for attr in attrs: + val = getattr(self, attr) + if val is not None: + if os.name == 'posix' or os.name == 'nt': + val = os.path.expanduser(val) + val = subst_vars(val, self.config_vars) + setattr(self, attr, val) + + def expand_basedirs(self): + """Calls `os.path.expanduser` on install_base, install_platbase and + root.""" + self._expand_attrs(['install_base', 'install_platbase', 'root']) + + def expand_dirs(self): + """Calls `os.path.expanduser` on install dirs.""" + self._expand_attrs(['install_purelib', 'install_platlib', + 'install_lib', 'install_headers', + 'install_scripts', 'install_data',]) + def run(self): if self.verbose<>self.distribution.verbose: log.set_verbosity(self.verbose) @@ -337,6 +360,7 @@ class easy_install(Command): def check_site_dir(self): """Verify that self.install_dir is .pth-capable dir, if needed""" + print 'install_dir', self.install_dir instdir = normalize_path(self.install_dir) pth_file = os.path.join(instdir,'easy-install.pth') -- cgit v1.2.3 From b99d0e8aefe94a718630cb6be3369e290a6ec060 Mon Sep 17 00:00:00 2001 From: Yannick Gingras Date: Mon, 15 Mar 2010 22:13:19 -0400 Subject: removed unsused imports --HG-- branch : distribute extra : rebase_source : 6c1870024a04c1b5393c85a5782809ef409c66a6 --- setuptools/command/easy_install.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'setuptools/command') diff --git a/setuptools/command/easy_install.py b/setuptools/command/easy_install.py index 33b14bf7..c96a43fd 100755 --- a/setuptools/command/easy_install.py +++ b/setuptools/command/easy_install.py @@ -9,7 +9,7 @@ file, or visit the `EasyInstall home page`__. __ http://peak.telecommunity.com/DevCenter/EasyInstall """ -import sys, os, os.path, zipimport, shutil, tempfile, zipfile, re, stat, random +import sys, os.path, zipimport, shutil, tempfile, zipfile, re, stat, random from glob import glob from setuptools import Command from setuptools.sandbox import run_setup @@ -18,7 +18,7 @@ from distutils.sysconfig import get_python_lib from distutils.errors import DistutilsArgError, DistutilsOptionError, \ DistutilsError from setuptools.archive_util import unpack_archive -from setuptools.package_index import PackageIndex, parse_bdist_wininst +from setuptools.package_index import PackageIndex from setuptools.package_index import URL_SCHEME from setuptools.command import bdist_egg, egg_info from pkg_resources import * -- cgit v1.2.3 From dee0ec5d40f2be83be1596fd12dbdb9b5eb159d0 Mon Sep 17 00:00:00 2001 From: Yannick Gingras Date: Mon, 15 Mar 2010 22:24:45 -0400 Subject: updated links to the new location of the easy_install docs --HG-- branch : distribute extra : rebase_source : 9d757c4d6c0d0c0b14b381961af69907e079d0ce --- setuptools/command/easy_install.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'setuptools/command') diff --git a/setuptools/command/easy_install.py b/setuptools/command/easy_install.py index c96a43fd..843c261c 100755 --- a/setuptools/command/easy_install.py +++ b/setuptools/command/easy_install.py @@ -7,7 +7,8 @@ A tool for doing automatic download/extract/build of distutils-based Python packages. For detailed documentation, see the accompanying EasyInstall.txt file, or visit the `EasyInstall home page`__. -__ http://peak.telecommunity.com/DevCenter/EasyInstall +__ http://packages.python.org/distribute/easy_install.html + """ import sys, os.path, zipimport, shutil, tempfile, zipfile, re, stat, random from glob import glob @@ -349,7 +350,7 @@ variable. For information on other options, you may wish to consult the documentation at: - http://peak.telecommunity.com/EasyInstall.html + http://packages.python.org/distribute/easy_install.html Please make the appropriate changes for your system and try again. """ @@ -1084,7 +1085,7 @@ Here are some of your options for correcting the problem: * You can set up the installation directory to support ".pth" files by using one of the approaches described here: - http://peak.telecommunity.com/EasyInstall.html#custom-installation-locations + http://packages.python.org/distribute/easy_install.html#custom-installation-locations Please make the appropriate changes for your system and try again.""" % ( self.install_dir, os.environ.get('PYTHONPATH','') -- cgit v1.2.3