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

Cannot install plugins within poetry #171042

Closed
4 tasks done
twam opened this issue May 7, 2024 · 9 comments
Closed
4 tasks done

Cannot install plugins within poetry #171042

twam opened this issue May 7, 2024 · 9 comments
Labels
bug Reproducible Homebrew/homebrew-core bug stale No recent activity

Comments

@twam
Copy link
Contributor

twam commented May 7, 2024

brew gist-logs <formula> link OR brew config AND brew doctor output

$ brew config                                       
HOMEBREW_VERSION: 4.2.21
ORIGIN: https://github.com/Homebrew/brew
HEAD: 82c2e743a5bcea725f9ca1429e3e21c3088ff904
Last commit: 30 hours ago
Core tap JSON: 07 May 12:18 UTC
Core cask tap JSON: 07 May 12:18 UTC
HOMEBREW_PREFIX: /usr/local
HOMEBREW_CASK_OPTS: ["--no-quarantine"]
HOMEBREW_EDITOR: subl --wait
HOMEBREW_GITHUB_API_TOKEN: set
HOMEBREW_MAKE_JOBS: 16
Homebrew Ruby: 3.1.4 => /usr/local/Homebrew/Library/Homebrew/vendor/portable-ruby/3.1.4/bin/ruby
CPU: 16-core 64-bit skylake
Clang: 15.0.0 build 1500
Git: 2.39.3 => /Library/Developer/CommandLineTools/usr/bin/git
Curl: 8.4.0 => /usr/bin/curl
macOS: 14.4.1-x86_64
CLT: 15.3.0.0.1.1708646388
Xcode: 15.3
$ brew doctor
Your system is ready to brew.

Verification

  • My brew doctor output says Your system is ready to brew. and am still able to reproduce my issue.
  • I ran brew update and am still able to reproduce my issue.
  • I have resolved all warnings from brew doctor and that did not fix my problem.
  • I searched for recent similar issues at https://github.com/Homebrew/homebrew-core/issues?q=is%3Aissue and found no duplicates.

What were you trying to do (and why)?

Install a plugin (poetry-dynamic-versioning) within poetry by

poetry self add "poetry-dynamic-versioning[plugin]"

What happened (include all command output)?

Installation fails as poetry is trying to update pycparser which was installed by brew:

poetry self add "poetry-dynamic-versioning[plugin]"
Using version ^1.3.0 for poetry-dynamic-versioning

Updating dependencies
Resolving dependencies... (0.9s)

Package operations: 4 installs, 9 updates, 0 removals

  - Updating certifi (2024.2.2 /private/tmp/python-certifi-20240202-5063-q0mlj8/certifi-2024.2.2 -> 2024.2.2)
  - Updating pycparser (2.22 /usr/local/lib/python3.12/site-packages -> 2.22): Failed

  CalledProcessError

  Command '['/usr/local/Cellar/poetry/1.8.2_2/libexec/bin/python', '/usr/local/Cellar/poetry/1.8.2_2/libexec/lib/python3.12/site-packages/virtualenv/seed/wheels/embed/pip-24.0-py3-none-any.whl/pip', 'uninstall', 'pycparser', '-y']' returned non-zero exit status 1.

  at /usr/local/Cellar/[email protected]/3.12.3/Frameworks/Python.framework/Versions/3.12/lib/python3.12/subprocess.py:571 in run
       567│             # We don't call process.wait() as .__exit__ does that for us.
       568│             raise
       569│         retcode = process.poll()
       570│         if check and retcode:
    →  571│             raise CalledProcessError(retcode, process.args,
       572│                                      output=stdout, stderr=stderr)
       573│     return CompletedProcess(process.args, retcode, stdout, stderr)
       574│ 
       575│ 

