コード例 #1
0
ファイル: pip_test.py プロジェクト: Eigenlabs/EigenD-Contrib
def compile_module(module,specification,include_path=[]):
    spec_file = 'testtmp_%s.pip' % module
    code_file = 'testtmp_%s.cpp' % module
    extra = []

    if sys.platform == 'darwin':
        extra.append('/usr/lib/libstdc++.6.dylib')

    ext = distutils.core.Extension(module,sources=[code_file],extra_objects=extra,extra_link_args=['-g'],extra_compile_args=['-g'])
    dist = distutils.dist.Distribution(dict(ext_modules=[ext]))
    bin_file = None

    try: os.mkdir('build')
    except: pass

    try:
        f=file(spec_file,"w")
        f.write(specification)
        f.close()

        pip.generate(module,spec_file,code_file,include_path)

        dist.get_option_dict('build_ext')['inplace']=('script',True)
        dist.get_option_dict('build_ext')['verbose']=('script',True)
        dist.run_command('build_ext')
        bin_file=dist.get_command_obj('build_ext').get_ext_filename(module)
        return imp.load_dynamic(module,bin_file)

    finally:
        if bin_file is not None:
            safe_remove(bin_file)
        dist.run_command('clean')
        safe_remove(spec_file)
        safe_remove(code_file)
コード例 #2
0
 def fetch_build_egg(self, req):
     """Fetch an egg needed for building"""
     from setuptools.command.easy_install import easy_install
     dist = self.__class__({'script_args': ['easy_install']})
     opts = dist.get_option_dict('easy_install')
     opts.clear()
     opts.update(
         (k, v)
         for k, v in self.get_option_dict('easy_install').items()
         if k in (
             # don't use any other settings
             'find_links', 'site_dirs', 'index_url',
             'optimize', 'site_dirs', 'allow_hosts',
         ))
     if self.dependency_links:
         links = self.dependency_links[:]
         if 'find_links' in opts:
             links = opts['find_links'][1] + links
         opts['find_links'] = ('setup', links)
     install_dir = self.get_egg_cache_dir()
     cmd = easy_install(
         dist, args=["x"], install_dir=install_dir,
         exclude_scripts=True,
         always_copy=False, build_directory=None, editable=False,
         upgrade=False, multi_version=True, no_report=True, user=False
     )
     cmd.ensure_finalized()
     return cmd.easy_install(req)
コード例 #3
0
ファイル: dist.py プロジェクト: jmavila/python
    def fetch_build_egg(self, req):
        """Fetch an egg needed for building"""

        try:
            cmd = self._egg_fetcher
            cmd.package_index.to_scan = []
        except AttributeError:
            from setuptools.command.easy_install import easy_install
            dist = self.__class__({'script_args':['easy_install']})
            dist.parse_config_files()
            opts = dist.get_option_dict('easy_install')
            keep = (
                'find_links', 'site_dirs', 'index_url', 'optimize',
                'site_dirs', 'allow_hosts'
            )
            for key in list(opts.keys()):
                if key not in keep:
                    del opts[key]   # don't use any other settings
            if self.dependency_links:
                links = self.dependency_links[:]
                if 'find_links' in opts:
                    links = opts['find_links'][1].split() + links
                opts['find_links'] = ('setup', links)
            cmd = easy_install(
                dist, args=["x"], install_dir=os.curdir, exclude_scripts=True,
                always_copy=False, build_directory=None, editable=False,
                upgrade=False, multi_version=True, no_report=True, user=False
            )
            cmd.ensure_finalized()
            self._egg_fetcher = cmd
        return cmd.easy_install(req)
コード例 #4
0
 def fetch_build_egg(self, req):
     """Fetch an egg needed for building"""
     from setuptools.command.easy_install import easy_install
     dist = self.__class__({'script_args': ['easy_install']})
     dist.parse_config_files()
     opts = dist.get_option_dict('easy_install')
     keep = (
         'find_links', 'site_dirs', 'index_url', 'optimize',
         'site_dirs', 'allow_hosts'
     )
     for key in list(opts):
         if key not in keep:
             del opts[key]  # don't use any other settings
     if self.dependency_links:
         links = self.dependency_links[:]
         if 'find_links' in opts:
             links = opts['find_links'][1].split() + links
         opts['find_links'] = ('setup', links)
     install_dir = self.get_egg_cache_dir()
     cmd = easy_install(
         dist, args=["x"], install_dir=install_dir,
         exclude_scripts=True,
         always_copy=False, build_directory=None, editable=False,
         upgrade=False, multi_version=True, no_report=True, user=False
     )
     cmd.ensure_finalized()
     return cmd.easy_install(req)
