Ejemplo n.º 1
0
 def update_submodules(self, location):
     if not os.path.exists(os.path.join(location, '.gitmodules')):
         return
     call_subprocess(
         [self.cmd, 'submodule', 'update', '--init', '--recursive', '-q'],
         cwd=location,
     )
Ejemplo n.º 2
0
    def install_editable(self,
                         install_options,
                         global_options=(),
                         prefix=None):
        logger.info('Running setup.py develop for %s', self.name)

        if self.isolated:
            global_options = list(global_options) + ["--no-user-cfg"]

        if prefix:
            prefix_param = ['--prefix={0}'.format(prefix)]
            install_options = list(install_options) + prefix_param

        with indent_log():
            # FIXME: should we do --install-headers here too?
            cwd = self.source_dir
            if self.editable_options and \
                    'subdirectory' in self.editable_options:
                cwd = os.path.join(cwd, self.editable_options['subdirectory'])
            call_subprocess(
                [sys.executable, '-c', SETUPTOOLS_SHIM % self.setup_py] +
                list(global_options) + ['develop', '--no-deps'] +
                list(install_options),
                cwd=cwd,
                show_stdout=False)

        self.install_succeeded = True
Ejemplo n.º 3
0
    def obtain(self, dest):
        url, rev = self.get_url_rev()
        if rev:
            rev_options = [rev]
            rev_display = ' (to %s)' % rev
        else:
            rev_options = ['origin/master']
            rev_display = ''
        if self.check_destination(dest, url, rev_options, rev_display):
            logger.info(
                'Cloning %s%s to %s',
                url,
                rev_display,
                display_path(dest),
            )
            call_subprocess([self.cmd, 'clone', '-q', url, dest])

            if rev:
                rev_options = self.check_rev_options(rev, dest, rev_options)
                # Only do a checkout if rev_options differs from HEAD
                if not self.get_revision(dest).startswith(rev_options[0]):
                    call_subprocess(
                        [self.cmd, 'checkout', '-q'] + rev_options,
                        cwd=dest,
                    )
            #: repo may contain submodules
            self.update_submodules(dest)
Ejemplo n.º 4
0
def _copy_dist_from_dir(link_path, location):
    """Copy distribution files in `link_path` to `location`.

    Invoked when user requests to install a local directory. E.g.:

        pip install .
        pip install ~/dev/git-repos/python-prompt-toolkit

    """

    # Note: This is currently VERY SLOW if you have a lot of data in the
    # directory, because it copies everything with `shutil.copytree`.
    # What it should really do is build an sdist and install that.
    # See https://github.com/pypa/pip/issues/2195

    if os.path.isdir(location):
        rmtree(location)

    # build an sdist
    setup_py = 'setup.py'
    sdist_args = [sys.executable]
    sdist_args.append('-c')
    sdist_args.append(SETUPTOOLS_SHIM % setup_py)
    sdist_args.append('sdist')
    sdist_args += ['--dist-dir', location]
    logger.info('Running setup.py sdist for %s', link_path)

    with indent_log():
        call_subprocess(sdist_args, cwd=link_path, show_stdout=False)

    # unpack sdist into `location`
    sdist = os.path.join(location, os.listdir(location)[0])
    logger.info('Unpacking sdist %s into %s', sdist, location)
    unpack_file(sdist, location, content_type=None, link=None)
Ejemplo n.º 5
0
def _copy_dist_from_dir(link_path, location):
    """Copy distribution files in `link_path` to `location`.

    Invoked when user requests to install a local directory. E.g.:

        pip install .
        pip install ~/dev/git-repos/python-prompt-toolkit

    """

    # Note: This is currently VERY SLOW if you have a lot of data in the
    # directory, because it copies everything with `shutil.copytree`.
    # What it should really do is build an sdist and install that.
    # See https://github.com/pypa/pip/issues/2195

    if os.path.isdir(location):
        rmtree(location)

    # build an sdist
    setup_py = 'setup.py'
    sdist_args = [sys.executable]
    sdist_args.append('-c')
    sdist_args.append(SETUPTOOLS_SHIM % setup_py)
    sdist_args.append('sdist')
    sdist_args += ['--dist-dir', location]
    logger.info('Running setup.py sdist for %s', link_path)

    with indent_log():
        call_subprocess(sdist_args, cwd=link_path, show_stdout=False)

    # unpack sdist into `location`
    sdist = os.path.join(location, os.listdir(location)[0])
    logger.info('Unpacking sdist %s into %s', sdist, location)
    unpack_file(sdist, location, content_type=None, link=None)
Ejemplo n.º 6
0
    def install_editable(self, install_options,
                         global_options=(), prefix=None):
        logger.info('Running setup.py develop for %s', self.name)

        if self.isolated:
            global_options = list(global_options) + ["--no-user-cfg"]

        if prefix:
            prefix_param = ['--prefix={0}'.format(prefix)]
            install_options = list(install_options) + prefix_param

        with indent_log():
            # FIXME: should we do --install-headers here too?
            call_subprocess(
                [
                    sys.executable,
                    '-c',
                    SETUPTOOLS_SHIM % self.setup_py
                ] +
                list(global_options) +
                ['develop', '--no-deps'] +
                list(install_options),

                cwd=self.setup_py_dir,
                show_stdout=False)

        self.install_succeeded = True
