How to recursively resolve dependencies using setup.py with local packages?

I am designing a python project like this:

packages/
    __init__.py
    setup.py
    requierment.txt         # Require package1
    commons/
        __init__.py
        setup.py
        requirement.txt
        Common_module.py
    package1/
        __init__.py
        setup.py
        requirement.txt      # Require commons
        Package1_module.py

      

When I do pip install -r requierment.txt -t ./installation

, I would like to create a folder where I have package1

and commons

, but it seems that it does not resolve dependencies package1

, leaving the installation with package1

.

How can I resolve return issues?

After some research, I found that I requierment.txt

should display all dependencies, but I really don't want to.

So, I tried the following:

from distutils.core import setup

required = []
with open('requirements.txt') as f:
     for line in f.readline():
         if not line.startswith('#'):
             required.append(line.rstrip())

setup(...
    install_requires=required)

      

But now it looks for my dependencies on the internet and not in my folder, even if it required

is a list of local paths.

This is a simplified view of my problems, I can modify my project a bit, but suppose the first .txt requirement cannot know the dependencies of the subpackages (like the commons package).

Is there a good way to solve dependencies successfully?

Thank!

+3


source to share





All Articles