-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
48229f1
commit f5ed13a
Showing
10 changed files
with
223 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
#!/usr/bin/env bash | ||
|
||
set -e -x | ||
|
||
if [[ "${VIRTUAL_ENV}" == "" ]]; then | ||
echo "error: VIRTUAL_ENV not set" | ||
exit 1 | ||
fi | ||
|
||
DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" | ||
|
||
# this is needed so that Go builds can find the Python headers etc | ||
cp -frv "${DIR}/python-config" "${VIRTUAL_ENV}/bin/python-config" | ||
|
||
# this is needed so that our Go builds can find the common tooling when invoked from within a Virtualenv | ||
cp -frv "${DIR}/native_build.sh" "${VIRTUAL_ENV}/bin/native_build.sh" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
#!/usr/bin/env bash | ||
|
||
set -e -x | ||
|
||
if [[ "${1}" == "" ]]; then | ||
echo "error: first argument must be name of lib (e.g. gomssql)" | ||
exit 1 | ||
fi | ||
|
||
NAME_OF_LIB="${1}" | ||
|
||
if [[ "${VIRTUAL_ENV}" == "" ]]; then | ||
echo "error: a virtualenv must be activated" | ||
exit 1 | ||
fi | ||
|
||
# TODO | ||
# GO_VERSION="$(go version)" | ||
# if [[ ${GO_VERSION} != *"go1.13"* ]]; then | ||
# echo "error: Go version is not 1.13 (was ${GO_VERSION})" | ||
# exit 1 | ||
# fi | ||
|
||
PKG_CONFIG_PATH="$(pwd)" | ||
export PKG_CONFIG_PATH | ||
|
||
OUTPUT_PATH="${NAME_OF_LIB}_python/built" | ||
|
||
if [[ "${2}" != "fast" ]]; then | ||
echo "installing python deps..." | ||
pip install --upgrade -r requirements-dev.txt | ||
echo "" | ||
|
||
echo "installing goimports..." | ||
go get golang.org/x/tools/cmd/goimports | ||
echo "" | ||
|
||
echo "installing gopy..." | ||
go get github.com/go-python/gopy@v0.3.4 | ||
echo "" | ||
fi | ||
|
||
echo "cleaning up output folder..." | ||
rm -frv "${OUTPUT_PATH:?}/*" || true | ||
mkdir -p "${OUTPUT_PATH}" || true | ||
touch "${OUTPUT_PATH}/__init__.py" || true | ||
echo "" | ||
|
||
echo "building ${NAME_OF_LIB}-python..." | ||
export PATH=${PATH}:~/go/bin/ | ||
export CFLAGS | ||
export C_INCLUDE_PATH | ||
gopy build -output="${OUTPUT_PATH}" -symbols=true -vm="$(command -v python)" "./${NAME_OF_LIB}_python_go" | ||
echo "" | ||
|
||
echo "hacking in some sed fixes..." | ||
sed -i'.bak' "s/import _${NAME_OF_LIB}_python_go/from ${NAME_OF_LIB}_python.built import _${NAME_OF_LIB}_python_go/g" "${NAME_OF_LIB}_python/built/${NAME_OF_LIB}_python_go.py" | ||
sed -i'.bak' "s/import go/from ${NAME_OF_LIB}_python.built import go/g" "${NAME_OF_LIB}_python/built/${NAME_OF_LIB}_python_go.py" | ||
sed -i'.bak' "s/import _${NAME_OF_LIB}_python_go/from ${NAME_OF_LIB}_python.built import _${NAME_OF_LIB}_python_go/g" "${NAME_OF_LIB}_python/built/go.py" | ||
echo "" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
#!/usr/bin/env bash | ||
|
||
set -e | ||
|
||
if [[ "${VIRTUAL_ENV}" == "" ]]; then | ||
echo "error: a virtualenv must be activated" | ||
exit 1 | ||
fi | ||
|
||
export TEST_COMMUNITY | ||
export TEST_DATABASE | ||
export TEST_HOSTNAME | ||
export TEST_PASSWORD | ||
export TEST_PORT | ||
export TEST_RETRIES | ||
export TEST_TIMEOUT | ||
export TEST_USERNAME | ||
|
||
FOCUS="test/smoke_test.py" | ||
if [[ "${1}" != "" ]]; then | ||
FOCUS="${*}" | ||
fi | ||
|
||
GODEBUG=cgocheck=0 python -m pytest --junit-xml "/srv/test_results/junit_results.xml" -vv -s "${FOCUS}" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
#!/usr/local/Cellar/python@3.9/3.9.1_6/Frameworks/Python.framework/Versions/3.9/bin/python3.9 | ||
# -*- python -*- | ||
|
||
# Keep this script in sync with python-config.sh.in | ||
|
||
import getopt | ||
import os | ||
import sys | ||
import sysconfig | ||
|
||
valid_opts = ['prefix', 'exec-prefix', 'includes', 'libs', 'cflags', | ||
'ldflags', 'extension-suffix', 'help', 'abiflags', 'configdir', | ||
'embed'] | ||
|
||
def exit_with_usage(code=1): | ||
print("Usage: {0} [{1}]".format( | ||
sys.argv[0], '|'.join('--'+opt for opt in valid_opts)), file=sys.stderr) | ||
sys.exit(code) | ||
|
||
try: | ||
opts, args = getopt.getopt(sys.argv[1:], '', valid_opts) | ||
except getopt.error: | ||
exit_with_usage() | ||
|
||
if not opts: | ||
exit_with_usage() | ||
|
||
getvar = sysconfig.get_config_var | ||
pyver = getvar('VERSION') | ||
|
||
opt_flags = [flag for (flag, val) in opts] | ||
|
||
if '--help' in opt_flags: | ||
exit_with_usage(code=0) | ||
|
||
for opt in opt_flags: | ||
if opt == '--prefix': | ||
print(getvar('prefix')) | ||
|
||
elif opt == '--exec-prefix': | ||
print(getvar('exec_prefix')) | ||
|
||
elif opt in ('--includes', '--cflags'): | ||
flags = ['-I' + sysconfig.get_path('include'), | ||
'-I' + sysconfig.get_path('platinclude')] | ||
if opt == '--cflags': | ||
flags.extend(getvar('CFLAGS').split()) | ||
print(' '.join(flags)) | ||
|
||
elif opt in ('--libs', '--ldflags'): | ||
libs = [] | ||
if '--embed' in opt_flags: | ||
libs.append('-lpython' + pyver + sys.abiflags) | ||
else: | ||
libpython = getvar('LIBPYTHON') | ||
if libpython: | ||
libs.append(libpython) | ||
libs.extend(getvar('LIBS').split() + getvar('SYSLIBS').split()) | ||
|
||
# add the prefix/lib/pythonX.Y/config dir, but only if there is no | ||
# shared library in prefix/lib/. | ||
if opt == '--ldflags': | ||
if not getvar('Py_ENABLE_SHARED'): | ||
libs.insert(0, '-L' + getvar('LIBPL')) | ||
print(' '.join(libs)) | ||
|
||
elif opt == '--extension-suffix': | ||
print(getvar('EXT_SUFFIX')) | ||
|
||
elif opt == '--abiflags': | ||
print(sys.abiflags) | ||
|
||
elif opt == '--configdir': | ||
print(getvar('LIBPL')) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
prefix=/System/Library/Frameworks/Python.framework/Versions/2.7 | ||
exec_prefix=${prefix} | ||
libdir=${exec_prefix}/lib | ||
includedir=${prefix}/include | ||
|
||
Name: Python | ||
Description: Python library | ||
Requires: | ||
Version: 2.7 | ||
Libs.private: -ldl -framework CoreFoundation | ||
Libs: -L${libdir} -lpython2.7 | ||
Cflags: -I${includedir}/python2.7 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
*.iml | ||
.git | ||
.idea | ||
go*_python/built | ||
go*_python/py2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
#!/usr/bin/env bash | ||
|
||
set -e -x | ||
|
||
.common/go-binding-utils/fix_venv.sh |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
#!/usr/bin/env bash | ||
|
||
set -e -x | ||
|
||
DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" | ||
pushd "${DIR}" | ||
|
||
if [[ -f "/tmp/native_build.sh" ]]; then | ||
/tmp/native_build.sh gomssql "${1}" | ||
elif which native_build.sh; then | ||
native_build.sh gomssql "${1}" | ||
else | ||
.common/go-binding-utils/native_build.sh gomssql "${1}" | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
prefix=/System/Library/Frameworks/Python.framework/Versions/2.7 | ||
exec_prefix=${prefix} | ||
libdir=${exec_prefix}/lib | ||
includedir=${prefix}/include | ||
|
||
Name: Python | ||
Description: Python library | ||
Requires: | ||
Version: 2.7 | ||
Libs.private: -ldl -framework CoreFoundation | ||
Libs: -L${libdir} -lpython2.7 | ||
Cflags: -I${includedir}/python2.7 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
-r requirements.txt | ||
|
||
PyBindGen==0.21.0 | ||
pytest==4.6.11 |