russ_user123
russ_user123

Reputation: 11

How to import specific packages from common/shared folder?

I am relatively new to python and am trying to find a good way to share common code amongst multiple projects.

Say I have folder structure below and both Proj1/Proj2 have their own environments (left out for simplification):

/Development
    /Common
        __init__.py
        setup.py
        /CommonA
            __init__.py
            commonA.py
        /CommonB
            __init__.py
            commonB.py
    /Proj1
        main1.py
    /Proj2
        main2.py

and setup.py:

from setuptools import setup, find_packages

setup(name='Common',
      version='0.1',
      description='Common Code',
      author='Me',
      license='MIT',
      packages=find_packages(),
      zip_safe=False)

If I am working in Proj1, I can "pip install .\Common" which pulls in both CommonA and CommonB.

That's great if Proj1 needs both modules, but what if Proj1 only needs CommonA? Is there a way to only install CommonA without changing setup.py each time I pip install?

Upvotes: 1

Views: 23

Answers (0)

Related Questions