示例#1
0
    def run(self):
        # Lazy import here to allow pkgutils to bootstrap itself
        from pkglib.setuptools.buildout import install

        if not self.update:
            install(
                self.get_easy_install_cmd(index_url=self.index_url),
                self.args,
                prefer_final=not self.dev,
                force_upgrade=self.update,
            )
        else:
            # Update mode - call the pyupdate command
            cls = self.distribution.get_command_class("update")
            cmd = cls(
                self.distribution,
                dev=self.dev,
                everything=self.everything,
                third_party=self.third_party,
                source=self.source,
                eggs=self.eggs,
                index_url=self.index_url,
            )
            cmd.args = self.args
            cmd.ensure_finalized()
            cmd.no_cleanup = True
            cmd.run()

        self.execute(self.run_cleanup_in_subprocess, (), "Cleaning up site-packages")
示例#2
0
    def run(self):
        # Lazy import here to allow pkgutils to bootstrap itself
        from pkglib.setuptools.buildout import install
        from zc.buildout.easy_install import MissingDistribution

        if self.update:
            # Update mode - call the pyupdate command
            cls = self.distribution.get_command_class('update')

            cmd = cls(self.distribution,
                      dev=self.dev,
                      everything=self.everything,
                      third_party=self.third_party,
                      source=self.source,
                      eggs=self.eggs,
                      index_url=self.index_url)

            cmd.args = self.args
            cmd.ensure_finalized()
            cmd.no_cleanup = True
            cmd.run()
        else:
            try:
                cmd = get_easy_install_cmd(self.distribution,
                                           index_url=self.index_url)
                install(cmd, self.args,
                        eggs=self.egg_args,
                        prefer_final=not self.dev,
                        force_upgrade=False,
                        reinstall=True)
            except MissingDistribution as e:
                raise DistutilsOptionError(str(e))

        self.execute(self.run_cleanup_in_subprocess, (),
                     'Cleaning up site-packages')
示例#3
0
文件: base.py 项目: drkjam/pkglib
    def fetch_build_eggs(self, reqs, prefer_final=True, use_existing=False):
        """ Uses the buildout installer for fetching setup requirements.
            Mostly lifted from setuptools.dist

            Parameters
            ----------
            reqs : `list`
                List if package requirements
            prefer_final : `bool`
                Prefer non-dev versions of package dependencies
            use_existing : `bool`
                Will use eggs found in working set, and not try and update
                them if it can
        """
        # Lazy import for bootstrapping
        from pkglib.setuptools.buildout import install
        # Run the installer, set the option to add to global working_set
        # so other commands in this run can use the packages.

        # Setting build_only to false here now, as we don't
        # really need to have the feature whereby test and build eggs are
        # installed in the cwd(), it just makes a mess of people's home
        # directories.
        if hasattr(self, 'index_url'):
            url = self.maybe_add_simple_index(self.index_url)
        else:
            url = self.maybe_add_simple_index(CONFIG.pypi_url)
        cmd = self.get_easy_install_cmd(build_only=False, index_url=url)
        return install(cmd, reqs, add_to_global=True, prefer_final=prefer_final,
                       use_existing=use_existing)
示例#4
0
    def run(self):
        # Lazy import here to allow pkgutils to bootstrap itself
        from pkglib.setuptools.buildout import install
        from zc.buildout.easy_install import MissingDistribution

        if self.update:
            # Update mode - call the pyupdate command
            cls = self.distribution.get_command_class('update')

            cmd = cls(self.distribution,
                      dev=self.dev,
                      everything=self.everything,
                      third_party=self.third_party,
                      source=self.source,
                      eggs=self.eggs,
                      index_url=self.index_url)

            cmd.args = self.args
            cmd.ensure_finalized()
            cmd.no_cleanup = True
            cmd.run()
        else:
            try:
                cmd = get_easy_install_cmd(self.distribution,
                                           index_url=self.index_url)
                install(cmd,
                        self.args,
                        eggs=self.egg_args,
                        prefer_final=not self.dev,
                        force_upgrade=False,
                        reinstall=True)
            except MissingDistribution as e:
                raise DistutilsOptionError(str(e))

        self.execute(self.run_cleanup_in_subprocess, (),
                     'Cleaning up site-packages')
示例#5
0
def fetch_build_eggs(reqs, dist=None, prefer_final=True, use_existing=False,
                     add_to_env=False):
    """ Uses the buildout installer for fetching setup requirements.
        Mostly lifted from setuptools.dist

        Parameters
        ----------
        reqs : `list`
            List if package requirements
        dist : `distutils.dist.Distribution`
            the main distribution
        prefer_final : `bool`
            Prefer non-dev versions of package dependencies
        use_existing : `bool`
            Will use eggs found in working set, and not try and update them if
            it can
        add_to_env : `bool`
            whether distributions should be added to the virtual environment
    """
    # Lazy imports here to allow pkglib to bootstrap itself.
    from pkglib.setuptools.buildout import install

    # Run the installer and set the option to add to the global working_set
    # so that other commands in this run can use the packages straight away.

    # Setting build_only to false here now, as we don't want build eggs
    # installed in the cwd(), it just makes a mess of people's home directories.

    # Also setting pth_file to None in order to disable polluting virtual
    # environment with distributions required only during setup

    if not dist:
        dist = Distribution(attrs=dict(name="pkglib.fetcher", version="1.0.0"))
    cmd = get_easy_install_cmd(dist, exclude_scripts=not add_to_env)

    if not add_to_env:
        cmd.pth_file = None

    return install(cmd, reqs, add_to_global=True, prefer_final=prefer_final,
                   use_existing=use_existing)