Ejemplo n.º 7
0
    def __build_one(self, req, tempd, python_tag=None, isolate=False):
        base_args = self._base_setup_args(req, isolate=isolate)

        spin_message = 'Running setup.py bdist_wheel for %s' % (req.name, )
        with open_spinner(spin_message) as spinner:
            logger.debug('Destination directory: %s', tempd)
            wheel_args = base_args + ['bdist_wheel', '-d', tempd] \
                + self.build_options

            if python_tag is not None:
                wheel_args += ["--python-tag", python_tag]

            env = {}
            if isolate:
                env['PYTHONNOUSERSITE'] = '1'

            try:
                call_subprocess(wheel_args,
                                cwd=req.setup_py_dir,
                                extra_environ=env,
                                show_stdout=False,
                                spinner=spinner)
                return True
            except:
                spinner.finish("error")
                logger.error('Failed building wheel for %s', req.name)
                return False
Ejemplo n.º 8
0
 def update_submodules(self, location):
     if not os.path.exists(os.path.join(location, '.gitmodules')):
         return
     call_subprocess(
         [self.cmd, 'submodule', 'update', '--init', '--recursive', '-q'],
         cwd=location,
     )
Ejemplo n.º 9
0
    def switch(self, dest, url, rev_options):
        call_subprocess(
            [self.cmd, 'config', 'remote.origin.url', url], cwd=dest)
        call_subprocess(
            [self.cmd, 'checkout', '-q'] + rev_options, cwd=dest)

        self.update_submodules(dest)
Ejemplo n.º 10
0
    def install_editable(self, install_options, global_options=()):
        logger.info('Running setup.py develop for %s', self.name)

        if self.isolated:
            global_options = list(global_options) + ["--no-user-cfg"]

        with indent_log():
            # FIXME: should we do --install-headers here too?
            cwd = self.source_dir
            if self.editable_options and \
                    'subdirectory' in self.editable_options:
                cwd = os.path.join(cwd, self.editable_options['subdirectory'])
            call_subprocess(
                [
                    sys.executable,
                    '-c',
                    "import setuptools, tokenize; __file__=%r; exec(compile("
                    "getattr(tokenize, 'open', open)(__file__).read().replace"
                    "('\\r\\n', '\\n'), __file__, 'exec'))" % self.setup_py
                ]
                + list(global_options)
                + ['develop', '--no-deps']
                + list(install_options),

                cwd=cwd, filter_stdout=self._filter_install,
                show_stdout=False)

        self.install_succeeded = True
Ejemplo n.º 11
0
    def install_editable(self, install_options, global_options=()):
        logger.info('Running setup.py develop for %s', self.name)

        if self.isolated:
            global_options = list(global_options) + ["--no-user-cfg"]

        with indent_log():
            # FIXME: should we do --install-headers here too?
            cwd = self.source_dir
            if self.editable_options and \
                    'subdirectory' in self.editable_options:
                cwd = os.path.join(cwd, self.editable_options['subdirectory'])
            call_subprocess(
                [
                    sys.executable,
                    '-c',
                    "import setuptools, tokenize; __file__=%r; exec(compile("
                    "getattr(tokenize, 'open', open)(__file__).read().replace"
                    "('\\r\\n', '\\n'), __file__, 'exec'))" % self.setup_py
                ] +
                list(global_options) +
                ['develop', '--no-deps'] +
                list(install_options),

                cwd=cwd, filter_stdout=self._filter_install,
                show_stdout=False)

        self.install_succeeded = True
Ejemplo n.º 12
0
    def install_editable(self,
                         install_options,
                         global_options=(),
                         prefix=None):
        logger.info('Running setup.py develop for %s', self.name)

        if self.isolated:
            global_options = list(global_options) + ["--no-user-cfg"]

        if prefix:
            prefix_param = ['--prefix={0}'.format(prefix)]
            install_options = list(install_options) + prefix_param

        with indent_log():
            # FIXME: should we do --install-headers here too?
            update_python_path()
            call_subprocess([
                PIP_PYTHON_PATH or sys.executable, '-c',
                SETUPTOOLS_SHIM % self.setup_py
            ] + list(global_options) + ['develop', '--no-deps'] +
                            list(install_options),
                            cwd=self.setup_py_dir,
                            show_stdout=False)

        self.install_succeeded = True
Ejemplo n.º 13
0
    def run_egg_info(self):
        assert self.source_dir
        if self.name:
            logger.debug(
                'Running setup.py (path:%s) egg_info for package %s',
                self.setup_py, self.name,
            )
        else:
            logger.debug(
                'Running setup.py (path:%s) egg_info for package from %s',
                self.setup_py, self.link,
            )

        with indent_log():
            script = SETUPTOOLS_SHIM % self.setup_py
            base_cmd = [sys.executable, '-c', script]
            if self.isolated:
                base_cmd += ["--no-user-cfg"]
            egg_info_cmd = base_cmd + ['egg_info']
            # We can't put the .egg-info files at the root, because then the
            # source code will be mistaken for an installed egg, causing
            # problems
            if self.editable:
                egg_base_option = []
            else:
                egg_info_dir = os.path.join(self.setup_py_dir, 'pip-egg-info')
                ensure_dir(egg_info_dir)
                egg_base_option = ['--egg-base', 'pip-egg-info']
            call_subprocess(
                egg_info_cmd + egg_base_option,
                cwd=self.setup_py_dir,
                show_stdout=False,
                command_level=logging.DEBUG,
                command_desc='python setup.py egg_info')

        if not self.req:
            if isinstance(
                    pkg_resources.parse_version(self.pkg_info()["Version"]),
                    Version):
                op = "=="
            else:
                op = "==="
            self.req = Requirement(
                "".join([
                    self.pkg_info()["Name"],
                    op,
                    self.pkg_info()["Version"],
                ])
            )
            self._correct_build_location()
        else:
            metadata_name = canonicalize_name(self.pkg_info()["Name"])
            if canonicalize_name(self.req.name) != metadata_name:
                logger.warning(
                    'Running setup.py (path:%s) egg_info for package %s '
                    'produced metadata for project name %s. Fix your '
                    '#egg=%s fragments.',
                    self.setup_py, self.name, metadata_name, self.name
                )
                self.req = Requirement(metadata_name)
