コード例 #1
0
ファイル: setup.py プロジェクト: HuXufeng/prophet
    def with_project_on_sys_path(self, func):
        # Ensure metadata is up-to-date
        self.reinitialize_command('build_py', inplace=0)
        self.run_command('build_py')
        bpy_cmd = self.get_finalized_command("build_py")
        build_path = normalize_path(bpy_cmd.build_lib)

        # Build extensions
        self.reinitialize_command('egg_info', egg_base=build_path)
        self.run_command('egg_info')

        self.reinitialize_command('build_ext', inplace=0)
        self.run_command('build_ext')

        ei_cmd = self.get_finalized_command("egg_info")

        old_path = sys.path[:]
        old_modules = sys.modules.copy()

        try:
            sys.path.insert(0, normalize_path(ei_cmd.egg_base))
            working_set.__init__()
            add_activation_listener(lambda dist: dist.activate())
            require('%s==%s' % (ei_cmd.egg_name, ei_cmd.egg_version))
            func()
        finally:
            sys.path[:] = old_path
            sys.modules.clear()
            sys.modules.update(old_modules)
            working_set.__init__()
コード例 #2
0
ファイル: test_pkg_resources.py プロジェクト: pypa/setuptools
    def test_normalize_path_trailing_sep(self, unnormalized, normalized):
        """Ensure the trailing slash is cleaned for path comparison.

        See pypa/setuptools#1519.
        """
        result_from_unnormalized = pkg_resources.normalize_path(unnormalized)
        result_from_normalized = pkg_resources.normalize_path(normalized)
        assert result_from_unnormalized == result_from_normalized
コード例 #3
0
ファイル: develop.py プロジェクト: Ashaba/rms
 def _resolve_setup_path(egg_base, install_dir, egg_path):
     """
     Generate a path from egg_base back to '.' where the
     setup script resides and ensure that path points to the
     setup path from $install_dir/$egg_path.
     """
     path_to_setup = egg_base.replace(os.sep, '/').rstrip('/')
     if path_to_setup != os.curdir:
         path_to_setup = '../' * (path_to_setup.count('/') + 1)
     resolved = normalize_path(os.path.join(install_dir, egg_path, path_to_setup))
     if resolved != normalize_path(os.curdir):
         raise DistutilsOptionError(
             "Can't get a consistent path to setup script from"
             " installation directory", resolved, normalize_path(os.curdir))
     return path_to_setup
コード例 #4
0
    def run_tests(self):
        from pkg_resources import _namespace_packages
        import pytest

        # Purge modules under test from sys.modules. The test loader will
        # re-import them from the build location. Required when 2to3 is used
        # with namespace packages.
        if sys.version_info >= (3,) and \
                getattr(self.distribution, 'use_2to3', False):
            module = self.test_args[-1].split('.')[0]
            if module in _namespace_packages:
                del_modules = []
                if module in sys.modules:
                    del_modules.append(module)
                module += '.'
                for name in sys.modules:
                    if name.startswith(module):
                        del_modules.append(name)
                map(sys.modules.__delitem__, del_modules)

            ## Run on the build directory for 2to3-built code..
            ei_cmd = self.get_finalized_command("egg_info")
            self.test_args = [normalize_path(ei_cmd.egg_base)]

        errno = pytest.main(self.test_args)
        sys.exit(errno)
コード例 #5
0
ファイル: setup.py プロジェクト: rshk/ObjPack
    def run_tests(self):
        import pytest
        from pkg_resources import normalize_path, _namespace_packages

        # Purge modules under test from sys.modules. The test loader will
        # re-import them from the build location. Required when 2to3 is used
        # with namespace packages.
        if sys.version_info >= (3,) and getattr(self.distribution, 'use_2to3', False):
            #module = self.test_args[-1].split('.')[0]
            module = self.test_package_name
            if module in _namespace_packages:
                del_modules = []
                if module in sys.modules:
                    del_modules.append(module)
                module += '.'
                for name in sys.modules:
                    if name.startswith(module):
                        del_modules.append(name)
                map(sys.modules.__delitem__, del_modules)

            ## Run on the build directory for 2to3-built code
            ## This will prevent the old 2.x code from being found
            ## by py.test discovery mechanism, that apparently
            ## ignores sys.path..
            ei_cmd = self.get_finalized_command("egg_info")

            ## Replace the module name with normalized path
            #self.test_args[-1] = normalize_path(ei_cmd.egg_base)
            self.test_args.append(normalize_path(ei_cmd.egg_base))

        errno = pytest.main(self.test_args)
        sys.exit(errno)
コード例 #6
0
ファイル: bdist_bbfreeze.py プロジェクト: RyanHope/ccfreeze
    def run(self, wininst=False):
        # import bbfreeze only thenabout to run the command
        from bbfreeze import Freezer

        # get information from egg_info
        ei = self.get_finalized_command("egg_info")
        target = normalize_path(self.bdist_base)
        dist = Distribution(
            target,
            PathMetadata(target, os.path.abspath(ei.egg_info)),
            project_name=ei.egg_name)

        # install wrapper_Scripts into self.bdist_base == self.script_dir
        self.install_wrapper_scripts(dist)

        # now get a Freezer()
        f = Freezer(os.path.join(self.dist_dir,
                                 "%s-%s" % (ei.egg_name, ei.egg_version)))
        f.include_py = self.include_py

        # freeze each of the scripts
        for args in get_script_args(dist, wininst=wininst):
            name = args[0]
            if name.endswith('.exe') or name.endswith(".exe.manifest"):
                # skip .exes
                continue
            log.info('bbfreezing %s', os.path.join(self.script_dir, name))
            f.addScript(os.path.join(self.script_dir, name),
                        gui_only=name.endswith('.pyw'))
        # starts the freezing process
        f()
コード例 #7
0
ファイル: setup.py プロジェクト: pombredanne/macholib-1
    def add_project_to_sys_path(self):
        from pkg_resources import normalize_path, add_activation_listener
        from pkg_resources import working_set, require

        self.reinitialize_command('egg_info')
        self.run_command('egg_info')
        self.reinitialize_command('build_ext', inplace=1)
        self.run_command('build_ext')


        # Check if this distribution is already on sys.path
        # and remove that version, this ensures that the right
        # copy of the package gets tested.

        self.__old_path = sys.path[:]
        self.__old_modules = sys.modules.copy()


        ei_cmd = self.get_finalized_command('egg_info')
        sys.path.insert(0, normalize_path(ei_cmd.egg_base))
        sys.path.insert(1, os.path.dirname(__file__))

        # Strip the namespace packages defined in this distribution
        # from sys.modules, needed to reset the search path for
        # those modules.

        nspkgs = getattr(self.distribution, 'namespace_packages')
        if nspkgs is not None:
            for nm in nspkgs:
                del sys.modules[nm]

        # Reset pkg_resources state:
        add_activation_listener(lambda dist: dist.activate())
        working_set.__init__()
        require('%s==%s'%(ei_cmd.egg_name, ei_cmd.egg_version))
コード例 #8
0
ファイル: runner.py プロジェクト: agiledata/pkglib
 def find_distributions(path_item, only=False):  # @UnusedVariable
     d = [d for d in dists
          if normalize_path(os.path.join(base_d, d.location)) == path_item]
     assert len(d) == 1, ("Distribution on path [%s] should not have "
                          "been added to '.pth' file" % str(path_item))
     dists.remove(d[0])
     return []
