1

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 environment and make it as simple as downloadable install on a users local machine, so they have all the appropriate 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.

1 Answer 1

2

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:

  • define which Python version is needed and pip will check if it is fulfilled
  • define dependencies that pip will also install along with it
  • define a path to a function that serves as entry point for a command that becomes available on the console (this will be your CLI tool)

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/

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.