My Python project uses various kind of libraries. What is the protocol if the end-user didn't have one or any of them?
Should a window pop up and notify him/her which package and version to download in his/her environment? Or I should include the libraries within my project?
What's the proper action?
Whatever your project is, you could try making it into a python package that the end-user would install. The way this works is
In the root directory of your package you would include a setup.py. You could include in this file a list of requirements/dependencies (the install_requires
key) that would be installed along with your package when the end-user installs it.
The end user could then use pip to install your package eg
pip install YourPackage
and all dependencies listed in setup.py would be installed first.
Additionally, as @Devesh Kumar Singh pointed out in his comment, you could also include a requirements.txt file. The user could then install using this file with
pip install -r requirements.txt YourPackage
See this guide for building a python package, setuptools documentation
To show other users, what libraries are needed for your project, you have multiple options. All options are some kind of files, that say which libraries are needed for this project.
Files that I am aware of
Another option: You can use PyInstaller to freeze (packages) Python applications into stand-alone executables, under Windows, GNU/Linux, Mac OS X, FreeBSD, Solaris and AIX.
PyInstaller Quickstart
This has worked very well for me. Indeed, you do not have to worry about whether the final user has Python installed.
Here is where packaging a python project into a module comes handy modules
We include a requirements.txt
file which contains all python module requirements needed for that python library, and installs them automatically when the module is setup.
A good primer on how to setup your module to be distributable is Structuring your project
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