#!/usr/bin/env bash # # Set up a development build of Oil on CPython. # This is in constrast to the release build, which bundles Oil with "OVM" (a # slight fork of CPython). # Build Python extension modules. We use symlinks instead of installing them # globally (or using virtualenv). # # Usage: # ./pybuild.sh set -o nounset set -o pipefail set -o errexit proc ubuntu-deps { # python-dev: for pylibc # gawk: used by spec-runner.sh for the special match() function. # time: used to collect the exit code and timing of a test # libreadline-dev: needed for the build/prepare.sh Python build. sudo apt-get install python-dev gawk time libreadline-dev test/spec.sh install-shells } # These produce _devbuild/{osh,oil}_help.py proc gen-help { build/doc.sh osh-quick-ref build/doc.sh oil-quick-ref } proc pylibc { mkdir -p _devbuild/pylibc var arch = $[uname -m] build/setup.py build --build-lib _devbuild/pylibc/$arch # Wildcard to match any Python 3 version. shopt -s failglob var so = $[echo _devbuild/pylibc/$arch/libc.so] ln -s -f -v $so libc.so file libc.so } # Also done by unit.sh. proc test-pylibc { export PYTHONPATH=. pylibc native/libc_test.py } proc clean-pylibc { rm -f --verbose libc.so rm -r -f --verbose _devbuild/pylibc } proc all { gen-help pylibc test-pylibc } @Argv (CommandList children: [ (C {(set)} {(-o)} {(nounset)}) (C {(set)} {(-o)} {(pipefail)}) (C {(set)} {(-o)} {(errexit)}) (FuncDef name: ubuntu-deps body: (BraceGroup children: [ (C {(sudo)} {(apt-get)} {(install)} {(python-dev)} {(gawk)} {(KW_Time time)} {(libreadline-dev)}) (C {(test/spec.sh)} {(install-shells)}) ] spids: [55] ) spids: [51 54] ) (FuncDef name: gen-help body: (BraceGroup children: [(C {(build/doc.sh)} {(osh-quick-ref)}) (C {(build/doc.sh)} {(oil-quick-ref)})] spids: [104] ) spids: [100 103] ) (FuncDef name: pylibc body: (BraceGroup children: [ (C {(mkdir)} {(-p)} {(_devbuild/pylibc)}) (Assignment keyword: Assign_Local pairs: [ (assign_pair lhs: (LhsName name:arch) op: Equal rhs: { (CommandSubPart command_list: (CommandList children:[(C {(uname)} {(-m)})]) left_token: spids: [136 140] ) } spids: [135] ) ] spids: [133] ) (C {(build/setup.py)} {(build)} {(--build-lib)} {(_devbuild/pylibc/) ($ VSub_Name "$arch")}) (C {(shopt)} {(-s)} {(failglob)}) (Assignment keyword: Assign_Local pairs: [ (assign_pair lhs: (LhsName name:so) op: Equal rhs: { (CommandSubPart command_list: (CommandList children: [ (C {(echo)} {(_devbuild/pylibc/) ($ VSub_Name "$arch") (/libc.so)}) ] ) left_token: spids: [168 174] ) } spids: [167] ) ] spids: [165] ) (C {(ln)} {(-s)} {(-f)} {(-v)} {($ VSub_Name "$so")} {(libc.so)}) (C {(file)} {(libc.so)}) ] spids: [123] ) spids: [119 122] ) (FuncDef name: test-pylibc body: (BraceGroup children: [ (C {(export)} {(Lit_VarLike "PYTHONPATH=") (.)}) (C {(pylibc)}) (C {(native/libc_test.py)}) ] spids: [205] ) spids: [201 204] ) (FuncDef name: clean-pylibc body: (BraceGroup children: [ (C {(rm)} {(-f)} {(--verbose)} {(libc.so)}) (C {(rm)} {(-r)} {(-f)} {(--verbose)} {(_devbuild/pylibc)}) ] spids: [226] ) spids: [222 225] ) (FuncDef name: all body: (BraceGroup children:[(C {(gen-help)})(C {(pylibc)})(C {(test-pylibc)})] spids:[255]) spids: [251 254] ) (C {(DQ ($ VSub_At "$@"))}) ] )