-
-
Notifications
You must be signed in to change notification settings - Fork 1k
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
[20.0.5+] 280ms overhead on python startup #1682
Comments
Well, unacceptable in your case, but first we need to be correct over fast and without this brew python on macOS does not work correctly. That being said let me think how else can we do this patching in a lazy way.🤔 |
The path here would be to install an import hook that does the fixup post-import, rather than unconditionally at startup. This could be injected during the |
can we only put the distutils hack in when it's needed (instead of unconditionally?) |
No because most python use setuptools. And not sure how would you put it conditionally, we don't know when will be needed. Setuptools doesn't fallback on distutils but has its own copy of distribution definition vendored 🤷♂️ |
I mean more like only do this on macos and when the config is detected |
That would be a hot patch at best not an actual fix 🤷♂️I'm looking here for a permanent solution, so people don't open issues about this. |
I'd like to understand the problem further, seems like we might be "fixing" something unfixable will spend some time this week doing research -- any pointers would be helpful |
I don't think it's unfixable. The issue is that global distutils configuration file values can break tools behaviour in virtualenv, mainly pip, setuptools and distutils related ones. |
One could argue that maybe the tools fix the issue, but than we're just throw the blame around, aka should setuptools support virtualenv or virtualenv support setuptools. As the tools generally don't know about virtual environments, especially on python 2, as there's no pep for it, historically virtualenv supported the tools, and this is what I was also proposing above with the pth file. We're not trying to fix here something that haven't fixed before. Just virtualenv 16 did the fix differently, in a method that's no longer compatible with venv. So now I'm proposing a solution that would do so, and also work on python 2. I agree importing the elements to patch is expensive, hence thinking of using the import hook... But need to play around with it to see it's viability. |
cool, yeah I want to understand the problem more:
|
It's not macOS only related. Can happen just as well with any other Python. It just happens that macOS brew always ships a distutils configuration that manifest this issue, while other platforms do not. Virtualenv 16 worked around by shipping it's own distutils copy, I really want to avoid this. This also no longer works on python 3 style venv, where it's no longer possible to override standard library modules due to how the venv is created. I'm not aware upstream trying to fix this yet. but I'd like to have a fix within virtualenv, as we had one before the rewrite. |
Hello, a fix for this issue has been released via virtualenv 20.0.8; see https://pypi.org/project/virtualenv/20.0.8/ (https://virtualenv.pypa.io/en/latest/changelog.html#v20-0-8-2020-03-04). Please give a try and report back if your issue has not been addressed; if not, please comment here, and we'll reopen the ticket. We want to apologize for the inconvenience this has caused you and say thanks for having patience while we resolve the unexpected bugs with this new major release. |
Issue
The changes to
site.py
introduce an (unacceptable imo) 280ms startup penalty under python 2.xI created virtualenvs via the following
comparing the startup time between the two:
this is (almost certainly) due to the import of
setuptools
in the critical path:The text was updated successfully, but these errors were encountered: