Menu

#14 Upload wheels to PyPI rather than eggs

1.0
open
nobody
None
2021-04-15
2021-04-15
John Hagen
No

Wheels are current best practice for distributing Python packages: https://packaging.python.org/discussions/wheel-vs-egg/

Wheels (.whl) for this package are currently missing from PyPI. Could wheels be uploaded for the current and future releases?

Read more about the advantages of wheels to understand why generating wheel distributions are important.

To create a wheel along with source distribution:

(venv) $ pip install --upgrade pip setuptools wheel
(venv) $ python setup.py sdist bdist_wheel

# See dist/*.whl

To upload wheels:

(venv) $ pip install twine
(venv) $ twine upload dist/*

I would recommend the publishing procedures for this project be updated to upload wheels in place of eggs. Eggs should no longer be needed these days (I have not seen an active project publish them in many years).

Discussion

  • Dave Kuhlman

    Dave Kuhlman - 2021-04-15

    John,

    Thank you for this suggestion and your guidance.

    OK. I've added it to my build script and have built a *.whl file. I have not yet uploaded it to PyPI.

    Am I supposed to upload both the wheel and the egg files? Or, are egg files no longer in use? Is there any downside to uploading both wheel and egg files o PyPI?

    I'm curious -- Given the way we currently have it (an egg but not a wheel at PyPI), does PyPI automatically convert the egg to a wheel when I install generateds using pip?

    Thanks in advance for help.

     
  • John Hagen

    John Hagen - 2021-04-15

    Am I supposed to upload both the wheel and the egg files? Or, are egg files no longer in use? Is there any downside to uploading both wheel and egg files o PyPI?

    The eggs are not needed and aren't used any more as far as I can tell. I would simply avoid uploading them any longer.

    From the test below, this is working as I had expected. The egg is ignored and the sdist (.tar.gz) is being downloaded for every client and a wheel is built after the fact.

    When a wheel is uploaded, pip will simply download and install it directly, avoiding the need for each user to run the build step.

    python --version
    Python 3.9.1
    
    pip list
    Package    Version
    ---------- -------
    pip        21.0.1
    setuptools 56.0.0
    wheel      0.36.2
    
    pip install generateds
    Collecting generateds
      Downloading generateDS-2.38.6.tar.gz (1.2 MB)
         |████████████████████████████████| 1.2 MB 729 kB/s 
    Collecting six
      Using cached six-1.15.0-py2.py3-none-any.whl (10 kB)
    Collecting lxml
      Downloading lxml-4.6.3-cp39-cp39-macosx_10_9_x86_64.whl (4.6 MB)
         |████████████████████████████████| 4.6 MB 1.6 MB/s 
    Collecting requests>=2.21.0
      Using cached requests-2.25.1-py2.py3-none-any.whl (61 kB)
    Collecting chardet<5,>=3.0.2
      Using cached chardet-4.0.0-py2.py3-none-any.whl (178 kB)
    Collecting urllib3<1.27,>=1.21.1
      Using cached urllib3-1.26.4-py2.py3-none-any.whl (153 kB)
    Collecting certifi>=2017.4.17
      Using cached certifi-2020.12.5-py2.py3-none-any.whl (147 kB)
    Collecting idna<3,>=2.5
      Using cached idna-2.10-py2.py3-none-any.whl (58 kB)
    Building wheels for collected packages: generateds
      Building wheel for generateds (setup.py) ... done
      Created wheel for generateds: filename=generateDS-2.38.6-py3-none-any.whl size=139817 sha256=0b72590ce94e60928b10cf13836f0ee380638f1c58d7126f0868fb6a113b6e8f
      Stored in directory: /Users/hagenjt1/Library/Caches/pip/wheels/84/4d/e0/e6d35450bbd581aa8445cea6fece9987fa2521c135a97fafab
    Successfully built generateds
    Installing collected packages: urllib3, idna, chardet, certifi, six, requests, lxml, generateds
    Successfully installed certifi-2020.12.5 chardet-4.0.0 generateds-2.38.6 idna-2.10 lxml-4.6.3 requests-2.25.1 six-1.15.0 urllib3-1.26.4
    
     

    Last edit: John Hagen 2021-04-15
  • Dave Kuhlman

    Dave Kuhlman - 2021-04-15

    Thanks for advice.

    I've uploaded the wheel for the latest version (v. 2.38.6). I won't try to delete any egg files at PyPI (don't know if that can be done).

    But I've remove the egg file from the script that I use to do the upload to PyPI (generateds/upload_pypi). So, the egg will not be at PyPI for future versions. If someone complains, I can always put it back.

    Thanks again for the suggestion. And, please let me know whether the wheel (from PyPI) does what you expect it to.

     
  • John Hagen

    John Hagen - 2021-04-15

    Everything looks great now:

    pip install generateds
    Collecting generateds
      Downloading generateDS-2.38.6-py3-none-any.whl (139 kB)
         |████████████████████████████████| 139 kB 682 kB/s 
    Collecting requests>=2.21.0
      Using cached requests-2.25.1-py2.py3-none-any.whl (61 kB)
    Collecting six
      Using cached six-1.15.0-py2.py3-none-any.whl (10 kB)
    Collecting lxml
      Using cached lxml-4.6.3-cp39-cp39-macosx_10_9_x86_64.whl (4.6 MB)
    Collecting urllib3<1.27,>=1.21.1
      Using cached urllib3-1.26.4-py2.py3-none-any.whl (153 kB)
    Collecting certifi>=2017.4.17
      Using cached certifi-2020.12.5-py2.py3-none-any.whl (147 kB)
    Collecting chardet<5,>=3.0.2
      Using cached chardet-4.0.0-py2.py3-none-any.whl (178 kB)
    Collecting idna<3,>=2.5
      Using cached idna-2.10-py2.py3-none-any.whl (58 kB)
    Installing collected packages: urllib3, idna, chardet, certifi, six, requests, lxml, generateds
    Successfully installed certifi-2020.12.5 chardet-4.0.0 generateds-2.38.6 idna-2.10 lxml-4.6.3 requests-2.25.1 six-1.15.0 urllib3-1.26.4
    
    generateds --version
    generateDS.py version 2.38.6
    
     

Log in to post a comment.

MongoDB Logo MongoDB