def create(self, **kwargs): python_bin = kwargs.get("python", self.python_bin) conda = kwargs.get('conda', self.conda_bin) upgrade = kwargs.get('upgrade', False) nosetupdevelop = kwargs.get('nosetupdevelop', False) clean = kwargs.get('clean', False) if clean: self.clean(**kwargs) venv_command = "{} create -y -m -p {} pip virtualenv".format( conda, self.venv_path) if python_bin: # should probably check this is int or int.int format venv_command += " python={}".format(self.python_bin) if not os.path.exists(self.venv_path): LOGGER.info("Bootstrapping conda env: {0}".format(self.venv_path)) local(venv_command) cmd = build_pip_command(self.config, self.venv_path, self.reqs_name, upgrade=upgrade) try: local(cmd) except OSError as ex: msg = ("Error running pip install command during build\n" "Error was {0}\n" "Running command: {1}\n" "Working Dir: {2}\n" "Conda env: {3}\n" "Requirements: {4}\n").format(ex, cmd, self.working_dir, self.venv_path, self.reqs_name) LOGGER.error(msg) raise for req in self.extra_reqs: cmd = build_pip_command(self.config, self.venv_path, req, upgrade=upgrade) LOGGER.info("Installing extra requirements... {}".format(cmd)) try: local(cmd) except OSError as ex: msg = ("Error running pip install command extra " "requirements install: {}\n{}").format(req, ex) LOGGER.error(msg) raise # setup for development if nosetupdevelop: msg = "skipping python setup.py develop..." LOGGER.info(msg) else: self.run_setup_develop()
def create(self, **kwargs): """ build the virtualenv """ clean = kwargs.get('clean', False) if clean: self.clean(**kwargs) site_packages = kwargs.get('system-site-packages', self.use_sitepackages) upgrade = kwargs.get('upgrade', False) nosetupdevelop = kwargs.get('nosetupdevelop', False) venv = VirtualEnvironment(self.venv_path, python=self.python_bin, system_site_packages=site_packages) LOGGER.info("Bootstrapping virtualenv: {}".format(self.venv_path)) venv.open_or_create() cmd = build_pip_command(self.config, self.venv_path, self.reqs_name, upgrade=upgrade) try: local(cmd) except OSError as ex: msg = ("Error running pip install command during build\n" "Error was {0}\n" "Running command: {1}\n" "Working Dir: {2}\n" "Virtualenv: {3}\n" "Requirements: {4}\n").format(ex, cmd, self.working_dir, self.venv_path, self.reqs_name) LOGGER.error(msg) raise for req in self.extra_reqs: cmd = build_pip_command(self.config, self.venv_path, req, upgrade=upgrade) LOGGER.info("Installing extra requirements... {}".format(cmd)) try: local(cmd) except OSError as ex: msg = ("Error running pip install command extra " "requirements install: {}\n{}").format(req, ex) LOGGER.error(msg) raise # setup for development if nosetupdevelop: msg = "skipping python setup.py develop..." LOGGER.info(msg) else: self.run_setup_develop()
def test_pip_command(self): config = mock.Mock() config.pypi_url = mock.Mock(return_value=None) config.pip_options = mock.Mock(return_value=' --pip-options ') pip = build_pip_command(config, 'PATH', 'requirements.txt', pypirc=self.file) self.assertEqual(pip.strip(), 'PATH/bin/pip install -r requirements.txt --pip-options') config.pypi_url = mock.Mock(return_value='devpi') config.pip_options = mock.Mock(return_value=None) pip = build_pip_command(config, 'PATH', 'requirements.txt', pypirc=self.file) self.assertEqual(pip, 'PATH/bin/pip install -i https://the_steve:stevespass@https://localhost:4000/simple -r requirements.txt') pip = build_pip_command(config, 'PATH', 'requirements.txt', upgrade=True, pypirc=self.file) self.assertEqual(pip, 'PATH/bin/pip install -i https://the_steve:stevespass@https://localhost:4000/simple --upgrade -r requirements.txt')
def create(self, **kwargs): python_bin = kwargs.get("python") if python_bin is not None: self.python_bin = python_bin LOGGER.info("Overriding python bin from command line: {}".format(python_bin)) conda = kwargs.get('conda', self.conda_bin) upgrade = kwargs.get('upgrade', False) nosetupdevelop = kwargs.get('nosetupdevelop', False) clean = kwargs.get('clean', False) if clean: self.clean(**kwargs) venv_command = "{} create -y -m -p {} pip virtualenv".format( conda, self.venv_path ) if self.python_bin: LOGGER.info("using python bin: {}".format(self.python_bin_for_conda)) # should probably check this is int or int.int format venv_command += " python={}".format(self.python_bin_for_conda) if not os.path.exists(self.venv_path): LOGGER.info("Bootstrapping conda env: {0}".format(self.venv_path)) local(venv_command) cmd = build_pip_command( self.config, self.venv_path, self.reqs_name, upgrade=upgrade ) try: local(cmd) except OSError as ex: msg = ( "Error running pip install command during build\n" "Error was {0}\n" "Running command: {1}\n" "Working Dir: {2}\n" "Conda env: {3}\n" "Requirements: {4}\n" ).format(ex, cmd, self.working_dir, self.venv_path, self.reqs_name) LOGGER.error(msg) raise for req in self.extra_reqs: cmd = build_pip_command( self.config, self.venv_path, req, upgrade=upgrade ) LOGGER.info("Installing extra requirements... {}".format(cmd)) try: local(cmd) except OSError as ex: msg = ( "Error running pip install command extra " "requirements install: {}\n{}" ).format(req, ex) LOGGER.error(msg) raise # setup for development if nosetupdevelop: msg = "skipping python setup.py develop..." LOGGER.info(msg) else: self.run_setup_develop()
def create(self, **kwargs): """ build the virtualenv """ clean = kwargs.get('clean', False) if clean: self.clean(**kwargs) site_packages = kwargs.get( 'system-site-packages', self.use_sitepackages ) upgrade = kwargs.get('upgrade', False) extras_require = kwargs.get('extras_require', []) all_extras = kwargs.get('all_extras', False) if all_extras: extras_require = self.config.extras_require().keys() nosetupdevelop = kwargs.get('nosetupdevelop', False) venv = VirtualEnvironment( self.venv_path, python=self.python_bin_for_venv, system_site_packages=site_packages ) LOGGER.info("Bootstrapping virtualenv: {}".format(self.venv_path)) venv.open_or_create() cmd = build_pip_command( self.config, self.venv_path, self.reqs_name, upgrade=upgrade ) try: local(cmd) except OSError as ex: msg = ( "Error running pip install command during build\n" "Error was {0}\n" "Running command: {1}\n" "Working Dir: {2}\n" "Virtualenv: {3}\n" "Requirements: {4}\n" ).format(ex, cmd, self.working_dir, self.venv_path, self.reqs_name) LOGGER.error(msg) raise for req in self.extra_reqs: cmd = build_pip_command( self.config, self.venv_path, req, upgrade=upgrade ) LOGGER.info("Installing extra requirements... {}".format(cmd)) try: local(cmd) except OSError as ex: msg = ( "Error running pip install command extra " "requirements install: {}\n{}" ).format(req, ex) LOGGER.error(msg) raise # setup for development if nosetupdevelop: msg = "skipping python setup.py develop..." LOGGER.info(msg) else: self.run_setup_develop() if extras_require: for extra in extras_require: self._install_extras(extra)