diff --git a/README.md b/README.md new file mode 100644 index 0000000..818f22d --- /dev/null +++ b/README.md @@ -0,0 +1,3 @@ +# clr-loader + +Implements a generic interface for loading one of the CLR (.NET) runtime implementations and calling simple functions on them. \ No newline at end of file diff --git a/build_netfx_loader.sh b/build_netfx_loader.sh deleted file mode 100755 index f837605..0000000 --- a/build_netfx_loader.sh +++ /dev/null @@ -1,10 +0,0 @@ -#!/bin/sh - -S=`dirname $0` -P=netfx_loader/ -O=$S/clr_loader/ffi/dlls/ - -mkdir -p "$O" || exit -1 - -dotnet build "$P" -r win-x86 -o "$O/x86" || exit -1 -dotnet build "$P" -r win-x64 -o "$O/amd64" || exit -1 diff --git a/setup.py b/setup.py index b80200b..64410f0 100755 --- a/setup.py +++ b/setup.py @@ -1,6 +1,46 @@ #!/usr/bin/env python -from distutils.core import setup +from setuptools import setup, find_packages +from distutils.cmd import Command + + +class DotnetLib: + def __init__(self, path, **kwargs): + self.path = path + self.args = kwargs + + +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 + + def run(self): + # self.spawn(["./build_netfx_loader.sh"]) + 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) + + +with open("README.md", "r") as f: + long_description = f.read() setup( name="clr_loader", @@ -8,6 +48,8 @@ setup( description="Generic pure Python loader for .NET runtimes", author="Benedikt Reinartz", author_email="filmor@gmail.com", + long_description=long_description, + long_description_content_type="text/markdown", license="MIT", install_requires=["cffi"], classifiers=[ @@ -19,6 +61,13 @@ setup( "Operating System :: POSIX :: Linux", "Operating System :: MacOS :: MacOS X", ], - package_data={"clr_loader.ffi": ["dlls/x86/*", "dlls/amd64/*"]}, - packages=["clr_loader", "clr_loader.ffi", "clr_loader.util"], + package_data={"clr_loader.ffi": ["dlls/x86/*.dll", "dlls/amd64/*.dll"]}, + packages=find_packages(), + cmdclass={"build_ext": BuildDotnet}, + ext_modules={ + DotnetLib("netfx_loader/", runtime="win-x86", output="clr_loader/ffi/dlls/x86"), + DotnetLib( + "netfx_loader/", runtime="win-x64", output="clr_loader/ffi/dlls/amd64" + ), + }, )