Creating an extension for ByteString for parsing pip stdout and modifying PyEnv install method.

This commit is contained in:
ruidajo 2024-09-09 20:01:27 -05:00
parent dafde6dda2
commit e4225d0bb1
2 changed files with 14 additions and 7 deletions

View File

@ -0,0 +1,6 @@
Extension { #name : #ByteString }
{ #category : #'*ExtEnvi' }
ByteString >> parsePipInstallStdout [
^ self lines collect: [ :line | line splitOn: ':' ]
]

View File

@ -57,18 +57,19 @@ PyEnv >> install: packageName [
{ #category : #accessing } { #category : #accessing }
PyEnv >> install: aPackageName in: anEnvDirName [ PyEnv >> install: aPackageName in: anEnvDirName [
| bins pip | | bins pip stdout |
(envs includesKey: anEnvDirName) (envs includesKey: anEnvDirName)
ifFalse: [ InformDebugger inform: 'Env doesn''t exist'. ifFalse: [ InformDebugger inform: 'Env doesn''t exist'.
^ self ]. ^ self ].
bins := (envs at: anEnvDirName) / 'bin'. bins := (envs at: anEnvDirName) / 'bin'.
pip := (bins / 'pip') fullName. pip := (bins / 'pip') fullName.
^ GtSubprocessWithInMemoryOutput new stdout := GtSubprocessWithInMemoryOutput new
workingDirectory: workingDirectory; workingDirectory: workingDirectory;
command: pip; command: pip;
arguments: #('install' 'instaloader'); arguments: #('install' 'instaloader');
runAndWait; runAndWait;
stdout stdout.
^ stdout parsePipInstallStdout
] ]
{ #category : #accessing } { #category : #accessing }