Skip to content

Refactor derive_setup_local function in the pythonbuild.cpython module - #1235

Merged
jjhelmus merged 1 commit into
mainfrom
jjh/refactor_derive_setup_local
Aug 27, 2026
Merged

Refactor derive_setup_local function in the pythonbuild.cpython module#1235
jjhelmus merged 1 commit into
mainfrom
jjh/refactor_derive_setup_local

Conversation

@jjhelmus

Copy link
Copy Markdown
Contributor

Refactor derive_setup_local into smaller, typed helpers while preserving existing extension module configuration and linkage behavior.

  • Separate parsing, classification, validation, and setup generation.
  • Dataclass to group extension classification and CPython module information.
  • Parse module configuration files from the CPython source archives rather than from lines.
  • Simplify static/shared linkage selection and Setup.local generation.

@jjhelmus jjhelmus added platform:darwin Specific to the macOS platform platform:linux Specific to the Linux platform python:all Select all Python versions labels Aug 26, 2026
@jjhelmus
jjhelmus marked this pull request as ready for review August 26, 2026 20:09
@jjhelmus
jjhelmus requested review from ewdurbin and zanieb August 26, 2026 22:21
Comment thread pythonbuild/cpython.py
Comment on lines +676 to +681
# makesetup interprets lines containing = as configuration options. Move
# -Dname=value defines into Makefile overrides for legacy Python builds.
if not use_setup_stdlib:
for match in define_pattern.finditer(parsed["line"]):
for obj_path in sorted(parsed["posix_obj_paths"]):
extra_cflags.setdefault(bytes(obj_path), []).append(match.group(0))

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

a little nit, but passing in the extra_cflags just to mutate them in the function feels a little surprising given the name. should this function return the flags that need added and let the caller apply them?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch. I spotted this in one of the run throughs but never got a fix in.
I'll address this in #1237 as that shuffles this block around further.

@jjhelmus
jjhelmus merged commit ef429f8 into main Aug 27, 2026
94 checks passed
@jjhelmus
jjhelmus deleted the jjh/refactor_derive_setup_local branch August 27, 2026 14:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

platform:darwin Specific to the macOS platform platform:linux Specific to the Linux platform python:all Select all Python versions

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants