More miscellaneous cleanup

This commit is contained in:
Anthony Sottile 2020-01-12 21:17:59 -08:00
parent 489d9f9926
commit df40e862f4
33 changed files with 209 additions and 296 deletions

View file

@ -30,9 +30,9 @@ def get_env_patch(env: str) -> PatchesT:
# seems to be used for python.exe.
path: SubstitutionT = (os.path.join(env, 'bin'), os.pathsep, Var('PATH'))
if os.name == 'nt': # pragma: no cover (platform specific)
path = (env, os.pathsep) + path
path = (os.path.join(env, 'Scripts'), os.pathsep) + path
path = (os.path.join(env, 'Library', 'bin'), os.pathsep) + path
path = (env, os.pathsep, *path)
path = (os.path.join(env, 'Scripts'), os.pathsep, *path)
path = (os.path.join(env, 'Library', 'bin'), os.pathsep, *path)
return (
('PYTHONHOME', UNSET),

View file

@ -18,6 +18,6 @@ def run_hook(
file_args: Sequence[str],
color: bool,
) -> Tuple[int, bytes]:
out = hook.entry.encode() + b'\n\n'
out = f'{hook.entry}\n\n'.encode()
out += b'\n'.join(f.encode() for f in file_args) + b'\n'
return 1, out

View file

@ -68,7 +68,7 @@ def install_environment(
# https://msdn.microsoft.com/en-us/library/windows/desktop/aa365247(v=vs.85).aspx?f=255&MSPPError=-2147217396#maxpath
if sys.platform == 'win32': # pragma: no cover
envdir = '\\\\?\\' + os.path.normpath(envdir)
envdir = f'\\\\?\\{os.path.normpath(envdir)}'
with clean_path_on_failure(envdir):
cmd = [
sys.executable, '-mnodeenv', '--prebuilt', '--clean-src', envdir,
@ -83,7 +83,7 @@ def install_environment(
helpers.run_setup_cmd(prefix, ('npm', 'install'))
helpers.run_setup_cmd(
prefix,
('npm', 'install', '-g', '.') + additional_dependencies,
('npm', 'install', '-g', '.', *additional_dependencies),
)

View file

@ -49,9 +49,8 @@ def _find_by_py_launcher(
if version.startswith('python'):
num = version[len('python'):]
try:
return cmd_output(
'py', f'-{num}', '-c', 'import sys; print(sys.executable)',
)[1].strip()
cmd = ('py', f'-{num}', '-c', 'import sys; print(sys.executable)')
return cmd_output(*cmd)[1].strip()
except CalledProcessError:
pass
return None

View file

@ -109,12 +109,14 @@ def install_environment(
# Need to call this after installing to set up the shims
helpers.run_setup_cmd(prefix, ('rbenv', 'rehash'))
helpers.run_setup_cmd(
prefix, ('gem', 'build') + prefix.star('.gemspec'),
prefix, ('gem', 'build', *prefix.star('.gemspec')),
)
helpers.run_setup_cmd(
prefix,
('gem', 'install', '--no-document') +
prefix.star('.gem') + additional_dependencies,
(
'gem', 'install', '--no-document',
*prefix.star('.gem'), *additional_dependencies,
),
)

View file

@ -27,10 +27,7 @@ healthy = helpers.basic_healthy
def get_env_patch(target_dir: str) -> PatchesT:
return (
(
'PATH',
(os.path.join(target_dir, 'bin'), os.pathsep, Var('PATH')),
),
('PATH', (os.path.join(target_dir, 'bin'), os.pathsep, Var('PATH'))),
)

View file

@ -18,6 +18,5 @@ def run_hook(
file_args: Sequence[str],
color: bool,
) -> Tuple[int, bytes]:
cmd = hook.cmd
cmd = (hook.prefix.path(cmd[0]),) + cmd[1:]
cmd = (hook.prefix.path(hook.cmd[0]), *hook.cmd[1:])
return helpers.run_xargs(hook, cmd, file_args, color=color)