Skip to content

Commit ea7137d

Browse files
committed
Move building into setup.py
1 parent 2bf7057 commit ea7137d

File tree

3 files changed

+55
-13
lines changed

3 files changed

+55
-13
lines changed

Diff for: README.md

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# clr-loader
2+
3+
Implements a generic interface for loading one of the CLR (.NET) runtime implementations and calling simple functions on them.

Diff for: build_netfx_loader.sh

-10
This file was deleted.

Diff for: setup.py

+52-3
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,55 @@
11
#!/usr/bin/env python
22

3-
from distutils.core import setup
3+
from setuptools import setup, find_packages
4+
from distutils.cmd import Command
5+
6+
7+
class DotnetLib:
8+
def __init__(self, path, **kwargs):
9+
self.path = path
10+
self.args = kwargs
11+
12+
13+
class BuildDotnet(Command):
14+
"""Build command for dotnet-cli based builds"""
15+
16+
description = "Build DLLs with dotnet-cli"
17+
user_options = [("dotnet-config", None, "dotnet build configuration")]
18+
19+
def initialize_options(self):
20+
self.dotnet_config = "release"
21+
22+
def finalize_options(self):
23+
pass
24+
25+
def run(self):
26+
# self.spawn(["./build_netfx_loader.sh"])
27+
for lib in self.distribution.ext_modules:
28+
opts = sum(
29+
[
30+
["--" + name.replace("_", "-"), value]
31+
for name, value in lib.args.items()
32+
],
33+
[],
34+
)
35+
36+
opts.append("--configuration")
37+
opts.append(self.dotnet_config)
38+
39+
self.spawn(["dotnet", "build", lib.path] + opts)
40+
41+
42+
with open("README.md", "r") as f:
43+
long_description = f.read()
444

545
setup(
646
name="clr_loader",
747
version="0.1.0",
848
description="Generic pure Python loader for .NET runtimes",
949
author="Benedikt Reinartz",
1050
author_email="[email protected]",
51+
long_description=long_description,
52+
long_description_content_type="text/markdown",
1153
license="MIT",
1254
install_requires=["cffi"],
1355
classifiers=[
@@ -19,6 +61,13 @@
1961
"Operating System :: POSIX :: Linux",
2062
"Operating System :: MacOS :: MacOS X",
2163
],
22-
package_data={"clr_loader.ffi": ["dlls/x86/*", "dlls/amd64/*"]},
23-
packages=["clr_loader", "clr_loader.ffi", "clr_loader.util"],
64+
package_data={"clr_loader.ffi": ["dlls/x86/*.dll", "dlls/amd64/*.dll"]},
65+
packages=find_packages(),
66+
cmdclass={"build_ext": BuildDotnet},
67+
ext_modules={
68+
DotnetLib("netfx_loader/", runtime="win-x86", output="clr_loader/ffi/dlls/x86"),
69+
DotnetLib(
70+
"netfx_loader/", runtime="win-x64", output="clr_loader/ffi/dlls/amd64"
71+
),
72+
},
2473
)

0 commit comments

Comments
 (0)