I'm trying to split a big (almost monolithic) Python project into multiple pieces by utilizing Pythons namespace packages. Therefore I extracted a parser for *.rules
files into a namespace package. Python calls this a distribution.
I followed that guide and as far as I can tell it partially works, but ...
In short: In the main project, the namespaces of separately distributed namespace packages are not visible, because the package search finds local packages first and does not merge with the system packages from site-packages
.
Project Structure
Here is a part of my directory / package and module structure.
Main project:
pyIPCMI/ # Git repository root
pyIPCMI/
__init__.py
Common/
__init__.py
File1.py
Compiler/
__init__.py
Vendor1.py
Vendor2.py
setup.py
Distribution for rules parser
pyIPCMI.Parser.Rules/ # Git repository root
pyIPCMI/
Parser/
Rules/
__init__.py
Parser.py
setup.py
Package Descriptions (setuptools)
The main project is packaged like this:
import setuptools
setuptools.setup(
name="pyIPCMI",
version="1.1.5",
author="Paebbels",
author_email="abc@xyz.de",
description="",
long_description="",
url="https://github.com/Paebbels/pyIPCMI",
packages=setuptools.find_packages(),
classifiers=["License :: OSI Approved :: Apache Software License"],
python_requires='>=3.5',
install_requires=[],
)
The embedded namespace is packaged like this:
import setuptools
namespace = ["pyIPCMI", "Parser", "Rules"]
setuptools.setup(
name=".".join(namespace),
version="1.1.4",
author="Paebbels",
author_email="abc@xyz.de",
description="",
long_description="",
url="https://github.com/Paebbels/pyIPCMI.Parser.Rules",
packages=setuptools.find_namespace_packages(
include=[".".join(namespace), ".".join(namespace) + ".*"]
),
namespace_packages=namespace[0:1],
classifiers=["License :: OSI Approved :: Apache Software License"],
python_requires='>=3.5',
install_requires=[],
)
All distributions have been:
- packaged with
setuptools
using Travis-CI - deployed to PyPI, and then
- installed on the local machine using
pip
.
Namespace Structure at PyPI
pyIPCMI
pyIPCMI.Parser.Files
pyIPCMI.Parser.Rules
pyIPCMI.Toolchains
pyIPCMI.Toolchains.Vendor1
pyIPCMI.Toolchains.Vendor2
Problem Description
When developing in the main project with e.g. PyCharm, the locally found namespaces are preferred over packages from site-packages
. Moreover, these namespace don't get merged.
Because the main project has the same root namespace pyIPCMI
, search continues in the local development project but does not search in site-packages
.
Any idea how to be able to develop the main project?
Please advise what information is needed to solve this question. I tried to write down all information I have so far. But this question may need improvement to get a solution.