From 0a35c2b31903ddf991db81bcc1bcf514c8b30831 Mon Sep 17 00:00:00 2001 From: howff Date: Fri, 24 May 2024 12:23:33 +0100 Subject: [PATCH] Windows installer - simplify and document --- install/windows/README.md | 42 +++++++++++++++++++++++++----- install/windows/construct.yaml | 3 --- install/windows/construct_pip.yaml | 20 ++++++++++++++ install/windows/post_install.bat | 2 +- install/windows/tuiview.bat | 7 ++++- install/windows/tuiviewexe.bat | 9 ++++--- 6 files changed, 69 insertions(+), 14 deletions(-) create mode 100644 install/windows/construct_pip.yaml diff --git a/install/windows/README.md b/install/windows/README.md index 4205b10..a124b67 100644 --- a/install/windows/README.md +++ b/install/windows/README.md @@ -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 @@ -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 ``` @@ -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 ``` @@ -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 @@ -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`. diff --git a/install/windows/construct.yaml b/install/windows/construct.yaml index e70e447..ad6c729 100644 --- a/install/windows/construct.yaml +++ b/install/windows/construct.yaml @@ -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 diff --git a/install/windows/construct_pip.yaml b/install/windows/construct_pip.yaml new file mode 100644 index 0000000..e70e447 --- /dev/null +++ b/install/windows/construct_pip.yaml @@ -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 diff --git a/install/windows/post_install.bat b/install/windows/post_install.bat index 620e884..356d3b9 100644 --- a/install/windows/post_install.bat +++ b/install/windows/post_install.bat @@ -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 diff --git a/install/windows/tuiview.bat b/install/windows/tuiview.bat index 1b73058..a7410ad 100644 --- a/install/windows/tuiview.bat +++ b/install/windows/tuiview.bat @@ -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 diff --git a/install/windows/tuiviewexe.bat b/install/windows/tuiviewexe.bat index f592aee..451c06c 100644 --- a/install/windows/tuiviewexe.bat +++ b/install/windows/tuiviewexe.bat @@ -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 \ No newline at end of file +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