(
prefix: Prefix, version: str, additional_dependencies: Sequence[str],
)
| 75 | |
| 76 | |
| 77 | def install_environment( |
| 78 | prefix: Prefix, version: str, additional_dependencies: Sequence[str], |
| 79 | ) -> None: |
| 80 | assert prefix.exists('package.json') |
| 81 | envdir = lang_base.environment_dir(prefix, ENVIRONMENT_DIR, version) |
| 82 | |
| 83 | # https://msdn.microsoft.com/en-us/library/windows/desktop/aa365247(v=vs.85).aspx?f=255&MSPPError=-2147217396#maxpath |
| 84 | if sys.platform == 'win32': # pragma: no cover |
| 85 | envdir = fr'\\?\{os.path.normpath(envdir)}' |
| 86 | cmd = [sys.executable, '-mnodeenv', '--prebuilt', '--clean-src', envdir] |
| 87 | if version != C.DEFAULT: |
| 88 | cmd.extend(['-n', version]) |
| 89 | cmd_output_b(*cmd) |
| 90 | |
| 91 | with in_env(prefix, version): |
| 92 | # https://npm.community/t/npm-install-g-git-vs-git-clone-cd-npm-install-g/5449 |
| 93 | # install as if we installed from git |
| 94 | |
| 95 | local_install_cmd = ( |
| 96 | 'npm', 'install', '--include=dev', '--include=prod', |
| 97 | '--ignore-prepublish', '--no-progress', '--no-save', |
| 98 | ) |
| 99 | lang_base.setup_cmd(prefix, local_install_cmd) |
| 100 | |
| 101 | _, pkg, _ = cmd_output('npm', 'pack', cwd=prefix.prefix_dir) |
| 102 | pkg = prefix.path(pkg.strip()) |
| 103 | |
| 104 | install = ('npm', 'install', '-g', pkg, *additional_dependencies) |
| 105 | lang_base.setup_cmd(prefix, install) |
| 106 | |
| 107 | # clean these up after installation |
| 108 | if prefix.exists('node_modules'): # pragma: win32 no cover |
| 109 | rmtree(prefix.path('node_modules')) |
| 110 | os.remove(pkg) |
nothing calls this directly
no test coverage detected