Creating methods for create virtual envs with python and PyEnv initialization.
This commit is contained in:
parent
97d50c3a40
commit
dafde6dda2
@ -4,17 +4,74 @@ Class {
|
||||
#instVars : [
|
||||
'workingDirectory',
|
||||
'pyVersion',
|
||||
'pyBinLocation'
|
||||
'pyBinLocation',
|
||||
'envs'
|
||||
],
|
||||
#category : #ExtEnvi
|
||||
}
|
||||
|
||||
{ #category : #'as yet unclassified' }
|
||||
PyEnv >> initialize [
|
||||
super initialize
|
||||
{ #category : #accessing }
|
||||
PyEnv >> createDefaultEnv [
|
||||
| temp |
|
||||
temp := self workingDirectory.
|
||||
GtSubprocessWithInMemoryOutput new
|
||||
workingDirectory: temp;
|
||||
command: 'python3';
|
||||
arguments: #('-m' 'venv' './Env/');
|
||||
runAndWait;
|
||||
stdout.
|
||||
^ workingDirectory
|
||||
]
|
||||
|
||||
{ #category : #'as yet unclassified' }
|
||||
{ #category : #accessing }
|
||||
PyEnv >> createEnv: aDirEnvName in: aLocation [
|
||||
self workingDirectory: aLocation.
|
||||
GtSubprocessWithInMemoryOutput new
|
||||
workingDirectory: self workingDirectory;
|
||||
command: 'python3';
|
||||
arguments: {'-m' . 'venv' . aDirEnvName};
|
||||
runAndWait;
|
||||
stdout.
|
||||
envs at: aDirEnvName put: aLocation / aDirEnvName
|
||||
]
|
||||
|
||||
{ #category : #accessing }
|
||||
PyEnv >> envs [
|
||||
^ envs ifNil: [ envs := Dictionary new ]
|
||||
]
|
||||
|
||||
{ #category : #initalization }
|
||||
PyEnv >> initialize [
|
||||
super initialize.
|
||||
self python3.
|
||||
self workingDirectory.
|
||||
self envs.
|
||||
]
|
||||
|
||||
{ #category : #accessing }
|
||||
PyEnv >> install: packageName [
|
||||
| wd |
|
||||
wd := self workingDirectory.
|
||||
^ wd
|
||||
]
|
||||
|
||||
{ #category : #accessing }
|
||||
PyEnv >> install: aPackageName in: anEnvDirName [
|
||||
| bins pip |
|
||||
(envs includesKey: anEnvDirName)
|
||||
ifFalse: [ InformDebugger inform: 'Env doesn''t exist'.
|
||||
^ self ].
|
||||
bins := (envs at: anEnvDirName) / 'bin'.
|
||||
pip := (bins / 'pip') fullName.
|
||||
^ GtSubprocessWithInMemoryOutput new
|
||||
workingDirectory: workingDirectory;
|
||||
command: pip;
|
||||
arguments: #('install' 'instaloader');
|
||||
runAndWait;
|
||||
stdout
|
||||
]
|
||||
|
||||
{ #category : #accessing }
|
||||
PyEnv >> python3 [
|
||||
pyVersion := (GtSubprocessWithInMemoryOutput new
|
||||
command: 'python3';
|
||||
@ -31,7 +88,9 @@ PyEnv >> python3 [
|
||||
|
||||
{ #category : #accessing }
|
||||
PyEnv >> workingDirectory [
|
||||
^ workingDirectory ifNil: [ workingDirectory := (FileLocator documents / 'TempPythonEnv') ensureCreateDirectory ]
|
||||
^ workingDirectory
|
||||
ifNil: [ workingDirectory := (FileLocator documents / 'ExtEnviPythonEnv')
|
||||
ensureCreateDirectory ]
|
||||
]
|
||||
|
||||
{ #category : #accessing }
|
||||
|
Loading…
Reference in New Issue
Block a user