Skip to content
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

Correct sys.version to say "CircuitPython" instead of "MicroPython" #8808

Merged
merged 10 commits into from
Feb 17, 2024

Conversation

bill88t
Copy link

@bill88t bill88t commented Jan 17, 2024

>>> sys.version
'3.4.0; Adafruit CircuitPython 9.0.0-alpha.6-25-g6bdf06c9e5-dirty on 2024-01-17; M5Stack Timer Camera X with ESP32'

Same string as pyexec_friendly_repl. This is also a great way to get the board info during runtime all at once!

Fixes #8802

@dhalbert
Copy link
Collaborator

This seems OK to me. In CPython, it's something like this:

>>> sys.version
'3.10.12 (main, Nov 20 2023, 15:14:05) [GCC 11.4.0]'

so including all the info above is not out of line with that. In CPython sys.version doesn't have the build target info, but that's OK. Ultimately platform is the more modern way of doing this.

Could you try changing

#define MICROPY_BANNER_NAME_AND_VERSION "MicroPython " MICROPY_GIT_TAG " on " MICROPY_BUILD_DATE

in py/mpconfig.h as well? That should probably say CircuitPython too, but it might break some tests.

@dhalbert
Copy link
Collaborator

Don't remove the const. Let's figure out what's going on first. Do a local pre-commit check or compile.

@bill88t
Copy link
Author

bill88t commented Jan 17, 2024

I put it back. It's just that locally it builds and runs fine.
I can't repro the CI failure.

gcc (GCC) 13.2.1 20230801

@dhalbert
Copy link
Collaborator

I'll look at it in more detail a little later, since this is not urgent.

@bill88t
Copy link
Author

bill88t commented Jan 17, 2024

Same here. I will try building in a container tomorrow.

@jepler
Copy link
Member

jepler commented Feb 15, 2024

Try with:

diff --git a/py/makeversionhdr.py b/py/makeversionhdr.py
index 430b9bef4b..edcb994b4f 100644
--- a/py/makeversionhdr.py
+++ b/py/makeversionhdr.py
@@ -119,7 +119,7 @@ def make_version_header(repo_path, filename):
 #define MICROPY_VERSION_STRING "%s"
 // Combined version as a 32-bit number for convenience
 #define MICROPY_VERSION (MICROPY_VERSION_MAJOR << 16 | MICROPY_VERSION_MINOR << 8 | MICROPY_VERSION_MICRO)
-#define MICROPY_FULL_VERSION_INFO "Adafruit CircuitPython " MICROPY_GIT_TAG " on " MICROPY_BUILD_DATE "; " MICROPY_HW_BOARD_NAME " with " MICROPY_HW_MCU_NAME
+#define MICROPY_FULL_VERSION_INFO "Adafruit CircuitPython " MICROPY_GIT_TAG " on " MICROPY_BUILD_DATE "; " MICROPY_BANNER_MACHINE
 """ % (
         git_tag,
         git_hash,

On the "unix port", MICROPY_HW_BOARD_NAME and MICROPY_HW_MCU_NAME are not defined. mpconfig picks one of two forms of BANNER depending on definedness so it should give what you want:

// String used for the second part of the banner, and sys.implementation._machine
#ifndef MICROPY_BANNER_MACHINE
#ifdef MICROPY_HW_BOARD_NAME
#define MICROPY_BANNER_MACHINE MICROPY_HW_BOARD_NAME " with " MICROPY_HW_MCU_NAME
#else
#define MICROPY_BANNER_MACHINE MICROPY_PY_SYS_PLATFORM " [" MICROPY_PLATFORM_COMPILER "] version"
#endif

@jepler
Copy link
Member

jepler commented Feb 16, 2024

I went ahead and added that change to this PR

jepler
jepler previously approved these changes Feb 16, 2024
Copy link
Member

@jepler jepler left a comment

Choose a reason for hiding this comment

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

Good to go if the build is green

@tannewt
Copy link
Member

tannewt commented Feb 16, 2024

@jepler Looks like the REPL tests were broken.

@bill88t
Copy link
Author

bill88t commented Feb 16, 2024

Oh whoops, sorry for the late response, I'm having exams currently, so I'm not very active.
Thanks Jepler for the fix.

Adafruit CircuitPython 9.0.0-alpha.6-32-gc7701709ef on 2024-02-16; DFRobot FireBeetle 2 ESP32-S3 with ESP32S3
>>> import sys
>>> sys.implementation
(name='circuitpython', version=(9, 0, 0), _machine='DFRobot FireBeetle 2 ESP32-S3 with ESP32S3', _mpy=262)
>>> sys.version
'3.4.0; Adafruit CircuitPython 9.0.0-alpha.6-32-gc7701709ef on 2024-02-16; DFRobot FireBeetle 2 ESP32-S3 with ESP32S3'

Works as intended. I will try to take a look at the tests.

Copy link
Member

@jepler jepler left a comment

Choose a reason for hiding this comment

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

In a video chat, Dan reiterated his concern about the growth of flash due to including the long "MICROPY_FULL_VERSION_INFO" so we might just make the smaller change in mpconfig.h and leave the rest aside for now.

@bill88t
Copy link
Author

bill88t commented Feb 16, 2024

growth of flash due to including the long "MICROPY_FULL_VERSION_INFO"

Even though that string already exists in flash?
Well if that's the case I will just go and change it back.

@dhalbert
Copy link
Collaborator

Even though that string already exists in flash?

MICROPY_FULL_VERSION is there, but the compile-time concatenated "3.4.0; " MICROPY_FULL_VERSION is not. So it's a new string. The board name is available from a couple of other sources, so I'd like to leave it out for now.

Copy link
Collaborator

@dhalbert dhalbert left a comment

Choose a reason for hiding this comment

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

Thanks for persevering on this as I changed my mind, and thanks for fixing the tests.

@dhalbert dhalbert merged commit d0fec0c into adafruit:main Feb 17, 2024
487 checks passed
@dhalbert dhalbert changed the title Change sys.version to return the whole port identification. Correct sys.version to say "CircuitPython" instead of "MicroPython" Feb 17, 2024
@bill88t bill88t deleted the sysvers branch March 21, 2024 14:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

sys.version reports as micropython
4 participants