Skip to content

py/mpconfig: Rename MICROPY_PY___FILE__ to MICROPY_MODULE___FILE__. #17886

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

Merged

Conversation

dpgeorge
Copy link
Member

Summary

There are now quite a few module related configuration options, of the form MICROPY_MODULE_xxx.

The old MICROPY_PY___FILE__ option has been around for a long time and it actually relates to modules, whether __file__ is set on a module when import it.

So, rename it to MICROPY_MODULE___FILE__ and organise it alongside the other module options in py/mpconfig.h.

Also, move MICROPY_MODULE___ALL__ so it's with all the other module options as well.

Testing

Should be a no-op, but will be tested by CI anyway.

Trade-offs and Alternatives

Could leave things as they are, but IMO this is a worthy clean up.

@dpgeorge dpgeorge added the py-core Relates to py/ directory in source label Aug 11, 2025
Copy link

Code size report:

   bare-arm:    +0 +0.000% 
minimal x86:    +0 +0.000% 
   unix x64:    +0 +0.000% standard
      stm32:    +0 +0.000% PYBV10
     mimxrt:    +0 +0.000% TEENSY40
        rp2:    +0 +0.000% RPI_PICO_W
       samd:    +0 +0.000% ADAFRUIT_ITSYBITSY_M4_EXPRESS
  qemu rv32:    +0 +0.000% VIRT_RV32

@@ -23,6 +23,7 @@
#define MICROPY_OPT_MATH_FACTORIAL (0)
#define MICROPY_REPL_EMACS_KEYS (0)
#define MICROPY_PY_BUILTINS_COMPLEX (0)
Copy link
Contributor

Choose a reason for hiding this comment

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

Looks like this one should be moved with the other PY_BUILTINS

Copy link
Member Author

Choose a reason for hiding this comment

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

I agree this looks strange, but the order here actually matches the ordering in py/mpconfig.h, and that's what I was aiming for.

Probably MICROPY_PY_BUILTINS_COMPLEX could be renamed, or moved around in py/mpconfig.h.

@dpgeorge dpgeorge requested a review from projectgus August 15, 2025 01:49
For consistency with other module-related configuration options.

Signed-off-by: Damien George <damien@micropython.org>
Signed-off-by: Damien George <damien@micropython.org>
@dpgeorge dpgeorge force-pushed the py-module-rename-file-config-option branch from aa71e8f to 989abae Compare August 19, 2025 03:01
@dpgeorge dpgeorge merged commit 989abae into micropython:master Aug 19, 2025
70 checks passed
@dpgeorge dpgeorge deleted the py-module-rename-file-config-option branch August 19, 2025 03:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
py-core Relates to py/ directory in source
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants