diff --git a/.github/workflows/build_installers.yaml b/.github/workflows/build_installers.yaml new file mode 100644 index 00000000..9dc900c4 --- /dev/null +++ b/.github/workflows/build_installers.yaml @@ -0,0 +1,91 @@ +name: build_installers + +on: + push: + tags: + - '**' + branches: + - '*' + +jobs: + build_intaller: + name: ${{ matrix.os }} + runs-on: ${{ matrix.os }} + + strategy: + fail-fast: false + matrix: + os: [windows-latest, ubuntu-latest, macos-latest] + + env: + PREPARE_SCRIPT: | + cd deployment + conda install -y -c conda-forge constructor + conda install -y -c conda-forge ruamel.yaml + conda install -y -c conda-forge mamba + mamba env create --file=env.yaml + RUN_SCRIPT: | + python version_getter.py + mkdir ./${{ matrix.os }}_x86_64 + constructor --output-dir ./${{ matrix.os }}_x86_64 . + + steps: + - name: checkout + uses: actions/checkout@v3 + + - name: setup conda + if: matrix.os == 'windows-latest' || matrix.os == 'ubuntu-latest' + uses: conda-incubator/setup-miniconda@v2 + with: + miniconda-version: "latest" + auto-activate-base: true + activate-environment: "" + env: + ACTIONS_ALLOW_UNSECURE_COMMANDS: true + + - name: build ${{ matrix.os }}_x86_64 + if: matrix.os == 'windows-latest' + shell: pwsh + run: | + ${{ env.PREPARE_SCRIPT }} + conda activate __MICROSAM_BUILD_ENV__ + conda install -c anaconda menuinst + python windows_menu_setup.py + conda activate base + ${{ env.RUN_SCRIPT }} + + - name: build ${{ matrix.os }}_x86_64 + if: matrix.os == 'ubuntu-latest' + shell: bash -el {0} + run: | + ${{ env.PREPARE_SCRIPT }} + ${{ env.RUN_SCRIPT }} + + - name: build ${{ matrix.os }}_x86_64_step1 + if: matrix.os == 'macos-latest' + shell: bash -el {0} + run: | + brew install micromamba + /usr/local/opt/micromamba/bin/micromamba shell init -s bash -p ~/micromamba + + - name: build ${{ matrix.os }}_x86_64_step2 + if: matrix.os == 'macos-latest' + shell: bash -el {0} + run: | + cd deployment + micromamba activate base + micromamba install -y -c conda-forge python=3.10 + micromamba install -y -c conda-forge constructor + micromamba install -y -c conda-forge ruamel.yaml + micromamba install -y -c conda-forge mamba + mamba env create --file=env.yaml + python version_getter.py + mkdir ./${{ matrix.os }}_x86_64 + constructor --conda-exe=$(which mamba) --output-dir ./${{ matrix.os }}_x86_64 . + + - name: upload installer + uses: actions/upload-artifact@v3 + with: + name: ${{ matrix.os }}_x86_64 + path: ./deployment/${{ matrix.os }}_x86_64 + retention-days: 5 diff --git a/deployment/construct.yaml b/deployment/construct.yaml new file mode 100644 index 00000000..3cb7ad9b --- /dev/null +++ b/deployment/construct.yaml @@ -0,0 +1,15 @@ +name: micro_sam +version: 0.1.0 +license_file: ../LICENSE +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. +environment: __MICROSAM_BUILD_ENV__ +welcome_image: ../doc/images/micro-sam-logo.png +header_image: ../doc/images/micro-sam-logo.png +icon_image: ../doc/images/micro-sam-logo.png +channels: +- conda-forge +welcome_text: Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod + tempor incididunt ut labore et dolore magna aliqua. +conclusion_text: Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris + nisi ut aliquip ex ea commodo consequat. +initialize_by_default: true \ No newline at end of file diff --git a/deployment/env.yaml b/deployment/env.yaml new file mode 100644 index 00000000..dc5d317a --- /dev/null +++ b/deployment/env.yaml @@ -0,0 +1,9 @@ +name: __MICROSAM_BUILD_ENV__ +channels: + - conda-forge +dependencies: + - napari + - pyqt + - pytorch::pytorch + - pytorch::torchvision + - micro_sam diff --git a/deployment/version_getter.py b/deployment/version_getter.py new file mode 100644 index 00000000..fef7eec0 --- /dev/null +++ b/deployment/version_getter.py @@ -0,0 +1,15 @@ +import runpy +import ruamel.yaml +import os + +yaml = ruamel.yaml.YAML() +yaml.preserve_quotes = True +ctor_fname = os.path.join("construct.yaml") + +with open(ctor_fname, 'r') as stream: + ctor_conf = yaml.load(stream) + +ctor_conf["version"] = runpy.run_path(os.path.join("..", "micro_sam", "__version__.py"))["__version__"] + +with open(ctor_fname, 'w') as outfile: + yaml.dump(ctor_conf, outfile) diff --git a/deployment/windows_menu.json b/deployment/windows_menu.json new file mode 100644 index 00000000..cf409eb2 --- /dev/null +++ b/deployment/windows_menu.json @@ -0,0 +1,14 @@ +{ + "menu_name": "micro_sam", + "menu_items": + [ + { + "script": "${PREFIX}/Scripts/micro_sam.annotator.exe", + "name": "micro_sam", + "icon": "${PREFIX}/Menu/micro-sam-logo.ico", + "workdir": "${PREFIX}", + "desktop": true, + "quicklaunch": true + } + ] +} \ No newline at end of file diff --git a/deployment/windows_menu_setup.py b/deployment/windows_menu_setup.py new file mode 100644 index 00000000..182a5123 --- /dev/null +++ b/deployment/windows_menu_setup.py @@ -0,0 +1,10 @@ +import menuinst +import shutil +import os + +conda_dir = os.environ["CONDA_PREFIX"] +menu_dir = os.path.join(conda_dir, "Menu") +os.makedirs(menu_dir, exist_ok = True) +shutil.copy("../doc/images/micro-sam-logo.ico", menu_dir) +shutil.copy("./windows_menu.json", menu_dir) +menuinst.install(os.path.join(menu_dir, 'windows_menu.json'), prefix=conda_dir) diff --git a/doc/images/micro-sam-logo.ico b/doc/images/micro-sam-logo.ico new file mode 100644 index 00000000..3c8d9687 Binary files /dev/null and b/doc/images/micro-sam-logo.ico differ