Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Option to use original package directory to install from pip. #9819

Closed
fx-kirin opened this issue Apr 20, 2021 · 4 comments
Closed

Option to use original package directory to install from pip. #9819

fx-kirin opened this issue Apr 20, 2021 · 4 comments
Labels
resolution: duplicate Duplicate of an existing issue/PR

Comments

@fx-kirin
Copy link

What's the problem this feature will solve?
Currently, pip install . command cannnot handle the relative path from Cargo.toml which is used in setup-tools-rust. Because installing from pip requires to copy the whole package to temporary directory and it breaks relative path link.

Installing the package through python setup.py install works completely. But trying to work with poetry requires to use pip. So I need some way to cope with the problem.

This issue might be related to PyO3/maturin#330.

Describe the solution you'd like
Want an option to use the original directory to install a python package not to use a temporary directory.

Alternative Solutions
Maybe an option to set current path to install package. But current --root option does not work.

Additional context
I modified the function _prepare_linked_requirement in pip/_internal/operations/prepare.py and the install was completed.

    def _prepare_linked_requirement(self, req, parallel_builds):
        # type: (InstallRequirement, bool) -> Distribution
        assert req.link
        link = req.link

        self._ensure_link_req_src_dir(req, parallel_builds)
        hashes = self._get_linked_req_hashes(req)
        if link.url not in self._downloaded:
            try:
                if not link.is_existing_dir():
                    local_file = unpack_url(
                        link, req.source_dir, self._download,
                        self.download_dir, hashes,
                    )
                else:
                    req.source_dir = link.file_path
                    local_file = None
            except NetworkConnectionError as exc:
                raise InstallationError(
                    'Could not install requirement {} because of HTTP '
                    'error {} for URL {}'.format(req, exc, link)
                )
        else:
            file_path, content_type = self._downloaded[link.url]
            if hashes:
                hashes.check_against_path(file_path)
            local_file = File(file_path, content_type)

        # For use in later processing,
        # preserve the file path on the requirement.
        if local_file:
            req.local_file_path = local_file.path

        dist = _get_prepared_distribution(
            req, self.req_tracker, self.finder, self.build_isolation,
        )
        return dist
@sbidoul
Copy link
Member

sbidoul commented Apr 20, 2021

This has been implemented and will be in pip 21.1. You can try the main branch with --use-feature=in-tree-build.

@uranusjr uranusjr added the resolution: duplicate Duplicate of an existing issue/PR label Apr 20, 2021
@uranusjr
Copy link
Member

See #9091

@fx-kirin
Copy link
Author

Thanks!

@chriamue
Copy link

This has been implemented and will be in pip 21.1. You can try the main branch with --use-feature=in-tree-build.

PIP 21.1 is out now. I tested it with

pip install . --use-feature=in-tree-build

and it works now.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Sep 26, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
resolution: duplicate Duplicate of an existing issue/PR
Projects
None yet
Development

No branches or pull requests

4 participants