Skip to content

Feature request: Hermetic toolchain w dynamic linkage #2540

Description

@driftregion

Feature Request

Affected Rule

python.toolchain(python_version = "3.10", is_default = True)

Description

I would like to be able to specify a hermetic toolchain that is not statically linked, or to use a locally installed toolchain as in #2070.

The default toolchain selected by rules_python contains a statically linked version of tkinter which causes my program to crash. This is a known issue with matplotlib + TkAgg matplotlib/matplotlib#23074 .

My system install of python on linux puts a bunch of dynamic libraries in /usr/lib/python3.10/lib-dynload including the one used by matplotlib (_tkinter.cpython-310-x86_64-linux-gnu.so).

🔬 Minimal Reproduction

https://github.com/driftregion/rules_python_tkinter_matplotlib_bug

bazel run //:test
INFO: Analyzed target //:test (0 packages loaded, 0 targets configured).
INFO: Found 1 target...
Target //:test up-to-date:
  bazel-bin/test
INFO: Elapsed time: 0.418s, Critical Path: 0.01s
INFO: 1 process: 1 internal.
INFO: Build completed successfully, 1 total action
INFO: Running command line: bazel-bin/test
interpreter: /home/nick/.cache/bazel/_bazel_nick/528c03734b70e438f6ad6178b0da02c9/execroot/_main/bazel-out/k8-fastbuild/bin/test.runfiles/rules_python++python+python_3_10_x86_64-unknown-linux-gnu/bin/python3
True
8.6
Traceback (most recent call last):
  File "/home/nick/.cache/bazel/_bazel_nick/528c03734b70e438f6ad6178b0da02c9/execroot/_main/bazel-out/k8-fastbuild/bin/test.runfiles/_main/test.py", line 7, in <module>
    print(_tkinter.__file__)
AttributeError: module '_tkinter' has no attribute '__file__'. Did you mean: '__name__'?

🌍 Your Environment

Output of bazel version:

  
Bazelisk version: v1.18.0
Build label: 8.0.0
Build target: @@//src/main/java/com/google/devtools/build/lib/bazel:BazelServer
Build time: Mon Dec 09 18:00:43 2024 (1733767243)
Build timestamp: 1733767243
Build timestamp as int: 1733767243
  

Rules_python version:

  
1.0.0
  

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions