Commits

Tarek Ziadé committed 1cec439

added the --no-find-links option

Comments (0)

Files changed (4)

 * 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

docs/easy_install.txt

     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!)
 

setuptools/command/easy_install.py

         ('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',
         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
         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.
             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:
         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:
         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')
             )

setuptools/tests/test_easy_install.py

             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'])
+
+
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.