コード例 #9
0
ファイル: develop.py プロジェクト: Orav/kbengine
    def finalize_options(self):
        ei = self.get_finalized_command("egg_info")
        if ei.broken_egg_info:
            raise DistutilsError(
            "Please rename %r to %r before using 'develop'"
            % (ei.egg_info, ei.broken_egg_info)
            )
        self.args = [ei.egg_name]




        easy_install.finalize_options(self)
        self.expand_basedirs()
        self.expand_dirs()
        # pick up setup-dir .egg files only: no .egg-info
        self.package_index.scan(glob.glob('*.egg'))

        self.egg_link = os.path.join(self.install_dir, ei.egg_name+'.egg-link')
        self.egg_base = ei.egg_base
        if self.egg_path is None:
            self.egg_path = os.path.abspath(ei.egg_base)

        target = normalize_path(self.egg_base)
        if normalize_path(os.path.join(self.install_dir, self.egg_path)) != target:
            raise DistutilsOptionError(
                "--egg-path must be a relative path from the install"
                " directory to "+target
        )

        # Make a distribution for the package's source
        self.dist = Distribution(
            target,
            PathMetadata(target, os.path.abspath(ei.egg_info)),
            project_name = ei.egg_name
        )

        p = self.egg_base.replace(os.sep,'/')
        if p!= os.curdir:
            p = '../' * (p.count('/')+1)
        self.setup_path = p
        p = normalize_path(os.path.join(self.install_dir, self.egg_path, p))
        if  p != normalize_path(os.curdir):
            raise DistutilsOptionError(
                "Can't get a consistent path to setup script from"
                " installation directory", p, normalize_path(os.curdir))
コード例 #10
0
 def test_add_from_site_is_ignored(self):
     location = '/test/location/does-not-have-to-exist'
     # PthDistributions expects all locations to be normalized
     location = pkg_resources.normalize_path(location)
     pth = PthDistributions('does-not_exist', [location, ])
     assert not pth.dirty
     pth.add(PRDistribution(location))
     assert not pth.dirty
コード例 #11
0
def main(path):
    patch_stdout_stderr()
    
    path = pkg_resources.normalize_path(path)
    moduleInstallationPrefix=path+os.sep+"inst"

    localSitePackages=localSitePackageFolder(moduleInstallationPrefix)
    
    addLocalSitePackageToPythonPath(moduleInstallationPrefix)

    os.makedirs(localSitePackages)
    
    # The preferred approach to install a package is to use pip...
    call_pip('pandas==0.22', localSitePackages)
#     # check that the installation worked
#    addLocalSitePackageToPythonPath(moduleInstallationPrefix)
#     import pandas# This fails intermittently

    # ...but - for some reason - pip breaks when we install the python synapse client
    # So we use 'setup' directly
    packageName = "synapseclient-1.9.2"
    
    if 'PYTHON_CLIENT_GITHUB_USERNAME' in os.environ and 'PYTHON_CLIENT_GITHUB_BRANCH' in os.environ:
        pythonClientGithubUsername = os.environ['PYTHON_CLIENT_GITHUB_USERNAME']
        pythonClientGithubBranch = os.environ['PYTHON_CLIENT_GITHUB_BRANCH']
        archivePrefix="synapsePythonClient-"+pythonClientGithubBranch
        archiveSuffix=".zip"
        url="https://github.com/"+pythonClientGithubUsername+"/synapsePythonClient/archive/"+pythonClientGithubBranch+archiveSuffix
    else:
        archivePrefix=packageName
        urlPrefix = "https://files.pythonhosted.org/packages/ed/fb/67055be256b6b0906d5627f3f39f5ba8db5737162ce619c04e8f9c2c2848/"
        archiveSuffix = ".tar.gz"
        url = urlPrefix+archivePrefix+archiveSuffix
    
    installPackage(packageName, url, archivePrefix, archiveSuffix, path, moduleInstallationPrefix)
        
    # check that the installation worked
    addLocalSitePackageToPythonPath(moduleInstallationPrefix)
    import synapseclient
    
    # When trying to 'synStore' a table we get the error:
    # pandas.Styler requires jinja2. Please install with `conda install Jinja2`
    # So let's install Jinja2 here:
    # https://stackoverflow.com/questions/43163201/pyinstaller-syntax-error-yield-inside-async-function-python-3-5-1

    # Jinja2 depends on MarkupSafe
    packageName = "MarkupSafe-1.0"
    linkPrefix = "https://pypi.python.org/packages/4d/de/32d741db316d8fdb7680822dd37001ef7a448255de9699ab4bfcbdf4172b/"
    installedPackageFolderName="markupsafe"
    simplePackageInstall(packageName, installedPackageFolderName, linkPrefix, path, localSitePackages)
    addLocalSitePackageToPythonPath(moduleInstallationPrefix)
    #import markupsafe  # This fails intermittently

    packageName = "Jinja2-2.8.1"
    linkPrefix = "https://pypi.python.org/packages/5f/bd/5815d4d925a2b8cbbb4b4960f018441b0c65f24ba29f3bdcfb3c8218a307/"
    installedPackageFolderName="jinja2"
    simplePackageInstall(packageName, installedPackageFolderName, linkPrefix, path, localSitePackages)
    addLocalSitePackageToPythonPath(moduleInstallationPrefix)
コード例 #12
0
ファイル: setup.py プロジェクト: benoit-pierre/pyobjc
    def add_project_to_sys_path(self):
        from pkg_resources import normalize_path, add_activation_listener
        from pkg_resources import working_set, require

        if getattr(self.distribution, 'use_2to3', False):

            # Using 2to3, cannot do this inplace:
            self.reinitialize_command('build_py', inplace=0)
            self.run_command('build_py')
            bpy_cmd = self.get_finalized_command("build_py")
            build_path = normalize_path(bpy_cmd.build_lib)

            self.reinitialize_command('egg_info', egg_base=build_path)
            self.run_command('egg_info')

            self.reinitialize_command('build_ext', inplace=0)
            self.run_command('build_ext')

        else:
            self.reinitialize_command('egg_info')
            self.run_command('egg_info')
            self.reinitialize_command('build_ext', inplace=1)
            self.run_command('build_ext')

        self.__old_path = sys.path[:]
        self.__old_modules = sys.modules.copy()

        if 'PyObjCTools' in sys.modules:
            del sys.modules['PyObjCTools']

        ei_cmd = self.get_finalized_command('egg_info')
        sys.path.insert(0, normalize_path(ei_cmd.egg_base))
        sys.path.insert(1, os.path.dirname(__file__))

        add_activation_listener(lambda dist: dist.activate())
        working_set.__init__()
        require('%s==%s'%(ei_cmd.egg_name, ei_cmd.egg_version))

        from PyObjCTools import TestSupport
        if os.path.realpath(os.path.dirname(TestSupport.__file__)) != os.path.realpath('Lib/PyObjCTools'):
            raise DistutilsError("Setting up test environment failed for 'PyObjCTools.TestSupport'")

        import objc
        if os.path.realpath(os.path.dirname(objc.__file__)) != os.path.realpath('Lib/objc'):
            raise DistutilsError("Setting up test environment failed for 'objc'")
コード例 #13
0
 def test_all_site_dirs(self, monkeypatch):
     """
     get_site_dirs should always return site dirs reported by
     site.getsitepackages.
     """
     path = normalize_path('/setuptools/test/site-packages')
     mock_gsp = lambda: [path]
     monkeypatch.setattr(site, 'getsitepackages', mock_gsp, raising=False)
     assert path in ei.get_site_dirs()
コード例 #14
0
ファイル: lint.py プロジェクト: Januson/subscription-manager
 def __init__(self, *args, **kwargs):
     ext_dir = pkg_resources.normalize_path('build_ext')
     dist = pkg_resources.Distribution(
         ext_dir,
         project_name='build_ext',
         metadata=pkg_resources.PathMetadata(ext_dir, ext_dir)
     )
     pkg_resources.working_set.add(dist)
     Flake8.__init__(self, *args, **kwargs)
