adafruit / cookiecutter-adafruit-circuitpython

Cookiecutter template for Adafruit's CircuitPython libraries.
MIT License
22 stars 37 forks source link

Metadata Errors and Python Wheel Issue #83

Closed walchko closed 2 years ago

walchko commented 4 years ago

I wrote this in another issue, adafruit/Adafruit_CircuitPython_LSM6DS#24, but it was suggested I make it its own issue.

siddacious commented 4 years ago

Thanks for creating this issue @walchko; I've moved it to the cookiecutter repo because it's the template we use for all of the libs, so the setup.py gets generated from here: https://github.com/adafruit/cookiecutter-adafruit-circuitpython/blob/master/%7B%7B%20cookiecutter.library_name%20%7D%7D/setup.py#L63

@theacodes can you give your input here? I'm a total newb when it comes to python packaging

sommersoft commented 4 years ago

While I wasn't personally involved in setting up the initial setup.py that is in use for PyPI'd CircuitPython libraries, I'll try and add some of the "why"s for the classifiers. @kattni, please correct me if I'm wrong on any of this speculation.

walchko commented 4 years ago

So, I am not sure there is any impact of showing older python versions in the metadata, but here in your gitworkflow, you are specifically pulling python 3.6 to run your tests.

Also, I made a mistake, when your code here builds the source and wheel package, it only checks if the readme will display correctly on pypi ... it doesn't push it to pypi. You do that in release.yml here, but you only do: python setup.py sdist. You could change that to python3 setup.py sdist bdist_wheel and build both wheels and source. Just a suggestion. :smile:

2bndy5 commented 3 years ago

The cookiecutter repo only calls setup.py sdist in the release.yml Technically, @walchko is correct: the python setup.py bdist_wheel --universal call doesn't need to be in the build.yml file. So this issue is actually 2 issues wrapped in 1.

About using setup.py bdist

See PyDocs about using wheels for install. @walchko the --universal option is documented in the PyDocs

To my understanding, the bdist option is meant for packages that:

  1. take an unusually long time to build. The package would have to be VERY large (consisting of many many modules) for this to become a problem.
  2. aren't all pure python. Say you have a package that's wrapping some C++ using pybind11 (or one of the various extensions that implement Python's C API), building/uploading wheels to pypi is required, so that pip can determine which binary wheel to install (based on the local machine's OS/arch bitness/Python Version/etc). Furthermore, distributing wheels in this situation relieves pip on the target machine of having to make sure the right version of gcc (and possibly boost.python) is installed.

Because CirPy firmware does not support extension packages that are written in C++ and typical CirPy packages are relatively small/quick to install, I'm not sure uploading binary wheels to pypi would be valuable (it might only complicate things for distribution).

About the classifiers list

The items in this list are only used to filter searching/browsing on pypi.org. They don't actually stipulate hard requirements for package installs/execution. (see PyDocs for more detail)

About pyproject.toml file

This file (introduced as part of PIP518) basically tells pip to create a temp venv for building the package during install. It is meant as an alternative to putting build-time-only dependencies in requirements.txt file. After install, the temp venv is destroyed. CirPy packages shouldn't need any extra build-time dependencies, especially for CirPy firmware compatible packages. Currently, this repo uses pyproject.toml to tell the black linter what Python version to support (I think)

@walchko I've never heard of the "poetry" project, but it does look interesting. Thanks for the lead! FYI, the pyproject.toml isn't specific to the peotry project, and I think some of the poetry project's usage in pyproject.toml may be specific to the poetry project.

tekktrik commented 2 years ago

With the migration to pyproject.toml, Python wheels are being built and uploaded, and the classifiers have been updated.