Skip to content

Commit

Permalink
feat: produce ABI-agnostic wheels for python (#1324)
Browse files Browse the repository at this point in the history
* feat: producce abi3 wheels for cpython

Signed-off-by: Frost Ming <mianghong@gmail.com>

* remove file added unexpectedly

Signed-off-by: Frost Ming <mianghong@gmail.com>

* Forcely write py2.py3-none wheels

Signed-off-by: Frost Ming <mianghong@gmail.com>

* Apply suggestions from code review

Co-authored-by: Jinjing Zhou <VoVAllen@users.noreply.github.com>
Signed-off-by: Frost Ming <mianghong@gmail.com>

Signed-off-by: Frost Ming <mianghong@gmail.com>
Co-authored-by: Jinjing Zhou <VoVAllen@users.noreply.github.com>
  • Loading branch information
frostming and VoVAllen authored Dec 20, 2022
1 parent 5c65988 commit 0a48acd
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 1 deletion.
2 changes: 2 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -78,9 +78,11 @@ jobs:
env:
CIBW_ARCHS_MACOS: arm64, x86_64
CIBW_ARCHS_LINUX: auto64
CIBW_SKIP: pp*
- name: Build source distribution
if: runner.os == 'Linux' # Only release source under linux to avoid conflict
run: |
python3 -m pip install wheel
python3 setup.py sdist
mv dist/*.tar.gz wheelhouse/
- name: Upload to PyPI
Expand Down
3 changes: 3 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[build-system]
requires = ["setuptools", "wheel"]
build-backend = "setuptools.build_meta"
15 changes: 14 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@
from setuptools.command.sdist import sdist
from setuptools import setup, Extension, find_packages
from setuptools.command.build_ext import build_ext
from wheel.bdist_wheel import bdist_wheel


import subprocess
import logging

Expand Down Expand Up @@ -53,6 +56,12 @@ def build_extension(self, ext: Extension) -> None:
build_envd_if_not_found()


class bdist_wheel_universal(bdist_wheel):
def get_tag(self):
*_, plat = super().get_tag()
return "py2.py3", "none", plat


class SdistCommand(sdist):
def run(self):
errno = subprocess.call(["make", "generate-git-tag-info"])
Expand Down Expand Up @@ -110,5 +119,9 @@ def get_version():
ext_modules=[
EnvdExtension(name="envd", sources=["cmd/*"]),
],
cmdclass=dict(build_ext=EnvdBuildExt, sdist=SdistCommand),
cmdclass=dict(
build_ext=EnvdBuildExt,
sdist=SdistCommand,
bdist_wheel=bdist_wheel_universal,
),
)

0 comments on commit 0a48acd

Please sign in to comment.