コード例 #15
0
    def project_on_sys_path(self, include_dists=[]):
        with_2to3 = getattr(self.distribution, 'use_2to3', False)

        if with_2to3:
            # If we run 2to3 we can not do this inplace:

            # Ensure metadata is up-to-date
            self.reinitialize_command('build_py', inplace=0)
            self.run_command('build_py')
            bpy_cmd = self.get_finalized_command("build_py")
            build_path = normalize_path(bpy_cmd.build_lib)

            # Build extensions
            self.reinitialize_command('egg_info', egg_base=build_path)
            self.run_command('egg_info')

            self.reinitialize_command('build_ext', inplace=0)
            self.run_command('build_ext')
        else:
            # Without 2to3 inplace works fine:
            self.run_command('egg_info')

            # Build extensions in-place
            self.reinitialize_command('build_ext', inplace=1)
            self.run_command('build_ext')

        ei_cmd = self.get_finalized_command("egg_info")

        old_path = sys.path[:]
        old_modules = sys.modules.copy()

        try:
            project_path = normalize_path(ei_cmd.egg_base)
            sys.path.insert(0, project_path)
            working_set.__init__()
            add_activation_listener(lambda dist: dist.activate())
            require('%s==%s' % (ei_cmd.egg_name, ei_cmd.egg_version))
            with self.paths_on_pythonpath([project_path]):
                yield
        finally:
            sys.path[:] = old_path
            sys.modules.clear()
            sys.modules.update(old_modules)
            working_set.__init__()
コード例 #16
0
ファイル: test.py プロジェクト: 52nlp/Text-Summarization
    def with_project_on_sys_path(self, func):
        with_2to3 = (
            sys.version_info >= (3,)
            and getattr(self.distribution, 'use_2to3', False)
        )
        if with_2to3:
            # If we run 2to3 we can not do this inplace:

            # Ensure metadata is up-to-date
            self.reinitialize_command('build_py', inplace=0)
            self.run_command('build_py')
            bpy_cmd = self.get_finalized_command("build_py")
            build_path = normalize_path(bpy_cmd.build_lib)

            # Build extensions
            self.reinitialize_command('egg_info', egg_base=build_path)
            self.run_command('egg_info')

            self.reinitialize_command('build_ext', inplace=0)
            self.run_command('build_ext')
        else:
            # Without 2to3 inplace works fine:
            self.run_command('egg_info')

            # Build extensions in-place
            self.reinitialize_command('build_ext', inplace=1)
            self.run_command('build_ext')

        ei_cmd = self.get_finalized_command("egg_info")

        old_path = sys.path[:]
        old_modules = sys.modules.copy()

        try:
            sys.path.insert(0, normalize_path(ei_cmd.egg_base))
            working_set.__init__()
            add_activation_listener(lambda dist: dist.activate())
            require('%s==%s' % (ei_cmd.egg_name, ei_cmd.egg_version))
            func()
        finally:
            sys.path[:] = old_path
            sys.modules.clear()
            sys.modules.update(old_modules)
            working_set.__init__()
コード例 #17
0
 def _resolve_setup_path(egg_base, install_dir, egg_path):
     """
     Generate a path from egg_base back to '.' where the
     setup script resides and ensure that path points to the
     setup path from $install_dir/$egg_path.
     """
     path_to_setup = egg_base.replace(os.sep, "/").rstrip("/")
     if path_to_setup != os.curdir:
         path_to_setup = "../" * (path_to_setup.count("/") + 1)
     resolved = pkg_resources.normalize_path(
         os.path.join(install_dir, egg_path, path_to_setup))
     if resolved != pkg_resources.normalize_path(os.curdir):
         raise DistutilsOptionError(
             "Can't get a consistent path to setup script from"
             " installation directory",
             resolved,
             pkg_resources.normalize_path(os.curdir),
         )
     return path_to_setup
コード例 #18
0
 def test_add_from_site_is_ignored(self):
     location = '/test/location/does-not-have-to-exist'
     # PthDistributions expects all locations to be normalized
     location = pkg_resources.normalize_path(location)
     pth = PthDistributions('does-not_exist', [
         location,
     ])
     assert not pth.dirty
     pth.add(PRDistribution(location))
     assert not pth.dirty
コード例 #19
0
ファイル: commands.py プロジェクト: DavidCnaup/grpc
 def _add_eggs_to_path(self):
   """Adds all egg files under .eggs to sys.path"""
   # TODO(jtattemusch): there has to be a cleaner way to do this
   import pkg_resources
   eggs_dir = os.path.join(PYTHON_STEM, '../../../.eggs')
   eggs = [os.path.join(eggs_dir, filename)
           for filename in os.listdir(eggs_dir)
           if filename.endswith('.egg')]
   for egg in eggs:
     sys.path.insert(0, pkg_resources.normalize_path(egg))
コード例 #20
0
ファイル: develop.py プロジェクト: Dnguy104/Twitter-Search
    def finalize_options(self):
        ei = self.get_finalized_command("egg_info")
        if ei.broken_egg_info:
            template = "Please rename %r to %r before using 'develop'"
            args = ei.egg_info, ei.broken_egg_info
            raise DistutilsError(template % args)
        self.args = [ei.egg_name]

        easy_install.finalize_options(self)
        self.expand_basedirs()
        self.expand_dirs()
        # pick up setup-dir .egg files only: no .egg-info
        self.package_index.scan(glob.glob('*.egg'))

        self.egg_link = os.path.join(self.install_dir,
                                     ei.egg_name + '.egg-link')
        self.egg_base = ei.egg_base
        if self.egg_path is None:
            self.egg_path = os.path.abspath(ei.egg_base)

        target = normalize_path(self.egg_base)
        egg_path = normalize_path(os.path.join(self.install_dir,
                                               self.egg_path))
        if egg_path != target:
            raise DistutilsOptionError(
                "--egg-path must be a relative path from the install"
                " directory to " + target)

        # Make a distribution for the package's source
        self.dist = Distribution(target,
                                 PathMetadata(target,
                                              os.path.abspath(ei.egg_info)),
                                 project_name=ei.egg_name)

        p = self.egg_base.replace(os.sep, '/')
        if p != os.curdir:
            p = '../' * (p.count('/') + 1)
        self.setup_path = p
        p = normalize_path(os.path.join(self.install_dir, self.egg_path, p))
        if p != normalize_path(os.curdir):
            raise DistutilsOptionError(
                "Can't get a consistent path to setup script from"
                " installation directory", p, normalize_path(os.curdir))
コード例 #21
0
    def finalize_options(self):
        ei = self.get_finalized_command("egg_info")
        if ei.broken_egg_info:
            template = "Please rename %r to %r before using 'develop'"
            args = ei.egg_info, ei.broken_egg_info
            raise DistutilsError(template % args)
        self.args = [ei.egg_name]

        easy_install.finalize_options(self)
        self.expand_basedirs()
        self.expand_dirs()
        # pick up setup-dir .egg files only: no .egg-info
        self.package_index.scan(glob.glob("*.egg"))

        egg_link_fn = ei.egg_name + ".egg-link"
        self.egg_link = os.path.join(self.install_dir, egg_link_fn)
        self.egg_base = ei.egg_base
        if self.egg_path is None:
            self.egg_path = os.path.abspath(ei.egg_base)

        target = pkg_resources.normalize_path(self.egg_base)
        egg_path = pkg_resources.normalize_path(
            os.path.join(self.install_dir, self.egg_path)
        )
        if egg_path != target:
            raise DistutilsOptionError(
                "--egg-path must be a relative path from the install"
                " directory to " + target
            )

        # Make a distribution for the package's source
        self.dist = pkg_resources.Distribution(
            target,
            pkg_resources.PathMetadata(target, os.path.abspath(ei.egg_info)),
            project_name=ei.egg_name,
        )

        self.setup_path = self._resolve_setup_path(
            self.egg_base,
            self.install_dir,
            self.egg_path,
        )
