-
Notifications
You must be signed in to change notification settings - Fork 435
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
Doesn't support Python. #92
Comments
OC can use native libraries so you can use this http://labix.org/lunatic-python. |
Brilliant phrasing. The biggest hurdle in adding additional languages is that the "os" has to be reimplemented in that language (meaning all the Lua scripts that are in the repo have to be rewritten for the other language). Which is something I probably won't do, at least not in the near future. A while back EcmaXp posted something that looked like a python interpreter written in Lua (see #33), not sure how far he got with that. If anyone wants to tackle this, what needs to be done to get basic functionality (i.e. to get a new language running) is to write an implementation of the
I'd like to avoid adding additional native libraries unless absolutely necessary, so Jython sounds more likely. If additional languages are added over time (which is somewhat of what I'm dreaming of in the long term) I might have to rethink that, but that's my current stance anyway. |
Simple: This OpenComputers are based on Lua Native Library, Can't support python. and supporting python are require more code. Well you will not interest in coding python compiler. (Python code to Lua code), but i will give a link for helper. https://github.com/EcmaXp/PyCraft I don't have much time because i MUST go army. :( ... What? the Architecture interface????? |
EcmaXp: python is faster than java, i dont think performance would matter |
No, CPython is slower than java (OracleJVM have JIT), but PyPy (it have JIT) is faster than java in most case. |
I think write python interpreter in lua (PyCraft) is failed because CPython's code are very huge and almost python user will hate tinypy (because they can't use 99.9...% library) I checked the Architecture and now i decided use that for Support Python in OpenComputers. New PyCraft Memos.
|
Estimate Time:
|
And it's clearly python will use different code for internal api (like fs) |
If you want to have a go at it (which would be amazing), it doesn't have to be in Scala, you can implement the Architecture trait/interface in a Java class. And yes, there'd have to be some kind of concept for what language is used. For testing you can just initialize the value in the Machine class differently, though. As for the language specific implementation (meaning everything in the lua/ folder), yes, that will have to be redone, which may turn out to be the largest chunk of work. But it reminds me that I wanted to move the source of the read-only memory to the architecture interface (so you could have a folder python/rom for that). |
This comment will update when PyCraft (https://github.com/EcmaXp/PyCraft) get updated. Current Status ( 36 % ) in Python Side
Current Status ( 0 % ) in Java Side.
|
I don't have time for learn java, and setup scala with eclipse, make build script are eat times. http://py4j.sourceforge.net/ (It use TCP Protocol (and TCP bind port=25334) for communicate) Callback provided, custom class, instance also. |
Thanks a lot for the time you've put into this! I missed the last update, sorry for not responding to that. I don't quite understand the intended architecture here. Assuming we use py4j as the bridge, what would actually run the python code? Surely not a separate python interpreter that has to manually be started on the host OS? Because that's what py4j seems to be meant for, from a quick look at it. Unless I'm overestimating the effort implementing the Java side of things would take immensely, I'm afraid I won't have the time to look into this at this time. I may in a couple of weeks/months, but it would probably make more sense for someone who knows both Java/Scala and python to get involved in this, since my python skills are very shallow and very rusty. |
Well even if use py4j, It still require manual launch from java process, exclude that. no problem with that. I will provide the python module for execute python code, and API also. Don't panic. https://github.com/MightyPirates/OpenComputers/blob/master/src/main/java/li/cil/oc/util/ExtendedLuaState.scala package li.cil.oc.server.component.machine
trait RemotePythonSpider {
def give_me_RemotePythonArchitecture(machine, collection_of_callback): RemotePythonArchitecture
// communicate with python process. by py4j with this interface.
} package li.cil.oc.server.component.machine
trait RemotePythonArchitecture extends Architecture {} package li.cil.oc.server.component.machine
import py4j.GatewayServer;
class NativePythonArchitecture(val machine: Machine) extends Architecture {
private var python: RemotePythonArchitecture = (object's NativePythonArchitecture).getNewRemote()
def isInitialized = python.isInitialized
def recomputeMemory() = python.recomputeMemory()
def runSynchronized() = ...
def runThreaded(enterState: Machine.State.Value): ExecutionResult = ...
// problem. runThreaded and runSynchronized are almost same. callback server is one, but still require thread for call it.
// signal processing and etc thing are in here.
def init(): Boolean = ...
def load(nbt: NBTTagCompound) = ...
def save(nbt: NBTTagCompound) = ...
}
object NativePythonArchitecture {
private val Process process;
private val RemotePythonSpider spider;
private val GatewayServer server;
def getNewRemote(machine: Machine) = {
spider.give_me_RemotePythonArchitecture(machine);
}
def attachedProcess(attached_spider: RemotePythonSpider) = {
spider = attached_spider;
}
def start() = {
// in different thread
(extract python library include my library called 'ocpy', download pypy or request to download that (more than 30 MB))
process = (java way's to make child process by "pypy-execute -m ocpy" with working dir in /tmp ?)
server = new GatewayServer(this);
server.start();
}
That is pusudo code, start function must call from different thread. |
Ok, i don't have time now. (I will go korea army) Somebody know Python (and CPython, PyPy) /Java (and Scala) will continue my work (https://github.com/EcmaXp/PyCraft // forkable) or make a new code for supporting python in OpenComptuters. Even if OpenComptuers not suppport python, it still very good mineraft mod. like first meet AE in minecraft. (My Minecraft Mod Rank: 0. Forge, 1. AE, 2. OpenComputers, 3. ThermalExpansion (And Arsunal Tool also), 4. Chisel (Thanks too many blocks for deco!)) |
So, there's an API for adding custom "architectures" now, which could be used to add python support in an addon mod, and I don't have the time nor motivation to implement this myself, so I'm closing this. If anyone wants to take this on, please feel free to contact me (e.g. on IRC) to get some pointers on how to use that API, if the JDoc isn't sufficient. |
I know this ticket is relatively old - I've compiled Lunatic Python (as @dangranos suggested) into a .so, what's the best way to get OC to load it? I've just stuck it in the server directory, and I can't seem to find any documentation on this. That is to say, I used this fork with Lua 5.1 (I can recompile with 5.2 if that's a problem) |
Come into the IRC channel and talk with gamax92, he's created some example mods for adding new architectures to OpenComputers (which is how you really need to do it) |
Sure, I'll join - but I'm not looking to write a new arch here, I'd really just like to be able to require("python") and work with it when it's suitable. I don't writing a small mod to make OC load the library, though. |
|
How are you planning on sandboxing this, IE making it "safe"? I'd love to see OC python but my main problem with writing this myself is that cpython and jython are both almost impossible to sandbox |
I have recently started developing a new project. |
That is quite impressive. Is it testable yet? How do we build it? |
Not testable. yet.
|
In that case, do you have a English checklist somewhere so that people can submit pull requests? |
Sorry. i don't have any checklist. if you are interested in my work,
then you can try micropython on jarm or unicorn emulator.
|
@gdude2002 I just created new Cortex-M0 register emulator with C# |
Added string versions of getStoredEU/getEUCapacity for huge values
Seems like a pretty huge issue to me.
The text was updated successfully, but these errors were encountered: