I have been developing a small python-based package that contains multiple scripts that are to be used as command line tools in linux environment.
This has a typical package structure:
MyPackage/
├── LICENSE
├── README.md
├── MyPackage
│ ├── __init__.py
│ ├── command1.py
│ ├── command2.py
│ ├── command3.py
│ ...
├── pyproject.toml
├── setup.py
I want for the commands to be found as command line tools after installing this package by
pip install .
However, after installation, my environment does not find the commands. Checking a lot of resources, it seems that the problem is likely to be with the setup.py file, or more specifically, with entry points. If entry points are set properly, the commands are supposed to be found at bin directory, but they are not found. pip show MyPackage prints the following directory only: /home/My/../python3.12/site-packages/MyPackage
The following is my setup.py
import setuptools
with open("README.md", "r") as fh:
long_description = fh.read()
setuptools.setup(
name="MyPackage",
version="0.0.1",
author="Me",
description="my package",
entry_points={
'console_scripts': [
'command1=MyPackage.command1:main',
'command2=MyPackage.command2:main',
'command3=MyPackage.command3:main'
],
},
packages=setuptools.find_packages(),
classifiers=[
"Programming Language :: Python :: 3",
"License :: OSI Approved :: MIT License",
"Operating System :: OS Independent"],
python_requires='>=3.6',
install_requires=['numpy>=1.17.2']
Of course, I can add some files to bin that calls the commands of my package. But I want to make it pip available for other users.
I am sure this is not a problem of my environment since I tested it with multiple devices. I am using conda, but I am not sure if this is relevant.
I tried to install the package as user specific by adding --user with pip installation as suggested by some people online. However, it did not resolve the issue.
Could you please give me some help make it easily installable as a command line tool package?
$PATHto be found without full path. "pip show MyPackageprints the following directory only: /home/My/../python3.12/site-packages/MyPackage" Trypip show --files MyPackageto list all installed files; trypip show --files MyPackage | grep -F /bin/to get the bin directory; the path is related to the root location which you can get withpip show --files MyPackage | grep "Location:\|/bin/"pip show --files MyPackageshowsLocation: /home/My/../python3.12/site-packagesand no any bin directories. If I understand setuptools correctly, the executable commands must be installed in a bin directory to be available without calling python or anything (like we can callpipcommand). This is the problem that I want to resolve.pip install .installs a package based onpyproject.tomlbut notsetup.py, and the commands were not defined in the pyproject. After defining them, I found that the commands are properly located in a bin directory. Thank you for your comments.