Search code examples
pythonpython-3.xsetuptoolspython-wheel

Difference between building distribution packages with python3 and python2?


I am trying to build python packages using this doc

I have couple of questions

  1. Is there any difference in wheel packages generated using tools(setuptools and wheel) with python2 versus python3.

  2. Are packages generated by python3 setup.py bdist_wheel compatible with python2 and vice versa (assuming the source code is compatible with both versions).


Solution

  • Is there any difference in wheel packages generated using tools(setuptools and wheel) with python2 versus python3.

    There may be some byte-for-byte differences due to differing zip compression algorithms, but there is no meaningful difference, except...

    Are packages generated by python3 setup.py bdist_wheel compatible with python2 and vice versa (assuming the source code is compatible with both versions).

    By default, a wheel built with Python 2 will only be valid for Python 2, and a wheel built with Python 3 will only be valid for Python 3. This can be changed by adding the following to the project's setup.cfg file:

    [bdist_wheel]
    universal = 1
    

    With this option added, generated wheels will be "universal", compatible with both Python 2 and Python 3.