Search code examples
pythonpackagerepositorystructuresetuptools

Python package organization/setup to shorten import


so I'm preparing a Python package which is completely new for me. The structure is as follow:

package_name/
├── package_name/
    ├── datasets/
    ├── __init__.py
    └── functions.py
├── tests/
├── LICENSE
├── MANIFEST.in
├── pyproject.toml
├── README.md
└── setup.cfg

I'm using setuptools and testing it using testpypi and everything is working correctly, installing all the dependencies and so on. However when I try to import it to a file and use a function, let's call it abc() from functions.py file in order to have it working I have to import the entire pipeline:

import package_name.package_name.functions as pnf

in order to access to the functions from there. What do I need to modify - files structure? or add - to setup, init or elsewhere to have it shorter, like:

import package_name.functions as pnf

? Thanks, Chris


Solution

  • So it turn out, the problem was relatively simple, all it had to be done was to change setup.cfg file, so:

    [options]
    packages = package_name
    

    instead of using find: this solved the problem. Chris