forked from fawkesley/python-windows-packager
-
Notifications
You must be signed in to change notification settings - Fork 0
/
package.sh
executable file
·67 lines (48 loc) · 1.79 KB
/
package.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
#!/bin/bash -e
if [ $# -ne 2 ]; then
echo "Usage: $0 /path/to/main.py ProjectName"
exit 1
else
FULL_PY_PATH=`readlink -f $1`
SOURCE_DIR_LINUX=`dirname ${FULL_PY_PATH}`
MAIN_PY=`basename ${FULL_PY_PATH}`
PROJECT_NAME="$2"
fi
THIS_SCRIPT_PATH=`readlink -f $0`
THIS_SCRIPT_DIR=`dirname ${THIS_SCRIPT_PATH}`
PYINSTALLER_ZIP=${THIS_SCRIPT_DIR}/installers/PyInstaller-2.1.zip
PYTHON_EXE_WIN="C:\\Python27\\python.exe"
WINE_TARBALL=${THIS_SCRIPT_DIR}/build_environment/wine.tar.gz
if [ ! -e "${WINE_TARBALL}" ]; then
echo "ERROR: You don't have a frozen wine environment at"
echo "${WINE_TARBALL}"
echo
echo "Option 1:"
echo " Create a new wine environment by running build_environment/create.sh"
echo " and following the instructions."
echo "Option 2:"
echo " Use an existing wine environment (with Python installed) by doing:"
echo " $ export WINEPREFIX=~/.wine # path to your existing wine env"
echo " $ build_environment/freeze.sh"
exit 2
else
export WINEPREFIX=`mktemp -d --suffix=_wine`
# Unpack wine environment
tar "--directory=${WINEPREFIX}" -xzf ${WINE_TARBALL}
fi
BUILD_DIR_LINUX=${WINEPREFIX}/drive_c/build
BUILD_DIR_WIN="C:\\build"
mkdir -p ${BUILD_DIR_LINUX}
# Unpack PyInstaller
unzip ${PYINSTALLER_ZIP} -d ${BUILD_DIR_LINUX} > /dev/null
PYINSTALLER_DIR_WIN=${BUILD_DIR_WIN}/pyinstaller-2.1
# Create symbolic link to source directory so Windows can access it
ln -s ${SOURCE_DIR_LINUX} ${BUILD_DIR_LINUX}/src_symlink
SOURCE_DIR_WIN=${BUILD_DIR_WIN}\\src_symlink
wine "${PYTHON_EXE_WIN}" "${PYINSTALLER_DIR_WIN}\\pyinstaller.py" \
"--name=${PROJECT_NAME}" \
--onefile \
--noconsole \
"${SOURCE_DIR_WIN}\\${MAIN_PY}"
rm -rf ${WINEPREFIX}
echo "Executable available at dist/${PROJECT_NAME}.exe"