| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 522e6cf commit 1048274
3 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1,18 +1,22 @@ | |||
| 1 | 1 | import os | |
| 2 | 2 | import errno | |
| 3 | 3 | from glob import glob | |
| 4 | - from os.path import dirname, basename, abspath, isdir | ||
| 4 | + from os.path import dirname, basename, abspath, isdir, join | ||
| 5 | 5 | ||
| 6 | 6 | libs_root = dirname(abspath(__file__)) | |
| 7 | 7 | ||
| 8 | + # temporary workaround for broken clang 5.1 error: `unknown argument: '-mno-fused-madd'` | ||
| 9 | + quickfix = 'ARCHFLAGS=-Wno-error=unused-command-line-argument-hard-error-in-future' | ||
| 10 | + build_cmd = '%s python2.7 setup.py -q build'%quickfix | ||
| 11 | + | ||
| 8 | 12 | def mkdirs(newdir, mode=0777): | |
| 9 | 13 | try: os.makedirs(newdir, mode) | |
| 10 | 14 | except OSError, err: | |
| 11 | 15 | # Reraise the error unless it's about an already existing directory | |
| 12 | 16 | if err.errno != errno.EEXIST or not isdir(newdir): | |
| 13 | 17 | raise | |
| 14 | 18 | ||
| 15 | - def build_libraries(): | ||
| 19 | + def build_libraries(dst_root): | ||
| 16 | 20 | print "Compiling required c-extensions" | |
| 17 | 21 | ||
| 18 | 22 | # Store the current working directory for later. | |
@@ -21,25 +25,22 @@ def build_libraries(): | |||
| 21 | 25 | for setup_script in setup_scripts: | |
| 22 | 26 | lib_name = basename(dirname(setup_script)) | |
| 23 | 27 | print "Building %s..."% lib_name | |
| 24 | - # run_setup gave some wonky errors, so we're defaulting to a simple os.system call. | ||
| 25 | 28 | os.chdir(dirname(setup_script)) | |
| 26 | - # temporary workaround for broken clang 5.1 error: `unknown argument: '-mno-fused-madd'` | ||
| 27 | - cmd = ('ARCHFLAGS=-Wno-error=unused-command-line-argument-hard-error-in-future python2.7 setup.py -q build') | ||
| 28 | - result = os.system(cmd) | ||
| 29 | + result = os.system(build_cmd) # call the lib's setup.py | ||
| 29 | 30 | if result > 0: | |
| 30 | 31 | raise OSError("Could not build %s" % lib_name) | |
| 31 | 32 | os.chdir(libs_root) | |
| 32 | 33 | ||
| 33 | 34 | # Make sure the destination folder exists. | |
| 34 | - mkdirs('../../build/deps') | ||
| 35 | + mkdirs(dst_root) | ||
| 35 | 36 | ||
| 36 | 37 | # Copy all build results to the ../../build/deps folder. | |
| 37 | 38 | build_dirs = glob("%s/*/build/lib*"%libs_root) | |
| 38 | 39 | for build_dir in build_dirs: | |
| 39 | 40 | lib_name = dirname(dirname(build_dir)) | |
| 40 | 41 | # print "Copying", lib_name | |
| 41 | - cmd = 'cp -R -p %s/* ../../build/deps' % build_dir | ||
| 42 | - # print cmd | ||
| 42 | + cmd = 'cp -R -p %s/* %s' % (build_dir, dst_root) | ||
| 43 | + print cmd | ||
| 43 | 44 | result = os.system(cmd) | |
| 44 | 45 | if result > 0: | |
| 45 | 46 | raise OSError("Could not copy %s" % lib_name) | |
@@ -55,9 +56,13 @@ def clean_build_files(): | |||
| 55 | 56 | ||
| 56 | 57 | if __name__=='__main__': | |
| 57 | 58 | import sys | |
| 58 | - clean = len(sys.argv)>1 and sys.argv[1]=='clean' | ||
| 59 | 59 | ||
| 60 | - if clean or os.environ.get('ACTION')=='clean': | ||
| 61 | - clean_build_files() | ||
| 60 | + if len(sys.argv)>1: | ||
| 61 | + arg = sys.argv[1] | ||
| 62 | + if os.path.exists(arg): | ||
| 63 | + dst_root = join(arg, 'plotdevice/lib') | ||
| 64 | + build_libraries(dst_root) | ||
| 65 | + elif arg=='clean': | ||
| 66 | + clean_build_files() | ||
| 62 | 67 | else: | |
| 63 | - build_libraries() | ||
| 68 | + print "usage: python build.py <destination-path>" | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -7,13 +7,13 @@ | |||
| 7 | 7 | lib_root = abspath(dirname(__file__)) | |
| 8 | 8 | inplace = exists(join(lib_root, '../../app/main.m')) | |
| 9 | 9 | if inplace: | |
| 10 | - sys.path.append(join(lib_root, '../../build/ext')) | ||
| 10 | + sys.path.append(join(lib_root, '../../build/lib/plotdevice/lib')) | ||
| 11 | 11 | ||
| 12 | 12 | # test the sys.path by attempting to load the c-extensions | |
| 13 | 13 | try: | |
| 14 | 14 | import geometry, io, pathmatics | |
| 15 | 15 | except ImportError: | |
| 16 | - print "failed with path", sys.path | ||
| 16 | + # print "failed with path", sys.path | ||
| 17 | 17 | suggest = ' (try running `python setup.py build` before using the module from within the repository)' | |
| 18 | 18 | notfound = "Couldn't locate C extensions%s." % (suggest if inplace else '') | |
| 19 | 19 | raise RuntimeError(notfound) | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -156,16 +156,16 @@ class BuildCommand(build_py): | |||
| 156 | 156 | def run(self): | |
| 157 | 157 | # first let the real build_py routine do its thing | |
| 158 | 158 | build_py.run(self) | |
| 159 | + | ||
| 159 | 160 | # then build the extensions | |
| 160 | - self.spawn(['/usr/bin/python', 'app/deps/buildlibs.py']) | ||
| 161 | + self.spawn(['/usr/bin/python', 'app/deps/build.py', os.path.abspath(self.build_lib)]) | ||
| 161 | 162 | ||
| 162 | 163 | # include some ui resources for running a script from the command line | |
| 163 | 164 | rsrc_dir = '%s/plotdevice/rsrc'%self.build_lib | |
| 164 | 165 | self.mkpath(rsrc_dir) | |
| 165 | 166 | self.copy_file("app/Resources/colors.json", '%s/colors.json'%rsrc_dir) | |
| 166 | 167 | self.spawn(['/usr/bin/ibtool','--compile', '%s/viewer.nib'%rsrc_dir, "app/Resources/English.lproj/PlotDeviceScript.xib"]) | |
| 167 | 168 | self.copy_file("app/Resources/PlotDeviceFile.icns", '%s/viewer.icns'%rsrc_dir) | |
| 168 | - self.spawn(['/usr/bin/ditto', 'build/deps', '%s/plotdevice/lib'%self.build_lib]) | ||
| 169 | 169 | ||
| 170 | 170 | ||
| 171 | 171 | if BUILD_APP: | |
@@ -195,20 +195,17 @@ def run(self): | |||
| 195 | 195 | RSRC = self.resdir | |
| 196 | 196 | BIN = join(dirname(RSRC), 'SharedSupport') | |
| 197 | 197 | MODULE = join(self.bdist_base, 'lib/plotdevice') | |
| 198 | - EGG = join(RSRC, 'lib/python2.7/site-packages.zip') | ||
| 199 | 198 | PY = join(RSRC, 'python') | |
| 200 | 199 | for pth in BIN, PY: | |
| 201 | 200 | self.mkpath(pth) | |
| 202 | 201 | ||
| 203 | 202 | # unpack the zipped up pyc files and merge with the module sources | |
| 204 | - self.spawn(['unzip', '-q', EGG, '-d', PY]) | ||
| 205 | 203 | self.spawn(['/usr/bin/ditto', MODULE, join(PY, 'plotdevice')]) | |
| 206 | 204 | ||
| 207 | 205 | # discard the eggery-pokery | |
| 208 | 206 | remove_tree(join(RSRC,'lib'), dry_run=self.dry_run) | |
| 209 | 207 | os.unlink(join(RSRC,'include')) | |
| 210 | 208 | os.unlink(join(RSRC,'site.pyc')) | |
| 211 | - os.unlink(join(PY,'test.pyc')) | ||
| 212 | 209 | ||
| 213 | 210 | # place the command line tool in SharedSupport | |
| 214 | 211 | self.copy_file("%s/app/plotdevice"%TOP, BIN) | |
| Back | FazBrowse Home | New Git URL |
0 commit comments