コード例 #22
0
 def _add_eggs_to_path(self):
     """Adds all egg files under .eggs to sys.path"""
     # TODO(jtattemusch): there has to be a cleaner way to do this
     import pkg_resources
     eggs_dir = os.path.join(PYTHON_STEM, '../../../.eggs')
     eggs = [
         os.path.join(eggs_dir, filename)
         for filename in os.listdir(eggs_dir) if filename.endswith('.egg')
     ]
     for egg in eggs:
         sys.path.insert(0, pkg_resources.normalize_path(egg))
コード例 #23
0
    def get_project_path(self):
        self.run_command('egg_info')

        # Build extensions in-place
        self.reinitialize_command('build_ext', inplace=1)
        self.run_command('build_ext')

        ei_cmd = self.get_finalized_command("egg_info")

        project_path = normalize_path(ei_cmd.egg_base)
        return os.path.join(project_path, to_filename(ei_cmd.egg_name))
コード例 #24
0
    def test_all_site_dirs(self, monkeypatch):
        """
        get_site_dirs should always return site dirs reported by
        site.getsitepackages.
        """
        path = normalize_path('/setuptools/test/site-packages')

        def mock_gsp():
            return [path]
        monkeypatch.setattr(site, 'getsitepackages', mock_gsp, raising=False)
        assert path in ei.get_site_dirs()
コード例 #25
0
    def finalize_options(self):
        ei = self.get_finalized_command("egg_info")
        if ei.broken_egg_info:
            template = "Please rename %r to %r before using 'develop'"
            args = ei.egg_info, ei.broken_egg_info
            raise DistutilsError(template % args)
        self.args = [ei.egg_name]

        easy_install.finalize_options(self)
        self.expand_basedirs()
        self.expand_dirs()
        # pick up setup-dir .egg files only: no .egg-info
        self.package_index.scan(glob.glob('*.egg'))

        egg_link_fn = ei.egg_name + '.egg-link'
        self.egg_link = os.path.join(self.install_dir, egg_link_fn)
        self.egg_base = ei.egg_base
        if self.egg_path is None:
            self.egg_path = os.path.abspath(ei.egg_base)

        target = normalize_path(self.egg_base)
        egg_path = normalize_path(os.path.join(self.install_dir,
                                               self.egg_path))
        if egg_path != target:
            raise DistutilsOptionError(
                "--egg-path must be a relative path from the install"
                " directory to " + target
            )

        # Make a distribution for the package's source
        self.dist = Distribution(
            target,
            PathMetadata(target, os.path.abspath(ei.egg_info)),
            project_name=ei.egg_name
        )

        self.setup_path = self._resolve_setup_path(
            self.egg_base,
            self.install_dir,
            self.egg_path,
        )
コード例 #26
0
ファイル: testrunner.py プロジェクト: pombredanne/trachacks
    def _run_tests(self):
        old_path = sys.path[:]
        ei_cmd = self.get_finalized_command("egg_info")
        path_item = normalize_path(ei_cmd.egg_base)
        metadata = PathMetadata(path_item, normalize_path(ei_cmd.egg_info))
        dist = Distribution(path_item, metadata, project_name=ei_cmd.egg_name)
        working_set.add(dist)
        require(str(dist.as_requirement()))
        loader_ep = EntryPoint.parse("x=" + self.test_loader)
        loader_class = loader_ep.load(require=False)

        try:
            import unittest
            unittest.main(None,
                          None, [unittest.__file__] + self.test_args,
                          testRunner=XMLTestRunner(
                              stream=sys.stdout,
                              xml_stream=self.xml_output_file),
                          testLoader=loader_class())
        except SystemExit, e:
            return e.code
コード例 #27
0
ファイル: easy_install.py プロジェクト: agiledata/pkglib
    def install_item(self, spec, download, tmpdir, deps, install_needed=False):
        """ The only difference between this and the standard implementation is that it doesn't copy
            eggs from the egg cache but links to them in place.
        """
        # Installation is also needed if file in tmpdir or is not an egg
        install_needed = install_needed or self.always_copy
        install_needed = install_needed or os.path.dirname(download) == tmpdir
        install_needed = install_needed or not download.endswith('.egg')
        install_needed = install_needed or (
            self.always_copy_from is not None and
            os.path.dirname(pkg_resources.normalize_path(download)) ==
            pkg_resources.normalize_path(self.always_copy_from)
        )

        # This is the only bit that is different:
        #  <---------- here ----------------->
        if not egg_cache.is_from_egg_cache(download) and spec and not install_needed:
            # at this point, we know it's a local .egg, we just don't know if
            # it's already installed.
            for dist in self.local_index[spec.project_name]:
                if dist.location == download:
                    break
            else:
                install_needed = True  # it's not in the local index

        log.info("Processing %s", os.path.basename(download))

        if install_needed:
            dists = self.install_eggs(spec, download, tmpdir)
            for dist in dists:
                self.process_distribution(spec, dist, deps)
        else:
            dists = [self.egg_distribution(download)]
            self.process_distribution(spec, dists[0], deps, "Using")

        if spec is not None:
            for dist in dists:
                if dist in spec:
                    return dist
コード例 #28
0
    def install_item(self, spec, download, tmpdir, deps, install_needed=False):
        """ The only difference between this and the standard implementation is that it doesn't copy
            eggs from the egg cache but links to them in place.
        """
        # Installation is also needed if file in tmpdir or is not an egg
        install_needed = install_needed or self.always_copy
        install_needed = install_needed or os.path.dirname(download) == tmpdir
        install_needed = install_needed or not download.endswith('.egg')
        install_needed = install_needed or (
            self.always_copy_from is not None
            and os.path.dirname(pkg_resources.normalize_path(download))
            == pkg_resources.normalize_path(self.always_copy_from))

        # This is the only bit that is different:
        #  <---------- here ----------------->
        if not egg_cache.is_from_egg_cache(
                download) and spec and not install_needed:
            # at this point, we know it's a local .egg, we just don't know if
            # it's already installed.
            for dist in self.local_index[spec.project_name]:
                if dist.location == download:
                    break
            else:
                install_needed = True  # it's not in the local index

        log.info("Processing %s", os.path.basename(download))

        if install_needed:
            dists = self.install_eggs(spec, download, tmpdir)
            for dist in dists:
                self.process_distribution(spec, dist, deps)
        else:
            dists = [self.egg_distribution(download)]
            self.process_distribution(spec, dists[0], deps, "Using")

        if spec is not None:
            for dist in dists:
                if dist in spec:
                    return dist
コード例 #29
0
ファイル: setup.py プロジェクト: aosm/pyobjc
    def add_project_to_sys_path(self):
        from pkg_resources import normalize_path, add_activation_listener
        from pkg_resources import working_set, require

        if getattr(self.distribution, 'use_2to3', False):

            # Using 2to3, cannot do this inplace:
            self.reinitialize_command('build_py', inplace=0)
            self.run_command('build_py')
            bpy_cmd = self.get_finalized_command("build_py")
            build_path = normalize_path(bpy_cmd.build_lib)

            self.reinitialize_command('egg_info', egg_base=build_path)
            self.run_command('egg_info')

            self.reinitialize_command('build_ext', inplace=0)
            self.run_command('build_ext')

        else:
            self.reinitialize_command('egg_info')
            self.run_command('egg_info')
            self.reinitialize_command('build_ext', inplace=1)
            self.run_command('build_ext')

        self.__old_path = sys.path[:]
        self.__old_modules = sys.modules.copy()

        if 'PyObjCTools' in sys.modules:
            del sys.modules['PyObjCTools']


        ei_cmd = self.get_finalized_command('egg_info')
        sys.path.insert(0, normalize_path(ei_cmd.egg_base))
        sys.path.insert(1, os.path.dirname(__file__))

        add_activation_listener(lambda dist: dist.activate())
        working_set.__init__()
        require('%s==%s'%(ei_cmd.egg_name, ei_cmd.egg_version))
