Skip to content
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

fix 20ms startup penalty added by virtualenv #2317

Merged
merged 1 commit into from Mar 18, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions docs/changelog/2317.bugfix.rst
@@ -0,0 +1 @@
Improve performance of python startup inside created virtualenvs - by :user:`asottile`.
6 changes: 3 additions & 3 deletions docs/changelog/examples.rst
Expand Up @@ -2,17 +2,17 @@

file ``544.doc.rst``::

explain everything much better - by ``passionate_technicalwriter``
explain everything much better - by :user:`passionate_technicalwriter`.

file ``544.feature.rst``::

``tox --version`` now shows information about all registered plugins - by ``obestwalter``
``tox --version`` now shows information about all registered plugins - by :user:`obestwalter`.


file ``571.bugfix.rst``::

``skip_install`` overrides ``usedevelop`` (``usedevelop`` is an option to choose the
installation type if the package is installed and ``skip_install`` determines if it should be
installed at all) - by ``ferdonline``
installed at all) - by :user:`ferdonline`.

.. see pyproject.toml for all available categories
8 changes: 4 additions & 4 deletions src/virtualenv/create/via_global_ref/_virtualenv.py
Expand Up @@ -37,11 +37,8 @@ def parse_config_files(self, *args, **kwargs):
_DISTUTILS_PATCH = "distutils.dist", "setuptools.dist"
if sys.version_info > (3, 4):
# https://docs.python.org/3/library/importlib.html#setting-up-an-importer
from functools import partial
from importlib.abc import MetaPathFinder
from importlib.util import find_spec

class _Finder(MetaPathFinder):
class _Finder:
"""A meta path finder that allows patching the imported distutils modules"""

fullname = None
Expand All @@ -65,6 +62,9 @@ def find_spec(self, fullname, path, target=None):
# https://docs.python.org/3/faq/library.html#what-kinds-of-global-value-mutation-are-thread-safe
self.lock.append(lock)

from functools import partial
from importlib.util import find_spec

with self.lock[0]:
self.fullname = fullname
try:
Expand Down