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",
],
)