I'm trying to create a python program that has an entry point script in pyproject.toml
. However, I haven't been able to get the program to execute from both the entry point script for the installed package in a venv, and from the command line in the usual manner. The only way I could get it to work was to have two copies of the starting module file, in separate directories.
The directory structure is:
/path/to/example/project/
├── example/ Python package directory.
│ ├── __init__.py This makes the directory a package.
│ ├── start_module.py The starting program module
│ └── main_module.py The main program module.
├── start_module.py Copy of the starting program module.
├── pyproject.toml Definition of build process of the package.
└── setup.cfg Configuration details of the python package.
and the pyproject.toml
has:
[project.scripts]
runscript = "example.start_module:main"
start_module.py
consists of:
from example.main_module import main_Module
def main():
result = main_Module()
I can run this program from the command line in root directory project/
using:
python start_module.py
and from the virtual environment where the package is installed using:
runscript
but I haven't been able to reconcile these two arrangements with a single copy of start_module.py
in either the root directory or the package directory. I think I'm missing something about package imports but can't put my finger on it.