Skip to content

py/mpconfig: Enable the sys module at all feature levels by default. #17927

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

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

dpgeorge
Copy link
Member

Summary

The sys module is a pretty fundamental module, and even minimal ports like unix and zephyr minimal have it enabled. So, enabled it by default at the lowest feature level.

Most things in the sys module are configurable, and off by default, so it shouldn't add to much to ports that don't already have it enabled (which is just the minimal port).

Testing

To be tested by CI.

Trade-offs and Alternatives

The aim here is to simplify configuration, and also eventually make it so the minimal configuration can run and pass the test suite. The sys module is something that's needed for introspection of the target, so it seems reasonable to include it by default on everything. Of course that costs code size, and it's still easy to disable if needed, you just need to do it explicitly now.

Also note that it's still disabled on the bare-arm port, to keep that ultra minimal. It means we now have bare-arm without sys but minimal port does have sys. That will allow different code size comparisons if/when new sys features are added.

@dpgeorge dpgeorge added the py-core Relates to py/ directory in source label Aug 15, 2025
@dpgeorge dpgeorge requested a review from projectgus August 15, 2025 03:21
Copy link

codecov bot commented Aug 15, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 98.38%. Comparing base (b7cfafc) to head (4da4436).

Additional details and impacted files
@@           Coverage Diff           @@
##           master   #17927   +/-   ##
=======================================
  Coverage   98.38%   98.38%           
=======================================
  Files         171      171           
  Lines       22297    22297           
=======================================
  Hits        21938    21938           
  Misses        359      359           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@dpgeorge dpgeorge force-pushed the py-mpconfig-enable-sys-by-default branch 2 times, most recently from 3c86fe1 to 8eaad59 Compare August 15, 2025 03:39
@dpgeorge
Copy link
Member Author

dpgeorge commented Aug 15, 2025

I'm not 100% sure this is the right thing to do. It's a choice of:

  1. Enable sys by default and then have to disable where it's not wanted (eg embedded example, bare-arm).
  2. Enable sys at a higher feature level and then have to enable it where needed (eg unix, zephyr minimal).

I lean towards option 1, hence this PR.

Copy link

github-actions bot commented Aug 15, 2025

Code size report:

   bare-arm:    +0 +0.000% 
minimal x86: +1327 +0.708% [incl +480(data)]
   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

This is a pretty fundamental module, and even minimal ports like unix and
zephyr minimal have it enabled.  So, enabled it by default at the lowest
feature level.

Signed-off-by: Damien George <damien@micropython.org>
@dpgeorge dpgeorge force-pushed the py-mpconfig-enable-sys-by-default branch from 8eaad59 to 6e318af Compare August 15, 2025 04:00
Signed-off-by: Damien George <damien@micropython.org>
Copy link
Contributor

@projectgus projectgus left a comment

Choose a reason for hiding this comment

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

This seems like a good idea to me.

There's a follow-up we can do to take some of the import sys in tests out of try/except/"SKIP" blocks as well. About 11 cases of that (although only 3 have import sys as the only line in the block, the others try to import multiple modules.)

@dpgeorge
Copy link
Member Author

There's a follow-up we can do to take some of the import sys in tests out of try/except/"SKIP" blocks as well.

Yes, good idea. Although it does mean the test suite requires sys to work, but I think that's a reasonable assumption.

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.

2 participants