Python pkg_resources 模块,EGG_DIST 实例源码

我们从Python开源项目中,提取了以下13个代码示例,用于说明如何使用pkg_resources.EGG_DIST

项目:whoseline    作者:bmorris3    | 项目源码 | 文件源码
def run(self):
        strategies = ['local_directory', 'local_file', 'index']
        dist = None

        # First, remove any previously imported versions of astropy_helpers;
        # this is necessary for nested installs where one package's installer
        # is installing another package via setuptools.sandbox.run_setup, as in
        # the case of setup_requires
        for key in list(sys.modules):
            try:
                if key == PACKAGE_NAME or key.startswith(PACKAGE_NAME + '.'):
                    del sys.modules[key]
            except AttributeError:
                # Sometimes mysterious non-string things can turn up in
                # sys.modules
                continue

        # Check to see if the path is a submodule
        self.is_submodule = self._check_submodule()

        for strategy in strategies:
            method = getattr(self, 'get_{0}_dist'.format(strategy))
            dist = method()
            if dist is not None:
                break
        else:
            raise _AHBootstrapSystemExit(
                "No source found for the {0!r} package; {0} must be "
                "available and importable as a prerequisite to building "
                "or installing this package.".format(PACKAGE_NAME))

        # This is a bit hacky, but if astropy_helpers was loaded from a
        # directory/submodule its Distribution object gets a "precedence" of
        # "DEVELOP_DIST".  However, in other cases it gets a precedence of
        # "EGG_DIST".  However, when activing the distribution it will only be
        # placed early on sys.path if it is treated as an EGG_DIST, so always
        # do that
        dist = dist.clone(precedence=pkg_resources.EGG_DIST)

        # Otherwise we found a version of astropy-helpers, so we're done
        # Just active the found distribution on sys.path--if we did a
        # download this usually happens automatically but it doesn't hurt to
        # do it again
        # Note: Adding the dist to the global working set also activates it
        # (makes it importable on sys.path) by default.

        try:
            pkg_resources.working_set.add(dist, replace=True)
        except TypeError:
            # Some (much) older versions of setuptools do not have the
            # replace=True option here.  These versions are old enough that all
            # bets may be off anyways, but it's easy enough to work around just
            # in case...
            if dist.key in pkg_resources.working_set.by_key:
                del pkg_resources.working_set.by_key[dist.key]
            pkg_resources.working_set.add(dist)
项目:dust_extinction    作者:karllark    | 项目源码 | 文件源码
def run(self):
        strategies = ['local_directory', 'local_file', 'index']
        dist = None

        # First, remove any previously imported versions of astropy_helpers;
        # this is necessary for nested installs where one package's installer
        # is installing another package via setuptools.sandbox.run_setup, as in
        # the case of setup_requires
        for key in list(sys.modules):
            try:
                if key == PACKAGE_NAME or key.startswith(PACKAGE_NAME + '.'):
                    del sys.modules[key]
            except AttributeError:
                # Sometimes mysterious non-string things can turn up in
                # sys.modules
                continue

        # Check to see if the path is a submodule
        self.is_submodule = self._check_submodule()

        for strategy in strategies:
            method = getattr(self, 'get_{0}_dist'.format(strategy))
            dist = method()
            if dist is not None:
                break
        else:
            raise _AHBootstrapSystemExit(
                "No source found for the {0!r} package; {0} must be "
                "available and importable as a prerequisite to building "
                "or installing this package.".format(PACKAGE_NAME))

        # This is a bit hacky, but if astropy_helpers was loaded from a
        # directory/submodule its Distribution object gets a "precedence" of
        # "DEVELOP_DIST".  However, in other cases it gets a precedence of
        # "EGG_DIST".  However, when activing the distribution it will only be
        # placed early on sys.path if it is treated as an EGG_DIST, so always
        # do that
        dist = dist.clone(precedence=pkg_resources.EGG_DIST)

        # Otherwise we found a version of astropy-helpers, so we're done
        # Just active the found distribution on sys.path--if we did a
        # download this usually happens automatically but it doesn't hurt to
        # do it again
        # Note: Adding the dist to the global working set also activates it
        # (makes it importable on sys.path) by default.

        try:
            pkg_resources.working_set.add(dist, replace=True)
        except TypeError:
            # Some (much) older versions of setuptools do not have the
            # replace=True option here.  These versions are old enough that all
            # bets may be off anyways, but it's easy enough to work around just
            # in case...
            if dist.key in pkg_resources.working_set.by_key:
                del pkg_resources.working_set.by_key[dist.key]
            pkg_resources.working_set.add(dist)
