Merge pull request #260 from puremourning/windows-install-cmd
Fix installation issues on windows - find npm.cmd
This commit is contained in:
commit
75e1c6b1c1
2 changed files with 66 additions and 21 deletions
|
|
@ -9,6 +9,15 @@
|
||||||
"configuration": {
|
"configuration": {
|
||||||
"request": "attach"
|
"request": "attach"
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
"Python: Run current script": {
|
||||||
|
"adapter": "debugpy",
|
||||||
|
"configuration": {
|
||||||
|
"request": "launch",
|
||||||
|
"program": "${file}",
|
||||||
|
"args": [ "*${args:--update-gadget-config}" ],
|
||||||
|
"justMyCode#json": "${justMyCode:true}"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -57,32 +57,32 @@ def Print( *args, **kwargs ):
|
||||||
print( *args, **kwargs )
|
print( *args, **kwargs )
|
||||||
|
|
||||||
|
|
||||||
def CheckCall( *args, **kwargs ):
|
class MissingExecutable( Exception ):
|
||||||
if options.quiet:
|
pass
|
||||||
try:
|
|
||||||
subprocess.check_output( *args, stderr=subprocess.STDOUT, **kwargs )
|
|
||||||
except subprocess.CalledProcessError as e:
|
|
||||||
print( e.output.decode( 'utf-8' ) )
|
|
||||||
raise
|
|
||||||
else:
|
|
||||||
subprocess.check_call( *args, **kwargs )
|
|
||||||
|
|
||||||
|
|
||||||
def PathToAnyWorkingPython3():
|
def GetPATHAsList():
|
||||||
# We can't rely on sys.executable because it's usually 'vim' (fixme, not with
|
|
||||||
# neovim?)
|
|
||||||
paths = os.environ[ 'PATH' ].split( os.pathsep )
|
paths = os.environ[ 'PATH' ].split( os.pathsep )
|
||||||
|
|
||||||
if install.GetOS() == 'windows':
|
if install.GetOS() == 'windows':
|
||||||
paths.insert( 0, os.getcwd() )
|
paths.insert( 0, os.getcwd() )
|
||||||
candidates = [ os.path.join( sys.exec_prefix, 'python.exe' ),
|
return paths
|
||||||
'python.exe' ]
|
|
||||||
else:
|
|
||||||
candidates = [ os.path.join( sys.exec_prefix, 'bin', 'python3' ),
|
def FindExecutable( executable: str, paths=None ):
|
||||||
'python3',
|
if not paths:
|
||||||
'python' ]
|
paths = GetPATHAsList()
|
||||||
|
|
||||||
|
if install.GetOS() == 'windows':
|
||||||
|
extensions = [ '.exe', '.bat', '.cmd' ]
|
||||||
|
else:
|
||||||
|
extensions = [ '' ]
|
||||||
|
|
||||||
|
for extension in extensions:
|
||||||
|
if executable.endswith( extension ):
|
||||||
|
candidate = executable
|
||||||
|
else:
|
||||||
|
candidate = executable + extension
|
||||||
|
|
||||||
for candidate in candidates:
|
|
||||||
for path in paths:
|
for path in paths:
|
||||||
filename = os.path.abspath( os.path.join( path, candidate ) )
|
filename = os.path.abspath( os.path.join( path, candidate ) )
|
||||||
if not os.path.isfile( filename ):
|
if not os.path.isfile( filename ):
|
||||||
|
|
@ -92,6 +92,42 @@ def PathToAnyWorkingPython3():
|
||||||
|
|
||||||
return filename
|
return filename
|
||||||
|
|
||||||
|
raise MissingExecutable( f"Unable to find executable { executable } in path" )
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
def CheckCall( cmd, *args, **kwargs ):
|
||||||
|
cmd[ 0 ] = FindExecutable( cmd[ 0 ] )
|
||||||
|
|
||||||
|
if options.quiet:
|
||||||
|
try:
|
||||||
|
subprocess.check_output( cmd, *args, stderr=subprocess.STDOUT, **kwargs )
|
||||||
|
except subprocess.CalledProcessError as e:
|
||||||
|
print( e.output.decode( 'utf-8' ) )
|
||||||
|
raise
|
||||||
|
else:
|
||||||
|
subprocess.check_call( cmd, *args, **kwargs )
|
||||||
|
|
||||||
|
|
||||||
|
def PathToAnyWorkingPython3():
|
||||||
|
# We can't rely on sys.executable because it's usually 'vim' (fixme, not with
|
||||||
|
# neovim?)
|
||||||
|
paths = GetPATHAsList()
|
||||||
|
|
||||||
|
if install.GetOS() == 'windows':
|
||||||
|
candidates = [ os.path.join( sys.exec_prefix, 'python.exe' ),
|
||||||
|
'python.exe' ]
|
||||||
|
else:
|
||||||
|
candidates = [ os.path.join( sys.exec_prefix, 'bin', 'python3' ),
|
||||||
|
'python3',
|
||||||
|
'python' ]
|
||||||
|
|
||||||
|
for candidate in candidates:
|
||||||
|
try:
|
||||||
|
return FindExecutable( candidate, paths=paths )
|
||||||
|
except MissingExecutable:
|
||||||
|
pass
|
||||||
|
|
||||||
raise RuntimeError( "Unable to find a working python3" )
|
raise RuntimeError( "Unable to find a working python3" )
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -348,7 +384,7 @@ def InstallDebugpy( name, root, gadget ):
|
||||||
|
|
||||||
|
|
||||||
def InstallTclProDebug( name, root, gadget ):
|
def InstallTclProDebug( name, root, gadget ):
|
||||||
configure = [ './configure' ]
|
configure = [ 'sh', './configure' ]
|
||||||
|
|
||||||
if install.GetOS() == 'macos':
|
if install.GetOS() == 'macos':
|
||||||
# Apple removed the headers from system frameworks because they are
|
# Apple removed the headers from system frameworks because they are
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue