Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix editable requirement parsing. #2464

Merged
merged 4 commits into from
Jul 14, 2024
Merged

Conversation

jsirois
Copy link
Member

@jsirois jsirois commented Jul 14, 2024

Previously, editable requirements in requirements files were not parsed
properly by Pex. Although they did not trigger parse errors, PEXes
created from editable requirements would fail to import those
requirements at runtime despite the editable project distribution being
embedded in the PEX file.

Fixes #2410

Previously, editable requirements in requirements files were not parsed
properly by Pex. Although they did not trigger parse errors, PEXes
created from editable requirements would fail to import those
requirements at runtime despite the editable project distribution being
embedded in the PEX file.

Fixes pex-tool#2410
pex = os.path.join(str(tmpdir), "pex")
run_pex_command(args=["-r", requirements, "-m", "example", "-o", pex]).assert_success()
output = (
subprocess.check_output(args=[pex, "A", "wet", "duck", "flies", "at", "night!"])
Copy link
Member Author

Choose a reason for hiding this comment

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

Without the fix in pex/requirements.py here this subprocess fails similarly to the OP in #2410:

tests/integration/test_issue_2410.py::test_pex_with_editable Traceback (most recent call last):
  File "<frozen runpy>", line 198, in _run_module_as_main
  File "<frozen runpy>", line 88, in _run_code
  File "/home/jsirois/.pex/unzipped_pexes/8a97e1ee50ec37bf439dfaac193544f17e281e0b/__main__.py", line 224, in <module>
    result = boot(
        bootstrap_dir='.bootstrap',
    ...<6 lines>...
        inject_python_args=(),
    )
  File "/home/jsirois/.pex/unzipped_pexes/8a97e1ee50ec37bf439dfaac193544f17e281e0b/__main__.py", line 218, in boot
    bootstrap_pex(
    ~~~~~~~~~~~~~^
        entry_point, python_args=python_args, execute=__SHOULD_EXECUTE__, venv_dir=venv_dir
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    )
    ^
  File "/home/jsirois/.pex/unzipped_pexes/8a97e1ee50ec37bf439dfaac193544f17e281e0b/.bootstrap/pex/pex_bootstrapper.py", line 643, in bootstrap_pex
    pex.PEX(entry_point).execute()
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^
  File "/home/jsirois/.pex/unzipped_pexes/8a97e1ee50ec37bf439dfaac193544f17e281e0b/.bootstrap/pex/pex.py", line 562, in execute
    sys.exit(self._wrap_coverage(self._wrap_profiling, self._execute))
             ~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/jsirois/.pex/unzipped_pexes/8a97e1ee50ec37bf439dfaac193544f17e281e0b/.bootstrap/pex/pex.py", line 469, in _wrap_coverage
    return runner(*args)
  File "/home/jsirois/.pex/unzipped_pexes/8a97e1ee50ec37bf439dfaac193544f17e281e0b/.bootstrap/pex/pex.py", line 500, in _wrap_profiling
    return runner(*args)
  File "/home/jsirois/.pex/unzipped_pexes/8a97e1ee50ec37bf439dfaac193544f17e281e0b/.bootstrap/pex/pex.py", line 606, in _execute
    return self.execute_entry(
           ~~~~~~~~~~~~~~~~~~^
        EntryPoint.parse("run = {}".format(self._pex_info.entry_point))
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    )
    ^
  File "/home/jsirois/.pex/unzipped_pexes/8a97e1ee50ec37bf439dfaac193544f17e281e0b/.bootstrap/pex/pex.py", line 810, in execute_entry
    return self.execute_module(entry_point.module)
           ~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^
  File "/home/jsirois/.pex/unzipped_pexes/8a97e1ee50ec37bf439dfaac193544f17e281e0b/.bootstrap/pex/pex.py", line 818, in execute_module
    runpy.run_module(module_name, run_name="__main__", alter_sys=True)
    ~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "<frozen runpy>", line 222, in run_module
  File "<frozen runpy>", line 142, in _get_module_details
ImportError: No module named example
FAILED

@jsirois jsirois merged commit e13f168 into pex-tool:main Jul 14, 2024
26 checks passed
@jsirois jsirois deleted the issues/2410 branch July 14, 2024 03:57
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.

Build fails/incomplete on requirements.txt schema not followed correctly
2 participants