项目:thejoker    作者:adrn    | 项目源码 | 文件源码
def run(self):
        strategies = ['local_directory', 'local_file', 'index']
        dist = None

        # First, remove any previously imported versions of astropy_helpers;
        # this is necessary for nested installs where one package's installer
        # is installing another package via setuptools.sandbox.run_setup, as in
        # the case of setup_requires
        for key in list(sys.modules):
            try:
                if key == PACKAGE_NAME or key.startswith(PACKAGE_NAME + '.'):
                    del sys.modules[key]
            except AttributeError:
                # Sometimes mysterious non-string things can turn up in
                # sys.modules
                continue

        # Check to see if the path is a submodule
        self.is_submodule = self._check_submodule()

        for strategy in strategies:
            method = getattr(self, 'get_{0}_dist'.format(strategy))
            dist = method()
            if dist is not None:
                break
        else:
            raise _AHBootstrapSystemExit(
                "No source found for the {0!r} package; {0} must be "
                "available and importable as a prerequisite to building "
                "or installing this package.".format(PACKAGE_NAME))

        # This is a bit hacky, but if astropy_helpers was loaded from a
        # directory/submodule its Distribution object gets a "precedence" of
        # "DEVELOP_DIST".  However, in other cases it gets a precedence of
        # "EGG_DIST".  However, when activing the distribution it will only be
        # placed early on sys.path if it is treated as an EGG_DIST, so always
        # do that
        dist = dist.clone(precedence=pkg_resources.EGG_DIST)

        # Otherwise we found a version of astropy-helpers, so we're done
        # Just active the found distribution on sys.path--if we did a
        # download this usually happens automatically but it doesn't hurt to
        # do it again
        # Note: Adding the dist to the global working set also activates it
        # (makes it importable on sys.path) by default.

        try:
            pkg_resources.working_set.add(dist, replace=True)
        except TypeError:
            # Some (much) older versions of setuptools do not have the
            # replace=True option here.  These versions are old enough that all
            # bets may be off anyways, but it's easy enough to work around just
            # in case...
            if dist.key in pkg_resources.working_set.by_key:
                del pkg_resources.working_set.by_key[dist.key]
            pkg_resources.working_set.add(dist)
项目:fiasco    作者:wtbarnes    | 项目源码 | 文件源码
def run(self):
        strategies = ['local_directory', 'local_file', 'index']
        dist = None

        # First, remove any previously imported versions of astropy_helpers;
        # this is necessary for nested installs where one package's installer
        # is installing another package via setuptools.sandbox.run_setup, as in
        # the case of setup_requires
        for key in list(sys.modules):
            try:
                if key == PACKAGE_NAME or key.startswith(PACKAGE_NAME + '.'):
                    del sys.modules[key]
            except AttributeError:
                # Sometimes mysterious non-string things can turn up in
                # sys.modules
                continue

        # Check to see if the path is a submodule
        self.is_submodule = self._check_submodule()

        for strategy in strategies:
            method = getattr(self, 'get_{0}_dist'.format(strategy))
            dist = method()
            if dist is not None:
                break
        else:
            raise _AHBootstrapSystemExit(
                "No source found for the {0!r} package; {0} must be "
                "available and importable as a prerequisite to building "
                "or installing this package.".format(PACKAGE_NAME))

        # This is a bit hacky, but if astropy_helpers was loaded from a
        # directory/submodule its Distribution object gets a "precedence" of
        # "DEVELOP_DIST".  However, in other cases it gets a precedence of
        # "EGG_DIST".  However, when activing the distribution it will only be
        # placed early on sys.path if it is treated as an EGG_DIST, so always
        # do that
        dist = dist.clone(precedence=pkg_resources.EGG_DIST)

        # Otherwise we found a version of astropy-helpers, so we're done
        # Just active the found distribution on sys.path--if we did a
        # download this usually happens automatically but it doesn't hurt to
        # do it again
        # Note: Adding the dist to the global working set also activates it
        # (makes it importable on sys.path) by default.

        try:
            pkg_resources.working_set.add(dist, replace=True)
        except TypeError:
            # Some (much) older versions of setuptools do not have the
            # replace=True option here.  These versions are old enough that all
            # bets may be off anyways, but it's easy enough to work around just
            # in case...
            if dist.key in pkg_resources.working_set.by_key:
                del pkg_resources.working_set.by_key[dist.key]
            pkg_resources.working_set.add(dist)
