Skip to content

zowex(py): Fix python bindings build process#968

Open
zFernand0 wants to merge 23 commits into
mainfrom
zf/fix-py
Open

zowex(py): Fix python bindings build process#968
zFernand0 wants to merge 23 commits into
mainfrom
zf/fix-py

Conversation

@zFernand0

@zFernand0 zFernand0 commented Apr 28, 2026

Copy link
Copy Markdown
Member

Supported Functionality

What It Does

  • Fix Build SWIG extenders
  • Fix Generate SWIG wrappers
  • Fix Build Python extension
    • building '_zusf_py' extension
    • building '_zds_py' extension
    • building '_zjb_py' extension
  • Add compiler feature macros (_EXT and _OPEN_SYS_FILE_EXT=1) to setup.py:
    • Resolved z/OS LE compilation errors (fldata_t and __amrc_type undefined)
  • Implement self-contained Source Distribution tool (package_zbind.py > zbind_src_dist.tar.gz)
  • Implement precompiled Binary Distribution tool (package_precompiled.py > zbind_bin_dist.tar.gz)
  • Resolve z/OS file-tagging/C-runtime autoconversion bugs to prevent file and archive corruption on extraction
  • Add master README.md to native/python/bindings/ detailing installation procedures for both distributions

How to Test

  • npm run z:upload python
  • npm run z:python:build
  • npm run z:python:pack (downloads the dist/zbind_bin_dist.tar.gz)
  • npm run z:python:post -- <PR-NUMBER> (e.g. npm run z:python:post -- 968)

Review Checklist
I certify that I have:

Additional Comments

TODO:

  • Fix automated tests internally npm run z:python:test

Signed-off-by: Fernando Rijo Cedeno <37381190+zFernand0@users.noreply.github.com>
@zowe-robot zowe-robot moved this from New Issues to In Progress in Zowe CLI Squad Apr 28, 2026
@github-actions

github-actions Bot commented Apr 28, 2026

Copy link
Copy Markdown

zFernand0 added 2 commits May 4, 2026 14:20
… zf/fix-py

Signed-off-by: Fernando Rijo Cedeno <37381190+zFernand0@users.noreply.github.com>
Signed-off-by: Fernando Rijo Cedeno <37381190+zFernand0@users.noreply.github.com>
@pull-request-size pull-request-size Bot added size/S and removed size/XS labels May 4, 2026
@zFernand0 zFernand0 changed the title chore: clear MD warning + generate SWIG wrappers zowex(py): Fix python bindings build process May 4, 2026
Signed-off-by: Fernando Rijo Cedeno <37381190+zFernand0@users.noreply.github.com>
@pull-request-size pull-request-size Bot added size/L and removed size/S labels May 7, 2026
zFernand0 added 2 commits May 7, 2026 10:02
… zf/fix-py

Signed-off-by: Fernando Rijo Cedeno <37381190+zFernand0@users.noreply.github.com>
… zf/fix-py

Signed-off-by: Fernando Rijo Cedeno <37381190+zFernand0@users.noreply.github.com>
@sonarqubecloud

sonarqubecloud Bot commented May 7, 2026

Copy link
Copy Markdown

… zf/fix-py

Signed-off-by: Fernando Rijo Cedeno <37381190+zFernand0@users.noreply.github.com>
@github-actions

github-actions Bot commented Jun 15, 2026

Copy link
Copy Markdown

… the main branch

Signed-off-by: Fernando Rijo Cedeno <37381190+zFernand0@users.noreply.github.com>
Signed-off-by: Fernando Rijo Cedeno <37381190+zFernand0@users.noreply.github.com>
@zFernand0
zFernand0 marked this pull request as ready for review June 15, 2026 02:40
@zowe-robot zowe-robot moved this from In Progress to Review/QA in Zowe CLI Squad Jun 15, 2026
@zFernand0
zFernand0 requested review from t1m0thyj and traeok June 15, 2026 14:03

@t1m0thyj t1m0thyj left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for your work on this Fernando! Left a few comments, will review again after manual testing.

Comment thread native/c/makefile Outdated
Comment thread native/python/bindings/zusf_py.hpp
Comment thread native/python/bindings/zjb_py.cpp Outdated
Comment thread native/python/bindings/package_precompiled.py
Comment thread native/python/bindings/package_zbind.py

@traeok traeok left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changes make sense to me, I have the same suggestions as Timothy so I just gave them a thumbs up 😋 will approve once those are resolved

