Uh oh!
There was an error while loading. Please reload this page.
forked from pythonnet/pythonnet
- Notifications
You must be signed in to change notification settings - Fork 31
Expand file tree
/
Copy pathsetup.py
More file actions
Latest commit
178 lines (144 loc) · 5.22 KB
/
Copy pathsetup.py
File metadata and controls
178 lines (144 loc) · 5.22 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
#!/usr/bin/env python
fromsetuptoolsimportsetup, Command, Extension
fromsetuptools.command.build_extimportbuild_ext
importdistutils
fromdistutils.commandimportbuild
fromsubprocessimportcheck_output, check_call
importsys, os
# Disable SourceLink during the build until it can read repo-format v1, #1613
os.environ["EnableSourceControlManagerQueries"] ="false"
classDotnetLib:
def__init__(self, name, path, **kwargs):
self.name=name
self.path=path
self.args=kwargs
classbuild_dotnet(Command):
"""Build command for dotnet-cli based builds"""
description="Build DLLs with dotnet-cli"
user_options= [
("dotnet-config=", None, "dotnet build configuration"),
(
"inplace",
"i",
"ignore build-lib and put compiled extensions into the source "
+"directory alongside your pure Python modules",
),
]
definitialize_options(self):
self.dotnet_config=None
self.build_lib=None
self.inplace=False
deffinalize_options(self):
ifself.dotnet_configisNone:
self.dotnet_config="release"
build=self.distribution.get_command_obj("build")
build.ensure_finalized()
ifself.inplace:
self.build_lib="."
else:
self.build_lib=build.build_lib
defrun(self):
dotnet_modules=self.distribution.dotnet_libs
forlibindotnet_modules:
output=os.path.join(
os.path.abspath(self.build_lib), lib.args.pop("output")
)
rename=lib.args.pop("rename", {})
opts=sum(
[
["--"+name.replace("_", "-"), value]
forname, valueinlib.args.items()
],
[],
)
opts.extend(["--configuration", self.dotnet_config])
opts.extend(["--output", output])
self.announce("Running dotnet build...", level=distutils.log.INFO)
self.spawn(["dotnet", "build", lib.path] +opts)
fork, vinrename.items():
source=os.path.join(output, k)
dest=os.path.join(output, v)
ifos.path.isfile(source):
try:
os.remove(dest)
exceptOSError:
pass
self.move_file(src=source, dst=dest, level=distutils.log.INFO)
else:
self.warn(
"Can't find file to rename: {}, current dir: {}".format(
source, os.getcwd()
)
)
# Add build_dotnet to the build tasks:
fromdistutils.command.buildimportbuildas_build
fromsetuptools.command.developimportdevelopas_develop
fromwheel.bdist_wheelimportbdist_wheelas_bdist_wheel
fromsetuptoolsimportDistribution
importsetuptools
classbuild(_build):
sub_commands=_build.sub_commands+ [("build_dotnet", None)]
classdevelop(_develop):
definstall_for_development(self):
# Build extensions in-place
self.reinitialize_command("build_dotnet", inplace=1)
self.run_command("build_dotnet")
returnsuper().install_for_development()
classbdist_wheel(_bdist_wheel):
deffinalize_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
# Monkey-patch Distribution s.t. it supports the dotnet_libs attribute
Distribution.dotnet_libs=None
cmdclass= {
"build": build,
"build_dotnet": build_dotnet,
"develop": develop,
"bdist_wheel": bdist_wheel,
}
withopen("README.rst", "r") asf:
long_description=f.read()
dotnet_libs= [
DotnetLib(
"python-runtime",
"src/runtime/Python.Runtime.csproj",
output="pythonnet/runtime",
)
]
setup(
cmdclass=cmdclass,
name="pythonnet",
version="3.0.0.dev1",
description=".Net and Mono integration for Python",
url="https://pythonnet.github.io/",
project_urls={
"Source": "https://github.com/pythonnet/pythonnet",
},
license="MIT",
author="The Contributors of the Python.NET Project",
author_email="pythonnet@python.org",
packages=["pythonnet", "pythonnet.find_libpython"],
install_requires=["clr_loader >= 0.1.7"],
long_description=long_description,
long_description_content_type="text/x-rst",
py_modules=["clr"],
dotnet_libs=dotnet_libs,
classifiers=[
"Development Status :: 5 - Production/Stable",
"Intended Audience :: Developers",
"License :: OSI Approved :: MIT License",
"Programming Language :: C#",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.6",
"Programming Language :: Python :: 3.7",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Operating System :: Microsoft :: Windows",
"Operating System :: POSIX :: Linux",
"Operating System :: MacOS :: MacOS X",
],
zip_safe=False,
)