Skip to content

Websockets 12.0, fixed index builder#5

Merged
FeodorFitsner merged 8 commits into
mainfrom
websockets
Jun 28, 2024
Merged

Websockets 12.0, fixed index builder#5
FeodorFitsner merged 8 commits into
mainfrom
websockets

Conversation

@FeodorFitsner
Copy link
Copy Markdown

@FeodorFitsner FeodorFitsner commented Jun 28, 2024

Summary by Sourcery

This pull request introduces support for Websockets version 12.0, enhances the upload and index builder scripts to handle SHA256 hashes for both wheel files and their metadata, and updates the AppVeyor build configuration to include the new Websockets version.

  • New Features:
    • Added support for Websockets version 12.0 in the build configurations for both Android and iOS.
  • Enhancements:
    • Improved the upload script to include SHA256 hashes for both wheel files and their metadata.
    • Enhanced the index builder script to handle and display separate SHA256 hashes for wheel files and their metadata.
  • Build:
    • Updated the AppVeyor configuration to include Websockets version 12.0 in the build matrix for Android and iOS.

@sourcery-ai
Copy link
Copy Markdown

sourcery-ai Bot commented Jun 28, 2024

Reviewer's Guide by Sourcery

This pull request refactors the hashing and metadata handling for wheel files, updates the HTML anchors and S3 metadata in the index builder, and adds support for websockets version 12.0 in the build configurations. A new meta.yaml file for websockets version 12.0 is also included.

File-Level Changes

Files Changes
.ci/publish-wheels.py
.ci/rebuild-simple-index.py
Refactored hashing functions and updated metadata handling for wheel files, including changes to HTML anchors and S3 metadata.
.appveyor.yml
recipes/websockets/meta.yaml
Added support for websockets version 12.0 in build configurations and created a new meta.yaml file for the package.

Tips
  • Trigger a new Sourcery review by commenting @sourcery-ai review on the pull request.
  • You can change your review settings at any time by accessing your dashboard:
    • Enable or disable the Sourcery-generated pull request summary or reviewer's guide;
    • Change the review language;
  • You can always contact us if you have any questions or feedback.

Copy link
Copy Markdown

@sourcery-ai sourcery-ai Bot left a comment

Choose a reason for hiding this comment

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

Hey @FeodorFitsner - I've reviewed your changes and they look great!

Here's what I looked at during the review
  • 🟡 General issues: 5 issues found
  • 🟢 Security: all looks good
  • 🟢 Testing: all looks good
  • 🟢 Complexity: all looks good
  • 🟢 Documentation: all looks good

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 to tell me if it was helpful.

Comment thread .ci/publish-wheels.py Outdated
remote_file_path = os.path.basename(file)

# extract and upload metadata
zip = zipfile.ZipFile(file)
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

suggestion: Consider using a context manager for ZipFile

Using a context manager (with zipfile.ZipFile(file) as zip:) ensures that the file is properly closed after its block of code is executed, even if an exception is raised.

Suggested change
zip = zipfile.ZipFile(file)
with zipfile.ZipFile(file) as zip:

Comment thread .ci/publish-wheels.py Outdated
metadata_filename = next(
filter(lambda f: f.endswith(".dist-info/METADATA"), zip.namelist())
)
f = zip.open(metadata_filename)
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

suggestion: Consider using a context manager for file handling

Using a context manager (with zip.open(metadata_filename) as f:) ensures that the file is properly closed after its block of code is executed, even if an exception is raised.

Suggested change
f = zip.open(metadata_filename)
with zip.open(metadata_filename) as f:
content = f.read()

Comment thread .ci/publish-wheels.py Outdated
cf_bucket_name,
file,
remote_file_path,
wheel_hash=get_file_sha256(file),
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

suggestion (performance): Potential inefficiency in reading file twice

The file is read twice: once for calculating the SHA256 hash and once for uploading. Consider reading the file once and using the content for both operations to improve efficiency.

Suggested change
wheel_hash=get_file_sha256(file),
with open(file, 'rb') as f:
file_content = f.read()
wheel_hash = hashlib.sha256(file_content).hexdigest()

Comment thread .ci/rebuild-simple-index.py Outdated
if not package_name in index:
index[package_name] = []
elif not key.endswith("index.html"):
elif not key.endswith("index.html") and key.endswith(".whl"):
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

suggestion: Redundant condition in elif statement

The condition not key.endswith("index.html") is redundant because key.endswith(".whl") will never be true if the key ends with index.html. Consider removing the redundant condition.