项目:lombscargle    作者:jakevdp    | 项目源码 | 文件源码
def run(self):
        strategies = ['local_directory', 'local_file', 'index']
        dist = None

        # First, remove any previously imported versions of astropy_helpers;
        # this is necessary for nested installs where one package's installer
        # is installing another package via setuptools.sandbox.run_setup, as in
        # the case of setup_requires
        for key in list(sys.modules):
            try:
                if key == PACKAGE_NAME or key.startswith(PACKAGE_NAME + '.'):
                    del sys.modules[key]
            except AttributeError:
                # Sometimes mysterious non-string things can turn up in
                # sys.modules
                continue

        # Check to see if the path is a submodule
        self.is_submodule = self._check_submodule()

        for strategy in strategies:
            method = getattr(self, 'get_{0}_dist'.format(strategy))
            dist = method()
            if dist is not None:
                break
        else:
            raise _AHBootstrapSystemExit(
                "No source found for the {0!r} package; {0} must be "
                "available and importable as a prerequisite to building "
                "or installing this package.".format(PACKAGE_NAME))

        # This is a bit hacky, but if astropy_helpers was loaded from a
        # directory/submodule its Distribution object gets a "precedence" of
        # "DEVELOP_DIST".  However, in other cases it gets a precedence of
        # "EGG_DIST".  However, when activing the distribution it will only be
        # placed early on sys.path if it is treated as an EGG_DIST, so always
        # do that
        dist = dist.clone(precedence=pkg_resources.EGG_DIST)

        # Otherwise we found a version of astropy-helpers, so we're done
        # Just active the found distribution on sys.path--if we did a
        # download this usually happens automatically but it doesn't hurt to
        # do it again
        # Note: Adding the dist to the global working set also activates it
        # (makes it importable on sys.path) by default.

        try:
            pkg_resources.working_set.add(dist, replace=True)
        except TypeError:
            # Some (much) older versions of setuptools do not have the
            # replace=True option here.  These versions are old enough that all
            # bets may be off anyways, but it's easy enough to work around just
            # in case...
            if dist.key in pkg_resources.working_set.by_key:
                del pkg_resources.working_set.by_key[dist.key]
            pkg_resources.working_set.add(dist)
项目:ChiantiPy    作者:chianti-atomic    | 项目源码 | 文件源码
def run(self):
        strategies = ['local_directory', 'local_file', 'index']
        dist = None

        # First, remove any previously imported versions of astropy_helpers;
        # this is necessary for nested installs where one package's installer
        # is installing another package via setuptools.sandbox.run_setup, as in
        # the case of setup_requires
        for key in list(sys.modules):
            try:
                if key == PACKAGE_NAME or key.startswith(PACKAGE_NAME + '.'):
                    del sys.modules[key]
            except AttributeError:
                # Sometimes mysterious non-string things can turn up in
                # sys.modules
                continue

        # Check to see if the path is a submodule
        self.is_submodule = self._check_submodule()

        for strategy in strategies:
            method = getattr(self, 'get_{0}_dist'.format(strategy))
            dist = method()
            if dist is not None:
                break
        else:
            raise _AHBootstrapSystemExit(
                "No source found for the {0!r} package; {0} must be "
                "available and importable as a prerequisite to building "
                "or installing this package.".format(PACKAGE_NAME))

        # This is a bit hacky, but if astropy_helpers was loaded from a
        # directory/submodule its Distribution object gets a "precedence" of
        # "DEVELOP_DIST".  However, in other cases it gets a precedence of
        # "EGG_DIST".  However, when activing the distribution it will only be
        # placed early on sys.path if it is treated as an EGG_DIST, so always
        # do that
        dist = dist.clone(precedence=pkg_resources.EGG_DIST)

        # Otherwise we found a version of astropy-helpers, so we're done
        # Just active the found distribution on sys.path--if we did a
        # download this usually happens automatically but it doesn't hurt to
        # do it again
        # Note: Adding the dist to the global working set also activates it
        # (makes it importable on sys.path) by default.

        try:
            pkg_resources.working_set.add(dist, replace=True)
        except TypeError:
            # Some (much) older versions of setuptools do not have the
            # replace=True option here.  These versions are old enough that all
            # bets may be off anyways, but it's easy enough to work around just
            # in case...
            if dist.key in pkg_resources.working_set.by_key:
                del pkg_resources.working_set.by_key[dist.key]
            pkg_resources.working_set.add(dist)
