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

Latest packaging (23.2) release breaks pipx detection of local path installation #1092

Closed
potiuk opened this issue Oct 20, 2023 · 3 comments
Closed

Comments

@potiuk
Copy link
Contributor

potiuk commented Oct 20, 2023

Describe the bug

Latest packaging release (23.2) breaks pipx detection of local path installation.

When you install pipx from the scratch and you are trying to run:

pipx install --editable  ./<path_to_package_spec>

You get this warning:

⚠️ Ignoring --editable install option. pipx disallows it for anything but a local path, to avoid having to create a new src/ directory.

This is clearly wrong, as we are trying to install package from local path, so --editable flag should be still OK.

How to reproduce

  • Prepare clean installation of pipx from the scratch. Make sure packaging version is 23.2
> pip freeze | grep packaging
packaging==23.2
  • Check out any Python source project to a local directory (for example you can check out git@github.com:apache/airflow.git and and look at ./dev/breeze project which is part of the repository)
  • Run pipx install --editable <path_to_the project> (for example pipx install --editable ./dev/breeze in checked out airflow repository
  • See the warning message produced:

⚠️ Ignoring --editable install option. pipx disallows it for anything but a local path, to avoid having to create a new src/ directory.

This change is caused by change in behaviour of the packaging (23.2) project, specifically pypa/packaging#120 . You can also go back t correct behaviour by downgrading the packaging to version 23.1)

pip install "packaging==23.1"
pipx install --editable ./dev/breeze

This works fine without the warning.

The root cause of it is this code from pipx/package_specifier.py:

 if not valid_pep508:
        try:
            package_req = Requirement("notapackagename @ " + package_spec)
        except InvalidRequirement:  # !!! <- this exception not thrown any more
            # not a valid url 
            pass
        else:
            valid_url = package_spec

    if not valid_pep508 and not valid_url:  #!!! <- valid_url is set, so we no longer determine if package_path_str exist
        (package_path_str, package_extras_str) = _split_path_extras(package_spec)

        (package_path, package_path_exists) = _check_package_path(package_path_str)

        if package_path_exists:
            valid_local_path = str(package_path.resolve()) + package_extras_str

The code relies implicitly on Requirement throwing an exception in case package specification is a local path. Since the exception is not thrown any more, valid_url is set and the check for existence of the path is not done.

Expected behavior

The local path should be detected as local path and editable install should be allowed.

@hussein-awala
Copy link

I wonder if this issue duplicates #1070, which was fixed by #1071 🤔

potiuk added a commit to potiuk/airflow that referenced this issue Oct 20, 2023
The latest packaging - 23.2 breaks `pipx` detection of local path
installation and renders breeze installation impossible. The
workaround to it until pypa/pipx#1092
is solved is to downgrade packaging to < 23.2 - this is mostly
applicable to fresh installations of `pipx` that pull the latest
packaging.

This PR adds appropriate description to breeze installation process
- what to do when it fails, it also updates the advice printed
when the fallback to non-editable installation and provide an
advice to downgrade packaging.
@potiuk
Copy link
Contributor Author

potiuk commented Oct 20, 2023

Ah yes. I was on holidays when it happened... Closing as duplicate then.

@potiuk potiuk closed this as completed Oct 20, 2023
@potiuk
Copy link
Contributor Author

potiuk commented Oct 20, 2023

I did not even remember I commented it then.

potiuk added a commit to apache/airflow that referenced this issue Oct 20, 2023
…35092)

The latest packaging - 23.2 breaks `pipx` detection of local path
installation and renders breeze installation impossible. The
workaround to it until pypa/pipx#1092
is solved is to downgrade packaging to < 23.2 - this is mostly
applicable to fresh installations of `pipx` that pull the latest
packaging.

This PR adds appropriate description to breeze installation process
- what to do when it fails, it also updates the advice printed
when the fallback to non-editable installation and provide an
advice to downgrade packaging.
potiuk added a commit to apache/airflow that referenced this issue Oct 29, 2023
…35092)

The latest packaging - 23.2 breaks `pipx` detection of local path
installation and renders breeze installation impossible. The
workaround to it until pypa/pipx#1092
is solved is to downgrade packaging to < 23.2 - this is mostly
applicable to fresh installations of `pipx` that pull the latest
packaging.

This PR adds appropriate description to breeze installation process
- what to do when it fails, it also updates the advice printed
when the fallback to non-editable installation and provide an
advice to downgrade packaging.

(cherry picked from commit 4e460bf)
ahidalgob pushed a commit to GoogleCloudPlatform/composer-airflow that referenced this issue May 15, 2024
…#35092)

The latest packaging - 23.2 breaks `pipx` detection of local path
installation and renders breeze installation impossible. The
workaround to it until pypa/pipx#1092
is solved is to downgrade packaging to < 23.2 - this is mostly
applicable to fresh installations of `pipx` that pull the latest
packaging.

This PR adds appropriate description to breeze installation process
- what to do when it fails, it also updates the advice printed
when the fallback to non-editable installation and provide an
advice to downgrade packaging.

(cherry picked from commit 4e460bf083db22590f6c3e36391490fe108586e5)

GitOrigin-RevId: e55c835cdd955e82dc93b51650eb93b179969489
kosteev pushed a commit to GoogleCloudPlatform/composer-airflow that referenced this issue Jul 18, 2024
…#35092)

The latest packaging - 23.2 breaks `pipx` detection of local path
installation and renders breeze installation impossible. The
workaround to it until pypa/pipx#1092
is solved is to downgrade packaging to < 23.2 - this is mostly
applicable to fresh installations of `pipx` that pull the latest
packaging.

This PR adds appropriate description to breeze installation process
- what to do when it fails, it also updates the advice printed
when the fallback to non-editable installation and provide an
advice to downgrade packaging.

GitOrigin-RevId: 4e460bf083db22590f6c3e36391490fe108586e5
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants