However, as of today, there's a much better way of achieving what you're describing in an Android phone: Termux (1)
With Termux you can use an amazing number of regular Linux/UNIX tools, interface them with phone specific functionality (like GPS or other sensors) and still enjoy having a modern smartphone in terms of apps available, performance and battery life.
(Shameless plug: you can watch Termux in action in this talk from last year (2). It's centered around Ruby, but Python works just fine, too)
(1) https://wiki.termux.com/wiki/Main_Page https://wiki.termux.com/wiki/Termux:API
(2) https://vimeo.com/482309000/1534e97efd
(edit: typo)
Actually switching to a pure Linux phone and might be the more viable long-term solution.
[0]: https://github.com/termux/termux-packages/wiki/Termux-and-An...
It's a shame we're losing so much useful functionality there.
Security is a worthy goal but getting rid of useful features just because Google wants to handhold Android users so much seems to me like throwing out the baby with the bathwater.
[0] https://en.wikipedia.org/wiki/Scripting_Layer_for_Android