Signed-off-by: Fernando Rijo Cedeno <37381190+zFernand0@users.noreply.github.com>
Signed-off-by: Fernando Rijo Cedeno <37381190+zFernand0@users.noreply.github.com>
@zFernand0
zFernand0 requested review from t1m0thyj and traeok June 29, 2026 12:56
@zFernand0

zFernand0 commented Jun 29, 2026

Copy link
Copy Markdown
Member Author

🐍 Precompiled Python bindings

Built from 4a05a984 on z/OS.

📦 Download zbind_bin_dist-pr968-4a05a984.tar.gz

Hosted as an asset on the py-bindings-dev prerelease (dev artifact, not for distribution).

Signed-off-by: Fernando Rijo Cedeno <37381190+zFernand0@users.noreply.github.com>
Comment thread scripts/postPrecompiledBindings.ts Fixed
Comment thread scripts/postPrecompiledBindings.ts Fixed
Comment thread scripts/postPrecompiledBindings.ts Fixed
Comment thread scripts/postPrecompiledBindings.ts Fixed
Signed-off-by: Fernando Rijo Cedeno <37381190+zFernand0@users.noreply.github.com>
Signed-off-by: Fernando Rijo Cedeno <37381190+zFernand0@users.noreply.github.com>
Signed-off-by: Fernando Rijo Cedeno <37381190+zFernand0@users.noreply.github.com>
Comment thread scripts/fetchPrecompiledFromPr.ts Fixed
Comment thread scripts/testPrecompiledLocal.ts Fixed
Signed-off-by: Fernando Rijo Cedeno <37381190+zFernand0@users.noreply.github.com>
Signed-off-by: Fernando Rijo Cedeno <37381190+zFernand0@users.noreply.github.com>
Signed-off-by: Fernando Rijo Cedeno <37381190+zFernand0@users.noreply.github.com>
Signed-off-by: Fernando Rijo Cedeno <37381190+zFernand0@users.noreply.github.com>
@zFernand0
zFernand0 marked this pull request as draft June 30, 2026 17:57
@zowe-robot zowe-robot moved this from Review/QA to In Progress in Zowe CLI Squad Jun 30, 2026
Signed-off-by: Fernando Rijo Cedeno <37381190+zFernand0@users.noreply.github.com>
… zf/fix-py

Signed-off-by: Fernando Rijo Cedeno <37381190+zFernand0@users.noreply.github.com>
Signed-off-by: Fernando Rijo Cedeno <37381190+zFernand0@users.noreply.github.com>
@sonarqubecloud

Copy link
Copy Markdown

@zFernand0
zFernand0 marked this pull request as ready for review July 14, 2026 18:04
@zowe-robot zowe-robot moved this from In Progress to Review/QA in Zowe CLI Squad Jul 14, 2026

@traeok traeok left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for working on this Fernando - leaving request for changes due to the missing sys import and the Windows allowlist paths, but the changes LGTM otherwise!

print(f"Packaged Python wrapper: {filename}")
else:
print(f"Error: Python wrapper not found: {filename}")
sys.exit(1)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sys is never imported, this may surface a NameError. Consider adding import sys to the top of this file

print(f"Copied object file: {filename}")
else:
print(f"Error: precompiled object file not found: {filename}")
sys.exit(1)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Similar suggestion as above for package_precompiled.py - missing an import sys at the top

Comment thread scripts/buildTools.ts
function resolveExecutable(name: string): string | null {
const trustedDirs =
process.platform === "win32"
? [path.join(process.env.SystemRoot ?? "C:\\Windows", "System32")]

@traeok traeok Jul 14, 2026

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On Windows, both the GitHub CLI and Git for Windows are installed in Program Files, not System32 - this detection likely won't catch gh or git when run on Windows clients.

I'd recommend adding these Program Files paths to the trustedDirs allowlist:

  • X:\Program Files\Git
  • X:\Program Files\GitHub CLI

Note that I used X: because the system drive may not be C: for all clients. I think we should use process.env.SystemDrive when applicable (instead of assuming C:) if we plan to have an allowlist for Windows paths

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the context of a dev tool, I don't know how important it is to guard against untrusted dirs for executables? Thinking this could be fragile if someone has an unconventional environment 😋

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's a fair point, although even if this was a production app and in a typical environment where Git / GitHub CLI is installed on Windows, this logic has no effect. It's essentially dead code / redundant logic on win32 in its current state. So maybe we should just remove it entirely?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If SWIG is absent and no precompiled bundle has been posted, the workflow emits ::warning:: and skips the Python test step rather than failing. Do we plan to resolve this in a separate PR? I noticed the TODO around fixing automated tests so I wasn't sure if we wanted to address that here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

Status: Review/QA

Development

Successfully merging this pull request may close these issues.

5 participants