Skip to content

Allow disabling cache_tag at build #144278

Closed

Description

@zooba

This effectively disables automatic .pyc file generation and loading of __pycache__ files, which is stronger and more reliable than setting PYTHONDONTWRITEBYTECODE.

Historically, we have supported sys.implementation.cache_tag is None (it's throughout about half the relevant tests), but there's some work to do to get other tests to properly check.

The only build-time option I'm proposing is a preprocessor define that isn't set by default, and when set will set cache_tag to None rather than the default value. Patching in a preprocessor define is much easier to maintain than replacing the code, and I expect anyone who needs this (such as myself) is likely already patching other parts of the source and can easily add a define.

Linked PRs

Activity

  1. self-assigned this
    on Jan 27, 2026
  2. added
    type-bugAn unexpected behavior, bug, or error
    and removed
    type-featureA feature request or enhancement
    on Jan 27, 2026
  3. zooba commented on Jan 27, 2026

    @zooba
    MemberAuthor

    It's actually documented that it may be None, so the fact that we don't handle it is the bug (mostly in tests). Adding the #ifdef with an internal name is hardly a feature.

  4. added a commit that references this issue on Feb 15, 2026
  5. added a commit that references this issue on Apr 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

buildThe build process and cross-buildtopic-importlibtype-bugAn unexpected behavior, bug, or error

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions