python-poetry / poetry

Python packaging and dependency management made easy
https://python-poetry.org
MIT License
30.92k stars 2.25k forks source link

pip_editable_install() got an unexpected keyword argument 'upgrade' #4265

Closed jnoortheen closed 2 years ago

jnoortheen commented 3 years ago

Issue

when installing packages without pyproject.toml in edit mode, it raises following exception


  at ~/.local/pipx/venvs/poetry@master/lib/python3.9/site-packages/poetry/installation/executor.py:129 in pip_install
      125│         if editable:
      126│             func = pip_editable_install
      127│ 
      128│         try:
    → 129│             func(req, self._env, upgrade=upgrade)
      130│         except EnvCommandError as e:
      131│             output = decode(e.e.output)
      132│             if (
      133│                 "KeyboardInterrupt" in output
jnoortheen commented 3 years ago

the particular line that is causing to install the dependency is

xonsh = { path = "xsh", extras = ["full"], develop = true }
desophos commented 2 years ago

I'm on Poetry version 1.2.0a2 and I've encountered this issue as well.

It appears to be caused by the mismatched signatures of pip_install and pip_editable_install. The upgrade kwarg is passed to both functions in executor.py, but pip_editable_install doesn't take such an argument.

Adding an upgrade kwarg to pip_editable_install fixed the problem:

def pip_editable_install(directory: Path, environment: Env, upgrade: bool = True) -> Union[int, str]:
    return pip_install(
        path=directory, environment=environment, editable=True, deps=False, upgrade=upgrade
    )
adamcharnock commented 2 years ago

I implemented @desophos fix in my local poetry installation and it worked great. Some useful notes for anyone doing the same:

giladbarnea commented 2 years ago

@python-poetry/triage

Hi! I would like fix this, if not already fixed (would be my first PR).

I'm not sure which implementation style best matches the project's. I made a chart that lays out the possibilities I could come up with (they're not mutually exclusive). Can you tell me which one(s) to go with?

poetry-pip-install-editable-fix

Edit: The @python-poetry/triage tag above doesn't work, does anyone know how to get the team's attention?

abn commented 2 years ago

Based on the method's current usage, i'd say we drop the editable wrapper in favour of using editable=True. This should also remove the conditional block in the executor.

There are a few test mocks that will have to be updated to ensure the right parameters are passed on.

benjaminaltieri commented 2 years ago

I am also running into this issue with poetry 1.2.0a2 with { path = ..., develop = true} as well as with poetry add -e ...

Is there potentially a workaround that doesn't involve modifying the poetry source? If not, also happy to help craft a PR if @giladbarnea hasn't moved forward with one.

github-actions[bot] commented 5 months ago

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.