Ejemplo n.º 14
0
    def __build_one(self, req, tempd, python_tag=None, isolate=False):
        base_args = self._base_setup_args(req, isolate=isolate)

        spin_message = 'Running setup.py bdist_wheel for %s' % (req.name,)
        with open_spinner(spin_message) as spinner:
            logger.debug('Destination directory: %s', tempd)
            wheel_args = base_args + ['bdist_wheel', '-d', tempd] \
                + self.build_options

            if python_tag is not None:
                wheel_args += ["--python-tag", python_tag]

            env = {}
            if isolate:
                env['PYTHONNOUSERSITE'] = '1'

            try:
                call_subprocess(wheel_args, cwd=req.setup_py_dir,
                                extra_environ=env,
                                show_stdout=False, spinner=spinner)
                return True
            except:
                spinner.finish("error")
                logger.error('Failed building wheel for %s', req.name)
                return False
Ejemplo n.º 15
0
    def run_egg_info(self):
        assert self.source_dir
        if self.name:
            logger.debug(
                'Running setup.py (path:%s) egg_info for package %s',
                self.setup_py, self.name,
            )
        else:
            logger.debug(
                'Running setup.py (path:%s) egg_info for package from %s',
                self.setup_py, self.link,
            )

        # Support
        PIP_PYTHON_PATH = os.environ.get('PIP_PYTHON_PATH')

        with indent_log():
            script = SETUPTOOLS_SHIM % self.setup_py
            base_cmd = [PIP_PYTHON_PATH or sys.executable, '-c', script]
            if self.isolated:
                base_cmd += ["--no-user-cfg"]
            egg_info_cmd = base_cmd + ['egg_info']
            # We can't put the .egg-info files at the root, because then the
            # source code will be mistaken for an installed egg, causing
            # problems
            if self.editable:
                egg_base_option = []
            else:
                egg_info_dir = os.path.join(self.setup_py_dir, 'pip-egg-info')
                ensure_dir(egg_info_dir)
                egg_base_option = ['--egg-base', 'pip-egg-info']
            call_subprocess(
                egg_info_cmd + egg_base_option,
                cwd=self.setup_py_dir,
                show_stdout=False,
                command_desc='python setup.py egg_info')

        if not self.req:
            if isinstance(parse_version(self.pkg_info()["Version"]), Version):
                op = "=="
            else:
                op = "==="
            self.req = Requirement(
                "".join([
                    self.pkg_info()["Name"],
                    op,
                    self.pkg_info()["Version"],
                ])
            )
            self._correct_build_location()
        else:
            metadata_name = canonicalize_name(self.pkg_info()["Name"])
            if canonicalize_name(self.req.name) != metadata_name:
                logger.warning(
                    'Running setup.py (path:%s) egg_info for package %s '
                    'produced metadata for project name %s. Fix your '
                    '#egg=%s fragments.',
                    self.setup_py, self.name, metadata_name, self.name
                )
                self.req = Requirement(metadata_name)
Ejemplo n.º 16
0
 def export(self, location):
     """Export the Hg repository at the url to the destination location"""
     temp_dir = tempfile.mkdtemp('-export', 'pip-')
     self.unpack(temp_dir)
     try:
         call_subprocess(
             [self.cmd, 'archive', location],
             filter_stdout=self._filter, show_stdout=False, cwd=temp_dir)
     finally:
         rmtree(temp_dir)
Ejemplo n.º 17
0
 def export(self, location):
     """Export the Hg repository at the url to the destination location"""
     temp_dir = tempfile.mkdtemp('-export', 'pip-')
     self.unpack(temp_dir)
     try:
         call_subprocess(
             [self.cmd, 'archive', location],
             filter_stdout=self._filter, show_stdout=False, cwd=temp_dir)
     finally:
         rmtree(temp_dir)
Ejemplo n.º 18
0
    def run_egg_info(self):
        assert self.source_dir
        if self.name:
            logger.debug(
                'Running setup.py (path:%s) egg_info for package %s',
                self.setup_py, self.name,
            )
        else:
            logger.debug(
                'Running setup.py (path:%s) egg_info for package from %s',
                self.setup_py, self.link,
            )

        with indent_log():
            script = self._run_setup_py
            script = script.replace('__SETUP_PY__', repr(self.setup_py))
            script = script.replace('__PKG_NAME__', repr(self.name))
            base_cmd = [sys.executable, '-c', script]
            if self.isolated:
                base_cmd += ["--no-user-cfg"]
            egg_info_cmd = base_cmd + ['egg_info']
            # We can't put the .egg-info files at the root, because then the
            # source code will be mistaken for an installed egg, causing
            # problems
            if self.editable:
                egg_base_option = []
            else:
                egg_info_dir = os.path.join(self.source_dir, 'pip-egg-info')
                ensure_dir(egg_info_dir)
                egg_base_option = ['--egg-base', 'pip-egg-info']
            cwd = self.source_dir
            if self.editable_options and \
                    'subdirectory' in self.editable_options:
                cwd = os.path.join(cwd, self.editable_options['subdirectory'])
            call_subprocess(
                egg_info_cmd + egg_base_option,
                cwd=cwd,
                show_stdout=False,
                command_level=logging.DEBUG,
                command_desc='python setup.py egg_info')

        if not self.req:
            if isinstance(
                    pkg_resources.parse_version(self.pkg_info()["Version"]),
                    Version):
                op = "=="
            else:
                op = "==="
            self.req = pkg_resources.Requirement.parse(
                "".join([
                    self.pkg_info()["Name"],
                    op,
                    self.pkg_info()["Version"],
                ]))
            self._correct_build_location()
