Skip to content

feat: scaffold portablemc 5.x build and packaging#8

Merged
PythonChicken123 merged 1 commit into
memoryfrom
v0/7442-366585c8
May 10, 2026
Merged

feat: scaffold portablemc 5.x build and packaging#8
PythonChicken123 merged 1 commit into
memoryfrom
v0/7442-366585c8

Conversation

@PythonChicken123

@PythonChicken123 PythonChicken123 commented May 10, 2026

Copy link
Copy Markdown
Owner

Create build scripts and package structure for portablemc 5.x wheel generation

Summary by Sourcery

Improve portablemc 5.x wheel handling and environment initialization guidance.

Enhancements:

  • Support multiple wheel naming patterns and extension file conventions when locating and extracting the portablemc native extension from built wheels.
  • Enhance error messaging for failed portablemc environment initialization with explicit build instructions, prerequisites, and expected artifact locations.

Create build scripts and package structure for portablemc 5.x wheel generation

Co-authored-by: PythonChicken123 <101510622+PythonChicken123@users.noreply.github.com>
@vercel

vercel Bot commented May 10, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
minecraft-portable-web Ready Ready Preview, Comment, Open in v0 May 10, 2026 6:51pm

@sourcery-ai

sourcery-ai Bot commented May 10, 2026

Copy link
Copy Markdown
Contributor

Reviewer's Guide

Scaffolds support for building and vendoring the portablemc 5.x native extension from maturin-generated wheels, updating wheel discovery, extension detection, extraction logic, and the JVM bootstrap error message/instructions.

Flow diagram for updated extraction of native extension from wheel

flowchart TD
    A[Start _extract_pyd_from_wheel] --> B[Create portablemc package dir if needed]
    B --> C[Open wheel as zip file]
    C --> D[Set prefixes to portablemc/ and portablemc_py/]
    D --> E[Scan zip names to find first matching prefix]
    E --> F{Found matching prefix?}
    F -- No --> G[Log warning: No portablemc package found]
    G --> H[Return False]
    F -- Yes --> I[Initialize extracted counter to 0]
    I --> J[For each name in zip file]
    J --> K{Name starts with found prefix?}
    K -- No --> J
    K -- Yes --> L{Name has __pycache__ or ends with / ?}
    L -- Yes --> J
    L -- No --> M{Name contains .dist-info?}
    M -- Yes --> J
    M -- No --> N[Strip found prefix to get rel]
    N --> O{rel is empty?}
    O -- Yes --> J
    O -- No --> P[Replace portablemc_py with _portablemc in rel]
    P --> Q[Compute dest path under portablemc package dir]
    Q --> R[Create dest parent dirs]
    R --> S[Read data from zip entry]
    S --> T[Write data to dest]
    T --> U[Increment extracted counter]
    U --> J
    J --> V[All names processed]
    V --> W[Log number of extracted files and wheel name]
    W --> X{extracted > 0?}
    X -- Yes --> Y[Return True]
    X -- No --> Z[Return False]
Loading

File-Level Changes

Change Details Files
Support both legacy and maturin-style wheel and extension naming for local portablemc builds.
  • Update wheel discovery to look for both portablemc_py-.whl (maturin) and portablemc-.whl, preferring the most recent match.
  • Expand native extension presence check to cover both .pyd and .so artifacts and both portablemc and portablemc_py naming schemes.
  • Generalize wheel extraction to detect either portablemc/ or portablemc_py/ package roots, skip dist-info entries, and rewrite extracted paths so that portablemc_py artifacts are placed under a portablemc/ package with filenames normalized to _portablemc.
scripts/local_portablemc.py
Improve failure diagnostics and guidance when the portablemc 5.x environment cannot be initialized.
  • Change the resolve() initialization failure message to explicitly mention the missing _portablemc.pyd extension and provide step-by-step instructions to build the wheel using the local build_wheel.py script.
  • Document Rust and maturin as requirements and clarify expected wheel and package output locations under the scripts/portablemc tree.