コード例 #5
0
ファイル: dist.py プロジェクト: arlogriffiths/isaw.web
    def fetch_build_egg(self, req):
        """Fetch an egg needed for building"""
        try:
            cmd = self._egg_fetcher
        except AttributeError:
            from setuptools.command.easy_install import easy_install

            dist = self.__class__({"script_args": ["easy_install"]})
            dist.parse_config_files()
            opts = dist.get_option_dict("easy_install")
            keep = ("find_links", "site_dirs", "index_url", "optimize", "site_dirs", "allow_hosts")
            for key in opts.keys():
                if key not in keep:
                    del opts[key]  # don't use any other settings
            if self.dependency_links:
                links = self.dependency_links[:]
                if "find_links" in opts:
                    links = opts["find_links"][1].split() + links
                opts["find_links"] = ("setup", links)
            cmd = easy_install(
                dist,
                args=["x"],
                install_dir=os.curdir,
                exclude_scripts=True,
                always_copy=False,
                build_directory=None,
                editable=False,
                upgrade=False,
                multi_version=True,
                no_report=True,
            )
            cmd.ensure_finalized()
            self._egg_fetcher = cmd
        return cmd.easy_install(req)
コード例 #6
0
def run_setup_command(prj: spec.BigflowProjectSpec, command, options=None):
    """Execute distutils command in the scope of same python process."""

    attrs = projectspec_to_setuppy_kwargs(prj)
    logger.debug("Create tmp Distribution with attrs %r", attrs)
    dist = BigflowDistribution(attrs)

    if options:
        logger.debug("Update command options with %s", options)
        dist.get_option_dict(command).update(options)

    cmd_obj = dist.get_command_obj(command)
    logger.debug("Command object is %s", cmd_obj)
    cmd_obj.ensure_finalized()

    logger.info("Run command %s with options %s", command, options)
    cmd_obj.run()
コード例 #7
0
ファイル: deps.py プロジェクト: pombredanne/pip-run
def _needs_pip_4106_workaround():
    """
    Detect if the environment is configured with a prefix, as
    the workaround is only required under those conditions.
    """
    import distutils.dist

    dist = distutils.dist.Distribution()
    dist.parse_config_files()
    return 'prefix' in dist.get_option_dict('install')
コード例 #8
0
ファイル: pip_test.py プロジェクト: fourks/Eigenharp
def compile_module(module, specification, include_path=[]):
    spec_file = 'testtmp_%s.pip' % module
    code_file = 'testtmp_%s.cpp' % module
    extra = []

    if sys.platform == 'darwin':
        extra.append('/usr/lib/libstdc++.6.dylib')

    ext = distutils.core.Extension(module,
                                   sources=[code_file],
                                   extra_objects=extra,
                                   extra_link_args=['-g'],
                                   extra_compile_args=['-g'])
    dist = distutils.dist.Distribution(dict(ext_modules=[ext]))
    bin_file = None

    try:
        os.mkdir('build')
    except:
        pass

    try:
        f = file(spec_file, "w")
        f.write(specification)
        f.close()

        pip.generate(module, spec_file, code_file, include_path)

        dist.get_option_dict('build_ext')['inplace'] = ('script', True)
        dist.get_option_dict('build_ext')['verbose'] = ('script', True)
        dist.run_command('build_ext')
        bin_file = dist.get_command_obj('build_ext').get_ext_filename(module)
        return imp.load_dynamic(module, bin_file)

    finally:
        if bin_file is not None:
            safe_remove(bin_file)
        dist.run_command('clean')
        safe_remove(spec_file)
        safe_remove(code_file)
コード例 #9
0
    def fetch_build_egg(self, req):
        """Fetch an egg needed for building"""

        try:
            cmd = self._egg_fetcher
            cmd.package_index.to_scan = []
        except AttributeError:
            from setuptools.command.easy_install import easy_install
            dist = self.__class__({'script_args':['easy_install']})
            dist.parse_config_files()
            opts = dist.get_option_dict('easy_install')
            keep = (
                'find_links', 'site_dirs', 'index_url', 'optimize',
                'site_dirs', 'allow_hosts'
            )
            for key in list(opts):
                if key not in keep:
                    del opts[key]   # don't use any other settings
            if self.dependency_links:
                links = self.dependency_links[:]
                if 'find_links' in opts:
                    links = opts['find_links'][1].split() + links
                opts['find_links'] = ('setup', links)