Skip to content

Commit

Permalink
Fix --unzip performance regression.
Browse files Browse the repository at this point in the history
This is a bandaid fix only. Appropriate comments have been added to
help prevent re-regression with a longer term fix tracked by pex-tool#1055.

Fixes pex-tool#1054
  • Loading branch information
jsirois committed Oct 3, 2020
1 parent cbb44f5 commit 51ac278
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion pex/pex_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,14 @@
from pex.common import can_write_dir, open_zip, safe_mkdtemp
from pex.compatibility import PY2
from pex.compatibility import string as compatibility_string
from pex.interpreter import PythonInterpreter
from pex.orderedset import OrderedSet
from pex.typing import TYPE_CHECKING
from pex.variables import ENV
from pex.version import __version__ as pex_version

if TYPE_CHECKING:
from pex.interpreter import PythonInterpreter

from typing import Optional


Expand Down Expand Up @@ -56,6 +57,15 @@ class PexInfo(object):

@classmethod
def make_build_properties(cls, interpreter=None):
# This lazy import is currently needed for performance reasons. At PEX runtime PexInfo is
# read in the bootstrap to see if the PEX should run in `--unzip` mode. If so, it must
# re-exec itself to run against its unzipped contents. Since `make_build_properties` is only
# used at PEX buildtime and the transitive imports of PythonInterpreter are large and slow,
# we avoid this import cost for runtime-only use.
#
# See: https://github.com/pantsbuild/pex/issues/1054
from pex.interpreter import PythonInterpreter

pi = interpreter or PythonInterpreter.get()
plat = pi.platform
platform_name = plat.platform
Expand Down

0 comments on commit 51ac278

Please sign in to comment.