コード例 #30
0
ファイル: setup.py プロジェクト: insynchq/pyobjc
    def add_project_to_sys_path(self):
        from pkg_resources import normalize_path, add_activation_listener
        from pkg_resources import working_set, require

        if getattr(self.distribution, 'use_2to3', False):

            # Using 2to3, cannot do this inplace:
            self.reinitialize_command('build_py', inplace=0)
            self.run_command('build_py')
            bpy_cmd = self.get_finalized_command("build_py")
            build_path = normalize_path(bpy_cmd.build_lib)

            self.reinitialize_command('egg_info', egg_base=build_path)
            self.run_command('egg_info')

            self.reinitialize_command('build_ext', inplace=0)
            self.run_command('build_ext')

        else:
            self.reinitialize_command('egg_info')
            self.run_command('egg_info')
            self.reinitialize_command('build_ext', inplace=1)
            self.run_command('build_ext')

        self.__old_path = sys.path[:]
        self.__old_modules = sys.modules.copy()

        if 'PyObjCTools' in sys.modules:
            del sys.modules['PyObjCTools']


        ei_cmd = self.get_finalized_command('egg_info')
        sys.path.insert(0, normalize_path(ei_cmd.egg_base))
        sys.path.insert(1, os.path.dirname(__file__))

        add_activation_listener(lambda dist: dist.activate())
        working_set.__init__()
        require('%s==%s'%(ei_cmd.egg_name, ei_cmd.egg_version))
コード例 #31
0
ファイル: testrunner.py プロジェクト: blaxter/Bitten
    def _run_tests(self):
        old_path = sys.path[:]
        ei_cmd = self.get_finalized_command("egg_info")
        path_item = normalize_path(ei_cmd.egg_base)
        metadata = PathMetadata(
            path_item, normalize_path(ei_cmd.egg_info)
        )
        dist = Distribution(path_item, metadata, project_name=ei_cmd.egg_name)
        working_set.add(dist)
        require(str(dist.as_requirement()))
        loader_ep = EntryPoint.parse("x=" + self.test_loader)
        loader_class = loader_ep.load(require=False)

        try:
            import unittest
            unittest.main(
                None, None, [unittest.__file__] + self.test_args,
                testRunner=XMLTestRunner(stream=sys.stdout,
                                         xml_stream=self.xml_output_file),
                testLoader=loader_class()
            )
        except SystemExit, e:
            return e.code
コード例 #32
0
    def install_for_development(self):
        if not six.PY2 and getattr(self.distribution, "use_2to3", False):
            # If we run 2to3 we can not do this inplace:

            # Ensure metadata is up-to-date
            self.reinitialize_command("build_py", inplace=0)
            self.run_command("build_py")
            bpy_cmd = self.get_finalized_command("build_py")
            build_path = pkg_resources.normalize_path(bpy_cmd.build_lib)

            # Build extensions
            self.reinitialize_command("egg_info", egg_base=build_path)
            self.run_command("egg_info")

            self.reinitialize_command("build_ext", inplace=0)
            self.run_command("build_ext")

            # Fixup egg-link and easy-install.pth
            ei_cmd = self.get_finalized_command("egg_info")
            self.egg_path = build_path
            self.dist.location = build_path
            # XXX
            self.dist._provider = pkg_resources.PathMetadata(
                build_path, ei_cmd.egg_info
            )
        else:
            # Without 2to3 inplace works fine:
            self.run_command("egg_info")

            # Build extensions in-place
            self.reinitialize_command("build_ext", inplace=1)
            self.run_command("build_ext")

        self.install_site_py()  # ensure that target dir is site-safe
        if setuptools.bootstrap_install_from:
            self.easy_install(setuptools.bootstrap_install_from)
            setuptools.bootstrap_install_from = None

        self.install_namespaces()

        # create an .egg-link in the installation dir, pointing to our egg
        log.info("Creating %s (link to %s)", self.egg_link, self.egg_base)
        if not self.dry_run:
            with open(self.egg_link, "w") as f:
                f.write(self.egg_path + "\n" + self.setup_path)
        # postprocess the installed distro, fixing up .pth, installing scripts,
        # and handling requirements
        self.process_distribution(None, self.dist, not self.no_deps)
コード例 #33
0
ファイル: setup.py プロジェクト: davidkitfriedman/plover
 def project_on_sys_path(self):
     self.build_in_place()
     ei_cmd = self.get_finalized_command("egg_info")
     old_path = sys.path[:]
     old_modules = sys.modules.copy()
     try:
         sys.path.insert(0, pkg_resources.normalize_path(ei_cmd.egg_base))
         pkg_resources.working_set.__init__()
         pkg_resources.add_activation_listener(lambda dist: dist.activate())
         pkg_resources.require('%s==%s' % (ei_cmd.egg_name, ei_cmd.egg_version))
         yield
     finally:
         sys.path[:] = old_path
         sys.modules.clear()
         sys.modules.update(old_modules)
         pkg_resources.working_set.__init__()
コード例 #34
0
ファイル: setup.py プロジェクト: smahood/plover
 def project_on_sys_path(self):
     self.build_in_place()
     ei_cmd = self.get_finalized_command("egg_info")
     old_path = sys.path[:]
     old_modules = sys.modules.copy()
     try:
         sys.path.insert(0, pkg_resources.normalize_path(ei_cmd.egg_base))
         pkg_resources.working_set.__init__()
         pkg_resources.add_activation_listener(lambda dist: dist.activate())
         pkg_resources.require('%s==%s' % (ei_cmd.egg_name, ei_cmd.egg_version))
         yield
     finally:
         sys.path[:] = old_path
         sys.modules.clear()
         sys.modules.update(old_modules)
         pkg_resources.working_set.__init__()
コード例 #35
0
ファイル: develop.py プロジェクト: DuongNguyen7691/Summer2019
    def install_for_development(self):
        if six.PY3 and getattr(self.distribution, 'use_2to3', False):
            # If we run 2to3 we can not do this inplace:

            # Ensure metadata is up-to-date
            self.reinitialize_command('build_py', inplace=0)
            self.run_command('build_py')
            bpy_cmd = self.get_finalized_command("build_py")
            build_path = pkg_resources.normalize_path(bpy_cmd.build_lib)

            # Build extensions
            self.reinitialize_command('egg_info', egg_base=build_path)
            self.run_command('egg_info')

            self.reinitialize_command('build_ext', inplace=0)
            self.run_command('build_ext')

            # Fixup egg-link and easy-install.pth
            ei_cmd = self.get_finalized_command("egg_info")
            self.egg_path = build_path
            self.dist.location = build_path
            # XXX
            self.dist._provider = pkg_resources.PathMetadata(
                build_path, ei_cmd.egg_info)
        else:
            # Without 2to3 inplace works fine:
            self.run_command('egg_info')

            # Build extensions in-place
            self.reinitialize_command('build_ext', inplace=1)
            self.run_command('build_ext')

        self.install_site_py()  # ensure that target dir is site-safe
        if setuptools.bootstrap_install_from:
            self.easy_install(setuptools.bootstrap_install_from)
            setuptools.bootstrap_install_from = None

        self.install_namespaces()

        # create an .egg-link in the installation dir, pointing to our egg
        log.info("Creating %s (link to %s)", self.egg_link, self.egg_base)
        if not self.dry_run:
            with open(self.egg_link, "w") as f:
                f.write(self.egg_path + "\n" + self.setup_path)
        # postprocess the installed distro, fixing up .pth, installing scripts,
        # and handling requirements
        self.process_distribution(None, self.dist, not self.no_deps)
