-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #281 from scenerygraphics/conda
Conda packaging
- Loading branch information
Showing
9 changed files
with
521 additions
and
26 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
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,66 @@ | ||
|
||
import os | ||
import subprocess | ||
|
||
travis_secure = os.environ['TRAVIS_SECURE_ENV_VARS'] | ||
PR = os.environ['TRAVIS_PULL_REQUEST'] | ||
is_PR = ( PR != 'false' ) | ||
|
||
# If this is a PR we use the source branch name, and last commit message | ||
if is_PR: | ||
print('Fetching PR information') | ||
branch = os.environ['TRAVIS_PULL_REQUEST_BRANCH'] | ||
|
||
import requests | ||
import json | ||
r = requests.get('https://api.github.com/repos/scenerygraphics/sciview/pulls/%d/commits' % int(PR)) | ||
|
||
if r.ok: | ||
commits = json.loads(r.text or r.content) | ||
commit_message = commits[-1]['commit']['message'] | ||
print('Commit message: %s' % commit_message) | ||
else: | ||
branch = os.environ['TRAVIS_BRANCH'] | ||
commit_message = os.environ['TRAVIS_COMMIT_MESSAGE'] | ||
|
||
release_properties_exists = os.path.exists('release.properties') | ||
|
||
print('travis pre_ci.py') | ||
print('') | ||
print('') | ||
print('Repo: %s' % os.environ['TRAVIS_REPO_SLUG']) | ||
print('Branch: %s' % branch) | ||
print('Release?: %s' % str(release_properties_exists)) | ||
print('Is Pull Request?: %s' % is_PR) | ||
print('Commit: %s' % commit_message) | ||
|
||
# Perform main build | ||
print('Starting build') | ||
# we now have our own version of travis-build.sh | ||
#subprocess.call(['curl', '-fsLO', 'https://raw.githubusercontent.com/scijava/scijava-scripts/master/travis-build.sh']) | ||
build_var1 = os.environ['encrypted_eb7aa63bf7ac_key'] | ||
build_var2 = os.environ['encrypted_eb7aa63bf7ac_iv'] | ||
subprocess.call(['bash', 'travis-build.sh', build_var1, build_var2]) | ||
|
||
# Setup conda environment | ||
# def build_conda(): | ||
# from pathlib import Path | ||
# home = str(Path.home()) | ||
|
||
# print('------ BUILD CONDA -----') | ||
|
||
# script_name = 'Miniconda3-latest-Linux-x86_64.sh' | ||
# miniconda_dir = '%s/miniconda' % home | ||
# subprocess.call(['curl', '-fsLO', 'https://repo.continuum.io/miniconda/%s' % script_name]) | ||
# subprocess.call(['bash', script_name, '-b', '-p', miniconda_dir]) | ||
# subprocess.call(['source', '%s/etc/profile.d/conda.sh' % miniconda_dir]) | ||
# subprocess.call(['hash', '-r']) | ||
# subprocess.call(['conda', 'config', '--set', 'always_yes', 'yes', '--set', 'changeps1', 'no']) | ||
# subprocess.call(['conda', 'update', '-q', 'conda']) | ||
# # Useful for debugging any issues with conda | ||
# subprocess.call(['conda', 'info', '-a']) | ||
|
||
# # Replace dep1 dep2 ... with your dependencies | ||
# subprocess.call(['conda', 'env', 'create', '-f', 'environment.yml']) | ||
# subprocess.call(['conda', 'activate', 'sciview']) | ||
# build_conda() |
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,116 @@ | ||
|
||
import os | ||
import subprocess | ||
|
||
travis_secure = os.environ['TRAVIS_SECURE_ENV_VARS'] | ||
PR = os.environ['TRAVIS_PULL_REQUEST'] | ||
is_PR = ( PR != 'false' ) | ||
|
||
# If this is a PR we use the source branch name, and last commit message | ||
if is_PR: | ||
print('Fetching PR information') | ||
branch = os.environ['TRAVIS_PULL_REQUEST_BRANCH'] | ||
|
||
import requests | ||
import json | ||
r = requests.get('https://api.github.com/repos/scenerygraphics/sciview/pulls/%d/commits' % int(PR)) | ||
|
||
if r.ok: | ||
commits = json.loads(r.text or r.content) | ||
commit_message = commits[-1]['commit']['message'] | ||
print('Commit message: %s' % commit_message) | ||
else: | ||
branch = os.environ['TRAVIS_BRANCH'] | ||
commit_message = os.environ['TRAVIS_COMMIT_MESSAGE'] | ||
|
||
release_properties_exists = os.path.exists('release.properties') | ||
|
||
print('') | ||
print('') | ||
print('') | ||
print('Repo: %s' % os.environ['TRAVIS_REPO_SLUG']) | ||
print('Branch: %s' % branch) | ||
print('Release?: %s' % str(release_properties_exists)) | ||
print('Is Pull Request?: %s' % is_PR) | ||
print('Commit: %s' % commit_message) | ||
|
||
# Perform main build | ||
print('Starting build') | ||
# we now have our own version of travis-build.sh | ||
#subprocess.call(['curl', '-fsLO', 'https://raw.githubusercontent.com/scijava/scijava-scripts/master/travis-build.sh']) | ||
build_var1 = os.environ['encrypted_eb7aa63bf7ac_key'] | ||
build_var2 = os.environ['encrypted_eb7aa63bf7ac_iv'] | ||
subprocess.call(['sh', 'travis-build.sh', build_var1, build_var2]) | ||
|
||
# Setup conda environment | ||
def build_conda(): | ||
from pathlib import Path | ||
home = str(Path.home()) | ||
|
||
print('------ BUILD CONDA -----') | ||
|
||
script_name = 'Miniconda3-latest-Linux-x86_64.sh' | ||
miniconda_dir = '%s/miniconda' % home | ||
subprocess.call(['curl', '-fsLO', 'https://repo.continuum.io/miniconda/%s' % script_name]) | ||
subprocess.call(['bash', script_name, '-b', '-p', miniconda_dir]) | ||
subprocess.call(['source', '%s/etc/profile.d/conda.sh' % miniconda_dir]) | ||
subprocess.call(['hash', '-r']) | ||
subprocess.call(['conda', 'config', '--set', 'always_yes', 'yes', '--set', 'changeps1', 'no']) | ||
subprocess.call(['conda', 'update', '-q', 'conda']) | ||
# Useful for debugging any issues with conda | ||
subprocess.call(['conda', 'info', '-a']) | ||
|
||
# Replace dep1 dep2 ... with your dependencies | ||
subprocess.call(['conda', 'env', 'create', '-f', 'environment.yml']) | ||
subprocess.call(['conda', 'activate', 'sciview']) | ||
build_conda() | ||
|
||
def package_conda(): | ||
subprocess.call(['sh', 'populate_fiji.sh']) | ||
subprocess.call(['pyinstaller', '--onefile', '--add-data', 'Fiji.app/jars:jars', 'src/main/python/sciview.py']) | ||
|
||
platform = subprocess.check_output(['uname', '-s']) | ||
arch = subprocess.check_output(['uname', '-m']) | ||
|
||
if platform == 'Linux' and arch == 'x86_64': | ||
exe_name = 'sciview-linux64' | ||
elif platform == 'Linux': | ||
exe_name = 'sciview-linux32' | ||
elif platform == 'Darwin': | ||
exe_name = 'sciview-macos' | ||
elif platform.startswith('MING'): | ||
exe_name = 'sciview-win32' | ||
elif platform.startswith('MSYS_NT'): | ||
exe_name = 'sciview-win32' | ||
|
||
subprocess.call(['mv', 'dist/sciview', exe_name]) | ||
package_conda() | ||
|
||
# Update sites | ||
print('') | ||
print('') | ||
print('') | ||
print('Checking if upload to update site needed') | ||
|
||
## Unstable | ||
## Commit message trigger requires one of these conditions: | ||
## - message begin with SV_IJ_DEPLOY_UNSTABLE | ||
## - push/merge to master | ||
|
||
if ( branch == 'master' and not is_PR and travis_secure ) or \ | ||
( '[SV_IJ_DEPLOY_UNSTABLE]' in commit_message ): | ||
|
||
print('Upload to SciView-Unstable') | ||
subprocess.call(['sh', 'sciview_deploy_unstable.sh']) | ||
|
||
## Primary | ||
## Commit message trigger requires one of these conditions: | ||
## - message begin with SV_IJ_DEPLOY_PRIMARY | ||
## - release | ||
|
||
# TODO: check branch == <pom-release-version> | ||
if ( not is_PR and travis_secure and release_properties_exists ) or \ | ||
( '[SV_IJ_DEPLOY_PRIMARY]' in commit_message ): | ||
print('Upload to SciView') | ||
subprocess.call(['sh', 'sciview_deploy.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,23 @@ | ||
name: sciview | ||
channels: | ||
- conda-forge | ||
- defaults | ||
dependencies: | ||
- python >=3.8 | ||
# - pyyaml | ||
# - numpy | ||
# - Pillow | ||
# - pyimagej | ||
# - opencv | ||
# - matplotlib | ||
# - openjdk | ||
- maven | ||
- git | ||
- openjdk >=8.0.192,<8.1.0a0 | ||
- pip | ||
- pip: | ||
- pathlib | ||
- requests | ||
- pyinstaller | ||
# - tensorflow | ||
# - keras |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import subprocess | ||
import os | ||
import sys | ||
|
||
# https://stackoverflow.com/questions/7674790/bundling-data-files-with-pyinstaller-onefile | ||
def resource_path(relative_path): | ||
""" Get absolute path to resource, works for dev and for PyInstaller """ | ||
try: | ||
# PyInstaller creates a temp folder and stores path in _MEIPASS | ||
base_path = sys._MEIPASS | ||
except Exception: | ||
base_path = os.path.abspath(".") | ||
|
||
return os.path.join(base_path, relative_path) | ||
|
||
classpath = resource_path('./jars/*') | ||
classpath += ':%s' % resource_path( './jars/bio-formats/*' ) | ||
classpath += ':%s' % resource_path( './jars/linux32/*' ) | ||
classpath += ':%s' % resource_path( './jars/linux64/*' ) | ||
classpath += ':%s' % resource_path( './jars/macosx/*' ) | ||
classpath += ':%s' % resource_path( './jars/win32/*' ) | ||
classpath += ':%s' % resource_path( './jars/win64/*' ) | ||
|
||
subprocess.call(['java', '-cp', classpath, 'sc.iview.Main']) |
Oops, something went wrong.