Skip to content

Commit

Permalink
Correct the platform tag (#94)
Browse files Browse the repository at this point in the history
Signed-off-by: nojaf <[email protected]>
  • Loading branch information
nojaf authored Dec 5, 2024
1 parent a2bd841 commit 21dfd2e
Showing 1 changed file with 26 additions and 2 deletions.
28 changes: 26 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import os
import pathlib
import subprocess
import sys
from glob import glob
from typing import List, Tuple
Expand All @@ -22,6 +23,30 @@ def _prune_go_files(path: str):
pass


def get_platform():
goos = os.getenv(
"TARGET_GOOS", subprocess.check_output(["go", "env", "GOOS"]).strip().decode("utf-8")
)
goarch = os.getenv(
"TARGET_GOARCH", subprocess.check_output(["go", "env", "GOARCH"]).strip().decode("utf-8")
)
plat = f"{goos}_{goarch}"
if plat == "darwin_amd64":
return "macosx_10_13_x86_64"
elif plat == "darwin_arm64":
return "macosx_11_0_arm64"
elif plat == "linux_amd64":
return "manylinux_2_17_x86_64.manylinux2014_x86_64"
elif plat == "linux_arm64":
return "manylinux_2_17_aarch64.manylinux2014_aarch64"
elif plat == "windows_amd64":
return "win_amd64"
elif plat == "windows_arm64":
return "win_arm64"
else:
raise ValueError("not supported platform.")


def finalize_distribution_options(dist: Distribution) -> None:
dist.has_ext_modules = lambda: True

Expand All @@ -30,8 +55,7 @@ def finalize_distribution_options(dist: Distribution) -> None:

class bdist_wheel_go(bdist_wheel_base_class):
def get_tag(self) -> Tuple[str, str, str]:
_, _, plat = super().get_tag()
return "py3", "none", plat
return "py3", "none", get_platform()

dist.cmdclass["bdist_wheel"] = bdist_wheel_go

Expand Down

0 comments on commit 21dfd2e

Please sign in to comment.