项目:specviz    作者:spacetelescope    | 项目源码 | 文件源码
def run(self):
        strategies = ['local_directory', 'local_file', 'index']
        dist = None

        # First, remove any previously imported versions of astropy_helpers;
        # this is necessary for nested installs where one package's installer
        # is installing another package via setuptools.sandbox.run_setup, as in
        # the case of setup_requires
        for key in list(sys.modules):
            try:
                if key == PACKAGE_NAME or key.startswith(PACKAGE_NAME + '.'):
                    del sys.modules[key]
            except AttributeError:
                # Sometimes mysterious non-string things can turn up in
                # sys.modules
                continue

        # Check to see if the path is a submodule
        self.is_submodule = self._check_submodule()

        for strategy in strategies:
            method = getattr(self, 'get_{0}_dist'.format(strategy))
            dist = method()
            if dist is not None:
                break
        else:
            raise _AHBootstrapSystemExit(
                "No source found for the {0!r} package; {0} must be "
                "available and importable as a prerequisite to building "
                "or installing this package.".format(PACKAGE_NAME))

        # This is a bit hacky, but if astropy_helpers was loaded from a
        # directory/submodule its Distribution object gets a "precedence" of
        # "DEVELOP_DIST".  However, in other cases it gets a precedence of
        # "EGG_DIST".  However, when activing the distribution it will only be
        # placed early on sys.path if it is treated as an EGG_DIST, so always
        # do that
        dist = dist.clone(precedence=pkg_resources.EGG_DIST)

        # Otherwise we found a version of astropy-helpers, so we're done
        # Just active the found distribution on sys.path--if we did a
        # download this usually happens automatically but it doesn't hurt to
        # do it again
        # Note: Adding the dist to the global working set also activates it
        # (makes it importable on sys.path) by default.

        try:
            pkg_resources.working_set.add(dist, replace=True)
        except TypeError:
            # Some (much) older versions of setuptools do not have the
            # replace=True option here.  These versions are old enough that all
            # bets may be off anyways, but it's easy enough to work around just
            # in case...
            if dist.key in pkg_resources.working_set.by_key:
                del pkg_resources.working_set.by_key[dist.key]
            pkg_resources.working_set.add(dist)
