[tor-commits] [bridgedb/master] Change setup.py/requirements.txt to allow URI/VCS resources.

isis at torproject.org isis at torproject.org
Sun Jan 12 06:06:32 UTC 2014


commit 9f36a33f67311cb4e39b48a7536e37253f16d1c9
Author: Isis Lovecruft <isis at torproject.org>
Date:   Sat Nov 16 09:07:44 2013 +0000

    Change setup.py/requirements.txt to allow URI/VCS resources.
    
    The maintainer of ipaddr has ceased uploading to PyPI, and so to get pip to
    download it, we need to add its URI and hash to requirements.txt. The
    get_requirements function in setup.py must be refactored to handle parse these
    URIs correctly, and return dependency_links in addition to install_requires.
---
 requirements.txt |    2 +-
 setup.py         |   34 ++++++++++++++++++++++++++++------
 2 files changed, 29 insertions(+), 7 deletions(-)

diff --git a/requirements.txt b/requirements.txt
index e4cd59b..eeab36f 100644
--- a/requirements.txt
+++ b/requirements.txt
@@ -4,7 +4,7 @@ Mako==0.8.1
 MarkupSafe==0.18
 Twisted==13.1.0
 coverage==3.6
-ipaddr==2.1.10
+https://ipaddr-py.googlecode.com/files/ipaddr-2.1.10.tar.gz#sha1=c608450b077b19773d4f1b5f1ef88b26f6650ce0#egg=ipaddr-2.1.10-py2.7
 pyOpenSSL==0.13.1
 pygeoip==0.2.7
 pygpgme==0.3
diff --git a/setup.py b/setup.py
index f73347f..d07e51a 100644
--- a/setup.py
+++ b/setup.py
@@ -90,19 +90,33 @@ def get_cmdclass():
     return cmdclass
 
 def get_requirements():
-    """Extract the list of requirements from our requirements.txt."""
+    """Extract the list of requirements from our requirements.txt.
+
+    :rtype: 2-tuple
+    :returns: Two lists, the first is a list of requirements in the form of
+        pkgname==version. The second is a list of URIs or VCS checkout strings
+        which specify the dependency links for obtaining a copy of the
+        requirement.
+    """
     requirements_file = os.path.join(os.getcwd(), 'requirements.txt')
     requirements = []
+    links=[]
     try:
         with open(requirements_file) as reqfile:
             for line in reqfile.readlines():
                 line = line.strip()
-                if not line.startswith('#'):
+                if line.startswith('#'):
+                    continue
+                elif line.startswith(
+                        ('https://', 'git://', 'hg://', 'svn://')):
+                    links.append(line)
+                else:
                     requirements.append(line)
-    except OSError as oserr:
-        print(oserr)
 
-    return requirements
+    except (IOError, OSError) as error:
+        print(error)
+
+    return requirements, links
 
 def get_supported_langs():
     """Get the paths for all compiled translation files.
@@ -243,6 +257,13 @@ class runTests(setuptools.Command):
             sys.path = old_path
 
 
+requires, deplinks = get_requirements()
+print('Found requirements:')
+[print('\t%s' % name) for name in requires]
+
+print('Found dependency links:')
+[print('\t%s' % uri) for uri in deplinks]
+
 setuptools.setup(
     name='bridgedb',
     version=versioneer.get_version(),
@@ -264,7 +285,8 @@ setuptools.setup(
     zip_safe=False,
     cmdclass=get_cmdclass(),
     include_package_data=True,
-    install_requires=get_requirements(),
+    install_requires=requires,
+    dependency_links=deplinks,
     package_data={'bridgedb': get_data_files(filesonly=True)},
     exclude_package_data={'bridgedb': ['*.po', '*.pot']},
     message_extractors={pkgpath: [





More information about the tor-commits mailing list