clr-loader/setup.py

70 строки
1.8 KiB
Python
Исходник Обычный вид История

2019-10-27 17:13:26 +03:00
#!/usr/bin/env python
from setuptools import setup, Command, Extension
2019-11-07 11:17:09 +03:00
from wheel.bdist_wheel import bdist_wheel
2019-11-07 10:36:49 +03:00
2019-11-07 11:17:09 +03:00
class DotnetLib(Extension):
def __init__(self, name, path, **kwargs):
2019-11-07 10:36:49 +03:00
self.path = path
self.args = kwargs
2019-11-07 11:17:09 +03:00
super().__init__(name, sources=[])
2019-11-07 10:36:49 +03:00
class BuildDotnet(Command):
"""Build command for dotnet-cli based builds"""
description = "Build DLLs with dotnet-cli"
user_options = [("dotnet-config=", None, "dotnet build configuration")]
2019-11-07 10:36:49 +03:00
def initialize_options(self):
self.dotnet_config = "release"
def finalize_options(self):
pass
2019-11-07 11:17:09 +03:00
def get_source_files(self):
return []
2019-11-07 10:36:49 +03:00
def run(self):
for lib in self.distribution.ext_modules:
opts = sum(
[
["--" + name.replace("_", "-"), value]
for name, value in lib.args.items()
],
[],
)
opts.append("--configuration")
opts.append(self.dotnet_config)
self.spawn(["dotnet", "build", lib.path] + opts)
2019-11-07 11:17:09 +03:00
class bdist_wheel_patched(bdist_wheel):
def finalize_options(self):
# Monkey patch bdist_wheel to think the package is pure even though we
# include DLLs
super().finalize_options()
self.root_is_pure = True
2019-10-27 17:13:26 +03:00
setup(
2019-11-07 11:17:09 +03:00
cmdclass={"build_ext": BuildDotnet, "bdist_wheel": bdist_wheel_patched},
2019-11-07 10:36:49 +03:00
ext_modules={
DotnetLib(
2019-11-07 11:17:09 +03:00
"netfx-loader-x86",
2020-11-13 20:30:10 +03:00
"netfx_loader/ClrLoader.csproj",
2019-11-07 11:17:09 +03:00
runtime="win-x86",
output="clr_loader/ffi/dlls/x86",
),
DotnetLib(
"netfx-loader-amd64",
2020-11-13 20:30:10 +03:00
"netfx_loader/ClrLoader.csproj",
2019-11-07 11:17:09 +03:00
runtime="win-x64",
output="clr_loader/ffi/dlls/amd64",
2019-11-07 10:36:49 +03:00
),
},
2019-10-27 17:13:26 +03:00
)