pythoninstallationcommand-line-interfacepackagingsoftware-packaging

How to distribute my python CLI scripting application?


I have a python script that uses CLI that I would like to package and share with the users of another team I am working with. Essentially, I was wondering what the best way would be to automate:

  1. Downloading and installing the appropriate version of Python that is required for the script to run automatically onto the user's local machine.
  2. Creating/Provisioning the appropriate virtual environmnent - with all the references/paths pointing to the user's local machine
  3. Packaging my python project - which includes scripts, class files, init file, and requirements.txt while maintaining the project structure I had to run the script
  4. How to determine the best location on the local machine to have this application live so it is simple for users to navigate and run the command from the appropriate location

My thought process was to create a .exe file to run all these steps but I feel like that may still be too complicated? Additionally, I would train the users on how to run the command and what flags they would need to use.

Any thoughts on what tools, libraries, packaging techniques, or containerizing would be very welcome.

TLDR - Want to completely bundle my enviroment and make it as simple as downloadable install on a users local machine, so they have all the appropraite provisioning for the app setup and all they need to know is how to run the command from the correct directory where the application lives.

Thank you!


Solution

  • You can create a Python package with setuptools that can be easily installed on another machine with pip, either from a directory or repository you provide, or even from PyPI if you upload your package to it. I think this allows you to define all the things you listed, by adding suitable entries in setup.py, which is the file that is used to specify what you want to do with setuptools:

    You can find descriptions and tutorials by searching for python setuptools cli in your favorite web search engine. Here's one example (but links don't last all eternity): https://click.palletsprojects.com/en/8.1.x/setuptools/