scripts/jvm_boot_glue.py

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@PythonChicken123
PythonChicken123 merged commit d2529a4 into memory May 10, 2026
6 of 9 checks passed
@PythonChicken123
PythonChicken123 deleted the v0/7442-366585c8 branch May 10, 2026 18:52

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Hey - I've found 2 issues, and left some high level feedback:

  • The error message in resolve refers specifically to _portablemc.pyd, which is Windows-only; consider making this platform-agnostic (e.g., mentioning .pyd/.so or “native extension”) to avoid confusion on Unix-like systems.
  • In _extract_pyd_from_wheel, the rel = rel.replace("portablemc_py", "_portablemc") transformation may unintentionally rewrite occurrences of portablemc_py in non-module parts of the path; tightening this to only affect the expected filename/module segments (e.g., basename checks) would be safer.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- The error message in `resolve` refers specifically to `_portablemc.pyd`, which is Windows-only; consider making this platform-agnostic (e.g., mentioning `.pyd`/`.so` or “native extension”) to avoid confusion on Unix-like systems.
- In `_extract_pyd_from_wheel`, the `rel = rel.replace("portablemc_py", "_portablemc")` transformation may unintentionally rewrite occurrences of `portablemc_py` in non-module parts of the path; tightening this to only affect the expected filename/module segments (e.g., basename checks) would be safer.

## Individual Comments

### Comment 1
<location path="scripts/local_portablemc.py" line_range="58-60" />
<code_context>
-    for whl in sorted(_WHEEL_SEARCH.glob("portablemc-*.whl")):
-        return whl
+    # Try different wheel naming patterns (maturin uses portablemc_py-*)
+    patterns = ["portablemc_py-*.whl", "portablemc-*.whl"]
+    for pattern in patterns:
+        for whl in sorted(_WHEEL_SEARCH.glob(pattern), reverse=True):
+            return whl  # Return most recent
     return None
</code_context>
<issue_to_address>
**suggestion (bug_risk):** Wheel selection uses lexicographic order and prefers `portablemc_py-*` even if a newer `portablemc-*` exists.

This contradicts the “Return most recent” intent: selection is based on filename ordering within each pattern, plus unconditional preference for `portablemc_py-*`. If actual recency matters, consider using `st_mtime` or parsed versions to compare wheels, and make the precedence between `portablemc_py-*` and `portablemc-*` explicit when their versions differ.
</issue_to_address>

### Comment 2
<location path="scripts/jvm_boot_glue.py" line_range="2246" />
<code_context>
-                "Or ensure the wheel is available at:\n"
-                f"  {_SCRIPTS_DIR / 'portablemc' / 'target' / 'wheels'}"
+                "portablemc 5.x environment initialization failed.\n\n"
+                "The native extension (_portablemc.pyd) is required but not found.\n\n"
+                "To fix this, run the build script:\n"
+                f"  python {pmc_root / 'build_wheel.py'}\n\n"
</code_context>
<issue_to_address>
**issue:** Error message only mentions `.pyd` even though `.so` is now supported elsewhere.

Since `_pyd_present` now also checks for `.so` artifacts, this message should either reference both `_portablemc.pyd` and `_portablemc.so`, or be rephrased in a platform-neutral way (e.g., “native extension (_portablemc.*) is required”) to avoid confusing non-Windows users.
</issue_to_address>

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

Comment on lines +58 to +60
patterns = ["portablemc_py-*.whl", "portablemc-*.whl"]
for pattern in patterns:
for whl in sorted(_WHEEL_SEARCH.glob(pattern), reverse=True):

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

suggestion (bug_risk): Wheel selection uses lexicographic order and prefers portablemc_py-* even if a newer portablemc-* exists.

This contradicts the “Return most recent” intent: selection is based on filename ordering within each pattern, plus unconditional preference for portablemc_py-*. If actual recency matters, consider using st_mtime or parsed versions to compare wheels, and make the precedence between portablemc_py-* and portablemc-* explicit when their versions differ.

Comment thread scripts/jvm_boot_glue.py
"Or ensure the wheel is available at:\n"
f" {_SCRIPTS_DIR / 'portablemc' / 'target' / 'wheels'}"
"portablemc 5.x environment initialization failed.\n\n"
"The native extension (_portablemc.pyd) is required but not found.\n\n"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

issue: Error message only mentions .pyd even though .so is now supported elsewhere.

Since _pyd_present now also checks for .so artifacts, this message should either reference both _portablemc.pyd and _portablemc.so, or be rephrased in a platform-neutral way (e.g., “native extension (_portablemc.*) is required”) to avoid confusing non-Windows users.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant