From 0e98f6fc9156c4c23480b2f2d459fc86148def4a Mon Sep 17 00:00:00 2001 From: Margely Cornelissen <134381864+MaCuinea@users.noreply.github.com> Date: Thu, 31 Oct 2024 12:12:42 +0100 Subject: [PATCH 1/4] Initial DCCN-specific configuration --- README.md | 20 +++++++++++++++- create_venv.bat | 52 +++++++++++++++++++++++++++--------------- start_venv_and_ide.bat | 21 ++++++++++++++--- 3 files changed, 71 insertions(+), 22 deletions(-) diff --git a/README.md b/README.md index 857224b..e96bda2 100644 --- a/README.md +++ b/README.md @@ -104,7 +104,7 @@ Ensure you have Python 3.10 installed and accessible from your command line. If **Note**: The script assumes that Python 3.10 is installed. If you have a different version, make sure to adjust the script accordingly or install Python 3.10. *Step 3: Create and setup a virtual environment* \ -Open your command prompt and run the following batch file to set up the virtual environment and install the necessary dependencies. You can use input parameters to customize the environment name or directory, or Python interpreter location. You must either rely on all default or provide all input parameters. +Open your command prompt and run the following batch file to set up the virtual environment and install the necessary dependencies. You can use input parameters to customize the environment name or directory, or Python interpreter location. You can use the default values or specify only the parameters you need by leaving others blank with "". ``` cd your_directory_with_cloned_repository @@ -121,6 +121,15 @@ create_venv.bat "C:\Path\To\Python310\python.exe" FUS_DS_PACKAGE "C:/Users/Me/En ``` The batch file will create a virtual environment and install the required Python packages. +*DCCN specific configuration* + +To use the DCCN-specific default values, you can provide a fourth input parameter to activate these settings. + +Example: +``` +create_venv.bat "" "" "" "DCCN" +``` + *Step 4: Verify the successful setup of the virtual environment* \ After running the batch file, ensure that the virtual environment and dependencies are installed. You can verify this by: @@ -183,6 +192,15 @@ How to use the script: ``` - VENV_PATH: Specify the path to the virtual environment (e.g., C:/Users/Me/Envs/MyEnv). If not provided, it defaults to C:/Users/{USERPROFILE}/Envs/FUS_DS_PACKAGE. - IDE: Specify the python interpreter. IF not provided, it defaults to spyder. + + *DCCN specific configuration* + + To use the DCCN-specific default values, you can soly provide the first input parameter to activate these settings. + + Example: + ``` + start_venv_and_ide.bat "" "" "DCCN" + ```
diff --git a/create_venv.bat b/create_venv.bat index 94a71b7..1ed662e 100644 --- a/create_venv.bat +++ b/create_venv.bat @@ -5,22 +5,39 @@ :: Set the Python executable path (ensure Python 3.10 is correctly installed and specify the correct path) set "DEFAULT_PYTHON_PATH=C:\Program Files\Python310\python.exe" -:: Set a default virtual environment name -set "DEFAULT_VENV_NAME=FUS_DS_PACKAGE" +:: Check if mode is provided as the fourth parameter; otherwise, set to "default" +if "%~4"=="" ( + set "MODE=default" +) else ( + set "MODE=%~4" +) -:: Set a default virtual environment directory -set "DEFAULT_VENV_DIR=%USERPROFILE%\Envs" +:: If mode is DCCN, use DCCN-specific default values. +if "%MODE%" == "DCCN" ( + :: Set a default virtual environment name + set "DEFAULT_VENV_NAME=venv310" -:: Collect input parameters -set "PYTHON_PATH=%~1" -set "VENV_NAME=%~2" -set "VENV_DIR=%~3" + :: Set a default virtual environment directory + set "DEFAULT_VENV_DIR=D:\Users\%USERNAME%" +) else ( + :: Set a default virtual environment name + set "DEFAULT_VENV_NAME=FUS_DS_PACKAGE" + :: Set a default virtual environment directory + set "DEFAULT_VENV_DIR=%USERPROFILE%\Envs" +) + +:: Collect input parameters with fallbacks to defaults +set "PYTHON_PATH=%~1" if "%PYTHON_PATH%"=="" set "PYTHON_PATH=%DEFAULT_PYTHON_PATH%" + +set "VENV_NAME=%~2" if "%VENV_NAME%"=="" set "VENV_NAME=%DEFAULT_VENV_NAME%" + +set "VENV_DIR=%~3" if "%VENV_DIR%"=="" set "VENV_DIR=%DEFAULT_VENV_DIR%" -:: Check if the Envs directory exists, if not, create it +:: Check if the Envs directory exists; if not, create it if not exist "%VENV_DIR%" ( mkdir "%VENV_DIR%" echo Created directory "%VENV_DIR%" @@ -38,11 +55,10 @@ if errorlevel 1 ( ) :: Ensure that virtualenv is installed (with --user flag for non-admin rights) -:: Check if virtualenv is installed "%PYTHON_PATH%" -m pip show virtualenv >nul 2>&1 if errorlevel 1 ( echo Installing virtualenv package... - "%PYTHON_PATH%" -m pip install virtualenv + "%PYTHON_PATH%" -m pip install --user virtualenv ) else ( echo virtualenv is already installed. ) @@ -58,14 +74,14 @@ if exist "%VENV_PATH%\Scripts\activate" ( ) :: Activate the virtual environment -call "%VENV_PATH%"\Scripts\activate +call "%VENV_PATH%\Scripts\activate" :: Install project-specific dependencies (with --user flag for non-admin rights) -echo Install requirements.txt... -pip install -r requirements.txt +echo Installing requirements from requirements.txt... +pip install --user -r requirements.txt -:: Upgrade pip (optional but recommended) -"%PYTHON_PATH%" -m pip install --upgrade pip +:: Upgrade pip in virtual environment +python.exe -m pip install --upgrade pip -echo Setup complete. To activate the virtual environment, run 'call %VENV_PATH%\Scripts\activate'. -echo The virtual environment is located at "%VENV_PATH%". \ No newline at end of file +echo Setup complete. To activate the virtual environment, run: call "%VENV_PATH%\Scripts\activate" +echo The virtual environment is located at: "%VENV_PATH%" \ No newline at end of file diff --git a/start_venv_and_ide.bat b/start_venv_and_ide.bat index 409c8c1..7705f63 100644 --- a/start_venv_and_ide.bat +++ b/start_venv_and_ide.bat @@ -2,11 +2,26 @@ setlocal REM Define environment variables -set "VENV_PATH=%USERPROFILE%\Envs\FUS_DS_PACKAGE" -set IDE=spyder +set "DEFAULT_MODE=default" +set "MODE=%~3" +if "%MODE%"=="" set "MODE=%DEFAULT_MODE%" + +if "%MODE%" == "DCCN" ( + set "DEFAULT_VENV_PATH=D:\Users\%USERNAME%\venv310" + set "DEFAULT_IDE=C:\Program Files\Python310\pythonw.exe C:\Program Files\Python310\Lib\idlelib\idle.pyw" +) else ( + set "DEFAULT_VENV_PATH=%USERPROFILE%\Envs\FUS_DS_PACKAGE" + set "DEFAULT_IDE=spyder" +) + +set "VENV_PATH=%~1" +if "%VENV_PATH%"=="" set "VENV_PATH=%DEFAULT_VENV_PATH%" + +set "IDE=%~2" +if "%IDE%"=="" set "IDE=%DEFAULT_IDE%" REM Activate the virtual environment and launch the IDE call "%VENV_PATH%\Scripts\activate" -start %IDE% +start "" "%IDE%" endlocal \ No newline at end of file From 23d0c6e6a648d597354966b992a2f6e03a33ec72 Mon Sep 17 00:00:00 2001 From: Margely Cornelissen <134381864+MaCuinea@users.noreply.github.com> Date: Thu, 31 Oct 2024 12:40:16 +0100 Subject: [PATCH 2/4] remove --user flag --- create_venv.bat | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/create_venv.bat b/create_venv.bat index 1ed662e..131291e 100644 --- a/create_venv.bat +++ b/create_venv.bat @@ -54,11 +54,11 @@ if errorlevel 1 ( exit /b 1 ) -:: Ensure that virtualenv is installed (with --user flag for non-admin rights) +:: Ensure that virtualenv is installed "%PYTHON_PATH%" -m pip show virtualenv >nul 2>&1 if errorlevel 1 ( echo Installing virtualenv package... - "%PYTHON_PATH%" -m pip install --user virtualenv + "%PYTHON_PATH%" -m pip install virtualenv ) else ( echo virtualenv is already installed. ) @@ -76,9 +76,9 @@ if exist "%VENV_PATH%\Scripts\activate" ( :: Activate the virtual environment call "%VENV_PATH%\Scripts\activate" -:: Install project-specific dependencies (with --user flag for non-admin rights) +:: Install project-specific dependencies echo Installing requirements from requirements.txt... -pip install --user -r requirements.txt +pip install -r requirements.txt :: Upgrade pip in virtual environment python.exe -m pip install --upgrade pip From 254ad4daf7e7182bbb3e054b84b8ab5571080aad Mon Sep 17 00:00:00 2001 From: Margely Cornelissen <134381864+MaCuinea@users.noreply.github.com> Date: Thu, 31 Oct 2024 12:43:45 +0100 Subject: [PATCH 3/4] Update README.md --- README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index e96bda2..a649e13 100644 --- a/README.md +++ b/README.md @@ -121,8 +121,8 @@ create_venv.bat "C:\Path\To\Python310\python.exe" FUS_DS_PACKAGE "C:/Users/Me/En ``` The batch file will create a virtual environment and install the required Python packages. -*DCCN specific configuration* - +**DCCN specific configuration** + To use the DCCN-specific default values, you can provide a fourth input parameter to activate these settings. Example: @@ -193,7 +193,7 @@ How to use the script: - VENV_PATH: Specify the path to the virtual environment (e.g., C:/Users/Me/Envs/MyEnv). If not provided, it defaults to C:/Users/{USERPROFILE}/Envs/FUS_DS_PACKAGE. - IDE: Specify the python interpreter. IF not provided, it defaults to spyder. - *DCCN specific configuration* + **DCCN specific configuration** To use the DCCN-specific default values, you can soly provide the first input parameter to activate these settings. From c48747a1dd63ae1f156a29b4858fee0740196d47 Mon Sep 17 00:00:00 2001 From: Margely Cornelissen <134381864+MaCuinea@users.noreply.github.com> Date: Wed, 6 Nov 2024 12:18:53 +0100 Subject: [PATCH 4/4] spyder default IDE --- README.md | 8 ++++---- requirements.txt | 1 + start_venv_and_ide.bat | 4 ++-- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index a649e13..1ccedb6 100644 --- a/README.md +++ b/README.md @@ -119,7 +119,7 @@ Example: ``` create_venv.bat "C:\Path\To\Python310\python.exe" FUS_DS_PACKAGE "C:/Users/Me/Envs" ``` -The batch file will create a virtual environment and install the required Python packages. +The batch file will create a virtual environment, install the required Python packages and the default IDE, Spyder. **DCCN specific configuration** @@ -160,14 +160,14 @@ call [VENV_PATH]\Scripts\activate ``` *Step 2: Install an IDE* \ -While the virtual environment is activated, you can install Spyder or any other IDE of your choice. To install Spyder, run: +While your virtual environment is activated, you can install any IDE of your choice. Spyder is pre-installed by default. To install another IDE, run: ``` -pip install spyder +pip install [IDE] ``` *Step 3: Launch the IDE* \ -After installing Spyder, you can launch it directly from the command line within the activated virtual environment by running: +After installing your IDE, you can launch it directly from the command line while the virtual environment is activated. For Spyder, enter: ``` spyder diff --git a/requirements.txt b/requirements.txt index 505c0c9..74cb825 100644 --- a/requirements.txt +++ b/requirements.txt @@ -4,4 +4,5 @@ pandas==2.2.2 pyserial==3.5 tk==0.1.0 openpyxl==3.1.5 +spyder ./fus_ds_package diff --git a/start_venv_and_ide.bat b/start_venv_and_ide.bat index 7705f63..2eac61e 100644 --- a/start_venv_and_ide.bat +++ b/start_venv_and_ide.bat @@ -8,12 +8,12 @@ if "%MODE%"=="" set "MODE=%DEFAULT_MODE%" if "%MODE%" == "DCCN" ( set "DEFAULT_VENV_PATH=D:\Users\%USERNAME%\venv310" - set "DEFAULT_IDE=C:\Program Files\Python310\pythonw.exe C:\Program Files\Python310\Lib\idlelib\idle.pyw" ) else ( set "DEFAULT_VENV_PATH=%USERPROFILE%\Envs\FUS_DS_PACKAGE" - set "DEFAULT_IDE=spyder" ) +set "DEFAULT_IDE=spyder" + set "VENV_PATH=%~1" if "%VENV_PATH%"=="" set "VENV_PATH=%DEFAULT_VENV_PATH%"