Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
fix 20ms startup penalty added by virtualenv
  • Loading branch information
asottile committed Mar 14, 2022
commit 2b700a51ebb35f2126a69bfc0cad56a489e3831a
1 change: 1 addition & 0 deletions docs/changelog/2317.bugfix.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Improve performance of python startup inside created virtualenvs - by :user:`asottile`.
6 changes: 3 additions & 3 deletions docs/changelog/examples.rst
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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