Suggested change
elif not key.endswith("index.html") and key.endswith(".whl"):
elif key.endswith(".whl"):

Comment thread .appveyor.yml
Comment on lines +17 to +21
# - job_name: 'Android: websockets'
# job_group: build_android
# FORGE_ARCH: android
# FORGE_PACKAGES: >-
# websockets:12.0
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

suggestion: Remove commented-out job configurations

If these job configurations are not needed, consider removing them to keep the configuration file clean and maintainable.

Comment thread .ci/publish-wheels.py Outdated
remote_file_path = os.path.basename(file)

# extract and upload metadata
zip = zipfile.ZipFile(file)
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

issue (code-quality): Don't assign to builtin variable zip (avoid-builtin-shadow)


ExplanationPython has a number of builtin variables: functions and constants that
form a part of the language, such as list, getattr, and type
(See https://docs.python.org/3/library/functions.html).
It is valid, in the language, to re-bind such variables:

list = [1, 2, 3]

However, this is considered poor practice.

  • It will confuse other developers.
  • It will confuse syntax highlighters and linters.
  • It means you can no longer use that builtin for its original purpose.

How can you solve this?

Rename the variable something more specific, such as integers.
In a pinch, my_list and similar names are colloquially-recognized
placeholders.

@@ -56,15 +56,21 @@ def normalize(name):
package_name = parts[1]
if not package_name in index:
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

issue (code-quality): We've found these issues:

@FeodorFitsner FeodorFitsner merged commit f99a287 into main Jun 28, 2024
@FeodorFitsner FeodorFitsner deleted the websockets branch June 28, 2024 22:29
ndonkoHenri added a commit to ndonkoHenri/mobile-forge that referenced this pull request Jun 1, 2026
flet-dev/python-build#5 has landed. The new v3.12 tarball relocates
sysconfigdata's baked NDK paths at runtime AND ships libpython3.so as
a proper linker script (with libpython3.12.so now carrying its
DT_SONAME, per Feodor's follow-up patchelf fix). Both consumer-side
band-aids in this repo become no-ops against that tarball — remove
them.

Removed:

1. `.ci/install_ndk.sh`: the `$HOME/ndk/<letter>` compat-symlink block.
   Existed because sysconfigdata baked `/home/runner/ndk/<letter>/...`
   compiler paths, so crossenv looked for clang there. PR flet-dev#5's
   tarball-side relocation consults `$NDK_HOME` (and a fallback list)
   at sysconfig import time, so the symlink is no longer needed.

2. `.github/workflows/build-wheels.yml`: the `for libpy in ...` loop
   that replaced libpython3.so with a GNU ld linker script
   `INPUT ( -lpython3.12 )`. PR flet-dev#5's `replace_libpython_stub` writes
   the same linker script in-place at tarball-assembly time, and the
   new SONAME on libpython3.12.so closes the link-name-fallback path
   that originally made the workaround necessary. The loop is now a
   no-op against any extracted tarball — delete it.

bash -n + YAML validation both pass.
ndonkoHenri added a commit to ndonkoHenri/mobile-forge that referenced this pull request Jun 2, 2026
The original assertion `hasattr(blis, "py")` could never pass: blis's
`__init__.py` is literally `from .cy import init; init()`, which loads
`blis/cy.cpython-*.so` only. Python doesn't auto-import sibling
submodules, so `blis.py` stays unset after `import blis` — regardless
of arch or whether libcpp_shared is bundled. The docstring claimed the
test was an x86_64 libcpp canary that failed because the published
numpy-2.2.2-4 wheel had no `Requires-Dist: flet-libcpp-shared`, but
that rationale is doubly stale:

  * numpy is now published at flet-dev#5 with `Requires-Dist:
    flet-libcpp-shared (>=27.2.12479018)`, so x86_64 Flet apps bundle
    libc++_shared.so. Confirmed in run 26836214663: `test_einsum` and
    `test_numpy_fft` both pass on x86_64 in the same job — neither
    could load numpy if libcpp were missing.

  * Even if numpy still lacked the dep, the assertion would fail on
    every platform, not just x86_64, because `import blis` never tries
    to load `blis/py.cpython-*.so` in the first place.

The fix matches the test to its docstring's intent: explicitly
`from blis import py` so `blis/py.cpython-*.so` actually dlopens, then
assert both `blis.cy` and `blis.py` are present. If libcpp_shared ever
goes missing again, both `.so` files fail to dlopen and both
assertions catch it — so the test still serves as the libcpp canary
it was meant to be, just correctly now.
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