Distribute wreath Python applications

Let's say I have a Python application that will be used as a command line tool. This application has some external dependencies. How am I going to distribute this?

I know it is common to install Python stuff in a virtual environment (virtualenv or pyvenv), but if the application is to be used from the command line, I don't want me or my users to activate the correct virtual environment every time they want to use my application.

Is there a solution? Or should I just put all the dependencies in setup.py and leave it to the user, whether they create a virtual environment or not?

+3


source to share


3 answers


Use setup.py

and specify dependencies in install_requires

.

Now to the part "How to distribute it?"

In our company, we run our own pypi server. Every package that is installed on our servers must be on our pypi server. The software is not downloaded directly from the Internet to the server.



If you want to create an open source tool, you must upload it to the official pypi server.

The tool doesn't have to take care of its environment. It should work in virtualenv and outside.

Maybe sampleproject can help you: https://github.com/pypa/sampleproject

+2


source


I mentioned an alternative file solution requirements.txt

for pip

. See Documentation:

https://pip.pypa.io/en/latest/user_guide.html#requirements-files



The user then knows what dependencies your application has and can easily install them into their virtual environment using pip install -r requirements.txt

.

The file can be easily created with pip freeze > requirements.txt

.

+1


source


This look depends on who you think will be using your application. If you distribute it via pip, your user should be able to decide whether to use virtual or not. If you want your users to just download your script from the website (maybe even for windows) and it "just works", you can link your dependencies (and maybe even the python interpreter) and then change the PYTHONPATH accordingly ... Of course, you can also use different distribution methods, eg. a docker image .

0


source







All Articles