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

Generated resources have wrong path in a pex_binary #21444

Open
grihabor opened this issue Sep 22, 2024 · 0 comments · May be fixed by #21438
Open

Generated resources have wrong path in a pex_binary #21444

grihabor opened this issue Sep 22, 2024 · 0 comments · May be fixed by #21438
Labels

Comments

@grihabor
Copy link
Contributor

Describe the bug
Generated resources created by experimental_wrap_as_resources -> relocated_files -> files targets have wrong path in a pex_binary

Pants version
2.22.0

OS
Ubuntu 22.04

Additional info
Test data:

{
    "assets/query.sql": "SELECT 1",
    "assets/BUILD": dedent(
        """\
        files(name='files', sources=['query.sql'])
        """
    ),
    "src/py/project/__init__.py": "",
    "src/py/project/app.py": dedent(
        """\
        from importlib.resources import files
        import project

        def main():
            assert files(project).joinpath("query.sql").read_text() == "SELECT 1"
        """
    ),
    "src/py/project/BUILD": dedent(
        """\
        python_sources()
        relocated_files(
            name='relocated',
            files_targets=['assets:files'],
            src='assets',
            dest='src/py/project',
        )
        experimental_wrap_as_resources(name='resources', inputs=[':relocated'])
        pex_binary(
            name="binary",
            dependencies=[':resources'],
            entry_point="project.app:main",
        )
        """
    ),
    "pants.toml": "",
}

The stacktrace:

File "/home/grihabor/.local/share/pyenv/versions/3.9.18/lib/python3.9/runpy.py", line 197, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "/home/grihabor/.local/share/pyenv/versions/3.9.18/lib/python3.9/runpy.py", line 87, in _run_code
    exec(code, run_globals)
  File "/home/grihabor/.cache/pex/unzipped_pexes/0/863e67da8f1f0e62558585db68f5a97a67734c0f/__main__.py", line 227, in <module>
    result, should_exit, is_globals = boot(
  File "/home/grihabor/.cache/pex/unzipped_pexes/0/863e67da8f1f0e62558585db68f5a97a67734c0f/__main__.py", line 219, in boot
    result = bootstrap_pex(
  File "/home/grihabor/.cache/pex/unzipped_pexes/0/863e67da8f1f0e62558585db68f5a97a67734c0f/.bootstrap/pex/pex_bootstrapper.py", line 666, in bootstrap_pex
    return pex.PEX(entry_point).execute()
  File "/home/grihabor/.cache/pex/unzipped_pexes/0/863e67da8f1f0e62558585db68f5a97a67734c0f/.bootstrap/pex/pex.py", line 577, in execute
    result = self._wrap_coverage(self._wrap_profiling, self._execute)
  File "/home/grihabor/.cache/pex/unzipped_pexes/0/863e67da8f1f0e62558585db68f5a97a67734c0f/.bootstrap/pex/pex.py", line 484, in _wrap_coverage
    return runner(*args)
  File "/home/grihabor/.cache/pex/unzipped_pexes/0/863e67da8f1f0e62558585db68f5a97a67734c0f/.bootstrap/pex/pex.py", line 515, in _wrap_profiling
    return runner(*args)
  File "/home/grihabor/.cache/pex/unzipped_pexes/0/863e67da8f1f0e62558585db68f5a97a67734c0f/.bootstrap/pex/pex.py", line 623, in _execute
    return self.execute_entry(parse_entry_point(self._pex_info.entry_point))
  File "/home/grihabor/.cache/pex/unzipped_pexes/0/863e67da8f1f0e62558585db68f5a97a67734c0f/.bootstrap/pex/pex.py", line 792, in execute_entry
    return self.execute_entry_point(entry_point)
  File "/home/grihabor/.cache/pex/unzipped_pexes/0/863e67da8f1f0e62558585db68f5a97a67734c0f/.bootstrap/pex/pex.py", line 810, in execute_entry_point
    return runner()
  File "/home/grihabor/.cache/pex/unzipped_pexes/0/863e67da8f1f0e62558585db68f5a97a67734c0f/project/app.py", line 5, in main
    assert files(project).joinpath("query.sql").read_text() == "SELECT 1"
  File "/home/grihabor/.local/share/pyenv/versions/3.9.18/lib/python3.9/pathlib.py", line 1266, in read_text
    with self.open(mode=\'r\', encoding=encoding, errors=errors) as f:
  File "/home/grihabor/.local/share/pyenv/versions/3.9.18/lib/python3.9/pathlib.py", line 1252, in open
    return io.open(self, mode, buffering, encoding, errors, newline,
  File "/home/grihabor/.local/share/pyenv/versions/3.9.18/lib/python3.9/pathlib.py", line 1120, in _opener
    return self._accessor.open(self, flags, mode)
FileNotFoundError: [Errno 2] No such file or directory: '/home/grihabor/.cache/pex/unzipped_pexes/0/863e67da8f1f0e62558585db68f5a97a67734c0f/project/query.sql'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant