Fix wheel tags by filmor · Pull Request #2716 · pythonnet/pythonnet
class DotnetLib:
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}}, )