From 0003eec1c25a9b31712822794586f81fef3595b9 Mon Sep 17 00:00:00 2001
From: Pablo Vasconez
Date: Tue, 21 Nov 2023 11:00:46 +0100
Subject: [PATCH] feat(#41): add first version of the install scripts for
windows.
---
install/windows/create_python_env.bat | 17 ++++++++++++++
install/windows/full_installation.bat | 24 +++++++++++++++++++
install/windows/full_installation_part2.bat | 24 +++++++++++++++++++
install/windows/install_jupyterlab.bat | 7 ++++++
install/windows/install_plxcontroller.bat | 14 +++++++++++
install/windows/install_python.bat | 26 +++++++++++++++++++++
install/windows/register_env_ipykernel.bat | 20 ++++++++++++++++
install/windows/setup_notebook_dir.bat | 19 +++++++++++++++
install/windows/start_jupyter_lab.bat | 18 ++++++++++++++
install/windows/update_plxcontroller.bat | 17 ++++++++++++++
10 files changed, 186 insertions(+)
create mode 100644 install/windows/create_python_env.bat
create mode 100644 install/windows/full_installation.bat
create mode 100644 install/windows/full_installation_part2.bat
create mode 100644 install/windows/install_jupyterlab.bat
create mode 100644 install/windows/install_plxcontroller.bat
create mode 100644 install/windows/install_python.bat
create mode 100644 install/windows/register_env_ipykernel.bat
create mode 100644 install/windows/setup_notebook_dir.bat
create mode 100644 install/windows/start_jupyter_lab.bat
create mode 100644 install/windows/update_plxcontroller.bat
diff --git a/install/windows/create_python_env.bat b/install/windows/create_python_env.bat
new file mode 100644
index 0000000..1010a57
--- /dev/null
+++ b/install/windows/create_python_env.bat
@@ -0,0 +1,17 @@
+@echo off
+setlocal enableDelayedExpansion
+
+Rem Parse input variables
+set python_env_dir=%1
+Rem C:\cems-notebooks\plxcontroller
+echo python_env_dir is %python_env_dir% and no more.
+
+Rem Create dir to install the python env dir (if it doesn't exist)
+mkdir %python_env_dir%
+cd %python_env_dir%
+python -m venv %python_env_dir%
+call %python_env_dir%/Scripts/activate.bat
+
+
+
+
diff --git a/install/windows/full_installation.bat b/install/windows/full_installation.bat
new file mode 100644
index 0000000..71b72e2
--- /dev/null
+++ b/install/windows/full_installation.bat
@@ -0,0 +1,24 @@
+@echo off
+setlocal enableDelayedExpansion
+
+Rem 1. Download and install python
+call install_python 3.9.13 C:\cems-python
+
+Rem 2. Install jupyter lab
+call install_jupyterlab
+
+Rem 3. Set-up notebook directory
+call setup_notebook_dir C:\cems-notebooks\plxcontroller
+
+Rem 4. Create python environment
+call create_python_env C:\cems-notebooks\plxcontroller\.env
+
+Rem 5. Register python environment in ipykernel
+call register_env_ipykernel C:\cems-notebooks\plxcontroller\.env "plxcontroller-env"
+
+Rem 6. Install plxcontroller
+call install_plxcontroller C:\cems-notebooks\plxcontroller\.env
+
+Rem 7. Update plxcontroller (so that the sample notebooks are downloaded)
+cd C:\cems-notebooks\plxcontroller
+call update_plxcontroller
\ No newline at end of file
diff --git a/install/windows/full_installation_part2.bat b/install/windows/full_installation_part2.bat
new file mode 100644
index 0000000..888e2c8
--- /dev/null
+++ b/install/windows/full_installation_part2.bat
@@ -0,0 +1,24 @@
+@echo off
+setlocal enableDelayedExpansion
+
+Rem 1. Download and install python
+Rem call install_python 3.9.13 C:\cems-python
+
+Rem 2. Install jupyter lab
+Rem call install_jupyterlab
+
+Rem 3. Set-up notebook directory
+call setup_notebook_dir C:\cems-notebooks\plxcontroller
+
+Rem 4. Create python environment
+call create_python_env C:\cems-notebooks\plxcontroller\.env
+
+Rem 5. Register python environment in ipykernel
+call register_env_ipykernel C:\cems-notebooks\plxcontroller\.env "plxcontroller-env"
+
+Rem 6. Install plxcontroller
+call install_plxcontroller C:\cems-notebooks\plxcontroller\.env
+
+Rem 7. Update plxcontroller (so that the sample notebooks are downloaded)
+cd C:\cems-notebooks\plxcontroller
+call update_plxcontroller
\ No newline at end of file
diff --git a/install/windows/install_jupyterlab.bat b/install/windows/install_jupyterlab.bat
new file mode 100644
index 0000000..9b23ae1
--- /dev/null
+++ b/install/windows/install_jupyterlab.bat
@@ -0,0 +1,7 @@
+@echo off
+setlocal enableDelayedExpansion
+
+Rem This script assumes that you have python installed and it will use the default python
+Rem installation
+pip install jupyterlab
+
diff --git a/install/windows/install_plxcontroller.bat b/install/windows/install_plxcontroller.bat
new file mode 100644
index 0000000..4bc1542
--- /dev/null
+++ b/install/windows/install_plxcontroller.bat
@@ -0,0 +1,14 @@
+@echo off
+setlocal enableDelayedExpansion
+
+Rem This script assumes that you have python installed and it will use the default python
+Rem Parse input variables
+set python_env_dir=%1
+Rem C:\cems-notebooks\plxcontroller\.env
+echo python_env_dir is %python_env_dir% and no more.
+
+Rem Install ipykernel and register virtual environment
+call %python_env_dir%\Scripts\activate.bat
+python -m pip install --upgrade pip setuptools
+pip install plxcontroller
+
diff --git a/install/windows/install_python.bat b/install/windows/install_python.bat
new file mode 100644
index 0000000..28f6445
--- /dev/null
+++ b/install/windows/install_python.bat
@@ -0,0 +1,26 @@
+@echo off
+setlocal enableDelayedExpansion
+
+Rem Check which python version is available
+Rem https://www.python.org/ftp/python/ #
+Rem For Windows it should there should be file ending with amd64.exe, e.g.:
+Rem https://www.python.org/ftp/python/3.9.13/python-3.9.13-amd64.exe
+
+Rem Parse input variables
+set python_version=%1
+Rem recommended: 3.9.13
+echo python_version is %python_version% and no more.
+
+set python_installation_dir=%2
+Rem C:\cems-python
+echo python_installation_dir is %python_installation_dir% and no more.
+
+Rem Download python
+curl https://www.python.org/ftp/python/%python_version%/python-%python_version%-amd64.exe -O
+
+Rem Install python
+mkdir %python_installation_dir%\python-%python_version%
+python-%python_version%-amd64.exe TargetDir=%python_installation_dir%\python-%python_version% PrependPath=1
+
+
+
diff --git a/install/windows/register_env_ipykernel.bat b/install/windows/register_env_ipykernel.bat
new file mode 100644
index 0000000..a71df25
--- /dev/null
+++ b/install/windows/register_env_ipykernel.bat
@@ -0,0 +1,20 @@
+@echo off
+setlocal enableDelayedExpansion
+
+Rem Parse input variables
+set python_env_dir=%1
+Rem C:\cems-notebooks\plxcontroller\.env
+echo python_env_dir is %python_env_dir% and no more.
+
+set kernel_name=%2
+Rem "plxcontroller-env"
+echo kernel_name is %kernel_name% and no more.
+
+Rem Install ipykernel and register virtual environment
+call %python_env_dir%/Scripts/activate.bat
+python -m pip install --upgrade pip setuptools
+pip install ipykernel
+python -m ipykernel install --name %kernel_name%
+
+
+
diff --git a/install/windows/setup_notebook_dir.bat b/install/windows/setup_notebook_dir.bat
new file mode 100644
index 0000000..09f237d
--- /dev/null
+++ b/install/windows/setup_notebook_dir.bat
@@ -0,0 +1,19 @@
+@echo off
+setlocal enableDelayedExpansion
+
+Rem Parse input variables
+set notebooks_installation_dir=%1
+Rem C:\cems-notebooks\plxcontroller
+echo notebooks_installation_dir is %notebooks_installation_dir% and no more.
+
+Rem Create notebook installation dir and add batch file
+mkdir %notebooks_installation_dir% %notebooks_installation_dir%\sample
+
+Rem Copy sample notebooks (old)
+Rem xcopy sample %notebooks_installation_dir%\sample
+
+Rem Copy batch file "start_jupyter_lab"
+copy start_jupyter_lab.bat %notebooks_installation_dir%
+copy update_plxcontroller.bat %notebooks_installation_dir%
+
+
diff --git a/install/windows/start_jupyter_lab.bat b/install/windows/start_jupyter_lab.bat
new file mode 100644
index 0000000..314513c
--- /dev/null
+++ b/install/windows/start_jupyter_lab.bat
@@ -0,0 +1,18 @@
+@echo off
+setlocal enableDelayedExpansion
+
+set current_dir_path=%~dp0
+
+jupyter lab --notebook-dir=%current_dir_path% --preferred-dir %current_dir_path%
+
+Rem Parse input variables
+Rem set notebooks_installation_dir=%1
+Rem C:\cems-notebooks\plxcontroller
+Rem echo notebooks_installation_dir is %notebooks_installation_dir% and no more.
+
+Rem Create notebook installation dir and add batch file
+Rem mkdir %notebooks_installation_dir% %notebooks_installation_dir%\sample
+
+
+
+
diff --git a/install/windows/update_plxcontroller.bat b/install/windows/update_plxcontroller.bat
new file mode 100644
index 0000000..cdab447
--- /dev/null
+++ b/install/windows/update_plxcontroller.bat
@@ -0,0 +1,17 @@
+@echo off
+setlocal enableDelayedExpansion
+
+Rem Install ipykernel and register virtual environment
+call .env\Scripts\activate.bat
+pip install --upgrade plxcontroller
+
+Rem Download files under the notebooks directory in plxcontroller repo
+curl https://raw.githubusercontent.com/cemsbv/plxcontroller/main/notebooks/Plaxis3D_input_controller.ipynb -O
+curl https://raw.githubusercontent.com/cemsbv/plxcontroller/main/notebooks/image.png -O
+curl https://raw.githubusercontent.com/cemsbv/plxcontroller/main/notebooks/requirements.txt -O
+
+Rem Save the files under the local sample folder
+mkdir sample
+move Plaxis3D_input_controller.ipynb sample
+move image.png sample
+move requirements.txt sample
\ No newline at end of file