2019-10-27 17:13:26 +03:00
|
|
|
#!/usr/bin/env python
|
|
|
|
|
2019-11-07 11:17:09 +03:00
|
|
|
from setuptools import setup, find_packages, Command, Extension
|
|
|
|
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")]
|
|
|
|
|
|
|
|
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-11-07 10:36:49 +03:00
|
|
|
with open("README.md", "r") as f:
|
|
|
|
long_description = f.read()
|
2019-10-27 17:13:26 +03:00
|
|
|
|
|
|
|
setup(
|
|
|
|
name="clr_loader",
|
2021-11-19 15:15:58 +03:00
|
|
|
version="0.1.7",
|
2019-10-27 17:13:26 +03:00
|
|
|
description="Generic pure Python loader for .NET runtimes",
|
|
|
|
author="Benedikt Reinartz",
|
|
|
|
author_email="filmor@gmail.com",
|
2019-11-07 10:36:49 +03:00
|
|
|
long_description=long_description,
|
|
|
|
long_description_content_type="text/markdown",
|
2019-10-27 17:13:26 +03:00
|
|
|
license="MIT",
|
2020-11-24 13:08:42 +03:00
|
|
|
python_requires=">=3.6",
|
2019-11-27 10:14:05 +03:00
|
|
|
install_requires=["cffi>=1.13"],
|
2019-10-27 17:13:26 +03:00
|
|
|
classifiers=[
|
|
|
|
"Development Status :: 2 - Pre-Alpha",
|
|
|
|
"Intended Audience :: Developers",
|
|
|
|
"License :: OSI Approved :: MIT License",
|
|
|
|
"Programming Language :: Python :: 3",
|
|
|
|
"Operating System :: Microsoft :: Windows",
|
|
|
|
"Operating System :: POSIX :: Linux",
|
|
|
|
"Operating System :: MacOS :: MacOS X",
|
|
|
|
],
|
2019-11-07 10:36:49 +03:00
|
|
|
package_data={"clr_loader.ffi": ["dlls/x86/*.dll", "dlls/amd64/*.dll"]},
|
|
|
|
packages=find_packages(),
|
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
|
|
|
)
|