Python 3.8 - alpha release
Pages: 1 2 3 4 5 6 7 8 9 10 11 12 13 14
Martin Avison (27) 1491 posts |
Surely if Python requires CryptRandom (and any other modules) they should be RMEnsured in the !Run file? |
Chris Johns (8262) 242 posts |
Yes, although !Run just launches it in a taskwindow. You can also run a python script by double-clicking on it. I am not sure about RMEnsuring things in the !Boot file, but that’s where it sets up the run action. |
Martin Avison (27) 1491 posts |
If the !Boot file is changed to: And the !Run file is changed to: Does that achieve what is required? If the Alias$python3 is required to just run a script without starting a TaskWindow, then perhaps another obey file could be used which also included the RMEnsures. I may be barking up the wrong tree, knowing nothing of Python! |
Steve Fryatt (216) 2103 posts |
That was going to be my suggestion. I was trying to think of a way around the conditional use of One further observation: !Boot should not be unconditionally setting any system variables. !Run can do this; !Boot must only set them if they are currently unset. |
Andrew Rawnsley (492) 1443 posts |
+1 to Steve’s post immediately above – that’s quite important. Did we come to any decisions on whether Python3 will have different filetypes to Python2? The only counter-argument would be if Python 3 was going to use the same filetype and claim precedence over Python 2. However, IIRC Stefen made a fairly convincing case for separate filetypes due to version incompatibilities. |
Stuart Swales (1481) 351 posts |
Simpler to just RMEnsure those modules on which it depends as the first thing in (RISC OS) Python’s main() if the executable is to be used directly to execute Python code. Or better still (specifically for CryptRandom), in UnixLib when /dev/urandom is accessed for the first time? |
Rick Murray (539) 13806 posts |
Unless, of course, you are the only “owner” of a file/namespace. Which isn’t the case here. ;-)
+2. It’s rather annoying how many things claim text, sprite, JPEG, etc simply by virtue of booting in alphabetical order. I find SwiftJPEG is quite picky about the JPEGs it will load, while PrivateEye isn’t… But S comes after P and I’m too lazy to muck around editing obey files…
Yeah. So nice that the rest of the world gives a …. about backwards compatibility, eh? |
Kevin (224) 322 posts |
How hard would it be to convert Python 2 code to Python 3 code? |
Chris Johns (8262) 242 posts |
Yes, that should work. I was thinking of if you wanted to run python without a taskwindow, but in that case you will have to do the RMensure stuff yourself. Python 3 has its own type (since alpha 2 or 3) distinct from python 2, so arguably it does “own” the types. |
Steve Fryatt (216) 2103 posts |
Potentially difficult (or at least time consuming). That’s why Python 2 repeatedly got its end-of-life date pushed out until it finally expired at the start of this year. |
Steve Fryatt (216) 2103 posts |
I have a feeling that UnixLib already RMensures SharedUnixLib internally. The one that doesn’t seem to be getting caught is CryptRand. |
Rick Murray (539) 13806 posts |
Looking online, it seems as if Python 3 really ought to be able to load (for backwards compatibility) Python 2, because many sources will tell you that the print statement is now a print function (needs brackets) and that they fixed integer division to output a non-integer result when appropriate (ie 5/2 is 2.5, not 2). Plus strings are Unicode, not that I’ve can imagine that making much difference in RISC OS. Well, they didn’t mention all the other things. Dig deeper and you’ll find https://www.digitalocean.com/community/tutorials/how-to-port-python-2-code-to-python-3 which shows a larger number of fundamental differences. So, in theory it would be possible for Python3 to have some sort of compatibility loader, but in reality you just gotta convert it, which is less onerous than it sounds given that 2to3 exists. |
Kevin (224) 322 posts |
I was thinking of an automatic way of converting python 2 to python 3, and it appears that someone has already thought of it and got something working. |
Andrew Conroy (370) 725 posts |
Is there anyone who’d be able to test my GPIO library? It’s a rough port of the RPi.GPIO library and implements most of the features from that. You’d need to have kit that uses GPIO and probably be familiar-ish with using the RPi.GPIO library so you can tell me what I’ve done wrong! This is my first foray into writing Python code, so it’s probably very rough around the edges and I’m sure the “real programmers” on here would turn their noses up at it, but hopefully, for now, it’s better than nothing and will suffice until someone comes along and does it “properly”. Drop me an email to a.m.conroy at owlart dot co dot uk |
Matthew Hambley (3084) 17 posts |
I’ve come across an issue which is not a problem with the port itself but with the Python standard library. The “unittest” package works when invoked by running a tests script:
But it doesn’t when used in discovery mode: It makes a lot of assumptions that file extensions exist and that they will be “.py”. Obviously this isn’t an impediment on finalising the port and getting it out of the door but it would be nice if it were improved afterwards. Having looked into the unittest package I feel a little trepidatious suggesting it as that code looks pretty old and warty. |
Chris Johns (8262) 242 posts |
Yes, there is a LOT of stuff that assumes that python files are names something.py, or more generally extensions exist and are separated with a dot. It’s causing me a lot of headache with pip too. It’s not helped by code doing stuff like name = os.path.join(“foo”,“bar”,“baz.txt”) – which on RISC OS will result in “foo.bar.baz.txt” instead of “foo.bar.baz/txt” (or even “foo.bar.baz” (type text). I did have a stab at making it try to be “clever” but there lots of corner cases. |
Chris Johns (8262) 242 posts |
Alpha 5 now available from https://github.com/c-jo/cpython/releases/tag/riscos-3.8.0-a5 |
David J. Ruck (33) 1629 posts |
It’s pretty straight forward for the majority of code, unless you like writing very tricky Python. There is a tool on Linux called 2to3 which does most of the donkey work, such as putting brackets around all the print statements. The bits it doesn’t do is convert some things which no longer return lists (e.g. map(f,a) needs to be list(map(f,a)) ) and that IO calls return arrays of bytes rather than strings so file.read() needs to be file.read().decode(‘utf8’) and file.write(string) needs to be file.write(string.encode(‘utf8’)). |
Chris Johns (8262) 242 posts |
Finally some progress on pip. I’ve managed to install (and uninstall) a simple package..
Still much to be done, but a step in the right direction. |
Tristan M. (2946) 1039 posts |
Ooh. That is amazing news! You are doing a great job. |
Chris Johns (8262) 242 posts |
Alpha 6 now out: https://github.com/c-jo/cpython/releases/download/riscos-3.8.0-a6/Python38a6.zip The new big feature here is pip. I am sure it will break in all sorts of ways, but that’s why it says ‘alpha’.. |
Tristan M. (2946) 1039 posts |
I’m trying this from a pretty fresh install due to accidentally snapping my MicroSD card in half, so my install may be missing some things. So far it seems to need zlib1g and libssl to get pip up and running.
No. I had no intent on using it as an OctoPrint server. I was just trying random packages that I could think of. e: broke the output up into a few lines because code doesn’t wrap. |
GavinWraith (26) 1563 posts |
I am not acquainted with the source code for Python, so I may be talking through my hat. In Lua’s source code the directory separator character is given by a line |
GavinWraith (26) 1563 posts |
I have just downloaded the Python 3.8.3 sources to have a look. The sheer size (84 Mbytes) makes my head hurt – Lua is 2 Mbytes. I take my hat off to you Chris. It is fairly clear that anything beyond Posix or Windows did not exist for Guido van R. No porting of Python to tumble-dryers or food-mixers, then :). I guess it must be a heavy task just to filter out what cannot ever be ported to RISC OS, and what can with a lot of effort. |
David Gee (1833) 268 posts |
There are directory and extension separator characters in Python, I think Chris was commenting that they weren’t used appropriately here as there was an assumption that the extension separator is always a “.” (it is on every other system except classic Mac OS which didn’t have them.) |
Pages: 1 2 3 4 5 6 7 8 9 10 11 12 13 14