Skip to content

Commit 9ea6e5f

Browse files
committed
Python packaging is hard...
1 parent ea7137d commit 9ea6e5f

File tree

3 files changed

+32
-8
lines changed

3 files changed

+32
-8
lines changed

Diff for: MANIFEST.in

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
include netfx_loader/*.sln netfx_loader/*.csproj netfx_loader/*.cs
2+
recursive-exclude clr_loader/ffi/dlls *.dll

Diff for: setup.cfg

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
[metadata]
2+
license_file = LICENSE

Diff for: setup.py

+28-8
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
11
#!/usr/bin/env python
22

3-
from setuptools import setup, find_packages
4-
from distutils.cmd import Command
3+
from setuptools import setup, find_packages, Command, Extension
4+
from wheel.bdist_wheel import bdist_wheel
55

66

7-
class DotnetLib:
8-
def __init__(self, path, **kwargs):
7+
class DotnetLib(Extension):
8+
def __init__(self, name, path, **kwargs):
99
self.path = path
1010
self.args = kwargs
11+
super().__init__(name, sources=[])
1112

1213

1314
class BuildDotnet(Command):
@@ -22,8 +23,10 @@ def initialize_options(self):
2223
def finalize_options(self):
2324
pass
2425

26+
def get_source_files(self):
27+
return []
28+
2529
def run(self):
26-
# self.spawn(["./build_netfx_loader.sh"])
2730
for lib in self.distribution.ext_modules:
2831
opts = sum(
2932
[
@@ -39,6 +42,14 @@ def run(self):
3942
self.spawn(["dotnet", "build", lib.path] + opts)
4043

4144

45+
class bdist_wheel_patched(bdist_wheel):
46+
def finalize_options(self):
47+
# Monkey patch bdist_wheel to think the package is pure even though we
48+
# include DLLs
49+
super().finalize_options()
50+
self.root_is_pure = True
51+
52+
4253
with open("README.md", "r") as f:
4354
long_description = f.read()
4455

@@ -51,6 +62,7 @@ def run(self):
5162
long_description=long_description,
5263
long_description_content_type="text/markdown",
5364
license="MIT",
65+
python_requires=">=3.3",
5466
install_requires=["cffi"],
5567
classifiers=[
5668
"Development Status :: 2 - Pre-Alpha",
@@ -63,11 +75,19 @@ def run(self):
6375
],
6476
package_data={"clr_loader.ffi": ["dlls/x86/*.dll", "dlls/amd64/*.dll"]},
6577
packages=find_packages(),
66-
cmdclass={"build_ext": BuildDotnet},
78+
cmdclass={"build_ext": BuildDotnet, "bdist_wheel": bdist_wheel_patched},
6779
ext_modules={
68-
DotnetLib("netfx_loader/", runtime="win-x86", output="clr_loader/ffi/dlls/x86"),
6980
DotnetLib(
70-
"netfx_loader/", runtime="win-x64", output="clr_loader/ffi/dlls/amd64"
81+
"netfx-loader-x86",
82+
"netfx_loader/",
83+
runtime="win-x86",
84+
output="clr_loader/ffi/dlls/x86",
85+
),
86+
DotnetLib(
87+
"netfx-loader-amd64",
88+
"netfx_loader/",
89+
runtime="win-x64",
90+
output="clr_loader/ffi/dlls/amd64",
7191
),
7292
},
7393
)

0 commit comments

Comments
 (0)