Search code examples
pythonpython-2.7setuptoolssetup.pypypi

How to add imported libraries into setup.py


I have a project in which I have imported different python libraries using pip install <library> I see I can create setup.py for that, but I couldn't exactly figure it out. So I have to add all imported libraries in packages? e.g. packages=['requests', 're']

Can I use it to install python if user doesn't have it? Or I just add python files which I have defined into packages? e.g. test1.py, test2.py edit

from setuptools import setup

setup(name='Testproject',
      version='0.1',
      description='testing',
      author='tester',
      packages=['requests', 'subprocess'],
      zip_safe=False)

Solution

  • Use install_requires to for dependencies:

    http://python-packaging-user-guide.readthedocs.org/en/latest/distributing/?highlight=install_requires#install-requires

    “install_requires” should be used to specify what dependencies a project minimally needs to run. When the project is installed by pip, this is the specification that is used to install its dependencies.