-
-
Notifications
You must be signed in to change notification settings - Fork 837
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
Pre-commit 2.0.0 does not work with conda based python in Windows. #1329
Comments
.pre-commit-config.yaml:
Good case with running git in activated conda environment 'pre-commit':
Bad case when deactivating environment right afterwards:
|
this is a bug with conda, I'd suggest opening an issue there |
The problem of running git within activated python environment where pre-commit is installed arises when using an IDE like PyCharm. There it is easy to configure the activation of different conda environments when running python, but it is not considered a useful feature for calling git |
This is expected behavior for conda. You are not supposed to call a python installed by conda without activating that environment. I hate that behavior, but I like to use the powerful package manager capabilities which span beyond python dependencies.. |
pre-commit only extracts the path to the python executable when "pre-commit install" is called. This is not enough for a conda installed python. |
then conda is violating some basic expectations of how python works and should be fixed |
A workaround may be for you to suggest your patch to the conda packaging of pre-commit, but I do not want to support it here |
I agree. I have ideas how conda should work instead. But I see no chance of getting that through. You would need to develop an alternative with the same complexity of features. |
did this work for pre-commit 1.x? |
I have a running system with pre-commit 1.12.0. The problem is that since more than one year, I see more and more actions with conda installed python tools to require activation. |
that's not what I asked, does the problem reproduce on pre-commit 1.21.1 |
I assume the problem is not just the pre-commit version. It may also be a change in one of pre-commit's dependencies. |
I doubt it, |
It may be a version change of sqlite3. All I can say is, I have a pre-commit 1.xx working. And I have a pre-commit 1.xx installation not working. I would need to explore further. |
And I had one colleague where downgrading pre-commit from 2.0.0 to 1.12.0 helped. |
this can be managed if INSTALL_PYTHON can be managed. |
heck, i just tried a wrapped python for |
seriously, why does INSTALL_PYTHON have priority over which(pre-commit) ???
|
because it is slow to look up please consider the tone of the language you're using, saying things like "seriously, why ... ???" is not appreciated |
apologies. |
fwiw, you can do
...but it's very slow and the output isn't nicely formatted. otherwise, use conda wrappers from |
This comment has been minimized.
This comment has been minimized.
shell=True is unsafe, you've introduced a security problem into your script. please don't suggest insecure solutions |
Thanks for the fix @gabrielecalvo 🎉
See the virtualenv in conda issue #10822. |
Hi @majidaldo, do you have a solution that uses |
yes. essentially replace |
Awesome! Do you have an example or a repo you can point me to? |
unfortunately, it's not public (yet). side note: since you're a data sciency user like i am, you can manage a fairly sophisticated data science project set up by using multiple conda environments simultaneously. but i only wanted 1 git and 1 corresponding precommit install; that's why i was interested in this. it's the solution that i'd like to make public. |
I am definitely interested in that solution. Anything else is going to be liable to break far too easily. If you are interested, we can collaborate on this on the project I am interested in? |
Hey @majidaldo have you made the solution public? |
hey let's take this conversation in private messages so we don't offtopic this thread. |
For me, adding following line after initialization of |
This has been fixed in conda-forge for Python 3.9+ |
Could you explain what exactly has been fixed or point to the changes you refer to? |
You can now run Python again without the need to activate the conda environment. You can see that changes at conda-forge/python-feedstock#532 but they are quite extensive. |
I still got the same error using a python
|
@ChristianZimpelmann This doesn't work with any Python 3.9.9 but only the latest build from conda-forge. Can you share your |
Anaconda/miniconda based python installations require an activated conda environment before calling python or any other entry-point executable. This requirement especially affects conda running on Windows.
"pre-commit install" only stores the python executable in git hooks. This is not enough for conda based python installations if the environment of pre-commit is not activated when calling "git commit".
The following (rejected) pull request is intended to solve that problem:
#1324
<problem reproduction instruction will be posted here, soon>
The text was updated successfully, but these errors were encountered: