commit 191a47f93659d2ec9e5f17c660f4dcd9ceb5dae9 Author: Isis Lovecruft isis@torproject.org Date: Mon Aug 19 23:56:57 2013 +0000
Add automatic installation of dependencies to setup.py.
* ADD function get_requirements() to setup.py file, for parsing the requirements.txt file and installing the dependencies specified there. This allows us to keep one place for keeping track of dependencies, regardless of whether we are installed from a source distribution (git or a tarball) or with pip. --- setup.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+)
diff --git a/setup.py b/setup.py index 3a1f737..2f72b9d 100644 --- a/setup.py +++ b/setup.py @@ -3,6 +3,8 @@ # Copyright (c) 2007-2009, The Tor Project, Inc. # See LICENSE for licensing information
+from __future__ import print_function + import subprocess from distutils.command.install_data import install_data as _install_data import os @@ -39,6 +41,21 @@ def get_cmdclass(): cmdclass.update(versioneer.get_cmdclass()) return cmdclass
+def get_requirements(): + """Extract the list of requirements from our requirements.txt.""" + requirements_file = os.path.join(os.getcwd(), 'requirements.txt') + requirements = [] + try: + with open(requirements_file) as reqfile: + for line in reqfile.readlines(): + line = line.strip() + if not line.startswith('#'): + requirements.append(line) + except OSError as oserr: + print(oserr) + + return requirements +
class installData(_install_data): def run(self): @@ -92,6 +109,7 @@ setuptools.setup( py_modules=['TorBridgeDB'], cmdclass=get_cmdclass(), include_package_data=True, + install_requires=get_requirements(), package_data={'bridgedb': ['i18n/*/LC_MESSAGES/*.mo', 'templates/*.html', 'templates/assets/*']},