Skip to content

No way to disable bytecode compilation when installing cpython #160835

Open

Description

@rossburton

Bug report

When building and installing cpython it can be preferable to have more control over when compileall is executed. It would be useful if there was a way to disable the compilation in the libinstall target for people who want to control the compilation without doing it twice.

(Happy to send a patch if this isn't rejected out of hand)

CPython versions tested on:

3.14

Operating systems tested on:

Linux

Activity

  1. added
    type-featureA feature request or enhancement
    buildThe build process and cross-build
    and removed
    type-bugAn unexpected behavior, bug, or error
    on Oct 28, 2026
  2. picnixz commented on Oct 28, 2026

    @picnixz
    Member

    What is the use case explicitly? is it a theoretical feature or is there a real need from redistributors?

  3. rossburton commented on Oct 28, 2026

    @rossburton
    ContributorAuthor

    The specific use case is that we're packaging the standard library in more than one package so the easy way to handle this is to split the packaging up and then compile the py, because then the pyc goes into the right package without needing more work.

  4. picnixz commented on Oct 30, 2026

    @picnixz
    Member

    I have no strong opinion here but not compiling bytecode may be relevant. cc @encukou

  5. encukou commented on Oct 30, 2026

    @encukou
    Member

    Maybe we can turn this into a compileall.py improvement?
    IMO, the invocation should be make install COMPILEALL_OPTS='--no-recursion --skip=.*', which would be possible with two patches:

    • allow multiple -x options, so Makefile's -x badsyntax doesn't overwrite COMPILEALL_OPTS
    • add long option aliases for readibility: --skip for -x, --[no-]recursion to -l; perhaps more.
  6. rossburton commented on Oct 30, 2026

    @rossburton
    ContributorAuthor

    I have a patch to add long options for clarity.

    The public API such as compileall.compile_dir exposes a single rx regex, so this can't be just changed to a list.

    However, the argument parser could allow multiple skips and construct a new regex. So something like python3 -mcompileall -x foo -x bar ... would result in rx = r"foo|bar". If this is acceptable I can post it.

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

    buildThe build process and cross-buildtype-featureA feature request or enhancement

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions