I just learned to upload my own python packages to PyPI thanks to this amazing tutorial. I am trying now to better understand how wheels
works and I found this article helpful.
However, I still do not understand why python setup.py bdist_wheel
creates an almost empty directory named build
with two subfolders: bdist.win-amd64
(empty) and lib
(which contains a copy of my package), in addition to the .whl
file in the dist
directory that developers will later upload to PyPI by doing python -m twine upload dist/*
.
Why is this build
directory necessary? I mean, would the dist
directory not be enough? Moreover, why is the .whl
called a binary distribution if the code is not actually compiled.
python setup.py bdist_wheel
internally runs python setup.py install
which in turn runs python setup.py build
which compiles/builds the project into a temporary location inside build/
directory and then installs compiled project into another temporary location inside build/
directory. From files in that second temporary location it creates a wheel.
As for the compilation — python modules could be written in C/C++ and often they are. So python setup.py build
needs to compile. If there is nothing to compile — well, the compilation step is skipped but the build step is still run.