Skip to content

Commit

Permalink
Build wheel for PyPy
Browse files Browse the repository at this point in the history
This is a tricky situation, because the PyPy wheel is special — it does
not contain the C extension. We do not want this being picked up by
anything except pypy.

Unfortunately, after pip version 19.3.1 (and until at least version
20.1.1), pip will not pick up the `pp3-none-any.whl` tag (see
https://github.com/pypa/pip/issues/8347 ), so pypy users with a recent
version of pip will get the sdist (which is our only alternative really
anyway). We'll ship these wheels anyway, since this seems to be an issue
with pip, and this is indeed the proper tag for PyPy 3 wheels.
  • Loading branch information
pganssle committed May 28, 2020
1 parent 90c755b commit 3c6e456
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 0 deletions.
22 changes: 22 additions & 0 deletions .github/workflows/build-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,28 @@ jobs:
name: dist
path: dist

build_pypy_wheel:
runs-on: 'ubuntu-latest'
name: Build PyPy wheel
steps:
- uses: actions/checkout@v2
- name: Setup python
uses: actions/setup-python@v2
with:
python-version: 'pypy3'
- name: Install dependencies
run: |
python3 -m pip install --upgrade pip
python3 -m pip install tox
- name: Build wheel
run: tox -e build -- -b
- name: Set python tags to pp3
run: python scripts/rename_pypy_wheel.py
- uses: actions/upload-artifact@v2
with:
name: dist
path: dist

deploy:
runs-on: 'ubuntu-latest'
needs: [build_sdist, build_wheel, build_manylinux_wheels]
Expand Down
22 changes: 22 additions & 0 deletions scripts/rename_pypy_wheel.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import pathlib


def main():
(generic_wheel,) = pathlib.Path("dist").glob("*.whl")

name = generic_wheel.name
old_comp = "-py3-none-any.whl"
if not name.endswith(old_comp):
raise ValueError(
f"Unexpected wheel name, does not end with " + f"{old_comp}: {name}"
)

new_name = name[: -len(old_comp)] + "-pp3-none-any.whl"
new_wheel = generic_wheel.parent / new_name

generic_wheel.rename(new_wheel)
print(f"Successfully renamed {generic_wheel} to {new_wheel}")


if __name__ == "__main__":
main()

0 comments on commit 3c6e456

Please sign in to comment.