Skip to content

Commit fdda4a3

Browse files
authored
feat: Add proper support for IBM i (#140)
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 35305d6 commit fdda4a3

4 files changed

Lines changed: 39 additions & 4 deletions

File tree

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

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)

pylib/gyp/generator/make.py

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -237,6 +237,24 @@ def CalculateGeneratorInputInfo(params):
237237
""" # noqa: E501
238238

239239

240+
LINK_COMMANDS_OS400 = """\
241+
quiet_cmd_alink = AR($(TOOLSET)) $@
242+
cmd_alink = rm -f $@ && $(AR.$(TOOLSET)) -X64 crs $@ $(filter %.o,$^)
243+
244+
quiet_cmd_alink_thin = AR($(TOOLSET)) $@
245+
cmd_alink_thin = rm -f $@ && $(AR.$(TOOLSET)) -X64 crs $@ $(filter %.o,$^)
246+
247+
quiet_cmd_link = LINK($(TOOLSET)) $@
248+
cmd_link = $(LINK.$(TOOLSET)) $(GYP_LDFLAGS) $(LDFLAGS.$(TOOLSET)) -o $@ $(LD_INPUTS) $(LIBS)
249+
250+
quiet_cmd_solink = SOLINK($(TOOLSET)) $@
251+
cmd_solink = $(LINK.$(TOOLSET)) -shared $(GYP_LDFLAGS) $(LDFLAGS.$(TOOLSET)) -o $@ $(LD_INPUTS) $(LIBS)
252+
253+
quiet_cmd_solink_module = SOLINK_MODULE($(TOOLSET)) $@
254+
cmd_solink_module = $(LINK.$(TOOLSET)) -shared $(GYP_LDFLAGS) $(LDFLAGS.$(TOOLSET)) -o $@ $(filter-out FORCE_DO_CMD, $^) $(LIBS)
255+
""" # noqa: E501
256+
257+
240258
LINK_COMMANDS_OS390 = """\
241259
quiet_cmd_alink = AR($(TOOLSET)) $@
242260
cmd_alink = rm -f $@ && $(AR.$(TOOLSET)) crs $@ $(filter %.o,$^)
@@ -2351,6 +2369,16 @@ def CalculateMakefilePath(build_file, base_name):
23512369
"flock_index": 2,
23522370
}
23532371
)
2372+
elif flavor == "os400":
2373+
copy_archive_arguments = "-pPRf"
2374+
header_params.update(
2375+
{
2376+
"copy_archive_args": copy_archive_arguments,
2377+
"link_commands": LINK_COMMANDS_OS400,
2378+
"flock": "./gyp-flock-tool flock",
2379+
"flock_index": 2,
2380+
}
2381+
)
23542382

23552383
build_file, _, _ = gyp.common.ParseQualifiedTarget(target_list[0])
23562384
make_global_settings_array = data[build_file].get("make_global_settings", [])

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"],

0 commit comments

Comments
 (0)