Add support for Python 3.13#948
Conversation
Mark2000
left a comment
There was a problem hiding this comment.
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.
Mark2000
left a comment
There was a problem hiding this comment.
Seems good to me, just need to add more detail or a warning to release notes.
7df288b to
272a44e
Compare
272a44e to
0bbfe17
Compare
4c3e298 to
f9a06d7
Compare
remain compatible with earlier versions of python as well.
change python code to not use eval()
f9a06d7 to
76a827a
Compare
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. Theeval()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 theeval()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 filescenarioDragDeorbit.pyhad to be updated to ensure thenumpylibrary 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