コード例 #36
0
    def run_tests(self):
        import pytest

        # Purge modules under test from sys.modules. The test loader will
        # re-import them from the build location. Required when 2to3 is used
        # with namespace packages.
        if sys.version_info >= (3,) and \
                getattr(self.distribution, 'use_2to3', False):
            sys.modules.__delitem__('nobel')
            sys.modules.__delitem__('nobel.api')

            ## Run on the build directory for 2to3-built code.
            ei_cmd = self.get_finalized_command("egg_info")
            self.test_args = [normalize_path(ei_cmd.egg_base)]

        errno = pytest.main(self.test_args)
        sys.exit(errno)
コード例 #37
0
def main(command, path):
    path = pkg_resources.normalize_path(path)
    moduleInstallationPrefix = path + os.sep + "inst"

    localSitePackages = localSitePackageFolder(moduleInstallationPrefix)

    addLocalSitePackageToPythonPath(moduleInstallationPrefix)

    if not os.path.exists(localSitePackages):
        os.makedirs(localSitePackages)

    if command == 'install':
        call_pip('pandas', localSitePackages, PANDAS_VERSION)
    elif command == 'uninstall':
        remove_dirs('pandas', localSitePackages)
    else:
        raise Exception("command not supported: " + command)
コード例 #38
0
ファイル: setup.py プロジェクト: vibragiel/nobel
    def run_tests(self):
        import pytest

        # Purge modules under test from sys.modules. The test loader will
        # re-import them from the build location. Required when 2to3 is used
        # with namespace packages.
        if sys.version_info >= (3,) and \
                getattr(self.distribution, 'use_2to3', False):
            sys.modules.__delitem__('nobel')
            sys.modules.__delitem__('nobel.api')

            ## Run on the build directory for 2to3-built code.
            ei_cmd = self.get_finalized_command("egg_info")
            self.test_args = [normalize_path(ei_cmd.egg_base)]

        errno = pytest.main(self.test_args)
        sys.exit(errno)
コード例 #39
0
ファイル: develop.py プロジェクト: rayman18/wydev
 def finalize_options(self):
     ei = self.get_finalized_command("egg_info")
     if ei.broken_egg_info:
         raise DistutilsError(
             "Please rename %r to %r before using 'develop'" %
             (ei.egg_info, ei.broken_egg_info))
     self.args = [ei.egg_name]
     easy_install.finalize_options(self)
     self.egg_link = os.path.join(self.install_dir,
                                  ei.egg_name + '.egg-link')
     self.egg_base = ei.egg_base
     self.egg_path = os.path.abspath(ei.egg_base)
     # Make a distribution for the package's source
     self.dist = Distribution(normalize_path(self.egg_path),
                              PathMetadata(self.egg_path,
                                           os.path.abspath(ei.egg_info)),
                              project_name=ei.egg_name)
コード例 #40
0
        def run(self):
            use_2to3 = getattr(self.distribution, 'use_2to3', False)
            test_dirs = getattr(self.distribution, 'test_dirs', [])
            test_base = self.test_base
            bpy_cmd = self.get_finalized_command("build_py")
            lib_base = normalize_path(bpy_cmd.build_lib)
            modified = []
            py_modified = []
            doc_modified = []
            dir_util.mkpath(test_base)
            for testdir in test_dirs:
                for srcdir, dirnames, filenames in os.walk(testdir):
                    destdir = os.path.join(test_base, srcdir)
                    dir_util.mkpath(destdir)
                    for fn in filenames:
                        if fn.startswith("."):
                            # Skip .svn folders and such
                            continue
                        dstfile, copied = file_util.copy_file(
                            os.path.join(srcdir, fn),
                            os.path.join(destdir, fn),
                            update=True)
                        if copied:
                            modified.append(dstfile)
                            if fn.endswith('.py'):
                                py_modified.append(dstfile)
                            for ext in self.distribution.doctest_exts:
                                if fn.endswith(ext):
                                    doc_modified.append(dstfile)
                                    break
            if use_2to3:
                self.run_2to3(py_modified)
                self.run_2to3(doc_modified, True)
            if self.distribution.pyversion_patching:
                if patch is not None:
                    for file in modified:
                        pyversion_patch(file)
                else:
                    log.warn(
                        "Warning: pyversion_patching specified in setup config but patch module not found.  Patching will not be performed."
                    )

            dir_util.mkpath(lib_base)
            self.reinitialize_command('egg_info', egg_base=lib_base)
            self.run_command('egg_info')
コード例 #41
0
ファイル: setup3lib.py プロジェクト: ArekSredzki/ubcsailbots
        def run(self):
            use_2to3 = getattr(self.distribution, 'use_2to3', False)
            test_dirs = getattr(self.distribution, 'test_dirs', [])
            test_base = self.test_base
            bpy_cmd = self.get_finalized_command("build_py")
            lib_base = normalize_path(bpy_cmd.build_lib)
            modified = []
            py_modified = []
            doc_modified = []
            dir_util.mkpath(test_base)
            for testdir in test_dirs:
              for srcdir, dirnames, filenames in os.walk(testdir):
                destdir = os.path.join(test_base, srcdir)
                dir_util.mkpath(destdir)
                for fn in filenames:
                    if fn.startswith("."):
                        # Skip .svn folders and such
                        continue
                    dstfile, copied = file_util.copy_file(
                                          os.path.join(srcdir, fn),
                                          os.path.join(destdir, fn),
                                          update=True)
                    if copied:
                        modified.append(dstfile)
                        if fn.endswith('.py'):
                            py_modified.append(dstfile)
                        for ext in self.distribution.doctest_exts:
                            if fn.endswith(ext):
                                doc_modified.append(dstfile)
                                break
            if use_2to3:
                self.run_2to3(py_modified)
                self.run_2to3(doc_modified, True)
            if self.distribution.pyversion_patching:
                if patch is not None:
                    for file in modified:
                        pyversion_patch(file)
                else:
                    log.warn("Warning: pyversion_patching specified in setup config but patch module not found.  Patching will not be performed.")

            dir_util.mkpath(lib_base)
            self.reinitialize_command('egg_info', egg_base=lib_base)
            self.run_command('egg_info')
コード例 #42
0
ファイル: pyuninstall.py プロジェクト: agiledata/pkglib
def patch_UninstallPathSet(egg_caches, install_dir):
    # pip uninstall doesn't realise that you can remove an entry from the virtualenv
    # easy-install.pth file even if the egg itself is outside the virtualenv i.e. in
    # the egg cache.  Fix it by adjusting the pth file and entry.
    from pip import req
    ei_pth_file = os.path.join(normalize_path(install_dir), 'easy-install.pth')

    class UninstallPathSet(req.UninstallPathSet):
        def _can_uninstall(self):
            return True

        def add_pth(self, pth_file, entry):
            if any(pth_file.startswith(egg_cache) for egg_cache in egg_caches):
                pth_file, entry = ei_pth_file, self.dist.location
            super(UninstallPathSet, self).add_pth(pth_file, entry)
    req.UninstallPathSet, old_UninstallPathSet = UninstallPathSet, req.UninstallPathSet
    try:
        yield None
    finally:
        req.UninstallPathSet = old_UninstallPathSet
コード例 #43
0
def patch_UninstallPathSet(egg_caches, install_dir):
    # pip uninstall doesn't realise that you can remove an entry from the virtualenv
    # easy-install.pth file even if the egg itself is outside the virtualenv i.e. in
    # the egg cache.  Fix it by adjusting the pth file and entry.
    from pip import req
    ei_pth_file = os.path.join(normalize_path(install_dir), 'easy-install.pth')

    class UninstallPathSet(req.UninstallPathSet):
        def _can_uninstall(self):
            return True

        def add_pth(self, pth_file, entry):
            if any(pth_file.startswith(egg_cache) for egg_cache in egg_caches):
                pth_file, entry = ei_pth_file, self.dist.location
            super(UninstallPathSet, self).add_pth(pth_file, entry)

    req.UninstallPathSet, old_UninstallPathSet = UninstallPathSet, req.UninstallPathSet
    try:
        yield None
    finally:
        req.UninstallPathSet = old_UninstallPathSet
