Skip to content

Commit b32b4d0

Browse files
committed
Create get_source_files function
1 parent ee21001 commit b32b4d0

File tree

1 file changed

+19
-16
lines changed

1 file changed

+19
-16
lines changed

setup.py

Lines changed: 19 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,24 @@ def _get_interop_filename():
100100
return os.path.join("src", "runtime", interop_filename)
101101

102102

103+
def _get_source_files():
104+
"""Walk project and collect the files needed for ext_module"""
105+
for ext in (".sln", ".snk", ".config"):
106+
for path in glob.glob("*" + ext):
107+
yield path
108+
109+
for root, dirnames, filenames in os.walk("src"):
110+
for ext in (".cs", ".csproj", ".sln", ".snk", ".config", ".il",
111+
".py", ".c", ".h", ".ico"):
112+
for filename in fnmatch.filter(filenames, "*" + ext):
113+
yield os.path.join(root, filename)
114+
115+
for root, dirnames, filenames in os.walk("tools"):
116+
for ext in (".exe", ".py", ".c", ".h"):
117+
for filename in fnmatch.filter(filenames, "*" + ext):
118+
yield os.path.join(root, filename)
119+
120+
103121
class BuildExtPythonnet(build_ext.build_ext):
104122
def build_extension(self, ext):
105123
"""Builds the .pyd file using msbuild or xbuild"""
@@ -333,21 +351,6 @@ def run(self):
333351
if setupdir:
334352
os.chdir(setupdir)
335353

336-
sources = []
337-
for ext in (".sln", ".snk", ".config"):
338-
sources.extend(glob.glob("*" + ext))
339-
340-
for root, dirnames, filenames in os.walk("src"):
341-
for ext in (".cs", ".csproj", ".sln", ".snk", ".config", ".il",
342-
".py", ".c", ".h", ".ico"):
343-
for filename in fnmatch.filter(filenames, "*" + ext):
344-
sources.append(os.path.join(root, filename))
345-
346-
for root, dirnames, filenames in os.walk("tools"):
347-
for ext in (".exe", ".py", ".c", ".h"):
348-
for filename in fnmatch.filter(filenames, "*" + ext):
349-
sources.append(os.path.join(root, filename))
350-
351354
setup_requires = []
352355
interop_file = _get_interop_filename()
353356
if not os.path.exists(interop_file):
@@ -377,7 +380,7 @@ def run(self):
377380
'Operating System :: MacOS :: MacOS X',
378381
],
379382
ext_modules=[
380-
Extension("clr", sources=sources)
383+
Extension("clr", sources=list(_get_source_files()))
381384
],
382385
data_files=[
383386
("{install_platlib}", [

0 commit comments

Comments
 (0)