https://pantsbuild.org/ logo
#pex
Title
# pex
a

aloof-angle-91616

09/05/2018, 2:21 AM
if python 3.6 has the
pkg_resources
module, but cannot import
find_distributions
from it (which is true on my machine), does the following look right?
Copy code
cosmicexplorer@breeze: ~
X> python3.6
Python 3.6.6 (default, Sep  1 2018, 10:39:12) 
[GCC 8.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from pkg_resources import find_distributions
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: cannot import name 'find_distributions'
>>> 
cosmicexplorer@breeze: ~
X> python3.7
Python 3.7.0 (default, Jul 15 2018, 10:44:58) 
[GCC 8.1.1 20180531] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from pkg_resources import find_distributions
>>>
And this snippet in `interpreter.py`:
Copy code
EXTRAS_PY = b"""\
try:
  import pkg_resources
except ImportError:
  sys.exit(0)

requirements = {}
for item in sys.path:
  for dist in pkg_resources.find_distributions(item):
    requirements[str(dist.as_requirement())] = dist.location

for requirement_str, location in requirements.items():
  rs = requirement_str.split('==', 2)
  if len(rs) == 2:
    print('%s %s %s' % (rs[0], rs[1], location))
"""