How to install multiple python namespace packages in editable mode

  pip, python, setuptools

I created multiple packages according to the PEP420 implicit namespace packaging method. Two of those distribution packages are dende-github-api and dende-gitlab-api. Each of those distributions contains one module which I want to be accessible unter the dende.api namespace. A minimal working example can be found here: https://github.com/dende/example-monorepositry

This is the folder structure of the Repository containing both distributions:

example-monorepository
├── dende-github-api
│   ├── dende
│   │   └── api
│   │       ├── github.py
│   │       └── __init__.py
│   └── setup.py
├── dende-gitlab-api
│   ├── dende
│   │   └── api
│   │       ├── gitlab.py
│   │       └── __init__.py
│   └── setup.py
├── requirements.dev.txt
└── requirements.txt

And the setup.py‘s look like this (only showing for dende-github-api):

from setuptools import setup

setup(
    name='dende-github-api',
    packages=['dende.api'],
    install_requires=[
        'PyGithub'
    ]
)

I can install both distributions and use them just fine:

$ pip install ./dende-github-api ./dende-gitlab-api
$ python -m dende.api.github
Hi from dende-github-api from /home/c/git/example-monorepositry/venv/lib/python3.8/site-packages/dende/api/github.py
$ python -m dende.api.gitlab
Hi from dende-gitlab-api from /home/c/git/example-monorepositry/venv/lib/python3.8/site-packages/dende/api/gitlab.py

When I install both distributions in editable mode, only one of the installations work:

$ pip install -e ./dende-github-api ./dende-gitlab-api
python -m dende.api.gitlab                          
Hi from dende-gitlab-api from /home/c/git/example-monorepositry/venv/lib/python3.8/site-packages/dende/api/gitlab.py
python -m dende.api.github
/home/c/git/example-monorepositry/venv/bin/python: No module named dende.api.github

Somehow the second installation seems to shadow the installation of the oder distribution in the overlapping namespace. Is there a way to install overlapping packages like these in editable mode?

Source: Python Questions

LEAVE A COMMENT