Skip to content

Commit

Permalink
Merge pull request #42 from cemsbv/41-add-install-scripts-for-windows
Browse files Browse the repository at this point in the history
Add install scripts for windows
  • Loading branch information
PabloVasconez authored Nov 21, 2023
2 parents cc3fc10 + f766fbd commit dcc3fee
Show file tree
Hide file tree
Showing 12 changed files with 320 additions and 127 deletions.
21 changes: 21 additions & 0 deletions install/windows/create_python_env.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
@echo off
setlocal enableDelayedExpansion

@REM Parse input variables
set python_exe=%1
set python_env_dir=%2

@REM Check whether the python.exe exists, otherwise exit without installing.
if not exist %python_exe% (
echo %python_exe% does not exists, python environment cannot be created from it.
cmd /k
)

Rem Create dir to install the python env dir (if it doesn't exist)
mkdir %python_env_dir%
cd %python_env_dir%
%python_exe% -m venv %python_env_dir%




8 changes: 8 additions & 0 deletions install/windows/download_sample_notebooks.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
@echo off
setlocal enableDelayedExpansion

mkdir sample
curl --output-dir sample -O https://raw.githubusercontent.com/cemsbv/plxcontroller/main/notebooks/Plaxis3D_input_controller.ipynb
curl --output-dir sample -O https://raw.githubusercontent.com/cemsbv/plxcontroller/main/notebooks/Plaxis3D_output_controller.ipynb
curl --output-dir sample -O https://raw.githubusercontent.com/cemsbv/plxcontroller/main/notebooks/image.png
curl --output-dir sample -O https://raw.githubusercontent.com/cemsbv/plxcontroller/main/notebooks/requirements.txt
46 changes: 46 additions & 0 deletions install/windows/full_installation.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
@echo off
setlocal enableDelayedExpansion

set python_installation_dir=C:\cems-python
set python_version=3.9.13
set plxcontroller_notebook_dir=C:\cems-notebooks\plxcontroller
set kernel_name=plxcontroller-env


echo 1. Download and install python
if not defined CEMS_PYTHON_DIR (
call install_python %python_version% %python_installation_dir%
Rem Set the system environmental variables of the location of the new installation
setx CEMS_PYTHON_DIR %python_installation_dir%\python-%python_version%
Rem Set it also locally so that it can be accessed without reloading cmd.
set CEMS_PYTHON_DIR %python_installation_dir%\python-%python_version%
) else (
echo Python is not downloaded and installed, because environmental variable CEMS_PYTHON_DIR is defined.
echo %CEMS_PYTHON_DIR%\python.exe will be used as base to create the python virtual environment.
)

echo 2. Install jupyter lab
call install_jupyterlab %CEMS_PYTHON_DIR%\python.exe

echo 3. Set-up notebook directory
call setup_notebook_dir %plxcontroller_notebook_dir%

echo 4. Create python environment
if not exist %plxcontroller_notebook_dir%\.env\Scripts\python.exe (
call create_python_env %CEMS_PYTHON_DIR%\python.exe %plxcontroller_notebook_dir%\.env
) else (
echo Python virtual environment at %plxcontroller_notebook_dir%\.env will be used, no new one is created.
)

echo 5. Register python environment in ipykernel
call register_env_ipykernel %plxcontroller_notebook_dir%\.env "%kernel_name%"

echo 6. Install plxcontroller
call install_plxcontroller %plxcontroller_notebook_dir%\.env

echo 7. Download sample notebooks
cd /D %plxcontroller_notebook_dir%
call download_sample_notebooks

echo Installation finished!
cmd /k
14 changes: 14 additions & 0 deletions install/windows/install_jupyterlab.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
@echo off
setlocal enableDelayedExpansion

@REM Parse input variables
set python_exe=%1

@REM Check whether the python.exe exists, otherwise exit without installing.
if not exist %python_exe% (
echo %python_exe% does not exists, jupyterlab cannot be installed.
cmd /k
)

@REM Install jupyter lab.
%python_exe% -m pip install jupyterlab
11 changes: 11 additions & 0 deletions install/windows/install_plxcontroller.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
@echo off
setlocal enableDelayedExpansion

Rem Parse input variables
set python_env_dir=%1

Rem Install ipykernel and register virtual environment
call %python_env_dir%\Scripts\activate.bat
python -m pip install --upgrade pip setuptools
pip install plxcontroller

29 changes: 29 additions & 0 deletions install/windows/install_python.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
@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% AppendPath=1






15 changes: 15 additions & 0 deletions install/windows/register_env_ipykernel.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
@echo off
setlocal enableDelayedExpansion

@REM Parse input variables
set python_env_dir=%1
set kernel_name=%2

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%



16 changes: 16 additions & 0 deletions install/windows/setup_notebook_dir.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
@echo off
setlocal enableDelayedExpansion

Rem Parse input variables
set plxcontroller_notebook_dir=%1

Rem Create notebook installation dir and add batch file
mkdir %plxcontroller_notebook_dir%
Rem mkdir %plxcontroller_notebook_dir%\sample

Rem Copy batch files "start_jupyter_lab", "update_plxcontroller", "download_sample_notebooks"
copy start_jupyter_lab.bat %plxcontroller_notebook_dir%
copy update_plxcontroller.bat %plxcontroller_notebook_dir%
copy download_sample_notebooks.bat %plxcontroller_notebook_dir%


15 changes: 15 additions & 0 deletions install/windows/start_jupyter_lab.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
@echo off
setlocal enableDelayedExpansion

set current_dir_path=%~dp0

if not defined CEMS_PYTHON_DIR (
echo Environmental variable CEMS_PYTHON_DIR does not exists, jupyterlab cannot be started.
cmd /k
)

%CEMS_PYTHON_DIR%\python -m jupyter lab --notebook-dir=%current_dir_path% --preferred-dir %current_dir_path%




18 changes: 18 additions & 0 deletions install/windows/update_plxcontroller.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
@echo off
setlocal enableDelayedExpansion

Rem Install ipykernel and register virtual environment
call .env\Scripts\activate.bat
pip install --upgrade --no-cache-dir plxcontroller

Rem Download sample notebooks
call download_sample_notebooks

echo.
echo.
echo The following version of the plxcontroller is installed:
echo.
pip show plxcontroller

Rem Keep the window open
cmd /k
4 changes: 2 additions & 2 deletions notebooks/Plaxis3D_input_controller.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
"metadata": {},
"outputs": [],
"source": [
"!pip install -r requirements.txt"
"%pip install -r requirements.txt"
]
},
{
Expand Down Expand Up @@ -147,7 +147,7 @@
],
"metadata": {
"kernelspec": {
"display_name": "env-notebook-local",
"display_name": "plxcontroller-env",
"language": "python",
"name": "python3"
},
Expand Down
Loading

0 comments on commit dcc3fee

Please sign in to comment.