コード例 #44
0
    def add_project_to_sys_path(self):
        from pkg_resources import normalize_path, add_activation_listener
        from pkg_resources import working_set, require

        self.reinitialize_command("egg_info")
        self.run_command("egg_info")
        self.reinitialize_command("build_ext", inplace=1)
        self.run_command("build_ext")

        self.__old_path = sys.path[:]
        self.__old_modules = sys.modules.copy()

        if "PyObjCTools" in sys.modules:
            del sys.modules["PyObjCTools"]

        ei_cmd = self.get_finalized_command("egg_info")
        sys.path.insert(0, normalize_path(ei_cmd.egg_base))
        sys.path.insert(1, os.path.dirname(__file__))

        add_activation_listener(lambda dist: dist.activate())
        working_set.__init__()
        require("%s==%s" % (ei_cmd.egg_name, ei_cmd.egg_version))
コード例 #45
0
    def add_project_to_sys_path(self):
        from pkg_resources import normalize_path, add_activation_listener
        from pkg_resources import working_set, require

        self.reinitialize_command('egg_info')
        self.run_command('egg_info')
        self.reinitialize_command('build_ext', inplace=1)
        self.run_command('build_ext')

        self.__old_path = sys.path[:]
        self.__old_modules = sys.modules.copy()

        if 'PyObjCTools' in sys.modules:
            del sys.modules['PyObjCTools']

        ei_cmd = self.get_finalized_command('egg_info')
        sys.path.insert(0, normalize_path(ei_cmd.egg_base))
        sys.path.insert(1, os.path.dirname(__file__))

        add_activation_listener(lambda dist: dist.activate())
        working_set.__init__()
        require('%s==%s' % (ei_cmd.egg_name, ei_cmd.egg_version))
コード例 #46
0
ファイル: setup.py プロジェクト: APSL/ecs-deploy.py
    def run_tests(self):
        import pytest
        from pkg_resources import normalize_path, _namespace_packages

        if sys.version_info >= (3, ) and getattr(self.distribution, 'use_2to3',
                                                 False):
            module = self.test_package_name
            if module in _namespace_packages:
                del_modules = []
                if module in sys.modules:
                    del_modules.append(module)
                module += '.'
                for name in sys.modules:
                    if name.startswith(module):
                        del_modules.append(name)
                map(sys.modules.__delitem__, del_modules)

            ei_cmd = self.get_finalized_command('egg_info')

            self.test_args.append(normalize_path(ei_cmd.egg_base))

        errno = pytest.main(self.test_args)
        sys.exit(errno)
コード例 #47
0
ファイル: setup.py プロジェクト: danchr/pyobjc-git
    def add_project_to_sys_path(self):
        from pkg_resources import normalize_path, add_activation_listener
        from pkg_resources import working_set, require

        self.reinitialize_command("egg_info")
        self.run_command("egg_info")
        self.reinitialize_command("build_ext", inplace=1)
        self.run_command("build_ext")

        self.__old_path = sys.path[:]
        self.__old_modules = sys.modules.copy()

        if "PyObjCTools" in sys.modules:
            del sys.modules["PyObjCTools"]

        ei_cmd = self.get_finalized_command("egg_info")
        sys.path.insert(0, normalize_path(ei_cmd.egg_base))
        sys.path.insert(1, os.path.dirname(__file__))

        add_activation_listener(lambda dist: dist.activate())
        working_set.__init__()
        require("%s==%s" % (ei_cmd.egg_name, ei_cmd.egg_version))

        from PyObjCTools import TestSupport

        if os.path.realpath(os.path.dirname(
                TestSupport.__file__)) != os.path.realpath("Lib/PyObjCTools"):
            raise DistutilsError(
                "Setting up test environment failed for 'PyObjCTools.TestSupport'"
            )

        import objc

        if os.path.realpath(os.path.dirname(
                objc.__file__)) != os.path.realpath("Lib/objc"):
            raise DistutilsError(
                "Setting up test environment failed for 'objc'")
コード例 #48
0
    def add_project_to_sys_path(self):
        from pkg_resources import (
            add_activation_listener,
            normalize_path,
            require,
            working_set,
        )

        self.reinitialize_command("egg_info")
        self.run_command("egg_info")
        self.reinitialize_command("build_ext", inplace=1)
        self.run_command("build_ext")

        # Check if this distribution is already on sys.path
        # and remove that version, this ensures that the right
        # copy of the package gets tested.

        self.__old_path = sys.path[:]
        self.__old_modules = sys.modules.copy()

        ei_cmd = self.get_finalized_command("egg_info")
        sys.path.insert(0, normalize_path(ei_cmd.egg_base))
        sys.path.insert(1, os.path.dirname(__file__))

        # Strip the namespace packages defined in this distribution
        # from sys.modules, needed to reset the search path for
        # those modules.

        nspkgs = getattr(self.distribution, "namespace_packages", None)
        if nspkgs is not None:
            for nm in nspkgs:
                del sys.modules[nm]

        # Reset pkg_resources state:
        add_activation_listener(lambda dist: dist.activate())
        working_set.__init__()
        require("%s==%s" % (ei_cmd.egg_name, ei_cmd.egg_version))
コード例 #49
0
ファイル: runner.py プロジェクト: pombredanne/pkglib
def assert_dists_in_pth(mocks, *dists):

    # Check that only the required distributions were added to "*.pth" file
    pth_file = [f for n, f in
                mocks[_easy_install_mocks][_written_pth_files].items()
                if os.path.basename(n) == "easy-install.pth"]

    pth_file = pth_file[0] if pth_file else io.BytesIO()

    dists = list(dists)

    pth_filename = "/<pth_file>"
    base_d = normalize_path(os.path.dirname(pth_filename))

    def find_distributions(path_item, only=False):  # @UnusedVariable
        d = [d for d in dists
             if normalize_path(os.path.join(base_d, d.location)) == path_item]
        assert len(d) == 1, ("Distribution on path [%s] should not have "
                             "been added to '.pth' file" % str(path_item))
        dists.remove(d[0])
        return []

    pth_file_dict = {pth_filename: pth_file}
    pth_file.seek(0)

    with ExitStack() as stack:
        ec = stack.enter_context
        ec(_patch_open(pth_file_dict))
        ec(patch("os.path.exists", new=lambda _: True))
        ec(patch("os.path.isfile", new=lambda f: f == pth_filename))
        ec(patch(_ei_find_distributions, new=find_distributions))

        PthDistributions(pth_filename)

    assert not dists, ("[%d] distributions were not added to the '.pth' "
                       "file: %s" % (len(dists), str(dists)))
コード例 #50
0
ファイル: develop.py プロジェクト: gusdn1135/amator
                pkg_resources.normalize_path(os.curdir))
        return path_to_setup

    def install_for_development(self):
<<<<<<< HEAD
        if not six.PY2 and getattr(self.distribution, 'use_2to3', False):
=======
        if getattr(self.distribution, 'use_2to3', False):
>>>>>>> 7e5c5fbd6c824de4d4c2b62da3f7cae87d462119
            # If we run 2to3 we can not do this inplace:

            # Ensure metadata is up-to-date
            self.reinitialize_command('build_py', inplace=0)
            self.run_command('build_py')
            bpy_cmd = self.get_finalized_command("build_py")
            build_path = pkg_resources.normalize_path(bpy_cmd.build_lib)

            # Build extensions
            self.reinitialize_command('egg_info', egg_base=build_path)
            self.run_command('egg_info')

            self.reinitialize_command('build_ext', inplace=0)
            self.run_command('build_ext')

            # Fixup egg-link and easy-install.pth
            ei_cmd = self.get_finalized_command("egg_info")
            self.egg_path = build_path
            self.dist.location = build_path
            # XXX
            self.dist._provider = pkg_resources.PathMetadata(
                build_path, ei_cmd.egg_info)
