1

How do you include local dependencies in setup.py such that pip install will find them? I have looked at this and that solution does not work...

I have a structure like this:

mypackage
├── mypackage
│   └── __init__.py
├── README.md
├── setup.py
└── subpackages
    └── subpackageA
        ├── setup.py
        └── subpackageA
            └── __init__.py

mypackage/setup.py:

import os
from setuptools import setup, find_packages
subpackage_dir = ''.join(['file://', os.path.join(os.getcwd(), 'subpackages','subpackageA#egg=subpackageA-0.1.0')])
setup(
    author="",
    author_email='',
    classifiers=[],
    description="",
    install_requires=['subpackageA==0.1.0'],
    long_description='None',
    include_package_data=True,
    keywords='mypackage',
    name='mypackage',
    packages=find_packages(),
    setup_requires=[],
    test_suite='tests',
    tests_require=[],
    version='0.0.1',
    zip_safe=False,
    dependency_links=[subpackage_dir],
)

mypackage/subpackages/subpackageA/setup.py:

from setuptools import setup, find_packages
setup(
    author="",
    author_email='',
    classifiers=[
    ],
    description="Toolkit",
    install_requires=[],
    long_description='None',
    include_package_data=True,
    keywords='subpackageA',
    name='subpackageA',
    packages=find_packages(),
    setup_requires=[],
    test_suite='tests',
    tests_require=[],
    version='0.0.1',
    zip_safe=False,
    dependency_links=[],
)

The subpackage installed fine on its own. I.e. these both work:

  • pip install -e subpackages/subpackageA
  • pip install --find-links=file://`pwd`/subpackages/subpackageA#egg=subpackageA-0.1.0 subpackageA==0.1.0

But when I install the parent package, it does not use the link and does not install.

  • pip install -e .

How do you use setup.py to install dependencies from a file?

jmerkow
  • 1,811
  • 3
  • 20
  • 35
  • Don't you have to have the path? I don't think you can just have -e as you're not defining the file path. – Leila Abdelrahman Jan 31 '20 at 22:11
  • If i take out the subpackage dependency, it works fine. – jmerkow Jan 31 '20 at 23:05
  • Like you’re saying it would work if you just had pip install -e subpackages ? – Leila Abdelrahman Feb 01 '20 at 15:26
  • Installing the subpackage directly with pip works fine both by specifying the directory and by adding the link and calling it by name. I am trying to get it to install when i install the parent package by adding it to setup.py – jmerkow Feb 01 '20 at 16:15

0 Answers0