FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Fix wheel tags by filmor · Pull Request #2716 · pythonnet/pythonnet · GitHub

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension .py  (1) .toml  (1) All 2 file types selected
Only manifest files
Viewed files
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Unified
Split
Hide whitespace
Diff view
Unified
Split
Hide whitespace
2 changes: 1 addition & 1 deletion pyproject.toml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[build-system]
requires = ["setuptools>=80"]
requires = ["setuptools>=80", "packaging>=24", "pyproject-parser>=0.14"]
build-backend = "setuptools.build_meta"

[project]
Expand Down
35 changes: 32 additions & 3 deletions setup.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@
import distutils
from distutils.command.build import build as _build
from setuptools.command.develop import develop as _develop
from setuptools.command.bdist_wheel import bdist_wheel as _bdist_wheel
from packaging.specifiers import SpecifierSet
from packaging.version import Version
from pyproject_parser import PyProject
from setuptools import Distribution
from setuptools import setup, Command

Expand All @@ -16,6 +20,7 @@
NET46_SUPPORT = NET46_SUPPORT_OPTION in sys.argv
if NET46_SUPPORT:
sys.argv.remove(NET46_SUPPORT_OPTION)
WINDOWS_PLATFORM_TAG = "win32.win_amd64"


class DotnetLib:
Expand Down Expand Up @@ -111,27 +116,51 @@ def install_for_development(self):
return super().install_for_development()


class bdist_wheel(_bdist_wheel):
def get_tag(self):
if NET46_SUPPORT:
platform_tag = WINDOWS_PLATFORM_TAG
else:
platform_tag = "any"
abi_tag = "none"
python_tag = self._get_python_tag()
return python_tag, abi_tag, platform_tag

def _get_python_tag(self) -> str:
pyproject = PyProject.load("pyproject.toml")
project = pyproject.project or {}

requires_python = project.get("requires-python")
if not requires_python:
raise RuntimeError("project.requires-python is required")

specifiers = SpecifierSet(str(requires_python))
return ".".join(
f"cp3{minor}"
for minor in range(0, 100)
if specifiers.contains(Version(f"3.{minor}"), prereleases=True)
)


# Monkey-patch Distribution s.t. it supports the dotnet_libs attribute
Distribution.dotnet_libs = None

cmdclass = {
"build": build,
"build_dotnet": build_dotnet,
"develop": develop,
"bdist_wheel": bdist_wheel,
}


if NET46_SUPPORT:
csproj = "src/compat/Python.Runtime.Compat.csproj"
plat_name = "win32"
else:
csproj = "src/runtime/Python.Runtime.csproj"
plat_name = "any"

dotnet_libs = [DotnetLib("python-runtime", csproj, output="pythonnet/runtime")]

setup(
cmdclass=cmdclass,
dotnet_libs=dotnet_libs,
options={"bdist_wheel": {"plat_name": plat_name}},
)
Loading

Back | FazBrowse Home | New Git URL