Ejemplo n.º 19
0
    def run_egg_info(self):
        assert self.source_dir
        if self.name:
            logger.debug(
                'Running setup.py (path:%s) egg_info for package %s',
                self.setup_py,
                self.name,
            )
        else:
            logger.debug(
                'Running setup.py (path:%s) egg_info for package from %s',
                self.setup_py,
                self.link,
            )

        with indent_log():
            script = self._run_setup_py
            script = script.replace('__SETUP_PY__', repr(self.setup_py))
            script = script.replace('__PKG_NAME__', repr(self.name))
            base_cmd = [sys.executable, '-c', script]
            if self.isolated:
                base_cmd += ["--no-user-cfg"]
            egg_info_cmd = base_cmd + ['egg_info']
            # We can't put the .egg-info files at the root, because then the
            # source code will be mistaken for an installed egg, causing
            # problems
            if self.editable:
                egg_base_option = []
            else:
                egg_info_dir = os.path.join(self.source_dir, 'pip-egg-info')
                ensure_dir(egg_info_dir)
                egg_base_option = ['--egg-base', 'pip-egg-info']
            cwd = self.source_dir
            if self.editable_options and \
                    'subdirectory' in self.editable_options:
                cwd = os.path.join(cwd, self.editable_options['subdirectory'])
            call_subprocess(egg_info_cmd + egg_base_option,
                            cwd=cwd,
                            show_stdout=False,
                            command_level=logging.DEBUG,
                            command_desc='python setup.py egg_info')

        if not self.req:
            if isinstance(
                    pkg_resources.parse_version(self.pkg_info()["Version"]),
                    Version):
                op = "=="
            else:
                op = "==="
            self.req = pkg_resources.Requirement.parse("".join([
                self.pkg_info()["Name"],
                op,
                self.pkg_info()["Version"],
            ]))
            self._correct_build_location()
Ejemplo n.º 20
0
    def _clean_one(self, req):
        base_args = self._base_setup_args(req)

        logger.info('Running setup.py clean for %s', req.name)
        clean_args = base_args + ['clean', '--all']
        try:
            call_subprocess(clean_args, cwd=req.source_dir, show_stdout=False)
            return True
        except:
            logger.error('Failed cleaning build dir for %s', req.name)
            return False
Ejemplo n.º 21
0
    def _clean_one(self, req):
        base_args = self._base_setup_args(req)

        logger.info('Running setup.py clean for %s', req.name)
        clean_args = base_args + ['clean', '--all']
        try:
            call_subprocess(clean_args, cwd=req.source_dir, show_stdout=False)
            return True
        except:
            logger.error('Failed cleaning build dir for %s', req.name)
            return False
Ejemplo n.º 22
0
 def run(self):
     if getattr(self.distribution, 'salt_installing_m2crypto_windows', None) is None:
         print('This command is not meant to be called on it\'s own')
         exit(1)
     import platform
     from pip.utils import call_subprocess
     from pip.utils.logging import indent_log
     platform_bits, _ = platform.architecture()
     with indent_log():
         call_subprocess(
             ['pip', 'install', '--egg', 'M2CryptoWin{0}'.format(platform_bits[:2])]
         )
Ejemplo n.º 23
0
 def export(self, location):
     """Export the Git repository at the url to the destination location"""
     temp_dir = tempfile.mkdtemp('-export', 'pip-')
     self.unpack(temp_dir)
     try:
         if not location.endswith('/'):
             location = location + '/'
         call_subprocess(
             [self.cmd, 'checkout-index', '-a', '-f', '--prefix', location],
             filter_stdout=self._filter, show_stdout=False, cwd=temp_dir)
     finally:
         rmtree(temp_dir)
Ejemplo n.º 24
0
Archivo: setup.py Proyecto: iquaba/salt
 def run(self):
     if getattr(self.distribution, 'salt_installing_m2crypto_windows', None) is None:
         print('This command is not meant to be called on it\'s own')
         exit(1)
     import platform
     from pip.utils import call_subprocess
     from pip.utils.logging import indent_log
     platform_bits, _ = platform.architecture()
     with indent_log():
         call_subprocess(
             ['pip', 'install', '--egg', 'M2CryptoWin{0}'.format(platform_bits[:2])]
         )
Ejemplo n.º 25
0
 def export(self, location):
     """Export the svn repository at the url to the destination location"""
     url, rev = self.get_url_rev()
     rev_options = get_rev_options(url, rev)
     logger.info('Exporting svn repository %s to %s', url, location)
     with indent_log():
         if os.path.exists(location):
             # Subversion doesn't like to check out over an existing
             # directory --force fixes this, but was only added in svn 1.5
             rmtree(location)
         call_subprocess(
             [self.cmd, 'export'] + rev_options + [url, location],
             filter_stdout=self._filter, show_stdout=False)
Ejemplo n.º 26
0
 def export(self, location):
     """Export the svn repository at the url to the destination location"""
     url, rev = self.get_url_rev()
     rev_options = get_rev_options(url, rev)
     logger.info('Exporting svn repository %s to %s', url, location)
     with indent_log():
         if os.path.exists(location):
             # Subversion doesn't like to check out over an existing
             # directory --force fixes this, but was only added in svn 1.5
             rmtree(location)
         call_subprocess([self.cmd, 'export'] + rev_options +
                         [url, location],
                         filter_stdout=self._filter,
                         show_stdout=False)