项目:carsus    作者:tardis-sn    | 项目源码 | 文件源码
def run(self):
        strategies = ['local_directory', 'local_file', 'index']
        dist = None

        # First, remove any previously imported versions of astropy_helpers;
        # this is necessary for nested installs where one package's installer
        # is installing another package via setuptools.sandbox.run_setup, as in
        # the case of setup_requires
        for key in list(sys.modules):
            try:
                if key == PACKAGE_NAME or key.startswith(PACKAGE_NAME + '.'):
                    del sys.modules[key]
            except AttributeError:
                # Sometimes mysterious non-string things can turn up in
                # sys.modules
                continue

        # Check to see if the path is a submodule
        self.is_submodule = self._check_submodule()

        for strategy in strategies:
            method = getattr(self, 'get_{0}_dist'.format(strategy))
            dist = method()
            if dist is not None:
                break
        else:
            raise _AHBootstrapSystemExit(
                "No source found for the {0!r} package; {0} must be "
                "available and importable as a prerequisite to building "
                "or installing this package.".format(PACKAGE_NAME))

        # This is a bit hacky, but if astropy_helpers was loaded from a
        # directory/submodule its Distribution object gets a "precedence" of
        # "DEVELOP_DIST".  However, in other cases it gets a precedence of
        # "EGG_DIST".  However, when activing the distribution it will only be
        # placed early on sys.path if it is treated as an EGG_DIST, so always
        # do that
        dist = dist.clone(precedence=pkg_resources.EGG_DIST)

        # Otherwise we found a version of astropy-helpers, so we're done
        # Just active the found distribution on sys.path--if we did a
        # download this usually happens automatically but it doesn't hurt to
        # do it again
        # Note: Adding the dist to the global working set also activates it
        # (makes it importable on sys.path) by default.

        try:
            pkg_resources.working_set.add(dist, replace=True)
        except TypeError:
            # Some (much) older versions of setuptools do not have the
            # replace=True option here.  These versions are old enough that all
            # bets may be off anyways, but it's easy enough to work around just
            # in case...
            if dist.key in pkg_resources.working_set.by_key:
                del pkg_resources.working_set.by_key[dist.key]
            pkg_resources.working_set.add(dist)
项目:saba    作者:astropy    | 项目源码 | 文件源码
def run(self):
        strategies = ['local_directory', 'local_file', 'index']
        dist = None

        # First, remove any previously imported versions of astropy_helpers;
        # this is necessary for nested installs where one package's installer
        # is installing another package via setuptools.sandbox.run_setup, as in
        # the case of setup_requires
        for key in list(sys.modules):
            try:
                if key == PACKAGE_NAME or key.startswith(PACKAGE_NAME + '.'):
                    del sys.modules[key]
            except AttributeError:
                # Sometimes mysterious non-string things can turn up in
                # sys.modules
                continue

        # Check to see if the path is a submodule
        self.is_submodule = self._check_submodule()

        for strategy in strategies:
            method = getattr(self, 'get_{0}_dist'.format(strategy))
            dist = method()
            if dist is not None:
                break
        else:
            raise _AHBootstrapSystemExit(
                "No source found for the {0!r} package; {0} must be "
                "available and importable as a prerequisite to building "
                "or installing this package.".format(PACKAGE_NAME))

        # This is a bit hacky, but if astropy_helpers was loaded from a
        # directory/submodule its Distribution object gets a "precedence" of
        # "DEVELOP_DIST".  However, in other cases it gets a precedence of
        # "EGG_DIST".  However, when activing the distribution it will only be
        # placed early on sys.path if it is treated as an EGG_DIST, so always
        # do that
        dist = dist.clone(precedence=pkg_resources.EGG_DIST)

        # Otherwise we found a version of astropy-helpers, so we're done
        # Just active the found distribution on sys.path--if we did a
        # download this usually happens automatically but it doesn't hurt to
        # do it again
        # Note: Adding the dist to the global working set also activates it
        # (makes it importable on sys.path) by default.

        try:
            pkg_resources.working_set.add(dist, replace=True)
        except TypeError:
            # Some (much) older versions of setuptools do not have the
            # replace=True option here.  These versions are old enough that all
            # bets may be off anyways, but it's easy enough to work around just
            # in case...
            if dist.key in pkg_resources.working_set.by_key:
                del pkg_resources.working_set.by_key[dist.key]
            pkg_resources.working_set.add(dist)