コード例 #51
0
ファイル: package_index.py プロジェクト: taratran/swe-project
def distros_for_filename(filename, metadata=None):
    """Yield possible egg or source distribution objects based on a filename"""
    return distros_for_location(normalize_path(filename),
                                os.path.basename(filename), metadata)
コード例 #52
0
ファイル: setup.py プロジェクト: bru08/mot
    def run(self):
        """A command's raison d'etre: carry out the action it exists to perform, controlled by the options initialized
        in 'initialize_options()', customized by other commands, the setup script, the command-line, and config files,
        and finalized in 'finalize_options()'.  All terminal output and filesystem interaction should be done by
        'run()'.
        """

        if not self.skip_build:
            # Make sure install requirements are actually installed
            if self.distribution.install_requires:
                self.announce('Installing *install_requires* packages')
                subprocess.check_call(
                    [sys.executable, '-m', 'pip', 'install', '--user', '-q'] +
                    self.distribution.install_requires)

            # Ensure metadata is up-to-date
            self.reinitialize_command('build_py', inplace=0)
            self.run_command('build_py')
            bpy_cmd = self.get_finalized_command("build_py")
            build_path = normalize_path(bpy_cmd.build_lib)

            # Build extensions
            self.reinitialize_command('egg_info', egg_base=build_path)
            self.run_command('egg_info')

            self.reinitialize_command('build_ext', inplace=0)
            self.run_command('build_ext')

        # Make sure test requirements are actually installed
        if self.distribution.tests_require:
            self.announce('Installing *test_require* packages')
            subprocess.check_call(
                [sys.executable, '-m', 'pip', 'install', '--user', '-q'] +
                self.distribution.tests_require)

        ei_cmd = self.get_finalized_command("egg_info")

        # Get actual package location
        if self.skip_build:
            # Retrieve installation directory
            package_path = normalize_path(
                get_distribution(PACKAGE_NAME).location)
        else:
            # Package was just built...
            package_path = normalize_path(ei_cmd.egg_base)

        old_path = sys.path[:]
        old_modules = sys.modules.copy()

        try:
            if self.skip_build:
                sys.path.pop(0)
            else:
                sys.path.insert(0, package_path)
            working_set.__init__()
            add_activation_listener(lambda dist: dist.activate())
            require('%s==%s' % (ei_cmd.egg_name, ei_cmd.egg_version))

            if not self._run_tests(package_path):
                raise DistutilsError("Tests failed!")

        finally:
            sys.path[:] = old_path
            sys.modules.clear()
            sys.modules.update(old_modules)
            working_set.__init__()
コード例 #53
0
ファイル: commands.py プロジェクト: bloomonkey/archiveshub
 def finalize_options(self):
     if self.with_httpd is not None:
         self.with_httpd = normalize_path(expanduser(self.with_httpd))
コード例 #54
0
    def finalize_options(self):
        ei = self.get_finalized_command("egg_info")
        if ei.broken_egg_info:
            raise DistutilsError(
            "Please rename %r to %r before using 'develop'"
            % (ei.egg_info, ei.broken_egg_info)
            )
        self.args = [ei.egg_name]


        py_version = sys.version.split()[0]
        prefix, exec_prefix = get_config_vars('prefix', 'exec_prefix')
        self.config_vars = {'dist_name': self.distribution.get_name(),
                            'dist_version': self.distribution.get_version(),
                            'dist_fullname': self.distribution.get_fullname(),
                            'py_version': py_version,
                            'py_version_short': py_version[0:3],
                            'py_version_nodot': py_version[0] + py_version[2],
                            'sys_prefix': prefix,
                            'prefix': prefix,
                            'sys_exec_prefix': exec_prefix,
                            'exec_prefix': exec_prefix,
                           }

        if HAS_USER_SITE:
            self.config_vars['userbase'] = self.install_userbase
            self.config_vars['usersite'] = self.install_usersite

        # fix the install_dir if "--user" was used
        if self.user:
            self.create_home_path()
            if self.install_userbase is None:
                raise DistutilsPlatformError(
                    "User base directory is not specified")
            self.install_base = self.install_platbase = self.install_userbase
            if os.name == 'posix':
                self.select_scheme("unix_user")
            else:
                self.select_scheme(os.name + "_user")

        self.expand_basedirs()
        self.expand_dirs()

        if self.user and self.install_purelib:
            self.install_dir = self.install_purelib
            self.script_dir = self.install_scripts

        easy_install.finalize_options(self)
        # pick up setup-dir .egg files only: no .egg-info
        self.package_index.scan(glob.glob('*.egg'))

        self.egg_link = os.path.join(self.install_dir, ei.egg_name+'.egg-link')
        self.egg_base = ei.egg_base
        if self.egg_path is None:
            self.egg_path = os.path.abspath(ei.egg_base)

        target = normalize_path(self.egg_base)
        if normalize_path(os.path.join(self.install_dir, self.egg_path)) != target:
            raise DistutilsOptionError(
                "--egg-path must be a relative path from the install"
                " directory to "+target
        )

        # Make a distribution for the package's source
        self.dist = Distribution(
            target,
            PathMetadata(target, os.path.abspath(ei.egg_info)),
            project_name = ei.egg_name
        )

        p = self.egg_base.replace(os.sep,'/')
        if p!= os.curdir:
            p = '../' * (p.count('/')+1)
        self.setup_path = p
        p = normalize_path(os.path.join(self.install_dir, self.egg_path, p))
        if  p != normalize_path(os.curdir):
            raise DistutilsOptionError(
                "Can't get a consistent path to setup script from"
                " installation directory", p, normalize_path(os.curdir))
コード例 #55
0
 def test_normalize_path_normcase(self, unnormalized, normalized):
     """Ensure mixed case is normalized on case-insensitive filesystems.
     """
     result_from_unnormalized = pkg_resources.normalize_path(unnormalized)
     result_from_normalized = pkg_resources.normalize_path(normalized)
     assert result_from_unnormalized == result_from_normalized
コード例 #56
0
def distros_for_filename(filename, metadata=None):
    """Yield possible egg or source distribution objects based on a filename"""
    return distros_for_location(
        normalize_path(filename), os.path.basename(filename), metadata
    )
コード例 #57
0
 def test_normalize_path_backslash_sep(self, unnormalized, expected):
     """Ensure path seps are cleaned on backslash path sep systems.
     """
     result = pkg_resources.normalize_path(unnormalized)
     assert result.endswith(expected)
コード例 #58
0
    def project_on_sys_path(self, include_dists=[]):
<<<<<<< HEAD
        with_2to3 = not six.PY2 and getattr(
            self.distribution, 'use_2to3', False)
=======
        with_2to3 = getattr(self.distribution, 'use_2to3', False)
>>>>>>> 7e5c5fbd6c824de4d4c2b62da3f7cae87d462119

        if with_2to3:
            # If we run 2to3 we can not do this inplace:

            # Ensure metadata is up-to-date
            self.reinitialize_command('build_py', inplace=0)
            self.run_command('build_py')
            bpy_cmd = self.get_finalized_command("build_py")
            build_path = normalize_path(bpy_cmd.build_lib)

            # Build extensions
            self.reinitialize_command('egg_info', egg_base=build_path)
            self.run_command('egg_info')

            self.reinitialize_command('build_ext', inplace=0)
            self.run_command('build_ext')
        else:
            # Without 2to3 inplace works fine:
            self.run_command('egg_info')

            # Build extensions in-place
            self.reinitialize_command('build_ext', inplace=1)
            self.run_command('build_ext')