Ejemplo n.º 27
0
 def update(self, dest, rev_options):
     # First fetch changes from the default remote
     call_subprocess([self.cmd, 'fetch', '-q'], cwd=dest)
     # Then reset to wanted revision (maby even origin/master)
     if rev_options:
         rev_options = self.check_rev_options(
             rev_options[0], dest, rev_options,
         )
     call_subprocess(
         [self.cmd, 'reset', '--hard', '-q'] + rev_options,
         cwd=dest,
     )
     #: update submodules
     self.update_submodules(dest)
Ejemplo n.º 28
0
 def export(self, location):
     """Export the Git repository at the url to the destination location"""
     temp_dir = tempfile.mkdtemp('-export', 'pip-')
     self.unpack(temp_dir)
     try:
         if not location.endswith('/'):
             location = location + '/'
         call_subprocess(
             [self.cmd, 'checkout-index', '-a', '-f', '--prefix', location],
             filter_stdout=self._filter,
             show_stdout=False,
             cwd=temp_dir)
     finally:
         rmtree(temp_dir)
Ejemplo n.º 29
0
 def switch(self, dest, url, rev_options):
     repo_config = os.path.join(dest, self.dirname, 'hgrc')
     config = configparser.SafeConfigParser()
     try:
         config.read(repo_config)
         config.set('paths', 'default', url)
         with open(repo_config, 'w') as config_file:
             config.write(config_file)
     except (OSError, configparser.NoSectionError) as exc:
         logger.warning(
             'Could not switch Mercurial repository to %s: %s', url, exc,
         )
     else:
         call_subprocess([self.cmd, 'update', '-q'] + rev_options, cwd=dest)
Ejemplo n.º 30
0
 def export(self, location):
     """
     Export the Bazaar repository at the url to the destination location
     """
     temp_dir = tempfile.mkdtemp('-export', 'pip-')
     self.unpack(temp_dir)
     if os.path.exists(location):
         # Remove the location to make sure Bazaar can export it correctly
         rmtree(location)
     try:
         call_subprocess([self.cmd, 'export', location], cwd=temp_dir,
                         filter_stdout=self._filter, show_stdout=False)
     finally:
         rmtree(temp_dir)
Ejemplo n.º 31
0
 def export(self, location):
     """
     Export the Bazaar repository at the url to the destination location
     """
     temp_dir = tempfile.mkdtemp('-export', 'pip-')
     self.unpack(temp_dir)
     if os.path.exists(location):
         # Remove the location to make sure Bazaar can export it correctly
         rmtree(location)
     try:
         call_subprocess([self.cmd, 'export', location], cwd=temp_dir,
                         filter_stdout=self._filter, show_stdout=False)
     finally:
         rmtree(temp_dir)
Ejemplo n.º 32
0
 def switch(self, dest, url, rev_options):
     repo_config = os.path.join(dest, self.dirname, 'hgrc')
     config = configparser.SafeConfigParser()
     try:
         config.read(repo_config)
         config.set('paths', 'default', url)
         with open(repo_config, 'w') as config_file:
             config.write(config_file)
     except (OSError, configparser.NoSectionError) as exc:
         logger.warning(
             'Could not switch Mercurial repository to %s: %s', url, exc,
         )
     else:
         call_subprocess([self.cmd, 'update', '-q'] + rev_options, cwd=dest)
Ejemplo n.º 33
0
    def _install_build_reqs(self, reqs, prefix):
        # Local import to avoid circular import (wheel <-> req_install)
        from pip.req.req_install import InstallRequirement
        from pip.index import FormatControl
        # Ignore the --no-binary option when installing the build system, so
        # we don't recurse trying to build a self-hosting build system.
        finder = copy.copy(self.finder)
        finder.format_control = FormatControl(set(), set())
        urls = [finder.find_requirement(InstallRequirement.from_line(r),
                                        upgrade=False).url
                for r in reqs]

        args = [sys.executable, '-m', 'pip', 'install', '--ignore-installed',
                '--prefix', prefix] + list(urls)
        with open_spinner("Installing build dependencies") as spinner:
            call_subprocess(args, show_stdout=False, spinner=spinner)
Ejemplo n.º 34
0
 def get_url(self, location):
     url = call_subprocess(
         [self.cmd, 'showconfig', 'paths.default'],
         show_stdout=False, cwd=location).strip()
     if self._is_local_repository(url):
         url = path_to_url(url)
     return url.strip()
Ejemplo n.º 35
0
    def setup_py(self):
        assert self.source_dir, "No source dir for %s" % self
        cmd = [sys.executable, '-c', 'import setuptools']
        output = call_subprocess(
            cmd,
            show_stdout=False,
            command_desc='python -c "import setuptools"',
            on_returncode='ignore',
        )

        if output:
            if get_installed_version('setuptools') is None:
                add_msg = "Please install setuptools."
            else:
                add_msg = output
            # Setuptools is not available
            raise InstallationError(
                "Could not import setuptools which is required to "
                "install from a source distribution.\n%s" % add_msg)

        setup_py = os.path.join(self.setup_py_dir, 'setup.py')

        # Python2 __file__ should not be unicode
        if six.PY2 and isinstance(setup_py, six.text_type):
            setup_py = setup_py.encode(sys.getfilesystemencoding())

        return setup_py
