@@ -551,9 +551,18 @@ def _create_batch_scripts_initial(self):
551
551
pathps = convps (self .prepath ) + ";$env:path;" + convps (self .postpath )
552
552
553
553
self .create_batch_script ('env.bat' , r"""@echo off
554
- set WINPYDIR=%~dp0..""" + "\\ " + self .python_name + r"""
554
+ set WINPYDIRBASE=%~dp0..
555
+ rem get a normalize path
556
+ CALL :NORMALIZEPATH "%WINPYDIRBASE%"
557
+ set WINPYDIRBASE=%RETVAL%
558
+ set RETVAL=
559
+
560
+ set WINPYDIR=%WINPYDIRBASE%""" + "\\ " + self .python_name + r"""
561
+
555
562
set WINPYVER=""" + self .winpyver + r"""
556
- set HOME=%~dp0..\settings
563
+ set HOME=%WINPYDIRBASE%\settings
564
+ set WINPYDIRBASE=
565
+
557
566
set JUPYTER_DATA_DIR=%HOME%
558
567
set WINPYARCH=WIN32
559
568
if "%WINPYDIR:~-5%"=="amd64" set WINPYARCH=WIN-AMD64
@@ -598,6 +607,17 @@ def _create_batch_scripts_initial(self):
598
607
echo #JUPYTER_DATA_DIR = %%HOME%%>>"%winpython_ini%"
599
608
echo #WINPYWORKDIR = %%HOMEDRIVE%%%%HOMEPATH%%\Documents\WinPython%%WINPYVER%%\Notebooks>>"%winpython_ini%"
600
609
)
610
+
611
+ rem *****
612
+ rem http://stackoverflow.com/questions/1645843/resolve-absolute-path-from-relative-path-and-or-file-name
613
+ rem *****
614
+ :: ========== FUNCTIONS ==========
615
+ EXIT /B
616
+
617
+ :NORMALIZEPATH
618
+ SET RETVAL=%~dpfn1
619
+ EXIT /B
620
+
601
621
""" )
602
622
603
623
self .create_batch_script ('WinPython_PS_Prompt.ps1' , r"""
@@ -607,15 +627,21 @@ def _create_batch_scripts_initial(self):
607
627
$0 = $myInvocation.MyCommand.Definition
608
628
$dp0 = [System.IO.Path]::GetDirectoryName($0)
609
629
630
+ $env:WINPYDIRBASE = "$dp0\.."
631
+ # get a normalize path
632
+ # http://stackoverflow.com/questions/1645843/resolve-absolute-path-from-relative-path-and-or-file-name
633
+ $env:WINPYDIRBASE = [System.IO.Path]::GetFullPath( $env:WINPYDIRBASE )
634
+
610
635
# avoid double_init (will only resize screen)
611
- if (-not $env:WINPYDIR -eq "$dp0\..\python-3.4.4.amd64") {
636
+ if (-not $env:WINPYDIR -eq [System.IO.Path]::GetFullPath( $env:WINPYDIRBASE+""" + '"\\ ' + self .python_name + '"' + r""") ) {
637
+
638
+
639
+ $env:WINPYDIR = $env:WINPYDIRBASE+""" + '"' + '\\ ' + self .python_name + '"' + r"""
612
640
613
- # $env:WINPYDIR = '$pwd\..\python-3.4.4.amd64'
614
- $env:WINPYDIR = "$dp0\..\python-3.4.4.amd64"
615
641
616
- $env:WINPYDIR = "$dp0\..""" + '\\ ' + self .python_name + '"' + r"""
617
642
$env:WINPYVER = '""" + self .winpyver + r"""'
618
- $env:HOME = "$env:WINPYDIR\..\settings"
643
+ $env:HOME = "$env:WINPYDIRBASE\settings"
644
+ $env:WINPYDIRBASE = ""
619
645
$env:JUPYTER_DATA_DIR = "$env:HOME"
620
646
$env:WINPYARCH = 'WIN32'
621
647
if ($env:WINPYARCH.subString($env:WINPYARCH.length-5, 5) -eq 'amd64') {
0 commit comments