I have a few projects, all containing setup.py
and requirements.txt
. Is it possible to package a whole project in one single file including all requirements compiled and ready to install?
What I have tried:
python setup.py bdist_wheel
Builds a .whl
file and puts it in the dist
directory. The wheel does not contain any dependencies.
pip wheel -r requirements.txt -w wheelhouse
Builds wheels for every single requirement and puts it in the wheelhouse
directory. Includes nicely compiled code for numpy
for example (I know I have to build this on every platform I want it to run later on, that's fine).
Seems I am just missing the last piece of the puzzle.
Installing Python dependencies The recommended way to install Python library dependencies is with the pip command when a virtualenv is activated. Pip and virtualenv work together and have complementary responsibilities. Pip downloads and installs application dependencies from the central PyPi repository.
Install_requires Example install_requires is a section within the setup.py file in which you need to input a list of the minimum dependencies needed for a project to run correctly on the target operating system (such as ubuntu). When pip runs setup.py, it will install all of the dependencies listed in install_requires.
Using venv and pipenv are two methods of managing dependencies in Python. They are simple to implement and, for most users, adequate solutions for handling multiple projects with different dependencies. However, they are not the only solutions. Other services can complement their use.
You probably want to take a look at tools like cx_Freeze or PyInstaller if you absolutely want one single file containing everything. Pip itself cannot do what you want.
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