Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a Windows installer #82

Merged
merged 3 commits into from
May 31, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
117 changes: 117 additions & 0 deletions install/windows/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,117 @@
# 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`.

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

* install Miniconda
* download from https://repo.anaconda.com/miniconda/Miniconda3-latest-Windows-x86_64.exe
* install only for me, don't add to PATH, don't use as system Python
* install path should be similar to `C:\Users\Me\miniconda3`

* Open a command prompt and run:
```
%USERPROFILE%\miniconda3\condabin\activate.bat
conda config --env --add channels conda-forge
conda config --env --set channel_priority strict
conda create -n tuiview tuiview
conda activate tuiview
```

## To run TuiView

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

## Create a Windows installer

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
`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

```
cd %USERPROFILE%\miniconda3
mkdir src
cd src
git clone https://github.com/ubarsc/tuiview
cd tuiview
mkdir build
mkdir build\lib.win-amd64-cpython-312
mkdir build\lib.win-amd64-cpython-312\tuiview
set GDAL_HOME=%USERPROFILE%\miniconda3\envs\tuiview\Library
python .\setup.py bdist_wheel
```

* If you can't build vectorrasterizer (no C compiler) then copy the existing one:
```
copy %USERPROFILE%\miniconda3\envs\tuiview/Lib/site-packages/tuiview/vectorrasterizer.cp312-win_amd64.pyd build\lib.win-amd64-cpython-312\tuiview
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.14-cp312-cp312-win_amd64.whl
```

* Copy the wheel into the `constructor` directory

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

* Use `constructor` to build the installer

```
cd install\windows
constructor .
```

* Tell the user to run `tuiviewexe.bat` to start the application
* TO DO: add tuiviewexe.bat into the Start menu

## 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.

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`.
17 changes: 17 additions & 0 deletions install/windows/construct.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
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
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: 2 additions & 0 deletions install/windows/post_install.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
call "%PREFIX%\Scripts\activate.bat"
pip install --no-deps --force-reinstall %PREFIX%\TuiView-1.2.14-cp312-cp312-win_amd64.whl
10 changes: 10 additions & 0 deletions install/windows/tuiview.bat
Original file line number Diff line number Diff line change
@@ -0,0 +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
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
11 changes: 11 additions & 0 deletions install/windows/tuiviewexe.bat
Original file line number Diff line number Diff line change
@@ -0,0 +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:
cd %USERPROFILE%\Downloads
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
Loading