Example #1
0
def build_sample_plugin():
    plugin_src_dir = os.path.join(os.path.dirname(__file__),
                                  '../../samples/scrapy-splitvariants-plugin')
    with cd(plugin_src_dir):
        if os.path.exists('dist'):
            shutil.rmtree('dist')
        d = Distribution(
            dict(
                version='1.0',
                name='scrapy_splitvariants_plugin',
                description='scrapy_splitvariants_plugin',
                packages=find_packages(exclude=['tests', 'tests.*']),
                entry_points={
                    'scrapydd.spliderplugin': [
                        'splitvariants = scrapy_splitvariants_plugin.plugin:Plugin',
                    ],
                },
                install_requires=['scrapy', 'scrapy-splitvariants'],
                zip_safe=True,
            ))
        d.script_name = 'setup.py'
        d.script_args = ['--quiet', 'clean', 'bdist_egg']
        d.parse_command_line()
        d.run_commands()

        egg_name = os.listdir('dist')[0]
        return os.path.abspath(os.path.join('dist', egg_name))
Example #2
0
def compile_c(code: str) -> Dict[str, Any]:
    """Compiles C code into a C extension, loads the extension and returns the included dict of compiled PyCapsules.

    This assumes that the code defines a module member
    ``__capi__``.

    :meta private:"""
    build_dir = "build"
    c_file_path = os.path.join(build_dir, "src", "module.c")
    prepare_c_src(c_file_path, code)
    dist = Distribution({
        "name":
        "c_api",
        "ext_modules": [Extension("c_api", sources=[c_file_path])],
        "script_name":
        "setup.py",
        "script_args": ["build_ext", "--inplace"],
    })
    dist.parse_command_line()
    dist.run_commands()
    sys.path.append(os.getcwd())
    return importlib.import_module("c_api").__capi__  # type: ignore
Example #3
0
 def run_commands(self):
       opts = self.command_options
       if "install" in opts:
             self.preprocess_files(opts["install"].get("prefix",
                                                       ("", None))[1])
       Distribution.run_commands(self)
Example #4
0
 def run_commands(self):
       opts = self.command_options
       if "install" in opts:
             self.preprocess_files(opts["install"].get("prefix",
                                                       ("", None))[1])
       Distribution.run_commands(self)
Example #5
0
 def run_commands(self):
     # By now the setup_requires deps have been fetched.
     if not self.ext_modules:
         self.ext_modules = list()
     self.ext_modules.extend(self.pyrobufize_builtins())
     Distribution.run_commands(self)
Example #6
0
 def run_commands(self):
     # By now the setup_requires deps have been fetched.
     if not self.ext_modules:
         self.ext_modules = list()
     self.ext_modules.extend(self.pyrobufize_builtins())
     Distribution.run_commands(self)