From 16a89c229e8b67af66d6951bcd4146ea4bf091da Mon Sep 17 00:00:00 2001 From: nibrahim Date: Mon, 22 Feb 2010 16:21:06 -0500 Subject: --help install command no longer tries to install fixes #121 --HG-- branch : distribute extra : rebase_source : 11dab4d1ff0d41ef9b7e808ce7e41592b18a7270 --- CHANGES.txt | 1 + CONTRIBUTORS.txt | 1 + setup.py | 4 +++- 3 files changed, 5 insertions(+), 1 deletion(-) diff --git a/CHANGES.txt b/CHANGES.txt index b16ad40f..7d1ff003 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -10,6 +10,7 @@ CHANGES * Issue 15 and 48: Introduced a socket timeout of 15 seconds on url openings * Added indexsidebar.html into MANIFEST.in * Issue 108: Fixed TypeError with Python3.1 +* Issue 121: Fixed --help install command trying to actually install. ------ 0.6.10 diff --git a/CONTRIBUTORS.txt b/CONTRIBUTORS.txt index bc2b3fe7..da9e0219 100644 --- a/CONTRIBUTORS.txt +++ b/CONTRIBUTORS.txt @@ -10,6 +10,7 @@ Contributors * Jannis Leidel * Lennart Regebro * Martin von Löwis +* Noufal Ibrahim * Philip Jenvey * Reinout van Rees * Tarek Ziadé diff --git a/setup.py b/setup.py index b8612b5c..064c2afd 100755 --- a/setup.py +++ b/setup.py @@ -82,7 +82,9 @@ def _being_installed(): # Installed by buildout, don't mess with a global setuptools. return False # easy_install marker - return 'install' in sys.argv[1:] or _easy_install_marker() + if "--help" in sys.argv[1:] or "-h" in sys.argv[1:]: # Don't bother doing anything if they're just asking for help + return False + return 'install' in sys.argv[1:] or _easy_install_marker() if _being_installed(): from distribute_setup import _before_install -- cgit v1.2.3 From 2762c22f7a4dd3a288c04bb10af98605114bb08e Mon Sep 17 00:00:00 2001 From: nibrahim Date: Mon, 22 Feb 2010 18:17:37 -0500 Subject: Added an os.makedirs so that Tarek's solution will work --HG-- branch : distribute extra : rebase_source : 91e7070818115d6ff2bcbf6db1912788e70b8d59 --- CHANGES.txt | 1 + setuptools/command/easy_install.py | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/CHANGES.txt b/CHANGES.txt index 7d1ff003..eeab73c6 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -11,6 +11,7 @@ CHANGES * Added indexsidebar.html into MANIFEST.in * Issue 108: Fixed TypeError with Python3.1 * Issue 121: Fixed --help install command trying to actually install. +* Issue 112: Added an os.makedirs so that Tarek's solution will work. ------ 0.6.10 diff --git a/setuptools/command/easy_install.py b/setuptools/command/easy_install.py index 421d0c09..366ac7bc 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.path, zipimport, shutil, tempfile, zipfile, re, stat, random +import sys, os, os.path, zipimport, shutil, tempfile, zipfile, re, stat, random from glob import glob from setuptools import Command from setuptools.sandbox import run_setup @@ -360,6 +360,7 @@ Please make the appropriate changes for your system and try again. ok_exists = os.path.exists(ok_file) try: if ok_exists: os.unlink(ok_file) + os.makedirs(os.path.dirname(ok_file)) f = open(pth_file,'w') except (OSError,IOError): self.cant_write_to_target() -- cgit v1.2.3 From b9da3bd8418678235816f840f4cd86c68527097a Mon Sep 17 00:00:00 2001 From: "Jason R. Coombs" Date: Mon, 22 Feb 2010 20:03:59 -0500 Subject: Added test to capture issue #118 --HG-- branch : distribute extra : rebase_source : 5c247cafcbecb311469147a46f7f82df47ea5341 --- setuptools/tests/test_sandbox.py | 47 +++++++++++++++++++++++++++++++++++----- 1 file changed, 41 insertions(+), 6 deletions(-) diff --git a/setuptools/tests/test_sandbox.py b/setuptools/tests/test_sandbox.py index 1b0dc4ea..8b9e08e6 100644 --- a/setuptools/tests/test_sandbox.py +++ b/setuptools/tests/test_sandbox.py @@ -6,7 +6,20 @@ import shutil import unittest import tempfile -from setuptools.sandbox import DirectorySandbox +from setuptools.sandbox import DirectorySandbox, SandboxViolation + +def has_win32com(): + """ + Run this to determine if the local machine has win32com, and if it + does, include additional tests. + """ + if not sys.platform.startswith('win32'): + return False + try: + mod = __import__('win32com') + except ImportError: + return False + return True class TestSandbox(unittest.TestCase): @@ -18,11 +31,33 @@ class TestSandbox(unittest.TestCase): def test_devnull(self): sandbox = DirectorySandbox(self.dir) + sandbox.run(self._file_writer(os.devnull)) - def _write(): - f = open(os.devnull, 'w') + @staticmethod + def _file_writer(path): + def do_write(): + f = open(path, 'w') f.write('xxx') f.close() - - sandbox.run(_write) - + return do_write + + + if has_win32com(): + def test_win32com(self): + """ + win32com should not be prevented from caching COM interfaces + in gen_py. + """ + import win32com + gen_py = win32com.__gen_path__ + target = os.path.join(gen_py, 'test_write') + sandbox = DirectorySandbox(self.dir) + try: + sandbox.run(self._file_writer(target)) + except SandboxViolation: + self.fail("Could not create gen_py file due to SandboxViolation") + finally: + if os.path.exists(target): os.remove(target) + +if __name__ == '__main__': + unittest.main() -- cgit v1.2.3 From 2cb36ad98366b3cad72f2be6b7a55fb51b43677c Mon Sep 17 00:00:00 2001 From: "Jason R. Coombs" Date: Tue, 2 Mar 2010 18:02:00 -0500 Subject: Worked out a fix for failing sandbox errors in Windows. Fixes #118. --HG-- branch : distribute extra : rebase_source : 69c8e59604f9d711cd29bb55e9edd3caab2b36a0 --- setuptools/sandbox.py | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/setuptools/sandbox.py b/setuptools/sandbox.py index 502598ca..630d5792 100755 --- a/setuptools/sandbox.py +++ b/setuptools/sandbox.py @@ -154,6 +154,12 @@ class AbstractSandbox: _EXCEPTIONS = [os.devnull,] +try: + gen_py = os.path.dirname(__import__('win32com.gen_py', fromlist=['__name__']).__file__) + _EXCEPTIONS.append(gen_py) +except ImportError: + pass + class DirectorySandbox(AbstractSandbox): """Restrict operations to a single subdirectory - pseudo-chroot""" @@ -165,7 +171,7 @@ class DirectorySandbox(AbstractSandbox): def __init__(self, sandbox, exceptions=_EXCEPTIONS): self._sandbox = os.path.normcase(os.path.realpath(sandbox)) self._prefix = os.path.join(self._sandbox,'') - self._exceptions = exceptions + self._exceptions = [os.path.normcase(os.path.realpath(path)) for path in exceptions] AbstractSandbox.__init__(self) def _violation(self, operation, *args, **kw): @@ -190,12 +196,16 @@ class DirectorySandbox(AbstractSandbox): try: self._active = False realpath = os.path.normcase(os.path.realpath(path)) - if (realpath in self._exceptions or realpath == self._sandbox + if (self._exempted(realpath) or realpath == self._sandbox or realpath.startswith(self._prefix)): return True finally: self._active = active + def _exempted(self, filepath): + exception_matches = map(filepath.startswith, self._exceptions) + return any(exception_matches) + def _remap_input(self,operation,path,*args,**kw): """Called for path inputs""" if operation in self.write_ops and not self._ok(path): -- cgit v1.2.3 From 9b4f204172ebab821cb677c978625c2e2479de5e Mon Sep 17 00:00:00 2001 From: Tarek Ziade Date: Sat, 13 Mar 2010 13:10:52 -0500 Subject: removing the easy_install installation process -- too much problem with sandboxing violations through easy_install --HG-- branch : distribute extra : rebase_source : e1528eb57170fd7dc5edf318eb56f0e7683c3332 --- README.txt | 18 ++++-------------- 1 file changed, 4 insertions(+), 14 deletions(-) diff --git a/README.txt b/README.txt index 8e78bc88..bd084770 100755 --- a/README.txt +++ b/README.txt @@ -68,9 +68,8 @@ Installation Instructions Distribute is only released as a source distribution. -It can be installed using easy_install or pip, and can be done so with the source -tarball, the eggs distribution, or by using the ``distribute_setup.py`` script -provided online. +It can be installed using pip, and can be done so with the source tarball, +or by using the ``distribute_setup.py`` script provided online. ``distribute_setup.py`` is the simplest and preferred way on all systems. @@ -88,20 +87,13 @@ If your shell has the ``curl`` program you can do:: Notice this file is also provided in the source release. -easy_install or pip -=================== +pip +=== Run easy_install or pip:: - $ easy_install -U distribute $ pip install distribute -If you want to install the latest dev version, you can also run:: - - $ easy_install -U distribute==dev - -This will get the latest development version at: http://bitbucket.org/tarek/distribute/get/0.6-maintenance.zip#egg=distribute-dev - Source installation =================== @@ -128,8 +120,6 @@ Distribute is installed in three steps: Distribute can be removed like this: -- run ``easy_install -m Distribute``. This will remove the Distribute reference - from ``easy-install.pth``. Otherwise, edit the file and remove it yourself. - remove the ``distribute*.egg`` file located in your site-packages directory - remove the ``setuptools.pth`` file located in you site-packages directory - remove the easy_install script located in you ``sys.prefix/bin`` directory -- cgit v1.2.3 From 38ae8ecbdc6a9f285a56add8c695b10b2786c679 Mon Sep 17 00:00:00 2001 From: Tarek Ziade Date: Sat, 13 Mar 2010 16:53:19 -0500 Subject: added the --no-find-links option --HG-- branch : distribute extra : rebase_source : fc2cbd4d369f7d5c77cae03e39354245b185cc60 --- CHANGES.txt | 3 ++- docs/easy_install.txt | 5 +++++ setuptools/command/easy_install.py | 14 +++++++++++--- setuptools/tests/test_easy_install.py | 25 +++++++++++++++++++++++++ 4 files changed, 43 insertions(+), 4 deletions(-) diff --git a/CHANGES.txt b/CHANGES.txt index eeab73c6..803045b6 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -11,7 +11,8 @@ CHANGES * Added indexsidebar.html into MANIFEST.in * Issue 108: Fixed TypeError with Python3.1 * Issue 121: Fixed --help install command trying to actually install. -* Issue 112: Added an os.makedirs so that Tarek's solution will work. +* Issue 112: Added an os.makedirs so that Tarek's solution will work. +* Issue 133: Added --no-find-links to easy_install ------ 0.6.10 diff --git a/docs/easy_install.txt b/docs/easy_install.txt index 3e39b811..a469bb55 100644 --- a/docs/easy_install.txt +++ b/docs/easy_install.txt @@ -768,6 +768,11 @@ Command-Line Options package not being available locally, or due to the use of the ``--update`` or ``-U`` option. +``--no-find-links`` Blocks the addition of any link. (New in Distribute 0.6.11) + This is useful if you want to avoid adding links defined in a project + easy_install is installing (wether it's a requested project or a + dependency.). When used, ``--find-links`` is ignored. + ``--delete-conflicting, -D`` (Removed in 0.6a11) (As of 0.6a11, this option is no longer necessary; please do not use it!) diff --git a/setuptools/command/easy_install.py b/setuptools/command/easy_install.py index 366ac7bc..33b14bf7 100755 --- a/setuptools/command/easy_install.py +++ b/setuptools/command/easy_install.py @@ -91,6 +91,8 @@ class easy_install(Command): ('allow-hosts=', 'H', "pattern(s) that hostnames must match"), ('local-snapshots-ok', 'l', "allow building eggs from local checkouts"), ('version', None, "print version information and exit"), + ('no-find-links', None, + "Don't load find-links defined in packages being installed") ] boolean_options = [ 'zip-ok', 'multi-version', 'exclude-scripts', 'upgrade', 'always-copy', @@ -112,6 +114,7 @@ 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.no_find_links = None # Options not specifiable via command line self.package_index = None @@ -153,6 +156,9 @@ class easy_install(Command): if self.script_dir is None: self.script_dir = self.install_dir + if self.no_find_links is None: + self.no_find_links = False + # Let install_dir get set by install_lib command, which in turn # gets its info from the install command, and takes into account # --prefix and --home and all that other crud. @@ -204,7 +210,8 @@ class easy_install(Command): self.find_links = [] if self.local_snapshots_ok: self.package_index.scan_egg_links(self.shadow_path+sys.path) - self.package_index.add_find_links(self.find_links) + if not self.no_find_links: + self.package_index.add_find_links(self.find_links) self.set_undefined_options('install_lib', ('optimize','optimize')) if not isinstance(self.optimize,int): try: @@ -229,7 +236,7 @@ class easy_install(Command): self.outputs = [] def run(self): - if self.verbose<>self.distribution.verbose: + if self.verbose != self.distribution.verbose: log.set_verbosity(self.verbose) try: for spec in self.args: @@ -523,7 +530,8 @@ Please make the appropriate changes for your system and try again. self.install_egg_scripts(dist) self.installed_projects[dist.key] = dist log.info(self.installation_report(requirement, dist, *info)) - if dist.has_metadata('dependency_links.txt'): + if (dist.has_metadata('dependency_links.txt') and + not self.no_find_links): self.package_index.add_find_links( dist.get_metadata_lines('dependency_links.txt') ) diff --git a/setuptools/tests/test_easy_install.py b/setuptools/tests/test_easy_install.py index 95909ca7..6f660a1e 100644 --- a/setuptools/tests/test_easy_install.py +++ b/setuptools/tests/test_easy_install.py @@ -90,3 +90,28 @@ class TestEasyInstallTest(unittest.TestCase): os.chdir(old_wd) shutil.rmtree(dir) + def test_no_find_links(self): + # new option '--no-find-links', that blocks find-links added at + # the project level + dist = Distribution() + cmd = easy_install(dist) + cmd.check_pth_processing = lambda : True + cmd.no_find_links = True + cmd.find_links = ['link1', 'link2'] + cmd.install_dir = os.path.join(tempfile.mkdtemp(), 'ok') + cmd.args = ['ok'] + cmd.ensure_finalized() + self.assertEquals(cmd.package_index.scanned_urls, {}) + + # let's try without it (default behavior) + cmd = easy_install(dist) + cmd.check_pth_processing = lambda : True + cmd.find_links = ['link1', 'link2'] + cmd.install_dir = os.path.join(tempfile.mkdtemp(), 'ok') + cmd.args = ['ok'] + cmd.ensure_finalized() + keys = cmd.package_index.scanned_urls.keys() + keys.sort() + self.assertEquals(keys, ['link1', 'link2']) + + -- 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(-) 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(-) 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 From ff3ee4aa6c6800d813162c09a58c6265c4675701 Mon Sep 17 00:00:00 2001 From: Yannick Gingras Date: Mon, 15 Mar 2010 22:41:40 -0400 Subject: fixed spelling typo --HG-- branch : distribute extra : rebase_source : 5ae197eeead6eae5f689f01ced730be068e8c64a --- setuptools/__init__.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/setuptools/__init__.py b/setuptools/__init__.py index d03d0bf0..c8a631a0 100644 --- a/setuptools/__init__.py +++ b/setuptools/__init__.py @@ -19,7 +19,8 @@ __all__ = [ # a distribution with the same version. # # The distribute_setup script for instance, will check if this -# attribute is present to decide wether to reinstall the package +# attribute is present to decide whether to reinstall the package +# or not. _distribute = True bootstrap_install_from = None -- cgit v1.2.3