Skip to content

Commit a8ddd1e

Browse files
Update install.sh to default to multi-file on OS X [artifacts]
- Default to downloading release at `sgr-osx-x86_64.tgz` when on OS X. This downloads a tarball of the multi-file executable creatd with `pyinstaller --onedir`, which means a directory that includes the `sgr` executable and its dependencies. This performs better than executables generated with `--onefile` on OS X. - Allow overriding and reverting to previous behavior (i.e., downloading the single-file executable which is still addressable at `sgr-osx-x86_64` in the release bundle) with `FORCE_ONEFILE` flag - Unzip the package to `~/.splitgraph/pkg/sgr` (overwrite if exists), then symlink `~/.splitgraph/sgr -> ~/.splitgraph/pkg/sgr/sgr`, in order to keep compatibility with existing scripts - Note: The self-upgrade (`sgr upgrade`) code might still need to be changed.
1 parent a705fd9 commit a8ddd1e

1 file changed

Lines changed: 31 additions & 1 deletion

File tree

install.sh

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,15 @@ _get_binary_name() {
6262
if [ "$os" == Linux ]; then
6363
BINARY="sgr-linux-x86_64"
6464
elif [ "$os" == Darwin ]; then
65-
BINARY="sgr-osx-x86_64"
65+
if [ -n "$FORCE_ONEFILE" ] ; then
66+
echo "Forcing --onefile installation on OS X because \$FORCE_ONEFILE is set."
67+
BINARY="sgr-osx-x86_64"
68+
else
69+
# OS X has bad single-file executable support (pyinstaller --onefile), so we default to --onedir variant
70+
echo "Installing optimized package for OS X (built with pyinstaller --onedir instead of --onefile)"
71+
echo "To force install single-file executable (not recommended), set FORCE_ONEFILE=1"
72+
BINARY="sgr-osx-x86_64.tgz"
73+
fi
6674
else
6775
_die "This installation method only supported on Linux/OSX. Please see https://www.splitgraph.com/docs/installation/ for other installation methods."
6876
fi
@@ -81,8 +89,30 @@ _install_binary () {
8189
if [ "$BINARY" == "sgr-osx-x86_64.tgz" ] ; then
8290
echo "Installing the compressed sgr binary and deps from $URL into $INSTALL_DIR"
8391
echo "Installing sgr binary and deps into $INSTALL_DIR/pkg"
92+
93+
if [ -d "$INSTALL_DIR/pkg/sgr" ] ; then
94+
echo "Removing existing $INSTALL_DIR/pkg/sgr"
95+
rm -rf "$INSTALL_DIR/pkg/sgr"
96+
fi
97+
98+
mkdir -p "$INSTALL_DIR/pkg/sgr"
99+
100+
curl -fsL "$URL" > "$INSTALL_DIR/pkg/sgr/sgr.tgz"
101+
102+
echo "Extract sgr binary and deps into $INSTALL_DIR/pkg/sgr (necessary on MacOS)"
103+
(cd "$INSTALL_DIR"/pkg/sgr && tar xfz sgr.tgz && rm sgr.tgz)
104+
echo "Main sgr binary is at $INSTALL_DIR/pkg/sgr/sgr"
105+
echo "Link $INSTALL_DIR/sgr -> $INSTALL_DIR/pkg/sgr/sgr"
106+
ln -fs "$INSTALL_DIR"/pkg/sgr/sgr "$INSTALL_DIR"/sgr
107+
else
108+
echo "Installing the sgr binary from $URL into $INSTALL_DIR"
109+
mkdir -p "$INSTALL_DIR"
110+
curl -fsL "$URL" > "$INSTALL_DIR/sgr"
111+
chmod +x "$INSTALL_DIR/sgr"
84112
fi
85113

114+
"$INSTALL_DIR/sgr" --version && echo "sgr binary installed." && echo && return 0
115+
_die "Installation apparently failed. got non-zero exit code from: $INSTALL_DIR/sgr --version"
86116
}
87117

88118
_setup_engine() {

0 commit comments

Comments
 (0)