Say I have a Python app that will be used as a command line tool. This app has some external dependencies. How would I go about distributing this?
I know it's common to install Python stuff in a virtual environment (virtualenv or pyvenv), but if the app is to be used from the command line I don't want to have me or my users to activate the correct virtual environment every time they want to use my app.
Is there a solution to this? Or should I just put all dependencies in setup.py and leave it up to the user whether they create a virtual environment or not?
Use a setup.py
and list the dependencies in install_requires
.
Now to the part "How to distribute this?"
In our company we run our own pypi server. Every package that gets installed on our servers must be from our pypi server. No software gets downloaded directly from the internet to the server.
If you want to build an open source tool, you should upload it to the official pypi server.
The tool should not care about its environment. It should work in a virtualenv and outside.
Maybe the sampleproject helps you: https://github.com/pypa/sampleproject
I will mention an alternative solution with a requirements.txt
file for pip
. See the documentation:
https://pip.pypa.io/en/latest/user_guide.html#requirements-files
The user then knows what dependencies your app has and can easily install them into his/her virtual environment with pip install -r requirements.txt
.
The file can easily be created with pip freeze > requirements.txt
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With