-
Notifications
You must be signed in to change notification settings - Fork 13
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
Showing
10 changed files
with
219 additions
and
35 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
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,76 @@ | ||
#!/usr/bin/env python3 | ||
"""Create a conda-pack'd SIFT installation tarball. | ||
Note: This script will place extra files in the currently activated python | ||
environment in order to include these files in the produced tarball. | ||
SIFT must be installed in the current environment with:: | ||
pip install --no-deps . | ||
Instead of installing it in development mode (`-e`). | ||
Example:: | ||
python build_conda_pack.py -c | ||
""" | ||
|
||
import os | ||
import sys | ||
import shutil | ||
import subprocess | ||
|
||
|
||
def get_version(): | ||
try: | ||
from uwsift import __version__ | ||
return __version__ | ||
except ImportError: | ||
raise RuntimeError("Could not determine SIFT version. Is SIFT installed?") | ||
|
||
|
||
def main(): | ||
import argparse | ||
parser = argparse.ArgumentParser( | ||
description="Build SIFT installation tarball (remaining arguments " | ||
"are passed to conda-pack)") | ||
parser.add_argument('--arcroot', | ||
help="Directory name inside the tarball (default: SIFT_X.Y.Z)") | ||
parser.add_argument('-o', '--output', | ||
help="Pathname for bundled file. Default is " | ||
"'SIFT_X.Y.Z_<platform>.<ext>' where platform is " | ||
"'linux', 'darwin', or 'win32' and ext is " | ||
"'.tar.gz' for linux and OSX, '.zip' for Windows.") | ||
args, unknown_args = parser.parse_known_args() | ||
|
||
version = get_version() | ||
if args.arcroot is None: | ||
args.arcroot = f"SIFT_{version}" | ||
if args.output is None: | ||
ext = '.zip' if 'win' in sys.platform else '.tar.gz' | ||
args.output = f"SIFT_{version}_{sys.platform}{ext}" | ||
|
||
# Copy appropriate wrapper scripts | ||
dst = sys.prefix | ||
script_dir = os.path.realpath(os.path.dirname(__file__)) | ||
if 'nux' in sys.platform: | ||
script = os.path.join(script_dir, 'bundle_scripts', 'SIFT.sh') | ||
shutil.copyfile(script, os.path.join(dst, 'SIFT.sh')) | ||
elif 'darwin' in sys.platform: | ||
script = os.path.join(script_dir, 'bundle_scripts', 'SIFT.sh') | ||
shutil.copyfile(script, os.path.join(dst, 'SIFT.command')) | ||
elif 'win' in sys.platform: | ||
script = os.path.join(script_dir, 'bundle_scripts', 'SIFT.bat') | ||
shutil.copyfile(script, os.path.join(dst, 'SIFT.bat')) | ||
else: | ||
raise RuntimeError(f"Unknown platform: {sys.platform}") | ||
|
||
subprocess.check_call(['conda-pack', '--arcroot', args.arcroot, | ||
'--output', args.output] + unknown_args) | ||
os.chmod(args.output, 0o755) | ||
|
||
# TODO: Do additional risky cleanup to reduce output file size | ||
|
||
|
||
if __name__ == "__main__": | ||
sys.exit(main()) |
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,13 @@ | ||
# Bundle Scripts | ||
|
||
The scripts in this directory are specially constructed to run from a | ||
conda-pack'd bundled installation of SIFT. The types of scripts included are | ||
currently: | ||
|
||
1. `SIFT.X` where `X` corresponds to a scripting extension specific to each | ||
platform. This is `.sh` for Linux (CentOS 7+), `.command` for OSX, and | ||
`.bat` for Windows. These scripts are placed in the root directory of | ||
the released bundle. | ||
|
||
Note to reuse code as much as possible some scripts may be copied to | ||
the appropriate name rather than existing as separate files. |
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,19 @@ | ||
@echo off | ||
REM Initialize SIFT installation if necessary and run SIFT | ||
|
||
set base_dir=%~p0 | ||
|
||
REM Activate the conda environment | ||
call %base_dir%Scripts\activate | ||
|
||
REM Create a signal file that we have run conda-unpack | ||
set installed=%base_dir%.installed | ||
if not exist "%installed%" ( | ||
echo Running one-time initialization of SIFT installation... | ||
conda-unpack | ||
echo %base_dir% > %installed% | ||
) | ||
|
||
echo Running SIFT... | ||
|
||
python -m uwsift %* |
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,30 @@ | ||
#!/usr/bin/env bash | ||
# Usage: SIFT.sh <command line arguments> | ||
# Description: Initialize the SIFT installation if necessary and run SIFT | ||
set -e | ||
|
||
# get current base directory for this script | ||
SOURCE="${BASH_SOURCE[0]}" | ||
while [[ -h "$SOURCE" ]] ; do SOURCE="$(readlink "$SOURCE")"; done | ||
BASE="$( cd -P "$( dirname "$SOURCE" )" && pwd )" | ||
|
||
# Remove user environment variables that may conflict with installation | ||
unset LD_PRELOAD | ||
unset LD_LIBRARY_PATH | ||
unset DYLD_LIBRARY_PATH | ||
unset PYTHONPATH | ||
export PYTHONNOUSERSITE=1 | ||
|
||
# Activate the conda-pack'd environment | ||
source $BASE/activate | ||
|
||
# Check if we already ran conda-unpack | ||
install_signal="${BASE}/.installed" | ||
if [[ ! -f "${install_signal}" ]]; then | ||
echo "Running one-time initialization of SIFT installation..." | ||
conda-unpack | ||
echo "${BASE}" > "${install_signal}" | ||
echo "Running SIFT..." | ||
fi | ||
|
||
python -m uwsift "$@" |
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
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
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
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
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