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
1314class 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+
4253with 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