The following error occurred when trying to handle this error:


  EnvCommandError

  Command ['/usr/local/Cellar/poetry/1.8.2_2/libexec/bin/python', '/usr/local/Cellar/poetry/1.8.2_2/libexec/lib/python3.12/site-packages/virtualenv/seed/wheels/embed/pip-24.0-py3-none-any.whl/pip', 'uninstall', 'pycparser', '-y'] errored with the following return code 1
  
  Output:
  Found existing installation: pycparser 2.22
  ERROR: Cannot uninstall pycparser 2.22, RECORD file not found. Hint: The package was installed by brew.
  

  at /usr/local/Cellar/poetry/1.8.2_2/libexec/lib/python3.12/site-packages/poetry/utils/env/base_env.py:342 in _run
      338│                 output = subprocess.check_output(
      339│                     cmd, stderr=stderr, env=env, text=True, **kwargs
      340│                 )
      341│         except CalledProcessError as e:
    → 342│             raise EnvCommandError(e)
      343│ 
      344│         return output
      345│ 
      346│     def execute(self, bin: str, *args: str, **kwargs: Any) -> int:

Cannot install pycparser.

What did you expect to happen?

Plugin is successfully installed.

Step-by-step reproduction instructions (by running brew commands)

brew install poetry
# weeks later
poetry self add "poetry-dynamic-versioning[plugin]"
@twam twam added the bug Reproducible Homebrew/homebrew-core bug label May 7, 2024
@woodruffw
Copy link
Member

Unfortunately I suspect this won't work, at least not with any poetry plugin that wants to upgrade Homebrew's Python environment: allowing these kinds of resolution changes would allow anything that gets brew installed to break other Homebrew-managed Python applications.

I believe there are two resolutions possible here:

  • We could package this poetry plugin as a formula with the same Python dependency as poetry itself, which would drop it into the same environment. Then, you could do brew install poetry-dynamic-version to enable it.
  • You could put poetry into its own environment, which is (probably) how it wants to be used (I don't know poetry super well, but this is what their docs suggest). I think brew install pipx; pipx install poetry; pipx inject poetry "poetry-dynamic-versioning[plugin]" would suffice for that.

@twam
Copy link
Contributor Author

twam commented May 17, 2024

I personally would prefer a way, that is managed by brew, so that a brew upgrade will also update poetry and its plugins.

The second suggestion works for now, but feels wrong, as there is a poetry package provided by brew which I cannot use. :)

@SMillerDev
Copy link
Member

You can make your own tap and maintain a package there.

Copy link
Contributor

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs.

@github-actions github-actions bot added the stale No recent activity label Jun 17, 2024
@btonasse
Copy link

btonasse commented Jul 4, 2024

Encountering the same issue :(

@woodruffw
Copy link
Member

Encountering the same issue :(

Have you tried either of the resolutions suggested above? Relying with a "me too" comment on its own doesn't help us address the underlying problem.

Keep in mind: Homebrew does not distribute Python with the expectation that arbitrary third-party packages can be loaded into Homebrewed Python's environment. If this is a capability that you need, you must use pip, pipx, or pyenv, depending on the layer of abstraction you need. For poetry, pipx with dependency injection is probably the simplest option, and seems to be recommended by poetry's maintainers.

@btonasse
Copy link

btonasse commented Jul 5, 2024

I do not expect you to "solve it", but I think developers like to have an idea of how many users are encountering an issue and how problematic it is for them. That alone is worth a "me too" post. You're of course free to do whatever you want with that information. But last time I checked this issue was not closed.

And yes, refraining from installing poetry with homebrew sidesteps the problem.

@heidi-jack
Copy link

I was also experiencing this issue, in the end I just uninstalled poetry via brew and installed it outside of brew. Not worth the faff. Not a solution within brew unfortunately but it unblocked me from getting work done

https://python-poetry.org/docs/#installing-with-the-official-installer

@woodruffw
Copy link
Member

I think this is currently non-actionable on Homebrew's side. Our recommendations to users who need Poetry plugins are:

  1. brew install pipx && pipx install poetry and use pipx's environment injection abilities to load plugins into Poetry's virtual environment (described above)
  2. Do python -m venv env && env/bin/python -m pip install poetry if using a directly managed virtual environment is appropriate for your use case
  3. brew install pyenv and then pyenv to install a non-Homebrew version of Python without PEP 668 restrictions, and then pip install --user poetry directly (if that's what you want)
  4. Use Poetry's own installer (keeping in mind that Homebrew doesn't check the contents of this installer, and doesn't guarantee that it works correctly with the Homebrewed Python)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Reproducible Homebrew/homebrew-core bug stale No recent activity
Projects
None yet
Development

No branches or pull requests

6 participants
@twam @SMillerDev @woodruffw @btonasse @heidi-jack and others