-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
Make pre-commit mirror? #3405
Comments
I'm generally in favour, but I have no idea how it'd work. I suppose we could create a mirror similar to mirrors-mypy and then advertise it heavily in the docs and other areas. We can't really deprecate the hook from here though (commit SHAs would never work in w/ a mirror). |
do people pin hooks to commit SHAs? I think tags are way more common, and if this would make |
Wait, are you suggesting to replace the hook here to pull Black from PyPI? I thought we were discussing creating a mirror. I was just noting it's not ideal having two official hooks "forever" since some people do pin down to the commit. |
Yes, my suggestion is to create a mirror (which pulls Alternatively, there might be some workaround to allow the hook to be pulled from PyPI within the hook here? |
(note: I got bored and felt like writing hacky code. This idea is stupid and would easily break.) A hacky idea would be to edit # pre_commit_shim.py
checker_code = """
import sys, black
sys.stdout.buffer.write(str(black.COMPILED).encode("utf-8"))
"""
try:
import subprocess
import sys
proc = subprocess.run([sys.executable, "-c", checker_code], check=True, stdout=subprocess.PIPE, encoding="utf-8")
if proc.stdout.strip() == "False":
subprocess.run([sys.executable, "-m" , "pip", "install", "black==22.12.0"], check=True)
except:
pass
import black
black.main(sys.argv[1:]) A mirror is certainly better and less prone to breakage though :) |
I was tired of slow pre-commit, so I made a mirror here: https://github.com/hauntsaninja/black-pre-commit-mirror Thanks for all the mypyc work! |
legeeeeeend 🙌 🥳 worth pointing to that one in the readme? |
Is it possible to make the mirror a bit more "official"? For example by moving the repo to the |
Just so I understand, is the advantage of the pre-commit mirror so it's a small faster mirror to check out rather than our larger checkout this repo would cause? Is it slow even with a shallow checkout? If so, @ambv how do we go about asking for a psf/black-pre-commit-mirror or something of the likes? |
No. The difference is how pre-commit installs |
Ha, that makes it attractive given that Black on PyPI is mypyc-compiled whereas the one installed from source most certainly is not. |
I can start |
Exactly, just as example for Home Assistant the normal run is |
Right. I get it now. I did miss that. I like the ambv -> psf plan. Thanks Łukasz. If no one beats me, I'll update docs once this is all setup. |
Actually, since @hauntsaninja's mirror already works, let's just move that one to psf/. I'm fine with that, too. So whenever you're ready Shantanu, make the move on GitHub. I will let PSF know to expect it. |
Hm, when I tried the transfer I got:
Might need to coordinate a little more on this one. I've added you all as collaborators to the mirror repo (didn't see a way to directly add you as admin). |
@hauntsaninja I believe you might first need to transfer ownership to @ambv from the repo settings page. Collaborator access isn't enough. After that @ambv should be able to transfer it over to the |
Any update here? Would love to use it and get the speedup. However, difficult to do unless it's moved to the
Please let me know if there is anything I can to do help. |
I couldn't move it directly to psf/. I'd transferred to ambv/, but I think he might need to accept |
Yeah, sorry, I missed the notification and the transfer expired. Can we try again? |
Aborted and retried! |
This is now moved to psf/black-pre-commit-mirror. All we need is to update docs. |
Documented in #3828. Thanks Łukasz! |
# Description Use black compiled with mypyc instead of pure python version to get it faster # References psf/black#3405 ## Type of change - [x] Maintenance (changes required to run napari, tests, & CI smoothly)
This mirror was created to leverage performance optimizations from mypyc wheels that are available if black is installed from PyPI. These wheels are not available if black is installed from source as it would be using the old URL. Please see psf/black#3828 and psf/black#3405 for more information.
This mirror was created to leverage performance optimizations from mypyc wheels that are available if black is installed from PyPI. These wheels are not available if black is installed from source as it would be using the old URL. Please see psf/black#3828 and psf/black#3405 for more information.
This mirror was created to leverage performance optimizations from mypyc wheels that are available if black is installed from PyPI. These wheels are not available if black is installed from source as it would be using the old URL. Please see psf/black#3828 and psf/black#3405 for more information. Co-authored-by: Nick <[email protected]>
This mirror was created to leverage performance optimizations from mypyc wheels that are available if black is installed from PyPI. These wheels are not available if black is installed from source as it would be using the old URL. Please see psf/black#3828 and psf/black#3405 for more information.
Thanks to
mypyc
,black
runs twice as fast when installed by PyPI vs in a pre-commit hook pandas-dev/pandas#49947Would you be open to making a mirror repo, like this one that exists for
ruff
, which will installblack
wheels and thus be fast?The text was updated successfully, but these errors were encountered: