Skip to content

Commit

Permalink
diff module and method
Browse files Browse the repository at this point in the history
  • Loading branch information
wisechengyi committed Jul 18, 2018
1 parent ca5fa38 commit a2cd12a
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions pex/pex_builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -242,10 +242,11 @@ def _verify_entry_point(self):
# Only module is specified
if len(ep_split) == 1:
ep_module = ep_split[0]
ep_method = None
import_statement = 'import {}'.format(ep_module)
elif len(ep_split) == 2:
ep_module = ep_split[0]
ep_method = ep_split[1]
import_statement = 'from {} import {}'.format(ep_module, ep_method)
else:
raise self.InvalidEntryPoint("Fail to parse: `{}`".format(entry_point))

Expand All @@ -254,11 +255,12 @@ def _verify_entry_point(self):
# ep_method = 'm'
python_paths = self._gather_tmp_pythonpath()

args = [self._interpreter.binary, '-c', 'from {} import {}'.format(ep_module, ep_method)]

args = [self._interpreter.binary, '-c', import_statement]
try:
subprocess.check_output(args, env={'PYTHONPATH': ':'.join(python_paths)})
except subprocess.CalledProcessError:
self._logger.error('Failed to do:\n`{}`'.format(args))
raise self.InvalidEntryPoint('Failed to:`{}`'.format(import_statement))

def _gather_tmp_pythonpath(self):
"""
Expand Down

0 comments on commit a2cd12a

Please sign in to comment.