-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathinit.bat
39 lines (35 loc) · 1001 Bytes
/
init.bat
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
@echo off
:: allow expansion of variables before access
setlocal enabledelayedexpansion
set sourced=""
set cwd="%cd%"
if "%pythonpath%" == "" (
echo "Environment not yet initialised."
set current_path=""
setx pythonpath "%cd%"
echo "Environment set with: %cd%"
) else (
echo "----------------------------"
echo "Test if current pythonpath contains environment:"
FOR /F %%p IN ("%pythonpath:;=";"%") do (
echo " # Pythonpath-Entry: %%~p"
echo " # Pythonpath-Candidate: %cwd%"
if "%%~p" == "%cwd%" (
echo "Found current working directory in path"
set sourced="true"
)
)
if !sourced! == "" (
echo "--> Environment not yet configured."
echo "----> Current pythonpath: %pythonpath%"
echo "----> Current directory: %cd%"
set current_path=%pythonpath%
set new_path=%cd%;!current_path:"=!
setx pythonpath "!new_path!"
echo "--> Environment set with: !new_path!"
) else (
echo "-->Environment already configured."
)
)
echo "----------------------------"
refreshenv