Skip to content

Commit

Permalink
Windows installer - simplify and document
Browse files Browse the repository at this point in the history
  • Loading branch information
howff committed May 24, 2024
1 parent 3cc0e2a commit 0a35c2b
Show file tree
Hide file tree
Showing 6 changed files with 69 additions and 14 deletions.
42 changes: 36 additions & 6 deletions install/windows/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
# Create a Windows installer for TuiView

Use conda `constructor` to create a Windows installer. This is quite simple for the basic case of installing tuiview from `conda-forge`. However, in the case where the version of tuiview in the git repo is newer than the version in conda-forge, we need a few additional steps to a) create a Python wheel, b) include that wheel in the installer, c) run `pip install` during the installation process to override the conda version with the pip version. An additional complication is that building the wheel will require a C compiler but if you don't have one then we simply copy the pre-compiled version (on the assumption it's not changed in git) and only use the newer python files.
Use conda `constructor` to create a Windows installer. This is quite simple for the basic case of installing tuiview from `conda-forge`.

If the version of tuiview in the git repo is newer than the version in conda-forge, we need a few additional steps to a) create a Python wheel, b) include that wheel in the installer, c) run `pip install` during the installation process to override the conda version with the pip version. An additional complication is that building the wheel will require a C compiler but if you don't have one then we simply copy the pre-compiled version (on the assumption that the source code has not changed in git) and only use the newer python files.

## Install TuiView via conda

Expand All @@ -20,11 +22,11 @@ conda activate tuiview

## To run TuiView

To run TuiView you can create a batch file:
To run TuiView you can create a batch file, e.g. `tuiview.bat`:
```
call %USERPROFILE%\miniconda3\condabin\activate.bat
call conda activate tuiview
set TUIVIEW_ALLOW_NOGEO=YES
REM set TUIVIEW_ALLOW_NOGEO=YES
tuiview
```

Expand All @@ -40,6 +42,32 @@ conda activate tuiview
conda install constructor
```

* Clone the git repo
`git clone https://github.com/ubarsc/tuiview`

* Run constructor

```
cd %USERPROFILE%\miniconda3
mkdir src
cd src
git clone https://github.com/ubarsc/tuiview
cd tuiview\install\windows
constructor .
```

## Create a Windows installer with the latest source code for github

Create a standalone Windows installer which combines conda and tuiview

* Open a command prompt to install `constructor`

```
%USERPROFILE%\miniconda3\Scripts\activate.bat
conda activate tuiview
conda install constructor
```

* Clone the git repo and build a new wheel

```
Expand All @@ -63,13 +91,13 @@ python .\setup.py bdist_wheel

* Install the new wheel into the conda environment and test run tuiview to make sure it works
```
pip install --force-reinstall dist\TuiView-1.2.13-cp312-cp312-win_amd64.whl
pip install --force-reinstall dist\TuiView-1.2.14-cp312-cp312-win_amd64.whl
```

* Copy the wheel into the `constructor` directory

```
copy dist\TuiView-1.2.13-cp312-cp312-win_amd64.whl install\windows
copy dist\TuiView-1.2.14-cp312-cp312-win_amd64.whl install\windows
```

* Use `constructor` to build the installer
Expand All @@ -84,4 +112,6 @@ constructor .

## How it works

Conda `constructor` reads `construct.yaml` which installs the packages listed in `specs` from the given `channels`. We include `menuinst` to allow creation of a Start Menu item, and `console_shortcut` to allow Anaconda Prompt to be added to the Start Menu. Three additional files will be installed, two batch files and the python wheel we built above. After installation the script `post_install.bat` will be run; this script simply activates the environment and runs `pip install`.
Conda `constructor` reads `construct.yaml` which installs the packages listed in `specs` from the given `channels`. We include `menuinst` to allow creation of a Start Menu item, and `console_shortcut` to allow Anaconda Prompt to be added to the Start Menu.

Additional files can be installed, two batch files and the python wheel we built above. After installation the script `post_install.bat` will be run; this script simply activates the environment and runs `pip install`.
3 changes: 0 additions & 3 deletions install/windows/construct.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,3 @@ specs:
extra_files:
- tuiview.bat
- tuiviewexe.bat
- TuiView-1.2.13-cp312-cp312-win_amd64.whl
post_install: post_install.bat
post_install_desc: Install the bundled version of TuiView instead of the version from Conda
20 changes: 20 additions & 0 deletions install/windows/construct_pip.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
name: TuiView
version: 0.3
installer_type: exe
#check_path_spaces: False
#check_path_length: False
channels:
- https://conda.anaconda.org/conda-forge/
- https://repo.anaconda.com/pkgs/main/
- https://repo.anaconda.com/pkgs/msys2/
specs:
- conda
- menuinst
- console_shortcut
- tuiview
extra_files:
- tuiview.bat
- tuiviewexe.bat
- TuiView-1.2.13-cp312-cp312-win_amd64.whl
post_install: post_install.bat
post_install_desc: Install the bundled version of TuiView instead of the version from Conda
2 changes: 1 addition & 1 deletion install/windows/post_install.bat
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
call "%PREFIX%\Scripts\activate.bat"
pip install --no-deps --force-reinstall %PREFIX%\TuiView-1.2.13-cp312-cp312-win_amd64.whl
pip install --no-deps --force-reinstall %PREFIX%\TuiView-1.2.14-cp312-cp312-win_amd64.whl
7 changes: 6 additions & 1 deletion install/windows/tuiview.bat
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
@echo off
rem * You can change directory to where your files are stored
cd %USERPROFILE%\Downloads
rem * You can activate the conda environment if you want
rem call %USERPROFILE%\miniconda3\condabin\activate.bat
rem call conda activate tuiview
set TUIVIEW_ALLOW_NOGEO=YES
rem * You can set some environment variables if you want
rem e.g. to allow loading non-georeferenced image files
rem set TUIVIEW_ALLOW_NOGEO=YES
%userprofile%\tuiview\scripts\tuiview.exe
9 changes: 6 additions & 3 deletions install/windows/tuiviewexe.bat
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
@echo off
rem * A startup script which could be added to the Windows Start menu
rem This assumes you've installed the TuiView application
rem into your tuiview directory in your user profile,
rem e.g. c:\users\myname\tuiview
rem You can change the default directory here:
rem * You can change the default directory here:
cd %USERPROFILE%\Downloads
set TUIVIEW_ALLOW_NOGEO=YES
%userprofile%\tuiview\scripts\tuiview.exe
rem * You can set environment variables here:
rem e.g. to allow loading non-georeferenced image files
rem set TUIVIEW_ALLOW_NOGEO=YES
%userprofile%\tuiview\scripts\tuiview.exe

0 comments on commit 0a35c2b

Please sign in to comment.