Skip to content

Commit 3b1d3f4

Browse files
committed
Restructure PythonBridge runtime
So that there isn't a circular symbolic link and it is possible to easily copy just the runtime files without copying the entire git repository. Issue: feenkcom/gtoolkit#1936
1 parent 22b6ffe commit 3b1d3f4

20 files changed

+5
-54
lines changed
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

src/PythonBridge-Pharo/PBPharoPlatform.class.st

+4-53
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,9 @@ PBPharoPlatform class >> weakRegistryClass [
3737
{ #category : #private }
3838
PBPharoPlatform >> copyApplicationTo: appFolder application: application [
3939
"Copy the PythonBridge runtime environment to the specified folder"
40-
| srcDir cpCommand proc pbSymLink srcFilename dstFilename |
40+
| srcDir cpCommand proc srcFilename dstFilename |
4141

42-
srcDir := FileLocator imageDirectory / 'PythonBridge'.
42+
srcDir := FileLocator imageDirectory / 'PythonBridgeRuntime'.
4343
(srcDir exists and: [ srcDir ~= appFolder ]) ifFalse:
4444
[ srcDir := self folderForApplication: application ].
4545
srcDir exists ifFalse:
@@ -60,28 +60,9 @@ PBPharoPlatform >> copyApplicationTo: appFolder application: application [
6060
runAndWait.
6161
proc isSuccess ifFalse:
6262
[ self error: 'Unable to install PythonBridge runtime' ].
63-
"Remove the existing symlink, which probably points to the source folder.
64-
FileReference>>delete doesn't handle symbolic links, so use the lower layer"
65-
pbSymLink := (appFolder / 'PythonBridge') resolve.
66-
pbSymLink exists ifTrue:
67-
[ pbSymLink isSymlink
68-
ifTrue: [ self removeFile: pbSymLink ]
69-
ifFalse: [ self error: 'PythonBridge should be a symbolic link' ] ].
7063

7164
]
7265

73-
{ #category : #'private - symlinks' }
74-
PBPharoPlatform >> createSymlinkFor: originalFile on: targetFile [
75-
OSSUnixSubprocess new
76-
command: '/bin/ln';
77-
arguments: (Array
78-
with: '-s'
79-
with: originalFile asFileReference fullName
80-
with: targetFile asFileReference fullName);
81-
terminateOnShutdown;
82-
runAndWaitOnExitDo: [ :command | ^ self ].
83-
]
84-
8566
{ #category : #'message broker strategy' }
8667
PBPharoPlatform >> defaultMessageBrokerClass [
8768
^ self class socketMessageBrokerClass
@@ -94,7 +75,7 @@ PBPharoPlatform >> ensureApplicationDirectory: application [
9475
appFolder := application workingDirectory.
9576
(appFolder / 'PythonBridge') exists ifTrue: [ ^ self ].
9677
self copyApplicationTo: appFolder application: application.
97-
self ensurePBridge: (self folderForApplication: application class baseApplication) symlinkIn: appFolder.
78+
9879
]
9980

10081
{ #category : #private }
@@ -104,30 +85,14 @@ PBPharoPlatform >> ensureEnvironmentForApp: anApplication [
10485
self installEnvironmentForApp: anApplication.
10586
]
10687

107-
{ #category : #'private - symlinks' }
108-
PBPharoPlatform >> ensureFolderSymlinkFor: aFolder [
109-
| symlinkRef |
110-
symlinkRef := aFolder basename asFileReference.
111-
symlinkRef exists ifFalse: [
112-
self createSymlinkFor: aFolder on: symlinkRef ]
113-
]
114-
115-
{ #category : #'private - symlinks' }
116-
PBPharoPlatform >> ensurePBridge: pbridgeFolder symlinkIn: aFolder [
117-
| symlinkRef |
118-
symlinkRef := aFolder / 'PythonBridge'.
119-
symlinkRef exists ifFalse: [
120-
self createSymlinkFor: aFolder on: symlinkRef ].
121-
]
122-
12388
{ #category : #utils }
12489
PBPharoPlatform >> folderForApplication: application [
12590
^ (IceRepository registry
12691
detect: [ :each | each includesPackageNamed: application class package name ]
12792
ifNone: [
12893
self inform: 'Please add a clone of this project to Iceberg to access to the resources'.
12994
"For travis!"
130-
^ '.' asFileReference ]) location
95+
^ '.' asFileReference ]) location / 'PythonBridgeRuntime'
13196
]
13297

13398
{ #category : #utils }
@@ -173,20 +138,6 @@ PBPharoPlatform >> pipenvForApplication: application [
173138
[ self class pipenvProcessClass pipenvPath ]
174139
]
175140

176-
{ #category : #'private - symlinks' }
177-
PBPharoPlatform >> removeFile: aFileReference [
178-
"Use the OS rm command to remove the specified file.
179-
Required since the file system primitive doesn't seem to handle symbolic links"
180-
| proc |
181-
182-
proc := OSSUnixSubprocess new
183-
command: 'rm';
184-
arguments: { aFileReference fullName };
185-
runAndWait.
186-
proc isSuccess ifFalse:
187-
[ self error: 'Unable to remove: ', aFileReference fullName ]
188-
]
189-
190141
{ #category : #accessing }
191142
PBPharoPlatform >> runtimeFolder [
192143
"Answer the directory where the PythonBridge runtime files are located"

src/PythonBridge/PBApplication.class.st

+1-1
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ PBApplication class >> resetUniqueInstance [
8484
PBApplication class >> runtimeDirectory [
8585
"This is the directory basename where the runtime files are located"
8686

87-
^ 'PythonBridge'
87+
^ 'PythonBridgeRuntime'
8888
]
8989

9090
{ #category : #instructions }

0 commit comments

Comments
 (0)