Skip to content

Add support for Python 3.13#948

Merged
schaubh merged 14 commits into
developfrom
feature/python_3_13
Mar 31, 2025
Merged

Add support for Python 3.13#948
schaubh merged 14 commits into
developfrom
feature/python_3_13

Conversation

@schaubh
Copy link
Copy Markdown
Contributor

@schaubh schaubh commented Mar 5, 2025

  • Review: By commit
  • Merge strategy: Merge (no squash)

Description

Python 3.13 changed how the eval() function works, see https://peps.python.org/pep-0667. This causes some BSK python scripts to fail. The eval() function use has now been replaced to use better python methods to do equivalent steps in a safer manner. In particular, the event creation code is upgraded to not use the eval() function.

However, the user must make note that with python 3.13 and later they may have to be more careful what code in eval() can reach. For example, the file scenarioDragDeorbit.py had to be updated to ensure the numpy library was available to the provided python function code.

Verification

All tests pass again with python 3.13

Documentation

Updated install instructions to include python 3.13, updated release notes.

Future work

None for now

@schaubh schaubh added documentation Improvements or additions to documentation enhancement New feature or request ci Continuous integration labels Mar 5, 2025
@schaubh schaubh self-assigned this Mar 5, 2025
@schaubh schaubh requested a review from a team as a code owner March 5, 2025 03:36
@schaubh schaubh added this to Basilisk Mar 5, 2025
@schaubh schaubh moved this to 👀 In review in Basilisk Mar 5, 2025
@schaubh schaubh requested a review from Mark2000 March 5, 2025 14:30
Copy link
Copy Markdown
Contributor

@Mark2000 Mark2000 left a comment

Choose a reason for hiding this comment

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

Primarily looked at uses in SimulationBaseClass since that's the code I'm most familiar with. While BSK-RL's use of events remains compatible in python≤3.12, it seems like it would break in 3.13, since I believe we access a number of imports that are available within SimulationBaseClass. I think that it's necessary to add a prominent note/warning that 3.13 support does not have feature parity with ≤3.12.

Maybe this is a basilisk 3.0 idea since it completely changes how the system works, but I think that using eval or exec is not a good coding practice, and makes event creation challenging for anything but the most simple events. We should pass conditions as a list of functions of the form condition(simbase) -> bool and side effects as a function of the form side_effect(simbase) -> None. This implementation would allow for feature parity across python versions, make variable scoping obvious, and allow IDE tools to interact with the function code.

Comment thread examples/scenarioDragDeorbit.py Outdated
Copy link
Copy Markdown
Contributor

@Mark2000 Mark2000 left a comment

Choose a reason for hiding this comment

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

Seems good to me, just need to add more detail or a warning to release notes.

@schaubh schaubh force-pushed the feature/python_3_13 branch 5 times, most recently from 7df288b to 272a44e Compare March 15, 2025 00:37
@schaubh schaubh force-pushed the feature/python_3_13 branch from 272a44e to 0bbfe17 Compare March 17, 2025 16:49
@schaubh schaubh force-pushed the feature/python_3_13 branch 2 times, most recently from 4c3e298 to f9a06d7 Compare March 27, 2025 18:35
@schaubh schaubh force-pushed the feature/python_3_13 branch from f9a06d7 to 76a827a Compare March 31, 2025 17:07
@schaubh schaubh merged commit 877aebb into develop Mar 31, 2025
11 checks passed
@schaubh schaubh deleted the feature/python_3_13 branch March 31, 2025 18:41
@github-project-automation github-project-automation Bot moved this from 👀 In review to ✅ Done in Basilisk Mar 31, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ci Continuous integration documentation Improvements or additions to documentation enhancement New feature or request

Projects

Status: ✅ Done

Development

Successfully merging this pull request may close these issues.

3 participants