Skip to content

Commit ddbb54f

Browse files
committed
Build .NET 4.6 wheel for Windows
1 parent 92e5912 commit ddbb54f

2 files changed

Lines changed: 24 additions & 11 deletions

File tree

Justfile

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
default:
2+
@just --choose
3+
4+
setup:
5+
dotnet restore
6+
uv sync
7+
8+
docs:
9+
doxygen doc/Doxyfile
10+
uv run --group doc sphinx-build doc/source/ ./doc/build/html/
11+
12+
build-wheels:
13+
uv build
14+
uv build --wheel -C="--global-option=--net46-support"

setup.py

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,20 @@
33
import distutils
44
from distutils.command.build import build as _build
55
from setuptools.command.develop import develop as _develop
6-
from wheel.bdist_wheel import bdist_wheel as _bdist_wheel
76
from setuptools import Distribution
87
from setuptools import setup, Command
98

109
import os
10+
import sys
1111

1212
# Disable SourceLink during the build until it can read repo-format v1, #1613
1313
os.environ["EnableSourceControlManagerQueries"] = "false"
1414

15+
NET46_SUPPORT_OPTION = "--net46-support"
16+
NET46_SUPPORT = NET46_SUPPORT_OPTION in sys.argv
17+
if NET46_SUPPORT:
18+
sys.argv.remove(NET46_SUPPORT_OPTION)
19+
1520

1621
class DotnetLib:
1722
def __init__(self, name, path, **kwargs):
@@ -106,33 +111,27 @@ def install_for_development(self):
106111
return super().install_for_development()
107112

108113

109-
class bdist_wheel(_bdist_wheel):
110-
def finalize_options(self):
111-
# Monkey patch bdist_wheel to think the package is pure even though we
112-
# include DLLs
113-
super().finalize_options()
114-
self.root_is_pure = True
115-
116-
117114
# Monkey-patch Distribution s.t. it supports the dotnet_libs attribute
118115
Distribution.dotnet_libs = None
119116

120117
cmdclass = {
121118
"build": build,
122119
"build_dotnet": build_dotnet,
123120
"develop": develop,
124-
"bdist_wheel": bdist_wheel,
125121
}
126122

127123

128-
if os.getenv("PYTHONNET_BUILD_NET46_SUPPORT"):
124+
if NET46_SUPPORT:
129125
csproj = "src/compat/Python.Runtime.Compat.csproj"
126+
plat_name = "win32"
130127
else:
131128
csproj = "src/runtime/Python.Runtime.csproj"
129+
plat_name = "any"
132130

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

135133
setup(
136134
cmdclass=cmdclass,
137135
dotnet_libs=dotnet_libs,
136+
options={"bdist_wheel": {"plat_name": plat_name}},
138137
)

0 commit comments

Comments
 (0)