Ejemplo n.º 36
0
 def get_info(self, location):
     """Returns (url, revision), where both are strings"""
     assert not location.rstrip('/').endswith(self.dirname), \
         'Bad directory: %s' % location
     output = call_subprocess(
         [self.cmd, 'info', location],
         show_stdout=False,
         extra_environ={'LANG': 'C'},
     )
     match = _svn_url_re.search(output)
     if not match:
         logger.warning(
             'Cannot determine URL of svn checkout %s',
             display_path(location),
         )
         logger.debug('Output that cannot be parsed: \n%s', output)
         return None, None
     url = match.group(1).strip()
     match = _svn_revision_re.search(output)
     if not match:
         logger.warning(
             'Cannot determine revision of svn checkout %s',
             display_path(location),
         )
         logger.debug('Output that cannot be parsed: \n%s', output)
         return url, None
     return url, match.group(1)
Ejemplo n.º 37
0
 def get_url(self, location):
     url = call_subprocess(
         [self.cmd, 'showconfig', 'paths.default'],
         show_stdout=False, cwd=location).strip()
     if self._is_local_repository(url):
         url = path_to_url(url)
     return url.strip()
Ejemplo n.º 38
0
 def run_command(self, cmd, show_stdout=True, cwd=None,
                 on_returncode='raise',
                 command_desc=None,
                 extra_environ=None, spinner=None):
     """
     Run a VCS subcommand
     This is simply a wrapper around call_subprocess that adds the VCS
     command name, and checks that the VCS is available
     """
     cmd = [self.name] + cmd
     try:
         return call_subprocess(cmd, show_stdout, cwd,
                                on_returncode,
                                command_desc, extra_environ,
                                spinner)
     except OSError as e:
         # errno.ENOENT = no such file or directory
         # In other words, the VCS executable isn't available
         if e.errno == errno.ENOENT:
             raise BadCommand(
                 'Cannot find command %r - do you have '
                 '%r installed and in your '
                 'PATH?' % (self.name, self.name))
         else:
             raise  # re-raise exception if a different error occurred
Ejemplo n.º 39
0
 def obtain(self, dest):
     url, rev = self.get_url_rev()
     rev_options = get_rev_options(url, rev)
     if rev:
         rev_display = ' (to revision %s)' % rev
     else:
         rev_display = ''
     if self.check_destination(dest, url, rev_options, rev_display):
         logger.info(
             'Checking out %s%s to %s',
             url,
             rev_display,
             display_path(dest),
         )
         call_subprocess(
             [self.cmd, 'checkout', '-q'] + rev_options + [url, dest])
Ejemplo n.º 40
0
 def obtain(self, dest):
     url, rev = self.get_url_rev()
     rev_options = get_rev_options(url, rev)
     if rev:
         rev_display = ' (to revision %s)' % rev
     else:
         rev_display = ''
     if self.check_destination(dest, url, rev_options, rev_display):
         logger.info(
             'Checking out %s%s to %s',
             url,
             rev_display,
             display_path(dest),
         )
         call_subprocess([self.cmd, 'checkout', '-q'] + rev_options +
                         [url, dest])
Ejemplo n.º 41
0
    def setup_py(self):
        assert self.source_dir, "No source dir for %s" % self
        cmd = [sys.executable, '-c', 'import setuptools']
        output = call_subprocess(
            cmd,
            show_stdout=False,
            command_desc='python -c "import setuptools"',
            on_returncode='ignore',
        )

        if output:
            if get_installed_version('setuptools') is None:
                add_msg = "Please install setuptools."
            else:
                add_msg = output
            # Setuptools is not available
            raise InstallationError(
                "Could not import setuptools which is required to "
                "install from a source distribution.\n%s" % add_msg
            )

        setup_py = os.path.join(self.setup_py_dir, 'setup.py')

        # Python2 __file__ should not be unicode
        if six.PY2 and isinstance(setup_py, six.text_type):
            setup_py = setup_py.encode(sys.getfilesystemencoding())

        return setup_py
Ejemplo n.º 42
0
 def update(self, dest, rev_options):
     # First fetch changes from the default remote
     call_subprocess([self.cmd, 'fetch', '-q'], cwd=dest)
     # Then reset to wanted revision (maby even origin/master)
     if rev_options:
         rev_options = self.check_rev_options(
             rev_options[0],
             dest,
             rev_options,
         )
     call_subprocess(
         [self.cmd, 'reset', '--hard', '-q'] + rev_options,
         cwd=dest,
     )
     #: update submodules
     self.update_submodules(dest)
Ejemplo n.º 43
0
 def get_info(self, location):
     """Returns (url, revision), where both are strings"""
     assert not location.rstrip('/').endswith(self.dirname), \
         'Bad directory: %s' % location
     output = call_subprocess(
         [self.cmd, 'info', location],
         show_stdout=False,
         extra_environ={'LANG': 'C'},
     )
     match = _svn_url_re.search(output)
     if not match:
         logger.warning(
             'Cannot determine URL of svn checkout %s',
             display_path(location),
         )
         logger.debug('Output that cannot be parsed: \n%s', output)
         return None, None
     url = match.group(1).strip()
     match = _svn_revision_re.search(output)
     if not match:
         logger.warning(
             'Cannot determine revision of svn checkout %s',
             display_path(location),
         )
         logger.debug('Output that cannot be parsed: \n%s', output)
         return url, None
     return url, match.group(1)
Ejemplo n.º 44
0
 def run_command(self,
                 cmd,
                 show_stdout=True,
                 cwd=None,
                 on_returncode='raise',
                 command_level=logging.DEBUG,
                 command_desc=None,
                 extra_environ=None,
                 spinner=None):
     """
     Run a VCS subcommand
     This is simply a wrapper around call_subprocess that adds the VCS
     command name, and checks that the VCS is available
     """
     cmd = [self.name] + cmd
     try:
         return call_subprocess(cmd, show_stdout, cwd, on_returncode,
                                command_level, command_desc, extra_environ,
                                spinner)
     except OSError as e:
         # errno.ENOENT = no such file or directory
         # In other words, the VCS executable isn't available
         if e.errno == errno.ENOENT:
             raise BadCommand('Cannot find command %r' % self.name)
         else:
             raise  # re-raise exception if a different error occurred
