1

I'm splitting up a large python project into multiple subcomponents (although not really relevant to the discussion, it's a Django project). The original project contained a root package rbx and subpackages under it, e.g.:

rbx/
    __init__.py
    a/
        __init__.py
        # etc.
    b/
        __init__.py
        # etc.
    etc.../

I've extracted rbx.a into a separate distributable component (setup.py and all) so that I now effectively have two projects:

rbx/
    __init__.py
    a/
        __init__.py
        # etc

...and...

rbx/
    __init__.py
    b/
        __init__.py
        # etc
    etc.../

When I try to install rbx.a it as a dependency in the second project (e.g. using pip install) python cannot find the package (cannot find a within rbx). It would look like since rbx exists locally, Python won't look outside in the PYTHONPATH for additional subpackages.

I was in a way expecting this to work like Java, but I understand Java packaging (which is just namespacing) and Python packages and import mechanics are quite different.

Is there a way to achieve this in Python? What would it be?


As requested, here is my anonymised setup.py:

try:
    from setuptools import setup
except ImportError:
    from distutils.core import setup

setup(
    name='rbx_a',
    version='1.0.0',
    author='xxx',
    author_email='tech@xxx.com',
    packages=['rbx_a', 'rbx_a.templatetags'],
    include_package_data=True,
    license='MIT',
    description='Common python/django library used across RBX projects',
    classifiers=[
        'Development Status :: 3 - Alpha',
        'Environment :: Web Environment',
        'Intended Audience :: Developers',
        'Framework :: Django',
        'License :: OSI Approved :: MIT License',
        'Natural Language :: English',
        'Operating System :: OS Independent',
        'Topic :: Internet :: WWW/HTTP',
    ],
    install_requires=[
        "Django>=1.4.13",
    ],
)
Carles Barrobés
  • 11,608
  • 5
  • 46
  • 60
  • I'm not really familiar with deploying & stuff, so I'm leaving writing a good answer to someone else. I'm unsure whether it would be appropriate to close this question as a duplicate or not, since the answers to the other questions are quite old and they may not be currently valid. Even though you could simply add a bounty to the other question to request for currently valid answers. – Bakuriu May 26 '14 at 09:23
  • Could you also post the contents of your `setup.py` file, please? – Midnighter May 26 '14 at 09:42
  • thanks @Bakuriu yes a namespace package is what I want and that question you linked to contains the solution to my problem. I've voted to close as duplicate. – Carles Barrobés May 26 '14 at 11:22

0 Answers0