I am writing a command line tool with Python. It should be as easy as possible for Windows 10 / 11 users to install and use. My goal is to make the following procedure work:
- Install Python from the Microsoft Store
- Install my program using
pip install "C:\path\to\myprogram.zip"
- Start my program using
myprogram
in Windows cmd
Currently, I have a setup.py
like this:
from setuptools import setup
setup(
name="myprogram",
# image additional arguments here
entry_points={"console_scripts": ["myprogram=myprogram.module:function"]},
)
Everything works great in virtual environments, but I don't want my users to necessarily deal with them. I understand that running the pip install ...
command above installs the entry point (in my case) to C:\Users\myuser\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.11_qbz5n2kfra8p0\LocalCache\local-packages\Python311\Scripts
, which is obviously not in Windows %PATH%.
So here comes my question: Is it possible to either
- write the script to one of the Windows %PATH%s (for example
C:\Users\myuser\AppData\Local\Microsoft\WindowsApps
) or - add
C:\Users\myuser\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.11_qbz5n2kfra8p0\LocalCache\local-packages\Python311\Scripts
to Windows %PATH%?
I want the solution to work directly from the setup.py
such that no additional installation step is necessary. I'm fully aware that there is only a small chance to find a solution that is not "hacky" in some way.
Workaround: As long as there is no solution to my question, I go with a __main__.py
module and burden the users with the command python -m myprogram
.