Python has a package management ecosystem (the libraries) integrated both in the language and in its own packages.
PIP - a much needed tool that has become part of the new Python installations since Python 3.3 solves manually the question of dependencies for those who are in a hurry and do not want to leave the round package to third parties.
Of course, all of this assumes that your project is already running in a separate virtualenv, where the only libraries installed besides your own project are the ones you want to ensure are installed in the destination.
If you are not already using Virtualenv for its development, take a look here:
http://docs.python-guide.org/en/latest/dev/virtualenvs/ (or, for Python >= 3.3 venv, which comes with Python): https://docs.python.org/3/library/venv.html
In this case, you can use PIP to create a file with the list of Python libraries installed in your project - type:
pip freeze >requirements.txt
in the terminal, with the virtualenv activated. This will automatically list the installed libraries in the "Reset.txt" file-- whoever installs your program, after having the code in hand, and creating virtualenv, must type:
pip -r requirements.txt
.
Python developers used to take and place projects on sites like github will know how to install packages and libraries following this recommendation.
But, that doesn’t answer your question - if you want a layman to be able to install your program, having only Python installed, that’s possible yes - but it takes a little more work to get it right the first time, for the developer.
You will then make use of "setuptools" - a Python package made for, from information about your project that you put in a filename setup.py
- This file is a small Python program where you put not only the dependencies of your project, (such as module build instructions, if there is part of the project in C or Cython), metadata about the version number of the project, author, and license of use and so on.
The setuptools makes the setup.py
function as a full command line application, with several options. One of them is even calling direct
python setup.py bdist_wininst
- that in a properly configured Windows environment will generate a file. EXE that installs your application and its requirements (only does not install Python - as pyfreeze and other utilities do).
Now setuptools is used, more normally, not to create installables for Windows - and yes - to put your project, once tested and fulfilling some quality requirements, right in Pypi - the "Python Package Index".
From there, anyone with Python and Pip (or easy_install) installed will be able to install your project simply by typing:
"Pip install " (and, yes, this installs your project and the libraries it depends on).
For programmers and Python users it turns out to be more practical than having an installer on some web site - you don’t have to find the site, download the file, and run it - just type the command. (And also your project becomes part of the list of projects that may be requirements of others).
For the lay public who will install, for example, a game made with Pygame, the form with Windows installer is certainly more convenient.
The setuptools documentation is something that is really worth studying if you want to distribute your projects to the general public, whether end users or even the Python programmer community. Start with the link:
https://pypi.python.org/pypi/setuptools
It would be interesting to open another question regarding password protection, even if it is the distribution process and python, so you can have help from more people and more direct answers.
– Delfino
I’ve already taken the last question.
– André