Creates a new environment in ``env_dir``.
(env_dir, args)
| 988 | |
| 989 | |
| 990 | def create_environment(env_dir, args): |
| 991 | """ |
| 992 | Creates a new environment in ``env_dir``. |
| 993 | """ |
| 994 | if os.path.exists(env_dir) and not args.python_virtualenv: |
| 995 | logger.info(' * Environment already exists: %s', env_dir) |
| 996 | if not args.force: |
| 997 | sys.exit(2) |
| 998 | src_dir = to_utf8(abspath(join(env_dir, 'src'))) |
| 999 | mkdir(src_dir) |
| 1000 | |
| 1001 | if args.node != "system": |
| 1002 | install_node(env_dir, src_dir, args) |
| 1003 | else: |
| 1004 | mkdir(join(env_dir, 'bin')) |
| 1005 | mkdir(join(env_dir, 'lib')) |
| 1006 | mkdir(join(env_dir, 'lib', 'node_modules')) |
| 1007 | # activate script install must be |
| 1008 | # before npm install, npm use activate |
| 1009 | # for install |
| 1010 | install_activate(env_dir, args) |
| 1011 | if node_version_from_args(args) < (0, 6, 3) or args.with_npm: |
| 1012 | instfunc = install_npm_win if is_WIN or is_CYGWIN else install_npm |
| 1013 | instfunc(env_dir, src_dir, args) |
| 1014 | if args.requirements: |
| 1015 | install_packages(env_dir, args) |
| 1016 | if args.python_virtualenv: |
| 1017 | set_predeactivate_hook(env_dir) |
| 1018 | # Cleanup |
| 1019 | if args.clean_src: |
| 1020 | shutil.rmtree(src_dir) |
| 1021 | |
| 1022 | |
| 1023 | def _get_versions_json(): |
no test coverage detected