Пример #1
0
 def run_egg_info(self):
     # type: () -> None
     if self.name:
         logger.debug(
             'Running setup.py (path:%s) egg_info for package %s',
             self.setup_py_path,
             self.name,
         )
     else:
         logger.debug(
             'Running setup.py (path:%s) egg_info for package from %s',
             self.setup_py_path,
             self.link,
         )
     base_cmd = make_setuptools_shim_args(self.setup_py_path,
                                          no_user_config=self.isolated)
     egg_info_cmd = base_cmd + ['egg_info']
     # We can't put the .egg-info files at the root, because then the
     # source code will be mistaken for an installed egg, causing
     # problems
     if self.editable:
         egg_base_option = []  # type: List[str]
     else:
         egg_info_dir = os.path.join(self.setup_py_dir, 'pip-egg-info')
         ensure_dir(egg_info_dir)
         egg_base_option = ['--egg-base', 'pip-egg-info']
     with self.build_env:
         call_subprocess(egg_info_cmd + egg_base_option,
                         cwd=self.setup_py_dir,
                         command_desc='python setup.py egg_info')
Пример #2
0
    def install_editable(
        self,
        install_options,  # type: List[str]
        global_options=(),  # type: Sequence[str]
        prefix=None  # type: Optional[str]
    ):
        # type: (...) -> None
        logger.info('Running setup.py develop for %s', self.name)

        if prefix:
            prefix_param = ['--prefix={}'.format(prefix)]
            install_options = list(install_options) + prefix_param
        base_cmd = make_setuptools_shim_args(
            self.setup_py_path,
            global_options=global_options,
            no_user_config=self.isolated
        )
        with indent_log():
            with self.build_env:
                call_subprocess(
                    base_cmd +
                    ['develop', '--no-deps'] +
                    list(install_options),

                    cwd=self.setup_py_dir,
                )

        self.install_succeeded = True
Пример #3
0
    def get_install_args(
            self,
            global_options,  # type: Sequence[str]
            record_filename,  # type: str
            root,  # type: Optional[str]
            prefix,  # type: Optional[str]
            pycompile  # type: bool
    ):
        # type: (...) -> List[str]
        install_args = make_setuptools_shim_args(self.setup_py_path,
                                                 global_options=global_options,
                                                 no_user_config=self.isolated,
                                                 unbuffered_output=True)
        install_args += ['install', '--record', record_filename]
        install_args += ['--single-version-externally-managed']

        if root is not None:
            install_args += ['--root', root]
        if prefix is not None:
            install_args += ['--prefix', prefix]

        if pycompile:
            install_args += ["--compile"]
        else:
            install_args += ["--no-compile"]

        if running_under_virtualenv():
            py_ver_str = 'python' + sysconfig.get_python_version()
            install_args += [
                '--install-headers',
                os.path.join(sys.prefix, 'include', 'site', py_ver_str,
                             self.name)
            ]

        return install_args
Пример #4
0
    def install_editable(
            self,
            install_options,  # type: List[str]
            global_options=(),  # type: Sequence[str]
            prefix=None  # type: Optional[str]
    ):
        # type: (...) -> None
        logger.info('Running setup.py develop for %s', self.name)

        if self.isolated:
            global_options = list(global_options) + ["--no-user-cfg"]

        if prefix:
            prefix_param = ['--prefix={}'.format(prefix)]
            install_options = list(install_options) + prefix_param

        with indent_log():
            # FIXME: should we do --install-headers here too?
            with self.build_env:
                call_subprocess(
                    make_setuptools_shim_args(self.setup_py_path) +
                    list(global_options) + ['develop', '--no-deps'] +
                    list(install_options),
                    cwd=self.setup_py_dir,
                )

        self.install_succeeded = True
Пример #5
0
    def get_install_args(
            self,
            global_options,  # type: Sequence[str]
            record_filename,  # type: str
            root,  # type: Optional[str]
            prefix,  # type: Optional[str]
            pycompile,  # type: bool
    ):
        # type: (...) -> List[str]
        install_args = make_setuptools_shim_args(self.setup_py_path,
                                                 unbuffered_output=True)
        install_args += list(global_options) + [
            "install", "--record", record_filename
        ]
        install_args += ["--single-version-externally-managed"]

        if root is not None:
            install_args += ["--root", root]
        if prefix is not None:
            install_args += ["--prefix", prefix]

        if pycompile:
            install_args += ["--compile"]
        else:
            install_args += ["--no-compile"]

        if running_under_virtualenv():
            py_ver_str = "python" + sysconfig.get_python_version()
            install_args += [
                "--install-headers",
                os.path.join(sys.prefix, "include", "site", py_ver_str,
                             self.name),
            ]

        return install_args
