Skip to content

Commit

Permalink
fix 20ms startup penalty added by virtualenv (#2317)
Browse files Browse the repository at this point in the history
  • Loading branch information
asottile committed Mar 18, 2022
1 parent d865c3e commit a16f609
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 7 deletions.
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

0 comments on commit a16f609

Please sign in to comment.