Skip to content

Commit ba23488

Browse files
committed
now bundling PyObjC in the module again (version 3.0.4)
- by default, use wheels hosted at plotdevice.io - if you run the rebuild.sh script before building plotdevice, it will compile its own copy of PyObjC from PyPI
1 parent ba516cf commit ba23488

5 files changed

Lines changed: 132 additions & 5 deletions

File tree

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
build/
44
dist/
55
app/deps/Sparkle*
6+
app/deps/PyObjC/*.tar.gz
67

78
# cds garbage
89
related/

app/deps/PyObjC/rebuild.sh

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
#!/bin/bash
2+
#
3+
# Build a new set of wheels from the current PyObjC sources on PyPI
4+
# - creates a tarball called wheelhouse-pyobjc-VERSION.tar.gz for use by setup.py
5+
# - the tarball can also be moved to plotdevice.io for use in typical installs
6+
#
7+
set -e
8+
9+
TOP=$(dirname "$0")
10+
BUILD_DIR="${TOP}/build"
11+
12+
VENV_VERSION="13.0.1"
13+
VENV_PKG="virtualenv-${VENV_VERSION}"
14+
VENV_TAR="${TOP}/${VENV_PKG}.tar.gz"
15+
VENV_URL="https://pypi.python.org/packages/source/v/virtualenv/${VENV_PKG}.tar.gz"
16+
VENV_DIR="${BUILD_DIR}/${VENV_PKG}"
17+
18+
ENV="${BUILD_DIR}/env"
19+
PIP="${ENV}/bin/pip"
20+
VIRTUALENV="python2.7 ${VENV_DIR}/virtualenv.py -q"
21+
PYOBJC_DIR="${BUILD_DIR}/wheelhouse"
22+
23+
#--
24+
25+
mkdir -p "${BUILD_DIR}"
26+
27+
# grab a copy of virtualenv to help with the installation
28+
if [ ! -d "$VENV_DIR" ]; then
29+
if [ ! -f "${VENV_TAR}" ]; then
30+
echo "${VENV_URL}"
31+
curl -L -# "${VENV_URL}" -o "${VENV_TAR}"
32+
fi
33+
tar xzf "${VENV_TAR}" -C "${BUILD_DIR}"
34+
fi
35+
36+
# create a temporary env that we'll only use for its pip command
37+
rm -rf "$ENV"
38+
if [ ! -d "${ENV}" ]; then
39+
echo "Setting up staging area..."
40+
$VIRTUALENV "${ENV}"
41+
fi
42+
43+
# build wheels from the PyPI version of PyObjC,
44+
rm -rf "$PYOBJC_DIR"
45+
$PIP install pyobjc-core
46+
$PIP wheel pyobjc -w "${PYOBJC_DIR}"
47+
48+
# stow a tarball of the wheelhouse in case we want to move it to the server
49+
PYOBJC_VERSION=`${ENV}/bin/python -c 'import objc; print objc.__version__'`
50+
tar czvf "${TOP}/wheelhouse-pyobjc-${PYOBJC_VERSION}.tar.gz" -C "${BUILD_DIR}" wheelhouse
51+
52+
# wipe out the env so setup.sh doesn't get an unexpected pyobjc-core
53+
rm -rf "${BUILD_DIR}"
54+
55+
#--

app/deps/PyObjC/setup.sh

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
#!/bin/bash
2+
#
3+
# Create a sitedir-style directory with an installed PyObjC distribution
4+
# - if the build/wheelhouse directory doesn't exist, pre-built copies will
5+
# be fetched from the website
6+
# - running rebuild.sh prior to setup will generate a fresh set of wheels from
7+
# the current source distribution on PyPI and fill the wheelhouse subdir
8+
# - the subsequent call to setup.sh will populate the sitedir using these
9+
# fresh copies
10+
#
11+
set -e
12+
13+
TOP=$(dirname "$0")
14+
BUILD_DIR="${TOP}/build"
15+
DEST_DIR="${BUILD_DIR}/lib/PyObjC"
16+
17+
VENV_VERSION="13.0.1"
18+
VENV_PKG="virtualenv-${VENV_VERSION}"
19+
VENV_TAR="${TOP}/${VENV_PKG}.tar.gz"
20+
VENV_URL="https://pypi.python.org/packages/source/v/virtualenv/${VENV_PKG}.tar.gz"
21+
VENV_DIR="${BUILD_DIR}/${VENV_PKG}"
22+
23+
PYOBJC_VERSION="3.0.4"
24+
PYOBJC_PKG="wheelhouse-pyobjc-${PYOBJC_VERSION}"
25+
PYOBJC_TAR="${TOP}/${PYOBJC_PKG}.tar.gz"
26+
PYOBJC_URL="http://plotdevice.io/${PYOBJC_PKG}.tar.gz"
27+
PYOBJC_DIR="${BUILD_DIR}/wheelhouse"
28+
29+
ENV="${BUILD_DIR}/env"
30+
PIP="${ENV}/bin/pip -q --isolated"
31+
VIRTUALENV="python2.7 ${VENV_DIR}/virtualenv.py -q"
32+
33+
#--
34+
35+
mkdir -p "${BUILD_DIR}"
36+
37+
# fetch/unpack the tarball of wheels
38+
if [ ! -d "$PYOBJC_DIR" ]; then
39+
if [ ! -f "$PYOBJC_TAR" ]; then
40+
echo "${PYOBJC_URL}"
41+
curl -L -# "${PYOBJC_URL}" -o "${PYOBJC_TAR}"
42+
fi
43+
tar xzf "${PYOBJC_TAR}" -C "${BUILD_DIR}"
44+
fi
45+
46+
# grab a copy of virtualenv to help with the installation
47+
if [ ! -d "$VENV_DIR" ]; then
48+
if [ ! -f "${VENV_TAR}" ]; then
49+
echo "${VENV_URL}"
50+
curl -L -# "${VENV_URL}" -o "${VENV_TAR}"
51+
fi
52+
tar xzf "${VENV_TAR}" -C "${BUILD_DIR}"
53+
fi
54+
55+
# create a temporary env that we'll only use for its pip command
56+
if [ ! -d "${ENV}" ]; then
57+
echo "Setting up staging area..."
58+
$VIRTUALENV "${ENV}"
59+
fi
60+
61+
# use our local pip to unpack the wheels into a subdirectory
62+
if [ ! -d "$DEST_DIR" ]; then
63+
echo "Unpacking ${PYOBJC_PKG}..."
64+
$PIP install --target="${DEST_DIR}" --no-index --find-links="${PYOBJC_DIR}" pyobjc
65+
fi
66+
67+
#--

app/deps/build.py

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

66
libs_root = dirname(abspath(__file__))
77

@@ -13,9 +13,8 @@ def mkdirs(newdir, mode=0777):
1313
raise
1414

1515
def build_libraries(dst_root):
16-
print "Compiling required c-extensions"
16+
print "\nCompiling required c-extensions"
1717

18-
# Store the current working directory for later.
1918
# Find all setup.py files in the current folder
2019
setup_scripts = glob('%s/*/setup.py'%libs_root)
2120
for setup_script in setup_scripts:
@@ -27,19 +26,24 @@ def build_libraries(dst_root):
2726
raise OSError("Could not build %s" % lib_name)
2827
os.chdir(libs_root)
2928

