From 004db89c60f8c35a1cb37511f75ecfdca44db297 Mon Sep 17 00:00:00 2001 From: Veit Heller Date: Mon, 13 Jun 2022 10:34:03 +0200 Subject: [PATCH] Closer to an evaluator --- lepiter/9py149sz34c10e429aqq1v7qc.bak | 8 ++++---- lepiter/9py149sz34c10e429aqq1v7qc.lepiter | 4 ++-- src/Carp/CarpApplication.class.st | 2 +- src/Carp/CarpPlatform.class.st | 5 +++++ src/Carp/CarpPythonProcess.class.st | 25 +++++++++++++++++++++++ 5 files changed, 37 insertions(+), 7 deletions(-) diff --git a/lepiter/9py149sz34c10e429aqq1v7qc.bak b/lepiter/9py149sz34c10e429aqq1v7qc.bak index 828a6f2..a9b8823 100644 --- a/lepiter/9py149sz34c10e429aqq1v7qc.bak +++ b/lepiter/9py149sz34c10e429aqq1v7qc.bak @@ -66,7 +66,7 @@ "__type" : "time", "time" : { "__type" : "dateAndTime", - "dateAndTimeString" : "2022-06-11T18:06:06.353672+02:00" + "dateAndTimeString" : "2022-06-12T12:51:14.365509+02:00" } }, "uid" : { @@ -76,7 +76,7 @@ "paragraphStyle" : { "__type" : "textStyle" }, - "string" : "I too was tempted to go down that route before realizing that that would mean understanding and implementing the LanguageLink protocol, a task I wasn’t particularly interested in. Instead, the Carp LanguageLink server uses the one provided by PythonBridge (which can be found [in the PythonBridge repository TODO: good link](github.com/feenkcom/pythonbridge)). It includes all the infrastructure needed, and the only thing that likely needs to be changed is how `EvalCommand`s are handled: in the case of Carp, a simple subprocess handler that feeds the statements into a Carp REPL and reads the result. You can inspect the custom code I wrote [in the gt4carp repository TODO: good link](https://git.veitheller.de/carpentry/gt4carp)." + "string" : "I too was tempted to go down that route before realizing that that would mean understanding and implementing the LanguageLink protocol, a task I wasn’t particularly interested in. Instead, the Carp LanguageLink server uses the one provided by PythonBridge (which can be found [in the PythonBridge repository TODO:](https://github.com/feenkcom/PythonBridge/tree/master/PythonBridgeRuntime)). It includes all the infrastructure needed, and the only thing that likely needs to be changed is how `EvalCommand`s are handled: in the case of Carp, a simple subprocess handler that feeds the statements into a Carp REPL and reads the result. You can inspect the custom code I wrote [in the gt4carp repository TODO: good link](https://git.veitheller.de/carpentry/gt4carp)." }, { "__type" : "textSnippet", @@ -103,7 +103,7 @@ "__type" : "time", "time" : { "__type" : "dateAndTime", - "dateAndTimeString" : "2022-06-11T18:07:19.529977+02:00" + "dateAndTimeString" : "2022-06-11T18:07:40.565555+02:00" } }, "uid" : { @@ -113,7 +113,7 @@ "paragraphStyle" : { "__type" : "textStyle" }, - "string" : "While I understand that this is a rather terse “figure it out yourself”, I don’t know the ins and outs of the LanguageLink protocol well enough to assist you any more—precisely because I took t" + "string" : "While I understand that this is a rather terse “figure it out yourself”, I don’t know the ins and outs of the LanguageLink protocol well enough to assist you any more—precisely because I took the effort of side-stepping the issue entirely. Hopefully you can too!" } ] }, diff --git a/lepiter/9py149sz34c10e429aqq1v7qc.lepiter b/lepiter/9py149sz34c10e429aqq1v7qc.lepiter index 88fca0c..1f6c273 100644 --- a/lepiter/9py149sz34c10e429aqq1v7qc.lepiter +++ b/lepiter/9py149sz34c10e429aqq1v7qc.lepiter @@ -66,7 +66,7 @@ "__type" : "time", "time" : { "__type" : "dateAndTime", - "dateAndTimeString" : "2022-06-11T18:06:06.353672+02:00" + "dateAndTimeString" : "2022-06-12T12:51:15.652112+02:00" } }, "uid" : { @@ -76,7 +76,7 @@ "paragraphStyle" : { "__type" : "textStyle" }, - "string" : "I too was tempted to go down that route before realizing that that would mean understanding and implementing the LanguageLink protocol, a task I wasn’t particularly interested in. Instead, the Carp LanguageLink server uses the one provided by PythonBridge (which can be found [in the PythonBridge repository TODO: good link](github.com/feenkcom/pythonbridge)). It includes all the infrastructure needed, and the only thing that likely needs to be changed is how `EvalCommand`s are handled: in the case of Carp, a simple subprocess handler that feeds the statements into a Carp REPL and reads the result. You can inspect the custom code I wrote [in the gt4carp repository TODO: good link](https://git.veitheller.de/carpentry/gt4carp)." + "string" : "I too was tempted to go down that route before realizing that that would mean understanding and implementing the LanguageLink protocol, a task I wasn’t particularly interested in. Instead, the Carp LanguageLink server uses the one provided by PythonBridge (which can be found [in the PythonBridge repository](https://github.com/feenkcom/PythonBridge/tree/master/PythonBridgeRuntime)). It includes all the infrastructure needed, and the only thing that likely needs to be changed is how `EvalCommand`s are handled: in the case of Carp, a simple subprocess handler that feeds the statements into a Carp REPL and reads the result. You can inspect the custom code I wrote [in the gt4carp repository TODO: good link](https://git.veitheller.de/carpentry/gt4carp)." }, { "__type" : "textSnippet", diff --git a/src/Carp/CarpApplication.class.st b/src/Carp/CarpApplication.class.st index a48de25..db0a36e 100644 --- a/src/Carp/CarpApplication.class.st +++ b/src/Carp/CarpApplication.class.st @@ -22,7 +22,7 @@ CarpApplication >> baseApplication [ CarpApplication >> debuggerClientFor: anException [ "Answer the debugger client to be used by the Gt Post Mortem debugger" - ^ CarpPostMortemDebugger new exception: anException + ^ GtPythonPostMortemDebugger new exception: anException ] { #category : #accessing } diff --git a/src/Carp/CarpPlatform.class.st b/src/Carp/CarpPlatform.class.st index 0e366a4..cb12ca7 100644 --- a/src/Carp/CarpPlatform.class.st +++ b/src/Carp/CarpPlatform.class.st @@ -7,6 +7,11 @@ Class { #category : #'Carp-Processes' } +{ #category : #accessing } +CarpPlatform class >> uiManagerClass [ + ^ LanguageLinkPharoUiManager +] + { #category : #hooks } CarpPlatform class >> weakRegistryClass [ ^ LanguageLinkPharoWeakRegistry diff --git a/src/Carp/CarpPythonProcess.class.st b/src/Carp/CarpPythonProcess.class.st index a4ba71f..7775828 100644 --- a/src/Carp/CarpPythonProcess.class.st +++ b/src/Carp/CarpPythonProcess.class.st @@ -9,6 +9,31 @@ CarpPythonProcess class >> program [ ^ 'python' ] +{ #category : #accessing } +CarpPythonProcess >> processArguments [ + | args | + + args := OrderedCollection new. + self settings serverDebugMode ifTrue: + [ args addAll: { + '-m'. + 'debugpy'. + '--listen'. + self settings debugSocketAddress printAddress. + '--wait-for-client'. } ]. + args + add: (self workingDirectory / self programFile) resolve fullName; + add: '--port'; + add: self settings serverSocketAddress port asString; + add: '--pharo'; + add: self settings clientSocketAddress port asString; + add: '--method'; + add: 'http'. + "self debugMode ifTrue: [ args add: '--log' ]." + args add: '--log'. + ^ args +] + { #category : #accessing } CarpPythonProcess >> programFile [ ^ 'src/languagelink.py'