Пример #6
0
def _generate_metadata_legacy(install_req):
    # type: (InstallRequirement) -> None
    req_details_str = install_req.name or "from {}".format(install_req.link)
    logger.debug(
        'Running setup.py (path:%s) egg_info for package %s',
        install_req.setup_py_path, req_details_str,
    )

    # Compose arguments for subprocess call
    base_cmd = make_setuptools_shim_args(install_req.setup_py_path)
    if install_req.isolated:
        base_cmd += ["--no-user-cfg"]

    # For non-editable installs, don't put the .egg-info files at the root,
    # to avoid confusion due to the source code being considered an installed
    # egg.
    egg_base_option = []  # type: List[str]
    if not install_req.editable:
        egg_info_dir = os.path.join(
            install_req.unpacked_source_directory, 'pip-egg-info',
        )
        egg_base_option = ['--egg-base', egg_info_dir]

        # setuptools complains if the target directory does not exist.
        ensure_dir(egg_info_dir)

    with install_req.build_env:
        call_subprocess(
            base_cmd + ["egg_info"] + egg_base_option,
            cwd=install_req.unpacked_source_directory,
            command_desc='python setup.py egg_info',
        )
Пример #7
0
def test_make_setuptools_shim_args__no_user_config(
        no_user_config: bool) -> None:
    args = make_setuptools_shim_args(
        "/dir/path/setup.py",
        no_user_config=no_user_config,
    )
    assert ("--no-user-cfg" in args) == no_user_config
Пример #8
0
 def _base_setup_args(self, req):
     # NOTE: Eventually, we'd want to also -S to the flags here, when we're
     # isolating. Currently, it breaks Python in virtualenvs, because it
     # relies on site.py to find parts of the standard library outside the
     # virtualenv.
     return make_setuptools_shim_args(req.setup_py_path,
                                      global_options=self.global_options,
                                      unbuffered_output=True)
Пример #9
0
def test_make_setuptools_shim_args__global_options(global_options):
    args = make_setuptools_shim_args(
        '/dir/path/setup.py',
        global_options=global_options,
    )

    if global_options:
        assert len(args) == 5
        for option in global_options:
            assert option in args
    else:
        assert len(args) == 3
Пример #10
0
def test_make_setuptools_shim_args(unbuffered_output):
    args = make_setuptools_shim_args(
        "/dir/path/setup.py",
        unbuffered_output=unbuffered_output
    )

    assert ("-u" in args) == unbuffered_output

    assert args[-2] == "-c"

    assert "sys.argv[0] = '/dir/path/setup.py'" in args[-1]
    assert "__file__='/dir/path/setup.py'" in args[-1]
Пример #11
0
def test_make_setuptools_shim_args__global_options(
    global_options: Optional[List[str]], ) -> None:
    args = make_setuptools_shim_args(
        "/dir/path/setup.py",
        global_options=global_options,
    )

    if global_options:
        assert len(args) == 5
        for option in global_options:
            assert option in args
    else:
        assert len(args) == 3
Пример #12
0
def test_make_setuptools_shim_args():
    # Test all arguments at once, including the overall ordering.
    args = make_setuptools_shim_args(
        '/dir/path/setup.py',
        global_options=['--some', '--option'],
        no_user_config=True,
        unbuffered_output=True,
    )

    assert args[1:3] == ['-u', '-c']
    # Spot-check key aspects of the command string.
    assert "sys.argv[0] = '/dir/path/setup.py'" in args[3]
    assert "__file__='/dir/path/setup.py'" in args[3]
    assert args[4:] == ['--some', '--option', '--no-user-cfg']
Пример #13
0
def test_make_setuptools_shim_args() -> None:
    # Test all arguments at once, including the overall ordering.
    args = make_setuptools_shim_args(
        "/dir/path/setup.py",
        global_options=["--some", "--option"],
        no_user_config=True,
        unbuffered_output=True,
    )

    assert args[1:3] == ["-u", "-c"]
    assert args[4:] == ["--some", "--option", "--no-user-cfg"]

    shim = args[3]
    # Spot-check key aspects of the command string.
    assert "import setuptools" in shim
    assert "'/dir/path/setup.py'" in args[3]
    assert "sys.argv[0] = __file__" in args[3]
Пример #14
0
def test_make_setuptools_shim_args__unbuffered_output(unbuffered_output):
    args = make_setuptools_shim_args('/dir/path/setup.py',
                                     unbuffered_output=unbuffered_output)
    assert ('-u' in args) == unbuffered_output
Пример #15
0
def test_make_setuptools_shim_args__no_user_config(no_user_config):
    args = make_setuptools_shim_args(
        '/dir/path/setup.py',
        no_user_config=no_user_config,
    )
    assert ('--no-user-cfg' in args) == no_user_config
Пример #16
0
def test_make_setuptools_shim_args__unbuffered_output(
        unbuffered_output: bool) -> None:
    args = make_setuptools_shim_args("/dir/path/setup.py",
                                     unbuffered_output=unbuffered_output)
    assert ("-u" in args) == unbuffered_output