Search code examples
pythonvirtualenvsoftware-distribution

Distribute Python applications "with" a venv


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?


Solution

  • 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