Skip to content

Commit ddf632d

Browse files
Merge pull request #91 from computational-cell-analytics/68_installer_skripts
Add installer script
2 parents 3651f65 + cbfc8d0 commit ddf632d

File tree

7 files changed

+152
-0
lines changed

7 files changed

+152
-0
lines changed
Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
name: build_installers
2+
3+
on:
4+
push:
5+
tags:
6+
- '**'
7+
8+
jobs:
9+
build_intaller:
10+
name: ${{ matrix.os }}
11+
runs-on: ${{ matrix.os }}
12+
13+
strategy:
14+
fail-fast: false
15+
matrix:
16+
os: [windows-latest, ubuntu-latest, macos-latest]
17+
18+
env:
19+
PREPARE_SCRIPT: |
20+
cd deployment
21+
conda install -y -c conda-forge constructor
22+
conda install -y -c conda-forge ruamel.yaml
23+
conda install -y -c conda-forge mamba
24+
mamba env create --file=env.yaml
25+
RUN_SCRIPT: |
26+
python version_getter.py
27+
mkdir ./${{ matrix.os }}_x86_64
28+
constructor --output-dir ./${{ matrix.os }}_x86_64 .
29+
30+
steps:
31+
- name: checkout
32+
uses: actions/checkout@v3
33+
34+
- name: setup conda
35+
if: matrix.os == 'windows-latest' || matrix.os == 'ubuntu-latest'
36+
uses: conda-incubator/setup-miniconda@v2
37+
with:
38+
miniconda-version: "latest"
39+
auto-activate-base: true
40+
activate-environment: ""
41+
env:
42+
ACTIONS_ALLOW_UNSECURE_COMMANDS: true
43+
44+
- name: build ${{ matrix.os }}_x86_64
45+
if: matrix.os == 'windows-latest'
46+
shell: pwsh
47+
run: |
48+
${{ env.PREPARE_SCRIPT }}
49+
conda activate __MICROSAM_BUILD_ENV__
50+
conda install -c anaconda menuinst
51+
python windows_menu_setup.py
52+
conda activate base
53+
${{ env.RUN_SCRIPT }}
54+
55+
- name: build ${{ matrix.os }}_x86_64
56+
if: matrix.os == 'ubuntu-latest'
57+
shell: bash -el {0}
58+
run: |
59+
${{ env.PREPARE_SCRIPT }}
60+
${{ env.RUN_SCRIPT }}
61+
62+
- name: build ${{ matrix.os }}_x86_64_step1
63+
if: matrix.os == 'macos-latest'
64+
shell: bash -el {0}
65+
run: |
66+
brew install micromamba
67+
/usr/local/opt/micromamba/bin/micromamba shell init -s bash -p ~/micromamba
68+
69+
- name: build ${{ matrix.os }}_x86_64_step2
70+
if: matrix.os == 'macos-latest'
71+
shell: bash -el {0}
72+
run: |
73+
cd deployment
74+
micromamba activate base
75+
micromamba install -y -c conda-forge python=3.10
76+
micromamba install -y -c conda-forge constructor
77+
micromamba install -y -c conda-forge ruamel.yaml
78+
micromamba install -y -c conda-forge mamba
79+
mamba env create --file=env.yaml
80+
python version_getter.py
81+
mkdir ./${{ matrix.os }}_x86_64
82+
constructor --conda-exe=$(which mamba) --output-dir ./${{ matrix.os }}_x86_64 .
83+
84+
- name: upload installer
85+
uses: actions/upload-artifact@v3
86+
with:
87+
name: ${{ matrix.os }}_x86_64
88+
path: ./deployment/${{ matrix.os }}_x86_64
89+
retention-days: 5

deployment/construct.yaml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
name: micro_sam
2+
version: 0.1.0
3+
license_file: ../LICENSE
4+
installer_type: pkg #[osx] # This will trigger pkg build on Mac Os. On windows and linux, native build will be done and this has no effect.
5+
environment: __MICROSAM_BUILD_ENV__
6+
welcome_image: ../doc/images/micro-sam-logo.png
7+
header_image: ../doc/images/micro-sam-logo.png
8+
icon_image: ../doc/images/micro-sam-logo.png
9+
channels:
10+
- conda-forge
11+
welcome_text: Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod
12+
tempor incididunt ut labore et dolore magna aliqua.
13+
conclusion_text: Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris
14+
nisi ut aliquip ex ea commodo consequat.
15+
initialize_by_default: true

deployment/env.yaml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
name: __MICROSAM_BUILD_ENV__
2+
channels:
3+
- conda-forge
4+
dependencies:
5+
- napari
6+
- pyqt
7+
- pytorch::pytorch
8+
- pytorch::torchvision
9+
- micro_sam

deployment/version_getter.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import runpy
2+
import ruamel.yaml
3+
import os
4+
5+
yaml = ruamel.yaml.YAML()
6+
yaml.preserve_quotes = True
7+
ctor_fname = os.path.join("construct.yaml")
8+
9+
with open(ctor_fname, 'r') as stream:
10+
ctor_conf = yaml.load(stream)
11+
12+
ctor_conf["version"] = runpy.run_path(os.path.join("..", "micro_sam", "__version__.py"))["__version__"]
13+
14+
with open(ctor_fname, 'w') as outfile:
15+
yaml.dump(ctor_conf, outfile)

deployment/windows_menu.json

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
{
2+
"menu_name": "micro_sam",
3+
"menu_items":
4+
[
5+
{
6+
"script": "${PREFIX}/Scripts/micro_sam.annotator.exe",
7+
"name": "micro_sam",
8+
"icon": "${PREFIX}/Menu/micro-sam-logo.ico",
9+
"workdir": "${PREFIX}",
10+
"desktop": true,
11+
"quicklaunch": true
12+
}
13+
]
14+
}

deployment/windows_menu_setup.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import menuinst
2+
import shutil
3+
import os
4+
5+
conda_dir = os.environ["CONDA_PREFIX"]
6+
menu_dir = os.path.join(conda_dir, "Menu")
7+
os.makedirs(menu_dir, exist_ok = True)
8+
shutil.copy("../doc/images/micro-sam-logo.ico", menu_dir)
9+
shutil.copy("./windows_menu.json", menu_dir)
10+
menuinst.install(os.path.join(menu_dir, 'windows_menu.json'), prefix=conda_dir)

doc/images/micro-sam-logo.ico

212 KB
Binary file not shown.

0 commit comments

Comments
 (0)