How to develop a company.package2 with company.package1 dependency without namespace conflicts (python, pep 423)

29 views Asked by At

I'm in the process of publishing several packages on pypi. After doing some reading I like the idea of using a company.package naming convention to avoid namespace conflicts. (e.g. https://peps.python.org/pep-0423/#use-a-single-name, https://medium.com/@ashley.e.shultz/naming-company-python-packages-d1295fb9008d)

For instance (from medium article):

import name package name distribution name
acme.requests_utils acme-requests-utils acme-requests-utils

Structure:


└── acme
    └── __init__.py
    └── request_utils
        └── __init__.py  

This isn't a problem per say, but becomes a problem if I want to develop, debug, test, etc. another company package that has a company package as a dependency (installed by pip) in an IDE.

So for example working on: acme-webcrawer as an active development (e.g. a project within an IDE at pythonprojects/)

With a structure:

└── acme
    └── __init__.py
    └── webcrawler
        └── __init__.py
        └── crawler.py

if crawler.py has an import :

from acme.request_utils import requester

will yield an exception:

ModuleNotFoundError: No module named acme.request_utils

as the local folder "pythonprojects/acme" overrides the "./site-packages/acme" folder

Once the package is published and installed via pip it's no problem as then everything in the site-packages/acme folder, but it makes it a real pain to fix bugs.

I must not be the first person to have this issue. Is there a clever solution or am I being dumb (a real possibility), or doing something dumb that's just going to make my life harder?

FYI if it's important I use pycharm as my IDE.

I have considered using relative imports in my package, but this seems like a poor strategy

0

There are 0 answers