I'm trying to create an installer for a CLI tool I'm developing with Click. The problem is that for some reason submodules aren't included in the installer, which results in the following error:
from modules.commands import modules
ModuleNotFoundError: No module named 'modules'
This is my directory structure:
.
├── LICENSE
├── README.md
├── setup.py
├── src
│ ├── app_config
│ │ ├── __init__.py
│ │ └── configuration.py
│ └── commands
│ ├── __init__.py
│ ├── config
│ │ ├── __init__.py
│ │ └── commands.py
│ ├── modules
│ │ ├── __init__.py
│ │ └── commands.py
│ └── cli.py
└── tests
cli.py
references commands created in config
and modules
. When I'm running cli.py
directly, it works fine. However, no matter what pattern I try for setup.py
to include packages, the submodules in commands
are not included.
This is the code for setup.py
:
setup(
name='cli',
version='0.1.0',
packages=find_packages(include=['src', 'src.*']),
install_requires=[
'Click'
],
entry_points={
'console_scripts': [
'cli = src.commands.cli:cli'
]
}
)
I've checked the find_packages
-implementation, but I can't see anything wrong with the way I've specified what is written above. I've also tried hardcoding all packages, but that didn't work either. I've also tried with src/*
, as maybe it uses full filepaths, but that didn't work either.
Edit: More Troubleshooting
Thanks to this question, I tried running python -c "from setuptools import setup, find_packages; print(find_packages('src'))"
. According to the output, it finds all the submodules:
['app_config', 'commands', 'commands.config', 'commands.modules']
However, when I update my setup to include the same value, it fails.
setup.py:
setup(
name='cli',
version='0.1.0',
packages=find_packages('src'),
install_requires=[
'Click'
],
entry_points={
'console_scripts': [
'cli = src.commands.cli:cli'
]
}
)
Output:
error: subprocess-exited-with-error
× python setup.py egg_info did not run successfully.
│ exit code: 1
...
error: package directory 'app_config' does not exist
[end of output]
note: This error originates from a subprocess, and is likely not a problem with pip.
packages
insetup.py
– Federicofedirko