Skip to content

Commit 8f41ead

Browse files
committed
feat: Add proper support for IBM i
Python 3.9 on IBM i now properly returns "os400" for sys.platform instead of claiming to be AIX as it did previously. While the IBM i PASE environment is compatible with AIX, it is a subset and has numerous differences which makes it beneficial to distinguish, however this means that it now needs explicit support here.
1 parent 245cd5b commit 8f41ead

File tree

7 files changed

+23
-9
lines changed

7 files changed

+23
-9
lines changed

addon.gypi

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,11 @@
103103
'-Wl,-bimport:<(node_exp_file)'
104104
],
105105
}],
106+
[ 'OS=="os400"', {
107+
'ldflags': [
108+
'-Wl,-bimport:<(node_exp_file)'
109+
],
110+
}],
106111
[ 'OS=="zos"', {
107112
'cflags': [
108113
'-q64',

gyp/pylib/gyp/common.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -454,6 +454,8 @@ def GetFlavor(params):
454454
return "aix"
455455
if sys.platform.startswith(("os390", "zos")):
456456
return "zos"
457+
if sys.platform == "os400":
458+
return "os400"
457459

458460
return "linux"
459461

@@ -463,9 +465,13 @@ def CopyTool(flavor, out_path, generator_flags={}):
463465
to |out_path|."""
464466
# aix and solaris just need flock emulation. mac and win use more complicated
465467
# support scripts.
466-
prefix = {"aix": "flock", "solaris": "flock", "mac": "mac", "win": "win"}.get(
467-
flavor, None
468-
)
468+
prefix = {
469+
"aix": "flock",
470+
"os400": "flock",
471+
"solaris": "flock",
472+
"mac": "mac",
473+
"win": "win",
474+
}.get(flavor, None)
469475
if not prefix:
470476
return
471477

gyp/pylib/gyp/flock_tool.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ def ExecFlock(self, lockfile, *cmd_list):
4141
# with EBADF, that's why we use this F_SETLK
4242
# hack instead.
4343
fd = os.open(lockfile, os.O_WRONLY | os.O_NOCTTY | os.O_CREAT, 0o666)
44-
if sys.platform.startswith("aix"):
44+
if sys.platform.startswith("aix") or sys.platform == "os400":
4545
# Python on AIX is compiled with LARGEFILE support, which changes the
4646
# struct size.
4747
op = struct.pack("hhIllqq", fcntl.F_WRLCK, 0, 0, 0, 0, 0, 0)

gyp/test_gyp.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,7 @@ def main(argv=None):
116116
else:
117117
format_list = {
118118
"aix5": ["make"],
119+
"os400": ["make"],
119120
"freebsd7": ["make"],
120121
"freebsd8": ["make"],
121122
"openbsd5": ["make"],

lib/build.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ function build (gyp, argv, callback) {
1111
var platformMake = 'make'
1212
if (process.platform === 'aix') {
1313
platformMake = 'gmake'
14+
} else if (process.platform === 'os400') {
15+
platformMake = 'gmake'
1416
} else if (process.platform.indexOf('bsd') !== -1) {
1517
platformMake = 'gmake'
1618
} else if (win && argv.length > 0) {

lib/configure.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -153,12 +153,12 @@ function configure (gyp, argv, callback) {
153153
// For AIX and z/OS we need to set up the path to the exports file
154154
// which contains the symbols needed for linking.
155155
var nodeExpFile
156-
if (process.platform === 'aix' || process.platform === 'os390') {
157-
var ext = process.platform === 'aix' ? 'exp' : 'x'
156+
if (process.platform === 'aix' || process.platform === 'os390' || process.platform === 'os400') {
157+
var ext = process.platform === 'os390' ? 'x' : 'exp'
158158
var nodeRootDir = findNodeDirectory()
159159
var candidates
160160

161-
if (process.platform === 'aix') {
161+
if (process.platform === 'aix' || process.platform === 'os400') {
162162
candidates = [
163163
'include/node/node',
164164
'out/Release/node',
@@ -215,7 +215,7 @@ function configure (gyp, argv, callback) {
215215
argv.push('-Dlibrary=shared_library')
216216
argv.push('-Dvisibility=default')
217217
argv.push('-Dnode_root_dir=' + nodeDir)
218-
if (process.platform === 'aix' || process.platform === 'os390') {
218+
if (process.platform === 'aix' || process.platform === 'os390' || process.platform === 'os400') {
219219
argv.push('-Dnode_exp_file=' + nodeExpFile)
220220
}
221221
argv.push('-Dnode_gyp_dir=' + nodeGypDir)

test/test-find-node-directory.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ const test = require('tap').test
44
const path = require('path')
55
const findNodeDirectory = require('../lib/find-node-directory')
66

7-
const platforms = ['darwin', 'freebsd', 'linux', 'sunos', 'win32', 'aix']
7+
const platforms = ['darwin', 'freebsd', 'linux', 'sunos', 'win32', 'aix', 'os400']
88

99
// we should find the directory based on the directory
1010
// the script is running in and it should match the layout

0 commit comments

Comments
 (0)