项目:ccsdspy    作者:ddasilva    | 项目源码 | 文件源码
def run(self):
        strategies = ['local_directory', 'local_file', 'index']
        dist = None

        # First, remove any previously imported versions of astropy_helpers;
        # this is necessary for nested installs where one package's installer
        # is installing another package via setuptools.sandbox.run_setup, as in
        # the case of setup_requires
        for key in list(sys.modules):
            try:
                if key == PACKAGE_NAME or key.startswith(PACKAGE_NAME + '.'):
                    del sys.modules[key]
            except AttributeError:
                # Sometimes mysterious non-string things can turn up in
                # sys.modules
                continue

        # Check to see if the path is a submodule
        self.is_submodule = self._check_submodule()

        for strategy in strategies:
            method = getattr(self, 'get_{0}_dist'.format(strategy))
            dist = method()
            if dist is not None:
                break
        else:
            raise _AHBootstrapSystemExit(
                "No source found for the {0!r} package; {0} must be "
                "available and importable as a prerequisite to building "
                "or installing this package.".format(PACKAGE_NAME))

        # This is a bit hacky, but if astropy_helpers was loaded from a
        # directory/submodule its Distribution object gets a "precedence" of
        # "DEVELOP_DIST".  However, in other cases it gets a precedence of
        # "EGG_DIST".  However, when activing the distribution it will only be
        # placed early on sys.path if it is treated as an EGG_DIST, so always
        # do that
        dist = dist.clone(precedence=pkg_resources.EGG_DIST)

        # Otherwise we found a version of astropy-helpers, so we're done
        # Just active the found distribution on sys.path--if we did a
        # download this usually happens automatically but it doesn't hurt to
        # do it again
        # Note: Adding the dist to the global working set also activates it
        # (makes it importable on sys.path) by default.

        try:
            pkg_resources.working_set.add(dist, replace=True)
        except TypeError:
            # Some (much) older versions of setuptools do not have the
            # replace=True option here.  These versions are old enough that all
            # bets may be off anyways, but it's easy enough to work around just
            # in case...
            if dist.key in pkg_resources.working_set.by_key:
                del pkg_resources.working_set.by_key[dist.key]
            pkg_resources.working_set.add(dist)
项目:sbpy    作者:mommermi    | 项目源码 | 文件源码
def run(self):
        strategies = ['local_directory', 'local_file', 'index']
        dist = None

        # First, remove any previously imported versions of astropy_helpers;
        # this is necessary for nested installs where one package's installer
        # is installing another package via setuptools.sandbox.run_setup, as in
        # the case of setup_requires
        for key in list(sys.modules):
            try:
                if key == PACKAGE_NAME or key.startswith(PACKAGE_NAME + '.'):
                    del sys.modules[key]
            except AttributeError:
                # Sometimes mysterious non-string things can turn up in
                # sys.modules
                continue

        # Check to see if the path is a submodule
        self.is_submodule = self._check_submodule()

        for strategy in strategies:
            method = getattr(self, 'get_{0}_dist'.format(strategy))
            dist = method()
            if dist is not None:
                break
        else:
            raise _AHBootstrapSystemExit(
                "No source found for the {0!r} package; {0} must be "
                "available and importable as a prerequisite to building "
                "or installing this package.".format(PACKAGE_NAME))

        # This is a bit hacky, but if astropy_helpers was loaded from a
        # directory/submodule its Distribution object gets a "precedence" of
        # "DEVELOP_DIST".  However, in other cases it gets a precedence of
        # "EGG_DIST".  However, when activing the distribution it will only be
        # placed early on sys.path if it is treated as an EGG_DIST, so always
        # do that
        dist = dist.clone(precedence=pkg_resources.EGG_DIST)

        # Otherwise we found a version of astropy-helpers, so we're done
        # Just active the found distribution on sys.path--if we did a
        # download this usually happens automatically but it doesn't hurt to
        # do it again
        # Note: Adding the dist to the global working set also activates it
        # (makes it importable on sys.path) by default.

        try:
            pkg_resources.working_set.add(dist, replace=True)
        except TypeError:
            # Some (much) older versions of setuptools do not have the
            # replace=True option here.  These versions are old enough that all
            # bets may be off anyways, but it's easy enough to work around just
            # in case...
            if dist.key in pkg_resources.working_set.by_key:
                del pkg_resources.working_set.by_key[dist.key]
            pkg_resources.working_set.add(dist)
