FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

dependencies no longer need their own build dir · plotdevice/plotdevice@1048274 · GitHub

Repository navigation

Commit 1048274

Browse files
committed
dependencies no longer need their own build dir
- now they install right on top of the pre-built module - the deps’ build.py script now takes a destination path as an arg, so it works with both module & py2app builds - updated .lib to look in the new location for in-place runs (though i think it’s time for that hack to go away)
1 parent 522e6cf commit 1048274

3 files changed

Lines changed: 22 additions & 20 deletions

File tree

Lines changed: 18 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,22 @@
11
import os
22
import errno
33
from glob import glob
4-
from os.path import dirname, basename, abspath, isdir
4+
from os.path import dirname, basename, abspath, isdir, join
55

66
libs_root = dirname(abspath(__file__))
77

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+
812
def mkdirs(newdir, mode=0777):
913
try: os.makedirs(newdir, mode)
1014
except OSError, err:
1115
# Reraise the error unless it's about an already existing directory
1216
if err.errno != errno.EEXIST or not isdir(newdir):
1317
raise
1418

15-
def build_libraries():
19+
def build_libraries(dst_root):
1620
print "Compiling required c-extensions"
1721

1822
# Store the current working directory for later.
@@ -21,25 +25,22 @@ def build_libraries():
2125
for setup_script in setup_scripts:
2226
lib_name = basename(dirname(setup_script))
2327
print "Building %s..."% lib_name
24-
# run_setup gave some wonky errors, so we're defaulting to a simple os.system call.
2528
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
2930
if result > 0:
3031
raise OSError("Could not build %s" % lib_name)
3132
os.chdir(libs_root)
3233

3334
# Make sure the destination folder exists.
34-
mkdirs('../../build/deps')
35+
mkdirs(dst_root)
3536

3637
# Copy all build results to the ../../build/deps folder.
3738
build_dirs = glob("%s/*/build/lib*"%libs_root)
3839
for build_dir in build_dirs:
3940
lib_name = dirname(dirname(build_dir))
4041
# 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
4344
result = os.system(cmd)
4445
if result > 0:
4546
raise OSError("Could not copy %s" % lib_name)
@@ -55,9 +56,13 @@ def clean_build_files():
5556

5657
if __name__=='__main__':
5758
import sys
58-
clean = len(sys.argv)>1 and sys.argv[1]=='clean'
5959

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()
6267
else:
63-
build_libraries()
68+
print "usage: python build.py <destination-path>"

‎plotdevice/lib/__init__.py‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,13 @@
77
lib_root = abspath(dirname(__file__))
88
inplace = exists(join(lib_root, '../../app/main.m'))
99
if inplace:
10-
sys.path.append(join(lib_root, '../../build/ext'))
10+
sys.path.append(join(lib_root, '../../build/lib/plotdevice/lib'))
1111

1212
# test the sys.path by attempting to load the c-extensions
1313
try:
1414
import geometry, io, pathmatics
1515
except ImportError:
16-
print "failed with path", sys.path
16+
# print "failed with path", sys.path
1717
suggest = ' (try running `python setup.py build` before using the module from within the repository)'
1818
notfound = "Couldn't locate C extensions%s." % (suggest if inplace else '')
1919
raise RuntimeError(notfound)

‎setup.py‎

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -156,16 +156,16 @@ class BuildCommand(build_py):
156156
def run(self):
157157
# first let the real build_py routine do its thing
158158
build_py.run(self)
159+
159160
# 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)])
161162

162163
# include some ui resources for running a script from the command line
163164
rsrc_dir = '%s/plotdevice/rsrc'%self.build_lib
164165
self.mkpath(rsrc_dir)
165166
self.copy_file("app/Resources/colors.json", '%s/colors.json'%rsrc_dir)
166167
self.spawn(['/usr/bin/ibtool','--compile', '%s/viewer.nib'%rsrc_dir, "app/Resources/English.lproj/PlotDeviceScript.xib"])
167168
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])
169169

170170

171171
if BUILD_APP:
@@ -195,20 +195,17 @@ def run(self):
195195
RSRC = self.resdir
196196
BIN = join(dirname(RSRC), 'SharedSupport')
197197
MODULE = join(self.bdist_base, 'lib/plotdevice')
198-
EGG = join(RSRC, 'lib/python2.7/site-packages.zip')
199198
PY = join(RSRC, 'python')
200199
for pth in BIN, PY:
201200
self.mkpath(pth)
202201

203202
# unpack the zipped up pyc files and merge with the module sources
204-
self.spawn(['unzip', '-q', EGG, '-d', PY])
205203
self.spawn(['/usr/bin/ditto', MODULE, join(PY, 'plotdevice')])
206204

207205
# discard the eggery-pokery
208206
remove_tree(join(RSRC,'lib'), dry_run=self.dry_run)
209207
os.unlink(join(RSRC,'include'))
210208
os.unlink(join(RSRC,'site.pyc'))
211-
os.unlink(join(PY,'test.pyc'))
212209

213210
# place the command line tool in SharedSupport
214211
self.copy_file("%s/app/plotdevice"%TOP, BIN)

0 commit comments

Comments
 (0)

Back | FazBrowse Home | New Git URL