-
-
Notifications
You must be signed in to change notification settings - Fork 529
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
base_python
with full path fails with env name conflict
#3191
Comments
PR welcome 👍 |
You're asking someone who's doesn't know tox well enough even to be sure if this is a buhttps://github.com/tox-dev/tox/issues/3191g or if he's using it wrong to write a PR? What on earth are you thinking? Or are you just trying to dismiss this issue as, "not the problem of tox developers"? From the commits, it looks as if you may know tox fairly well; are you not even going to be helpful enough to answer my question about whether this is a bug or a misconfiguration? (And if you didn't intend to come across as incredibly unhelpful, condescending and dismissive, you might want also to reconsider the communications style you use when talking to people who don't know you.) |
Let me rephrase. This is a community maintained OSS project. There's no such thing really as tox developers. If you run into an issue and want to fix it, you'll need to put in a PR yourself. What you're doing is definitely not the expected way of using the tool, because of:
However, the configuration you set should still work. |
So let me suggest a different approach when receiving issues like this. First, "PR welcome" not only can come across as condescending, but it's not helpful to anyone. Those who are capable of creating a useful PR can already easily see that this project accepts PRs; those who do not understand how community-maintained OSS projects work are very unlikely to be able to provide a PR anyway. So you can just leave that out. Second, if you don't have time or desire to try to fix the issue, that's fair enough: that's how community-maintained projects work. (And I don't see that there's really any need to post a message stating that.) But if you're interested in seeing fixes come in, and you have a little bit of time, throwing out a few hints in comments on the issue can be really helpful, such as what tests cover this, what files and functions might be a good place to start looking for the problem, and so on. Again, only if you have time. But with such information, I might be encouraged to have a quick look at what's going on. I've already put a several hours into learning a bit about tox, tracking down the problems I've been having, and writing up detailed issues for them, so another half hour look into starting a PR would be worthwhile for me. But as it is, knowing nothing about where to start looking in the code base, I don't feel it's worth it to spend an unknown amount of time to dig through it just to find the general location where the problem might be. |
I just noticed I was assigned to this issue. Assigning someone without even discussing it with them is passive-aggressive, at best. That's what unpleasant bosses do. As I mentioned above, I am willing to consider looking at this, if I can get some guidance from a developer who knows the code. But if everybody here is taking the, "Hey buddy, you're on your own" attitude, I feel no special urge to try to be super-co-operative. |
Sadly, I don't know from the top of my head where exactly the issue is, a general area to look around would be https://github.com/tox-dev/tox/blob/main/src/tox/tox_env/python/api.py#L165; however, it can also end up being a bug in virtualenv. Currently, I don't have time to guide you more in-depth (as this is a side project, and I'm very busy with other life obligations). However, if you put in a PR to address the problem, I'll make some time to review it. |
Thanks; that's a good starting point. |
Ok, I chased this down a bit and it's definitely related to virtualenv's I tried out a little test to characterise its behaviour with both just an interpreter filename Just A relative or absolute path produces So is Documenting the |
PythonSpec is intended to work for spec and paths at the same time 👍 |
Well that's rather vague. Can you describe in more detail what the |
If a string does not parse as a spec, it falls back to be validated as an explicit path. Likely a bug in PythonSpec. |
I take it a "spec" is something like "312" or "3.12". (This does not seem to be documented anywhere; I think it should be.) I still don't understand what the And again, are the tests I linked above showing misunderstanding of how I think it might help a lot if you'd update the docstrings in that module to clearly describe the intent of the class and its methods, and the problems you intend it to solve. |
We don't redefine the spec definition, but we reuse virtualenv https://virtualenv.pypa.io/en/latest/user_guide.html#python-discovery. So information from there applies.
I don't have time/plan to do this, but I'll accept a PR if someone takes the effort. |
Ah, so that's where the docs are! It would be a big help to have the Other than that, the docs seem pretty clear on the specifier, but not so much on the "a relative/absolute path to a Python interpreter" part. Is Actually coding up a fix for this doesn't seem that hard, and I'm happy to work on it, but I really need to understand (in detail) the intent of |
The documentation might not be completely up-to-date 😊 PRs to improve it is welcome.
That's done at a later stage as a validation step by https://github.com/pypa/virtualenv/blob/main/src/virtualenv/discovery/py_info.py in virtualenv from the path. PythonSpec is defining the interpreter you wish to have, PythonInfo is enquiring what the interpreter actually is,. |
I would love to do a PR to improve the documentation, not to mention one to fix any bugs, but if you won't explain to me how you intend |
I had the impression that I already said that the test you shown should pass (minus the |
On a further thought, perhaps the relative and absolute paths should not generate any python implementation or version specification info, just path. So if someone symlinks 3.11 to 3.10 we don't end up in a confusing situation. |
No, I didn't get "the tests should pass" from what you said, much less " So I think I (partially, anyway) see where you're going with this: anything with a The "symlinking 3.11 to 3.10" issue is a good point which I feel is getting to the core of the problem: the current implementation of Perhaps what tox should be doing is:
|
Probably option 3. Option 2 and 1 would introduce a significant performance degradation. |
Option 3 requires at least option 1; otherwise how do you tell if And while of course actually trying first to run whatever you're given is a hit on performance, I did think about that and my first instinct is that it's probably closer to "minimal" than "significant," given that the client code using this is in most cases about to run some stuff that's way heavier than the python interpreter startup cost. (That said, I'm open to ideas about how to optimise things.) |
On Windows is significant. Speaking from experience. That's how version 3 used to work. You can do file system checks to validate. |
Actually, trying to pull back a bit and see what's going on here, I'm feeling like there's two different things that tox wants: one is to be able to find a Python interpreter given a spec, and the other is to be able to check that an interpreter's version matches a spec derived from the tox environment name. I should note that I find the latter extremely valuable if it works properly; I really don't want a tox environment that has But either way, perhaps it might make sense to tweak tox (and/or Regarding the Windows thing, you've got me there: I don't do development on Windows. But you seem to be indicating that, even if it's too expensive to launch the intepreter, one could fairly cheaply check to see if the string one's been given matches to an executable file? That sounds like it might be a reasonable compromise. |
Oh, as we think about this, I'd also appreciate it if you can make clear for proposed solutions (to both tox and virtualenv issues) what needs to be changed in tox, and what needs to be changed in virtualenv. I've no issue with doing PRs for both, but of course I need to understand what behaviour should belong to one or the other. |
Hello! We're experiencing this problem in our organisation as well. We tend to use our Python interpreters as absolute paths, as opposed to system-wide installations. We have tried various ways of side-stepping this for Linux but then this breaks Windows, and vice-versa. Option 3 sounds great to me -- if Assuming that we agree on this approach (@gaborbernat are you happy with this?), I'm more than happy to submit a PR. |
Sure, I can accept and live with something like that. So yeah, please go ahead and submit that pull request. However note, you are required to also add a test validating the change together with the changelog for it to be accepted. Thank you for your contribution. |
PR #3311 opened. On a related note, it transpires that I will need to make a similar change to P.S. also opened tox-dev/tox-uv#69 |
btw, the merged PR only fixes it for |
Issue
I'm not sure if I'm doing this right; I asked on StackOverflow a couple of days ago and got no reply.
This may be related to #2838, though that has been closed as fixed by #2840.
I have a set of test environments that test my code with different versions of Python, using environment names with
py*
factors (e.g.,py3.8-pytest7
). When I run my tests without an explicitbase_python
setting, they work fine, finding the correct versions of Python only because I've explicitly added all of them to myPATH
environment variable.I would prefer to explicitly specify paths to my various versions of Python, which are built with pythonz, rather than adding all of them to my
PATH
. For example:I have confirmed that the versions of Python above are what they look like:
But when I try this, tox fails:
Am I somehow specifying these wrong, or is this a bug?
Environment
The test cases above were run from my pytest_pt project; that doesn't have any other configuration that could be triggering the problem, as far as I can tell. However, I can probably cons up a smaller test case if necessary.
The text was updated successfully, but these errors were encountered: