-
Notifications
You must be signed in to change notification settings - Fork 2.3k
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
Poetry with virtualenvs.create false
installs packages into the wrong place on Ubuntu
#6459
Comments
Looks like this is the old Debian patching of poetry/src/poetry/utils/env.py Lines 193 to 222 in c4b2253
If I had to guess, it's because we always treat the target environment as a Honestly, this is such an edge case (and mostly the result of bad Debian packaging) that I'm not sure there's much value in fixing it -- it's easily resolved if you make use of a self-compiled Python or virtual environments (there is no reason to avoid them in a container, and doing so exposes you to all sorts of sharp edges like this). This feels like another instance of #6398 -- I would highly suggest looking at the pattern here #6397 (comment) for something that is as ergonomic, but unlikely to be broken by distro packaging decisions. |
Some more reading on this issue: mesonbuild/meson#8739 I also suppose I'll ping @abn as historically he's the one interested in trying to paper over these bad decisions. |
Thanks @neersighted - this is indeed an instance of that. The context here from our perspective is that the OS package for But, that led to us wanting to manage certain OS level dependencies via python packaging rather than OS level packaging. At the time that seemed like a reasonable thing to do. We were originally just doing something simple like I hope that adds some context around situations where managing OS level dependencies via a python dependency management tool might be desirable. Perhaps the path forward for us is to manipulate the default |
a sensible pattern is, |
I'd definitely say that this is one of the rare cases where 'I know what I'm doing and the global environment is the best solution' is the case... Certainly, MRs to fix it are welcome since this is functionality we should have -- it's just functionality that only comes up during installs to the global environment on 4+ year old Debian releases 😆 If anyone would like advice on working on this, please feel free to reach out -- otherwise I'll try to look at it, but the timeline on that may be a while. That being said, this is a bit of a square peg round hole situation, and ultimately pipx or something else probably is a more natural fit. |
I'm running into this with a simpler setup again with virtualenvs = false. Dependencies aren't being installed into the right location, so the system python can't find them.
I guess for the time being we will start using venvs |
@Mattwmaster58 Please report what OS version and Python package version you are encountering this with. |
Facing this with python 3.8 on Ubuntu 20.04. on docker image mcr.microsoft.com/playwright/python:v1.24.0-focal I had to replace to pip install poetry==1.1.14 to get this working expected. but with current poetry version the issue persist. |
@neersighted @manojatlas is my exact case where I'm seeing the problem. I can share a minimum docker file if you'd like |
Does that mean you're on the same image (or at least OS version)? |
Same image yes |
Okay, thanks for the info -- in the mean time, is there a reason that you cannot use virtual environments (like @amcinnes)? There are myriad reasons to prefer them, from being insulated from the packaging choices of the distro, to avoiding mixing unexpected Python code into your environment, to being able to copy them across multi-stage container builds. |
No, not any substantial reason. We ended up that it to get around this bug. |
The reason I wanted to disable virtual environment was that inside the docker image Playwright is install in system environment and I use poetry then the dependencies will be installed in the virtual environment. so it wont work as cant find packages. So for this I had to disable the virtual environment and install all dependencies in the system. @Mattwmaster58 : what alternative way you've used? also if you can share your minimum docker file would be great. |
@manojatlas nothing special really, I can share if you want. Playwright images don't have client libraries preinstalled, only necessary libs and binaries to run the browsers it supports. Installing in a venv does not prevent you from using those preinstalled browsers. |
Maybe out of topic question: ok in that case I have to activate virtual environment when I want to execute tests? |
Yes, or use poetry run
…On Mon, Sep 12, 2022, 10:30 PM manojatlas ***@***.***> wrote:
ok in that case I have to activate virtual environment when I want to
execute tests?
—
Reply to this email directly, view it on GitHub
<#6459 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AGI56LIXAADXU5BVLHBOPB3V577OBANCNFSM6AAAAAAQILJ47U>
.
You are receiving this because you were mentioned.Message ID:
***@***.***>
|
I was trying to find a bug report opened against Ubuntu describing this behavior. I think it's this one, but I'd appreciate it if someone else can confirm: https://bugs.launchpad.net/ubuntu/+source/python3-defaults/+bug/1408092 The biggest reason I'm doubting myself is that this one has been open since 2015, but no apparent progress. |
We do have code to work around this, but it is just not being triggered properly -- so there is a Poetry bug, but Poetry would not have to do anything special if the distro patches were applied properly/consistently (trying to get this information out of distutils is fraught). |
I see that the conversation has moved on quite a bit since this comment about the bug being an edge case, but I just wanted to push back on it a little bit: not only are Ubuntu and Debian a considerable portion of the total Linux space on their own, but also the official Python docker containers are built from Debian bullseye and buster (unless we want to use alpine). I would think poetry would hope to work out of the box with the official Python images. Edit: not to say that it isn't annoying that this issue has persisted for so long in those distros, but it really does seem like something poetry needs to be resilient to. |
The official Python images are just fine as they use a Python.org build of Python and not a patched/hacked distro-supplied Python. The edge case is mostly installing to system site-packages using a Debian-derived Python, which is definitely a thing people do, but is often ill-advised and will always be prone to sharp edges due to deviation from the standard Python ecosystem. |
It's not so much that Poetry isn't resilient to it -- it's that Debian makes undocumented and invasive adjustments to code that isn't meant to be exposed/portable to any external tooling like Poetry, and we have to constantly hit a moving target that is not documented anywhere. It's hard to be truly robust and resilient when Debian doesn't make their patches in a way that is stable or consumable. If the linked launchpad issue is ever fixed this will just work -- but as long as Debian monkeypatches distutils and doesn't properly set sysconfig paths (like specified in the Python Packager's documentation) this will remain a moving target as we have to introspect unexported internals of a deprecated module. |
Adding to the argument by saying that I'd very much like to use official Using a virtual environment would defeat the purpose of using an image with everything pre-installed (including jupyter notebook). |
It's also causing issues with the Tensorflow images. |
+1 for this issue. We shouldn't need to use a virtual environment inside a Docker image. I'm facing the issue when using an |
I'm running into this issue as well on Fedora 36 |
Any update on the fix for this bug? |
Same issue for me |
Plus one for this - it's not just aws cli it's a problem for us deploying our docker containers - we want our installed [tool.poetry.scripts] to be runnable at system level without having to prepend with poetry run. |
In a container, you can use |
@neersighted Thanks for the feedback :) Of course there are workarounds, but it was working very seamlessly before. I think also using the term "virtual environment" is kind of misleading when one just wants to use the system Python environment. So the expecation of (Finding out the correct path of the system Python environment is also not super easy 😄) |
Anyway, you should still at the very least use virtual environments to keep Poetry and your project from mixing in a container, or Poetry will happily uninstall parts of itself when they intersect with your project. |
Is it hard to fix that? If you can give some pointers, maybe I can try? |
looks as though debian do patch
NB the above contains with python 3.7 near enough eol, that only leaves debian-based distributions of python 3.8 and 3.9 as problematic. That's still a non-zero number of users: but hopefully a dwindling number, for many of whom "use a newer distribution / python" should be a reasonable answer. |
#7766 implicitly makes this wontfix: if on debian, use a virtual environment or python >= 3.10 |
the above is both irrelevant in this issue, and untrue. FROM python:3.11.3-slim-bullseye
RUN pip install -U poetry
RUN poetry config virtualenvs.create false
CMD ["/usr/local/bin/poetry"] $ docker run -it --rm foo:latest poetry config --list | grep virtualenvs.create
virtualenvs.create = false |
@dimbleby |
Still irrelevant to this issue (you are mixing users) |
Here is a tmp solution I used to set poetry env as the default python interpreter in docker.
|
I'm seeing what seems to be the same problem with using We're onto poetry = 1.8.3 at the time of writing this... FIXEDAfter install, there doesn't appear to be an actual config file in the expected locations for Poetry. Thus, in my scenario, I was setting venv=false, but then I was manually putting in a custom repository via By putting the I'm still left wondering where the poetry config exists after install though, before any explicit additional config is added - and why is there no file evidence after using |
-vvv
option).Issue
To reproduce the issue:
Expected behaviour (seen with poetry 1.1.14): the
aws
command runs successfully.Observed behaviour (with poetry 1.2.0): the
aws
command fails.This seems to be because with poetry 1.2.0,
awscli
has been installed into/usr/lib/python3.8/site-packages/awscli
which is not in the Python path.The text was updated successfully, but these errors were encountered: