Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dccn config #21

Merged
merged 4 commits into from
Nov 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 23 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -119,7 +119,16 @@ 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**

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:
Expand Down Expand Up @@ -151,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
Expand All @@ -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"
```

<p align="right">(<a href="#readme-top">back to top</a>)</p>

Expand Down
52 changes: 34 additions & 18 deletions create_venv.bat
Original file line number Diff line number Diff line change
Expand Up @@ -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%"
Expand All @@ -37,8 +54,7 @@ if errorlevel 1 (
exit /b 1
)

:: Ensure that virtualenv is installed (with --user flag for non-admin rights)
:: Check if virtualenv is installed
:: Ensure that virtualenv is installed
"%PYTHON_PATH%" -m pip show virtualenv >nul 2>&1
if errorlevel 1 (
echo Installing virtualenv package...
Expand All @@ -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...
:: Install project-specific dependencies
echo Installing requirements from requirements.txt...
pip install -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%".
echo Setup complete. To activate the virtual environment, run: call "%VENV_PATH%\Scripts\activate"
echo The virtual environment is located at: "%VENV_PATH%"
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@ pandas==2.2.2
pyserial==3.5
tk==0.1.0
openpyxl==3.1.5
spyder
./fus_ds_package
21 changes: 18 additions & 3 deletions start_venv_and_ide.bat
Original file line number Diff line number Diff line change
Expand Up @@ -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"
) 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