项目:synthesizAR    作者:wtbarnes    | 项目源码 | 文件源码
def run(self):
        strategies = ['local_directory', 'local_file', 'index']
        dist = None

        # First, remove any previously imported versions of astropy_helpers;
        # this is necessary for nested installs where one package's installer
        # is installing another package via setuptools.sandbox.run_setup, as in
        # the case of setup_requires
        for key in list(sys.modules):
            try:
                if key == PACKAGE_NAME or key.startswith(PACKAGE_NAME + '.'):
                    del sys.modules[key]
            except AttributeError:
                # Sometimes mysterious non-string things can turn up in
                # sys.modules
                continue

        # Check to see if the path is a submodule
        self.is_submodule = self._check_submodule()

        for strategy in strategies:
            method = getattr(self, 'get_{0}_dist'.format(strategy))
            dist = method()
            if dist is not None:
                break
        else:
            raise _AHBootstrapSystemExit(
                "No source found for the {0!r} package; {0} must be "
                "available and importable as a prerequisite to building "
                "or installing this package.".format(PACKAGE_NAME))

        # This is a bit hacky, but if astropy_helpers was loaded from a
        # directory/submodule its Distribution object gets a "precedence" of
        # "DEVELOP_DIST".  However, in other cases it gets a precedence of
        # "EGG_DIST".  However, when activing the distribution it will only be
        # placed early on sys.path if it is treated as an EGG_DIST, so always
        # do that
        dist = dist.clone(precedence=pkg_resources.EGG_DIST)

        # Otherwise we found a version of astropy-helpers, so we're done
        # Just active the found distribution on sys.path--if we did a
        # download this usually happens automatically but it doesn't hurt to
        # do it again
        # Note: Adding the dist to the global working set also activates it
        # (makes it importable on sys.path) by default.

        try:
            pkg_resources.working_set.add(dist, replace=True)
        except TypeError:
            # Some (much) older versions of setuptools do not have the
            # replace=True option here.  These versions are old enough that all
            # bets may be off anyways, but it's easy enough to work around just
            # in case...
            if dist.key in pkg_resources.working_set.by_key:
                del pkg_resources.working_set.by_key[dist.key]
            pkg_resources.working_set.add(dist)
项目:hips    作者:hipspy    | 项目源码 | 文件源码
def run(self):
        strategies = ['local_directory', 'local_file', 'index']
        dist = None

        # First, remove any previously imported versions of astropy_helpers;
        # this is necessary for nested installs where one package's installer
        # is installing another package via setuptools.sandbox.run_setup, as in
        # the case of setup_requires
        for key in list(sys.modules):
            try:
                if key == PACKAGE_NAME or key.startswith(PACKAGE_NAME + '.'):
                    del sys.modules[key]
            except AttributeError:
                # Sometimes mysterious non-string things can turn up in
                # sys.modules
                continue

        # Check to see if the path is a submodule
        self.is_submodule = self._check_submodule()

        for strategy in strategies:
            method = getattr(self, 'get_{0}_dist'.format(strategy))
            dist = method()
            if dist is not None:
                break
        else:
            raise _AHBootstrapSystemExit(
                "No source found for the {0!r} package; {0} must be "
                "available and importable as a prerequisite to building "
                "or installing this package.".format(PACKAGE_NAME))

        # This is a bit hacky, but if astropy_helpers was loaded from a
        # directory/submodule its Distribution object gets a "precedence" of
        # "DEVELOP_DIST".  However, in other cases it gets a precedence of
        # "EGG_DIST".  However, when activing the distribution it will only be
        # placed early on sys.path if it is treated as an EGG_DIST, so always
        # do that
        dist = dist.clone(precedence=pkg_resources.EGG_DIST)

        # Otherwise we found a version of astropy-helpers, so we're done
        # Just active the found distribution on sys.path--if we did a
        # download this usually happens automatically but it doesn't hurt to
        # do it again
        # Note: Adding the dist to the global working set also activates it
        # (makes it importable on sys.path) by default.

        try:
            pkg_resources.working_set.add(dist, replace=True)
        except TypeError:
            # Some (much) older versions of setuptools do not have the
            # replace=True option here.  These versions are old enough that all
            # bets may be off anyways, but it's easy enough to work around just
            # in case...
            if dist.key in pkg_resources.working_set.by_key:
                del pkg_resources.working_set.by_key[dist.key]
            pkg_resources.working_set.add(dist)