Ejemplo n.º 45
0
 def run_command(
     self,
     cmd,
     show_stdout=True,
     filter_stdout=None,
     cwd=None,
     raise_on_returncode=True,
     command_level=logging.DEBUG,
     command_desc=None,
     extra_environ=None,
 ):
     """
     Run a VCS subcommand
     This is simply a wrapper around call_subprocess that adds the VCS
     command name, and checks that the VCS is available
     """
     cmd = [self.name] + cmd
     try:
         return call_subprocess(
             cmd, show_stdout, filter_stdout, cwd, raise_on_returncode, command_level, command_desc, extra_environ
         )
     except OSError as e:
         # errno.ENOENT = no such file or directory
         # In other words, the VCS executable isn't available
         if e.errno == errno.ENOENT:
             raise BadCommand("Cannot find command %r" % self.name)
         else:
             raise  # re-raise exception if a different error occured
Ejemplo n.º 46
0
    def _install_build_reqs(self, reqs, prefix):
        # Local import to avoid circular import (wheel <-> req_install)
        from pip.req.req_install import InstallRequirement
        from pip.index import FormatControl
        # Ignore the --no-binary option when installing the build system, so
        # we don't recurse trying to build a self-hosting build system.
        finder = copy.copy(self.finder)
        finder.format_control = FormatControl(set(), set())
        urls = [finder.find_requirement(InstallRequirement.from_line(r),
                                        upgrade=False).url
                for r in reqs]

        args = [sys.executable, '-m', 'pip', 'install', '--ignore-installed',
                '--prefix', prefix] + list(urls)
        with open_spinner("Installing build dependencies") as spinner:
            call_subprocess(args, show_stdout=False, spinner=spinner)
Ejemplo n.º 47
0
 def obtain(self, dest):
     url, rev = self.get_url_rev()
     if rev:
         rev_options = [rev]
         rev_display = ' (to revision %s)' % rev
     else:
         rev_options = []
         rev_display = ''
     if self.check_destination(dest, url, rev_options, rev_display):
         logger.info(
             'Cloning hg %s%s to %s',
             url,
             rev_display,
             display_path(dest),
         )
         call_subprocess([self.cmd, 'clone', '--noupdate', '-q', url, dest])
         call_subprocess([self.cmd, 'update', '-q'] + rev_options, cwd=dest)
Ejemplo n.º 48
0
 def obtain(self, dest):
     url, rev = self.get_url_rev()
     if rev:
         rev_options = [rev]
         rev_display = ' (to revision %s)' % rev
     else:
         rev_options = []
         rev_display = ''
     if self.check_destination(dest, url, rev_options, rev_display):
         logger.info(
             'Cloning hg %s%s to %s',
             url,
             rev_display,
             display_path(dest),
         )
         call_subprocess([self.cmd, 'clone', '--noupdate', '-q', url, dest])
         call_subprocess([self.cmd, 'update', '-q'] + rev_options, cwd=dest)
Ejemplo n.º 49
0
    def __build_one(self, req, tempd):
        base_args = [
            sys.executable, '-c',
            "import setuptools;__file__=%r;"
            "exec(compile(open(__file__).read().replace('\\r\\n', '\\n'), "
            "__file__, 'exec'))" % req.setup_py
        ] + list(self.global_options)

        logger.info('Running setup.py bdist_wheel for %s', req.name)
        logger.debug('Destination directory: %s', tempd)
        wheel_args = base_args + ['bdist_wheel', '-d', tempd] \
            + self.build_options
        try:
            call_subprocess(wheel_args, cwd=req.source_dir, show_stdout=False)
            return True
        except:
            logger.error('Failed building wheel for %s', req.name)
            return False
Ejemplo n.º 50
0
    def __build_one(self, req, tempd, python_tag=None):
        base_args = self._base_setup_args(req)

        spin_message = "Running setup.py bdist_wheel for %s" % (req.name,)
        with open_spinner(spin_message) as spinner:
            logger.debug("Destination directory: %s", tempd)
            wheel_args = base_args + ["bdist_wheel", "-d", tempd] + self.build_options

            if python_tag is not None:
                wheel_args += ["--python-tag", python_tag]

            try:
                call_subprocess(wheel_args, cwd=req.setup_py_dir, show_stdout=False, spinner=spinner)
                return True
            except:
                spinner.finish("error")
                logger.error("Failed building wheel for %s", req.name)
                return False
Ejemplo n.º 51
0
    def __build_one(self, req, tempd):
        base_args = [
            sys.executable, '-c',
            "import setuptools;__file__=%r;"
            "exec(compile(open(__file__).read().replace('\\r\\n', '\\n'), "
            "__file__, 'exec'))" % req.setup_py
        ] + list(self.global_options)

        logger.info('Running setup.py bdist_wheel for %s', req.name)
        logger.debug('Destination directory: %s', tempd)
        wheel_args = base_args + ['bdist_wheel', '-d', tempd] \
            + self.build_options
        try:
            call_subprocess(wheel_args, cwd=req.source_dir, show_stdout=False)
            return True
        except:
            logger.error('Failed building wheel for %s', req.name)
            return False
