From 760a98a409a9f2c76640e51f022c5342201c381a Mon Sep 17 00:00:00 2001 From: Cody Piersall Date: Mon, 15 Jan 2024 21:04:49 -0600 Subject: [PATCH] Have cibuildwheel also create source distribution. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Does it *actually* make sense for a job called "cibuildwheel" to build a source distribution? I mean, not really, if you go by the words literally. The whole point of the job, it would seem, is to build *wheels*. And here we are building a *source* distribution. Completely absurd! Absolutely ridiculous! Has nothing to do with the name of the job! Au contrare mon frère, the while the name of the job would indicate that it should only build wheels, the *purpose* of the job, truly, is to build all things that should be uploaded to PyPI. With that understanding, the cibuildwheel job should certainly be the job that builds the source distribution as well. "But", perhapse you say, "the way you are building the source distribution is an absurdity! You install the package first, then build the source distribution! Why build the package if you just want the source? The rest of the job is *already* building everything anyway!" Ah yes, an excellent point. Ideally, one would not need to install the package to simply create a source distribution. That certainly seems counterintuitive. However, in our case, the way our setup script works is to download *and build* our dependencies in a single step. This is clearly not *conceptually* the best way to do it, but it sure as heck is convenient. Plus we don't understand setuptools when we get right down to it, and we don't want to figure out how to separate the fetching from the building. It's not my idea of a good time. Anyway, this is a Good Commit™ because then you don't have to build a sdist manually later. And when I say "you" I really mean "I", since I am the one that does it. And when I have to do manual steps, I do them wrong. Not all the time, but sometimes. Often enough that I fear them. With this commit in place, you can just download all artifacts, then upload them to PyPI. Someday, perhaps, we will allow GitHub to upload to PyPI automatically, once we build up confidence. --- .github/workflows/cibuildwheel.yml | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/.github/workflows/cibuildwheel.yml b/.github/workflows/cibuildwheel.yml index bb9fe2c..50351e5 100644 --- a/.github/workflows/cibuildwheel.yml +++ b/.github/workflows/cibuildwheel.yml @@ -19,3 +19,22 @@ jobs: - uses: actions/upload-artifact@v3 with: path: ./wheelhouse/*.whl + # create the source distribution + make_sdist: + name: Make SDist + runs-on: ubuntu-20.04 + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 0 # Optional, use if you use setuptools_scm + submodules: true # Optional, use if you have submodules + + - name: Build SDist + run: | + pip install build + pip install -e . + python -m build --sdist + + - uses: actions/upload-artifact@v3 + with: + path: dist/*.tar.gz