diff --git a/install/windows/README.md b/install/windows/README.md new file mode 100644 index 0000000..a124b67 --- /dev/null +++ b/install/windows/README.md @@ -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`. diff --git a/install/windows/construct.yaml b/install/windows/construct.yaml new file mode 100644 index 0000000..ad6c729 --- /dev/null +++ b/install/windows/construct.yaml @@ -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 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 new file mode 100644 index 0000000..356d3b9 --- /dev/null +++ b/install/windows/post_install.bat @@ -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 diff --git a/install/windows/tuiview.bat b/install/windows/tuiview.bat new file mode 100644 index 0000000..a7410ad --- /dev/null +++ b/install/windows/tuiview.bat @@ -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 diff --git a/install/windows/tuiviewexe.bat b/install/windows/tuiviewexe.bat new file mode 100644 index 0000000..451c06c --- /dev/null +++ b/install/windows/tuiviewexe.bat @@ -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