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

[Discussion/Bug] Replace jaraco.collections.KeyTransformingDict to avoid breaks in Bazel builds #2002

Open
2 of 3 tasks
rahul-theorem opened this issue Oct 19, 2023 · 0 comments

Comments

@rahul-theorem
Copy link

rahul-theorem commented Oct 19, 2023

I'm submitting a ...

  • bug report
  • feature request
  • question about the decisions made in the repository

Do you want to request a feature or report a bug?
Bug/discussion

What is the current behavior?
We're using rules_python to manage our Python dependencies/toolchain in our Bazel build, and a library we're using (scoutsuite) that depends on cherrypy is leading to an error while resolving dependencies (stacktrace at bottom). This is due to a number of long-standing issues where jaraco.text has a space in a file (Lorem ipsum.txt) it loads on import, and Bazel doesn't support spaces in file names due to a number of reasons about its internal runfiles manifest structure (see bazelbuild/bazel#4327)

This is pulled into cherrypy by jaraco.collections.KeyTransformingDict in httputils.py. To support using cherrypy in a bazel build w/ rules_python/pip_compile, it'd be fairly straightforward to replace the KeyTransformingDict import from jaraco.collections with a version that's vendored in the repo

If the current behavior is a bug, please provide the steps to reproduce and if possible a screenshots and logs of the problem. If you can, show us your code.
Add cherrypy as a dependency in a Bazel build using rules_python and attempt to build any target that depends on it

Please tell us about your environment:

  • Cheroot version: 10.0.0
  • CherryPy version: 18.8.0
  • Python version: 3.10.8
  • OS: MacOS 13.6
  • Browser: N/A

Other information

Stacktrace when attempting to resolve requirements:

Traceback (most recent call last):
  File "/private/var/tmp/_bazel/46aa123924747c319eb8f588f2d86f2a/execroot/_main/bazel-out/darwin-fastbuild/bin/scout.runfiles/_main/rules_python_entry_point_scout.py", line 11, in <module>
    from ScoutSuite.__main__ import run_from_cli
  File "/private/var/tmp/_bazel/46aa123924747c319eb8f588f2d86f2a/execroot/_main/bazel-out/darwin-fastbuild/bin/scout.runfiles/rules_python~0.26.0~pip~deps_311_scoutsuite/site-packages/ScoutSuite/__main__.py", line 15, in <module>
    from ScoutSuite.core.server import Server
  File "/private/var/tmp/_bazel/46aa123924747c319eb8f588f2d86f2a/execroot/_main/bazel-out/darwin-fastbuild/bin/scout.runfiles/rules_python~0.26.0~pip~deps_311_scoutsuite/site-packages/ScoutSuite/core/server.py", line 2, in <module>
    import cherrypy
  File "/private/var/tmp/_bazel/46aa123924747c319eb8f588f2d86f2a/execroot/_main/bazel-out/darwin-fastbuild/bin/scout.runfiles/rules_python~0.26.0~pip~deps_311_cherrypy/site-packages/cherrypy/__init__.py", line 66, in <module>
    from ._cperror import (
  File "/private/var/tmp/_bazel/46aa123924747c319eb8f588f2d86f2a/execroot/_main/bazel-out/darwin-fastbuild/bin/scout.runfiles/rules_python~0.26.0~pip~deps_311_cherrypy/site-packages/cherrypy/_cperror.py", line 135, in <module>
    from cherrypy.lib import httputil as _httputil
  File "/private/var/tmp/_bazel/46aa123924747c319eb8f588f2d86f2a/execroot/_main/bazel-out/darwin-fastbuild/bin/scout.runfiles/rules_python~0.26.0~pip~deps_311_cherrypy/site-packages/cherrypy/lib/httputil.py", line 20, in <module>
    import jaraco.collections
  File "/private/var/tmp/_bazel/46aa123924747c319eb8f588f2d86f2a/execroot/_main/bazel-out/darwin-fastbuild/bin/scout.runfiles/rules_python~0.26.0~pip~deps_311_jaraco_collections/site-packages/jaraco/collections.py", line 12, in <module>
    import jaraco.text
  File "/private/var/tmp/_bazel/46aa123924747c319eb8f588f2d86f2a/execroot/_main/bazel-out/darwin-fastbuild/bin/scout.runfiles/rules_python~0.26.0~pip~deps_311_jaraco_text/site-packages/jaraco/text/__init__.py", line 231, in <module>
    files(__name__).joinpath('Lorem ipsum.txt').read_text(encoding='utf-8')
  File "/private/var/tmp/_bazel/46aa123924747c319eb8f588f2d86f2a/external/rules_python~0.26.0~python~python_3_11_x86_64-apple-darwin/lib/python3.11/pathlib.py", line 1058, in read_text
    with self.open(mode='r', encoding=encoding, errors=errors) as f:
         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/private/var/tmp/_bazel/46aa123924747c319eb8f588f2d86f2a/external/rules_python~0.26.0~python~python_3_11_x86_64-apple-darwin/lib/python3.11/pathlib.py", line 1044, in open
    return io.open(self, mode, buffering, encoding, errors, newline)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
FileNotFoundError: [Errno 2] No such file or directory: '/private/var/tmp/_bazel/46aa123924747c319eb8f588f2d86f2a/execroot/_main/bazel-out/darwin-fastbuild/bin/scout.runfiles/rules_python~0.26.0~pip~deps_311_jaraco_text/site-packages/jaraco/text/Lorem ipsum.txt'
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

No branches or pull requests

1 participant