29+
print "Building PyObjC..."
30+
result = os.system('bash "%s/PyObjC/setup.sh"'%libs_root)
31+
if result > 0:
32+
raise OSError("Failed to unpack PyObjC wheels")
33+
3034
# Make sure the destination folder exists.
3135
mkdirs(dst_root)
3236

3337
# Copy all build results to the ../../build/deps folder.
3438
build_dirs = glob("%s/*/build/lib*"%libs_root)
3539
for build_dir in build_dirs:
3640
lib_name = dirname(dirname(build_dir))
37-
# print "Copying", lib_name
3841
cmd = 'cp -R -p %s/* %s' % (build_dir, dst_root)
3942
print cmd
4043
result = os.system(cmd)
4144
if result > 0:
4245
raise OSError("Could not copy %s" % lib_name)
46+
print
4347

4448
def clean_build_files():
4549
print "Cleaning all library build files..."

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,7 @@ def run(self):
233233
# success!
234234
print "done building PlotDevice.app in ./dist"
235235

236-
except DistributionNotFound:
236+
except (DistributionNotFound, ImportError):
237237
# virtualenv doesn't include pyobjc, py2app, etc. in the sys.path for some reason.
238238
# not being able to access py2app isn't a big deal for 'build', 'app', 'dist', or 'clean'
239239
# so only abort the build if the 'py2app' command was given

0 commit comments

Comments
 (0)