Ejemplo n.º 52
0
 def run(self):
     if getattr(self.distribution, 'salt_installing_pyyaml_windows',
                None) is None:
         print('This command is not meant to be called on it\'s own')
         exit(1)
     import platform
     from pip.utils import call_subprocess
     from pip.utils.logging import indent_log
     platform_bits, _ = platform.architecture()
     call_arguments = ['easy_install', '-Z']
     if platform_bits == '64bit':
         call_arguments.append(
             uri_to_resource('64/PyYAML-3.11.win-amd64-py2.7.exe'))
     else:
         call_arguments.append(
             uri_to_resource('32/PyYAML-3.11.win32-py2.7.exe'))
     with indent_log():
         call_subprocess(call_arguments)
Ejemplo n.º 53
0
Archivo: setup.py Proyecto: iquaba/salt
 def run(self):
     if getattr(self.distribution, 'salt_installing_pycrypto_windows', None) is None:
         print('This command is not meant to be called on it\'s own')
         exit(1)
     import platform
     from pip.utils import call_subprocess
     from pip.utils.logging import indent_log
     platform_bits, _ = platform.architecture()
     call_arguments = ['pip', 'install', 'wheel']
     if platform_bits == '64bit':
         call_arguments.append(
             'http://repo.saltstack.com/windows/dependencies/64/pycrypto-2.6.1-cp27-none-win_amd64.whl'
         )
     else:
         call_arguments.append(
             'http://repo.saltstack.com/windows/dependencies/32/pycrypto-2.6.1-cp27-none-win32.whl'
         )
     with indent_log():
         call_subprocess(call_arguments)
Ejemplo n.º 54
0
 def run(self):
     if getattr(self.distribution, 'salt_installing_pycrypto_windows', None) is None:
         print('This command is not meant to be called on it\'s own')
         exit(1)
     import platform
     from pip.utils import call_subprocess
     from pip.utils.logging import indent_log
     platform_bits, _ = platform.architecture()
     call_arguments = ['pip', 'install', 'wheel']
     if platform_bits == '64bit':
         call_arguments.append(
             'http://repo.saltstack.com/windows/dependencies/64/pycrypto-2.6.1-cp27-none-win_amd64.whl'
         )
     else:
         call_arguments.append(
             'http://repo.saltstack.com/windows/dependencies/32/pycrypto-2.6.1-cp27-none-win32.whl'
         )
     with indent_log():
         call_subprocess(call_arguments)
Ejemplo n.º 55
0
 def get_tag_revs(self, svn_tag_url):
     stdout = call_subprocess([self.cmd, 'ls', '-v', svn_tag_url],
                              show_stdout=False)
     results = []
     for line in stdout.splitlines():
         parts = line.split()
         rev = int(parts[0])
         tag = parts[-1].strip('/')
         results.append((tag, rev))
     return results
Ejemplo n.º 56
0
Archivo: setup.py Proyecto: bryson/salt
 def run(self):
     if getattr(self.distribution, 'salt_installing_pyyaml_windows', None) is None:
         print('This command is not meant to be called on it\'s own')
         exit(1)
     import platform
     from pip.utils import call_subprocess
     from pip.utils.logging import indent_log
     platform_bits, _ = platform.architecture()
     call_arguments = ['easy_install', '-Z']
     if platform_bits == '64bit':
         call_arguments.append(
             'https://repo.saltstack.com/windows/dependencies/64/PyYAML-3.11.win-amd64-py2.7.exe'
         )
     else:
         call_arguments.append(
             'https://repo.saltstack.com/windows/dependencies/32/PyYAML-3.11.win32-py2.7.exe'
         )
     with indent_log():
         call_subprocess(call_arguments)
Ejemplo n.º 57
0
 def get_tag_revs(self, svn_tag_url):
     stdout = call_subprocess(
         [self.cmd, 'ls', '-v', svn_tag_url], show_stdout=False)
     results = []
     for line in stdout.splitlines():
         parts = line.split()
         rev = int(parts[0])
         tag = parts[-1].strip('/')
         results.append((tag, rev))
     return results
    def __build_one(self, req, tempd, python_tag=None):
        base_args = self._base_setup_args(req)

        spin_message = 'Running setup.py bdist_wheel for %s' % (req.name,)
        with open_spinner(spin_message) as spinner:
            logger.debug('Destination book: %s', tempd)
            wheel_args = base_args + ['bdist_wheel', '-d', tempd] \
                + self.build_options

            if python_tag is not None:
                wheel_args += ["--python-tag", python_tag]

            try:
                call_subprocess(wheel_args, cwd=req.setup_py_dir,
                                show_stdout=False, spinner=spinner)
                return True
            except:
                spinner.finish("error")
                logger.error('Failed building wheel for %s', req.name)
                return False
Ejemplo n.º 59
0
 def get_tag_revs(self, location):
     tags = call_subprocess(
         [self.cmd, 'tags'], show_stdout=False, cwd=location)
     tag_revs = []
     for line in tags.splitlines():
         tags_match = re.search(r'([.\w-]+)\s*(.*)$', line)
         if tags_match:
             tag = tags_match.group(1)
             rev = tags_match.group(2)
             tag_revs.append((rev.strip(), tag.strip()))
     return dict(tag_revs)
Ejemplo n.º 60
0
 def get_tag_revs(self, location):
     tags = call_subprocess(
         [self.cmd, 'tags'], show_stdout=False, cwd=location)
     tag_revs = []
     for line in tags.splitlines():
         tags_match = re.search(r'([.\w-]+)\s*(.*)$', line)
         if tags_match:
             tag = tags_match.group(1)
             rev = tags_match.group(2)
             tag_revs.append((rev.strip(), tag.strip()))
     return dict(tag_revs)