How to organize python package file structure for development and deployment?

37 views Asked by At

For a Python package I am developing, I have my package contents organized under a src/ subdir like so:

mylib/
    dist/
    docs/
    src/
        __init__.py
        foo/
            __init__.py
            foo1.py
            ...
        bar/
            __init__.py
            bar1.py
            ...
        ...              
    README.rst
    pyproject.toml
    requirements.txt

Building a wheel with python build and deployment works, but on my dev machine, I would like to import the new package right from the development directory rather than local-installing it every time I make a change. How do I skip the src/ directory from the import statement? I.e., in Python, I would like to be able to do

>>> from mylib import foo

rather than

>>> from mylib.src import foo

How do I do that?

0

There are 0 answers