Update building script to copy source files to build directory if missing.

test2
Michael Cohen 10 years ago
parent 05522dcb8c
commit f217d2872f
  1. 3
      bindings/python/.gitignore
  2. 12
      bindings/python/setup.py

@ -0,0 +1,3 @@
MANIFEST
dist/
src/

@ -32,10 +32,13 @@ def get_sources():
create the library. create the library.
""" """
result = [] result = []
# Make the src directory if it does not exist.
if not os.access("./src/", os.F_OK):
custom_sdist.copy_sources()
for root, _, files in os.walk("./src/"): for root, _, files in os.walk("./src/"):
for name in files: for name in files:
if name.endswith(".c") or name.endswith(".h") or \ if name.endswith(".c"):
name.endswith(".inc") or root == "./src/":
result.append(os.path.join(root, name)) result.append(os.path.join(root, name))
return result return result
@ -48,7 +51,8 @@ class custom_sdist(sdist):
self.copy_sources() self.copy_sources()
return sdist.run(self) return sdist.run(self)
def copy_sources(self): @staticmethod
def copy_sources():
"""Copy the C sources into the source directory. """Copy the C sources into the source directory.
This rearranges the source files under the python distribution This rearranges the source files under the python distribution
@ -58,7 +62,7 @@ class custom_sdist(sdist):
try: try:
dir_util.remove_tree("src/") dir_util.remove_tree("src/")
except: except (IOError, OSError):
pass pass
dir_util.copy_tree("../../arch", "src/arch/") dir_util.copy_tree("../../arch", "src/arch/")
dir_util.copy_tree("../../include", "src/include/") dir_util.copy_tree("../../include", "src/include/")

Loading…
Cancel
Save