Create Windows and Linux installers for conda-based projects

You can create a user-friendly installers for Windows and Linux using a dedicated conda package called conda-bundle.

Warning: conda-bundle is still actively modified and should be considered as a Work in Progress. Features will change in the future and things will break. But hopefully if your installer is correctly generated you should get a decently installer.

conda-bundle is a fork of conda-constructor, its code is hosted on the SED Inria Sophia GitHub, and the package is built and hosted on my (Jonathan Lévy) personal Anaconda repository at the moment. You can install conda-bundle in your base Conda environment by entering:

conda install -c jolevy conda-bundle

The installer for your program is built using the latest release of your program on your Conda channel and the informations about how to build it must be in a file called construct.yaml, that we usually put in pkg/construct/construct.yaml. It follows the same structure as conda-constructor with a few additions that are specific for Windows :

  • the shortcuts key lets you add shortcuts that are added to the Start Menu and the Desktop. Follow the way they’re written if you want to add more shortcuts. Entries "name" and "path" are mandatory, "options" and "icon" are facultative.
  • finish_link lets you add a URL at the end of the installer, with 2 keys url and text.
  • win_register_shell lets the user add a shortcut to "Open myProgram Prompt" to the context menu (right-click menu in the explorer), to open a prompt with all command line programs available wherever they want,
  • more entries may come later on. (remember, conda-bundle is still a Work in Progress.)

Here is a boilerplate example of how construct.yaml can be written:

name: myProgram
version: 0.0.1

install_in_dependency_order: True
ignore_duplicate_files: True
license_file: ..\..\LICENSE.md [win]
#license_file: ../../LICENSE.md [unix]
company: Inria

installer_type: sh [linux]

welcome_image: ..\..\doc\_static\logo.png [win]
welcome_image: ../../doc/_static/logo.png [unix]

channels:
  - http://repo.anaconda.com/pkgs/main/
  - http://conda.anaconda.org/conda-forge/
  - http://conda.anaconda.org/dtk-forge/

specs:
  - python=3.7
  - conda
  - dtk-core >=2.7.1,<2.8.0
  - vtk=8.2.0=py37h7276a58_300 [win]
  - vtk=8.2.0 [unix]
  - myProgram=0.0.1

# Note: numbers 0, 1, ... have no meaning whatsoever. It's just to have multiple entries.
# entries "name" and "path" are mandatory, "options" and "icon" are facultative.
shortcuts:
  0:
    name: "myProgram"
    path: "__INSTALL_PATH__\\Library\\bin\\myProgram.exe" [win]
    path: "__INSTALL_PATH/bin/myProgram" [linux]
    icon: "__INSTALL_PATH\\Menu\\app.ico" [win]
    icon: "__INSTALL_PATH/Menu/app.png" [linux]
    terminal: false [linux]
  1:
    name: "myProgram Command Prompt"
    path: "$WINDIR\\System32\\cmd.exe" [win]
    options: "$\\\"/K$\\\" __INSTALL_PATH__\\Scripts\\activate.bat __INSTALL_PATH__" [win]
    path: "__INSTALL_PATH__/bin/activate __INSTALL_PATH__/" [linux]
    terminal: true [linux]

finish_link:
  url: "https://myteam.gitlabpages.inria.fr/myprogram/"
  text: "Open the documentation website"

# This is to let the user add the right-click menu shortcut to open the console prompt wherever they want.
# If set to true, the user can add this option in the installer
# (it's enabled by default but they can uncheck it).
# If set to false, the option is not presented to the user and is disabled.
win_register_shell: true

With the file described as above in ./pkg/construct/construct.yaml you can create your installer with the command:

conda bundle .\pkg\construct\ (for Windows)
conda bundle ./pkg/construct/ (for Linux)

An installer should be created in your directory. This installer holds all packages that belong to your program, so you can run it on any computer without being connected to the local Inria network on any VPN (you should even be able to run it on any computer without internet access).

It creates shortcuts on the desktop, shortcuts in the Start Menu, and an uninstaller available as any other Windows uninstaller (in Parameters -> Programs -> Uninstall a program for Windows 10, or simply under Control Panel -> Programs and Features for older versions of Windows). You can also add a shortcut to your right-click menu to open the dedicated shell with your installed environment anywhere easily. This installer should be independent of any other Conda installations, so you can install various programs without modifying your system path nor creating various bugs when trying to uninstall one of them.

Leave a Reply

Your email address will not be published. Required fields are marked *