Skip to content

Commit 11fd2ce

Browse files
committed
add installer script
1 parent b394c99 commit 11fd2ce

File tree

7 files changed

+154
-0
lines changed

7 files changed

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