Skip to content

Check for scripts directory in get_script_from_egg#328

Merged
kwlzn merged 6 commits into
pex-tool:masterfrom
yolken:byolken/fix_egg_scripts
Dec 8, 2016
Merged

Check for scripts directory in get_script_from_egg#328
kwlzn merged 6 commits into
pex-tool:masterfrom
yolken:byolken/fix_egg_scripts

Conversation

@yolken

@yolken yolken commented Dec 7, 2016

Copy link
Copy Markdown
Contributor

Background

Some eggs (e.g., those for v0.13 of the Flask-Cache library) don't have scripts. This can cause problems when they are bundled in a pex with another library and the pex entrypoint is set to a (valid) script in the latter.

Depending on the order in which the libraries are searched for the script, it's possible to get errors like the following when executing the pex:

Traceback (most recent call last):
  File ".bootstrap/_pex/pex.py", line 326, in execute
  File ".bootstrap/_pex/pex.py", line 258, in _wrap_coverage
  File ".bootstrap/_pex/pex.py", line 290, in _wrap_profiling
  File ".bootstrap/_pex/pex.py", line 372, in _execute
  File ".bootstrap/_pex/pex.py", line 405, in execute_script
  File ".bootstrap/_pex/finders.py", line 286, in get_script_from_distributions
  File ".bootstrap/_pex/finders.py", line 270, in get_script_from_distribution
  File ".bootstrap/_pex/finders.py", line 243, in get_script_from_egg
  File ".bootstrap/pkg_resources/__init__.py", line 1480, in metadata_listdir
  File ".bootstrap/pkg_resources/__init__.py", line 1566, in _listdir
OSError: [Errno 2] No such file or directory: '/Users/ben_yolken/.pex/install/Flask_Cache-0.13.1-py2.7.egg.57c4257163765d8d5a7be01c059b291c0880ed47/Flask_Cache-0.13.1-py2.7.egg/EGG-INFO/scripts'

The fix is to check in get_script_from_egg whether the scripts directory exists before calling metadata_listdir.

Content

  • Check for scripts directory in get_script_from_egg

@kwlzn kwlzn left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks for the bugfix - lgtm.

while you're in here, how would you feel about adding a quick unit or integration test to help pin this behavior down?

@yolken

yolken commented Dec 8, 2016

Copy link
Copy Markdown
Contributor Author

@kwlzn Added a small test for the Flask-Cache case. Thanks.

@kwlzn kwlzn left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm, thanks for the PR!

@kwlzn kwlzn merged commit eeefe1a into pex-tool:master Dec 8, 2016
@kwlzn kwlzn mentioned this pull request Dec 21, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants