Skip to content

Conversation

@georgeciubotaru
Copy link
Contributor

@georgeciubotaru georgeciubotaru commented Jun 16, 2025

resolves: #61

@georgeciubotaru georgeciubotaru self-assigned this Jun 16, 2025
@pr-time-tracker
Copy link

pr-time-tracker bot commented Jun 16, 2025

Time Submission Status

Member Status Time Action Last Update
georgeciubotaru ✅ Submitted 7h Update time Jun 24, 2025, 3:23 PM
MicBun ✅ Submitted 1h Update time Jun 24, 2025, 3:23 PM
williamrusdyputra ✅ Submitted 1h Update time Jun 24, 2025, 3:23 PM
@MicBun
Copy link
Member

MicBun commented Jun 16, 2025

Have you tested it on forked repository somewhere? @georgeciubotaru

@MicBun
Copy link
Member

MicBun commented Jun 17, 2025

checking on my forked repo

@MicBun
Copy link
Member

MicBun commented Jun 17, 2025

@georgeciubotaru I try it on my forked repo, but it fails

Found release v0.3.3 (with id=225752365) 🤔 dist/*.whl does not include a valid file. 

More details:
https://github.com/MicBun/sdk-py/actions/runs/15699789402/job/44231931745

Copy link
Member

@MicBun MicBun left a comment

Choose a reason for hiding this comment

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

I am unable to run the examples file now.

steps to reproduce

pip install --force-reinstall https://github.com/MicBun/sdk-py/releases/download/v0.3.4/trufnetwork_sdk_py-0.1.0-py3-none-any.whl cd examples python main.py 

logs

Traceback (most recent call last): File "/home/micbun/MicBun/sdk-py/examples/main.py", line 2, in <module> from trufnetwork_sdk_py.client import TNClient File "/home/micbun/MicBun/sdk-py/.venv/lib/python3.12/site-packages/trufnetwork_sdk_py/__init__.py", line 1, in <module> from .client import ( File "/home/micbun/MicBun/sdk-py/.venv/lib/python3.12/site-packages/trufnetwork_sdk_py/client.py", line 2, in <module> import trufnetwork_sdk_c_bindings.exports as truf_sdk File "/home/micbun/MicBun/sdk-py/.venv/lib/python3.12/site-packages/trufnetwork_sdk_c_bindings/exports.py", line 17, in <module> from . import _trufnetwork_sdk_c_bindings ImportError: cannot import name '_trufnetwork_sdk_c_bindings' from 'trufnetwork_sdk_c_bindings' (/home/micbun/MicBun/sdk-py/.venv/lib/python3.12/site-packages/trufnetwork_sdk_c_bindings/__init__.py) 
@MicBun
Copy link
Member

MicBun commented Jun 17, 2025

@MicBun
Copy link
Member

MicBun commented Jun 17, 2025

Now i got

pip install --force-reinstall https://github.com/MicBun/sdk-py/releases/download/v0.3.6/trufnetwork_sdk_py-0.3.3-py3-none-any.whl Collecting trufnetwork-sdk-py==0.3.3 Using cached https://github.com/MicBun/sdk-py/releases/download/v0.3.6/trufnetwork_sdk_py-0.3.3-py3-none-any.whl (8.5 MB) Installing collected packages: trufnetwork-sdk-py Attempting uninstall: trufnetwork-sdk-py Found existing installation: trufnetwork_sdk_py 0.1.0 Uninstalling trufnetwork_sdk_py-0.1.0: Successfully uninstalled trufnetwork_sdk_py-0.1.0 Rolling back uninstall of trufnetwork_sdk_py Moving to /home/micbun/MicBun/sdk-py/.venv/lib/python3.12/site-packages/trufnetwork_sdk_c_bindings/ from /home/micbun/MicBun/sdk-py/.venv/lib/python3.12/site-packages/~rufnetwork_sdk_c_bindings Moving to /home/micbun/MicBun/sdk-py/.venv/lib/python3.12/site-packages/trufnetwork_sdk_py-0.1.0.dist-info/ from /home/micbun/MicBun/sdk-py/.venv/lib/python3.12/site-packages/~rufnetwork_sdk_py-0.1.0.dist-info Moving to /home/micbun/MicBun/sdk-py/.venv/lib/python3.12/site-packages/trufnetwork_sdk_py/ from /home/micbun/MicBun/sdk-py/.venv/lib/python3.12/site-packages/~rufnetwork_sdk_py ERROR: Exception: Traceback (most recent call last): File "/home/micbun/MicBun/sdk-py/.venv/lib/python3.12/site-packages/pip/_internal/cli/base_command.py", line 180, in exc_logging_wrapper status = run_func(*args) ^^^^^^^^^^^^^^^ File "/home/micbun/MicBun/sdk-py/.venv/lib/python3.12/site-packages/pip/_internal/cli/req_command.py", line 245, in wrapper return func(self, options, args) ^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/micbun/MicBun/sdk-py/.venv/lib/python3.12/site-packages/pip/_internal/commands/install.py", line 452, in run installed = install_given_reqs( ^^^^^^^^^^^^^^^^^^^ File "/home/micbun/MicBun/sdk-py/.venv/lib/python3.12/site-packages/pip/_internal/req/__init__.py", line 72, in install_given_reqs requirement.install( File "/home/micbun/MicBun/sdk-py/.venv/lib/python3.12/site-packages/pip/_internal/req/req_install.py", line 856, in install install_wheel( File "/home/micbun/MicBun/sdk-py/.venv/lib/python3.12/site-packages/pip/_internal/operations/install/wheel.py", line 725, in install_wheel _install_wheel( File "/home/micbun/MicBun/sdk-py/.venv/lib/python3.12/site-packages/pip/_internal/operations/install/wheel.py", line 585, in _install_wheel file.save() File "/home/micbun/MicBun/sdk-py/.venv/lib/python3.12/site-packages/pip/_internal/operations/install/wheel.py", line 384, in save shutil.copyfileobj(f, dest) File "/usr/lib/python3.12/shutil.py", line 203, in copyfileobj while buf := fsrc_read(length): ^^^^^^^^^^^^^^^^^ File "/usr/lib/python3.12/zipfile/__init__.py", line 989, in read data = self._read1(n) ^^^^^^^^^^^^^^ File "/usr/lib/python3.12/zipfile/__init__.py", line 1079, in _read1 self._update_crc(data) File "/usr/lib/python3.12/zipfile/__init__.py", line 1007, in _update_crc raise BadZipFile("Bad CRC-32 for file %r" % self.name) zipfile.BadZipFile: Bad CRC-32 for file 'trufnetwork_sdk_c_bindings/_trufnetwork_sdk_c_bindings.so' 

Have you try to install from created wheel? Is it working on Mac? @georgeciubotaru

@georgeciubotaru
Copy link
Contributor Author

@MicBun Yes.

followed the commands

make gopy_build
pip install .
python examples/main.py

@MicBun
Copy link
Member

MicBun commented Jun 17, 2025

I still get this error when running examples (using pip install from whl)

Traceback (most recent call last): File "/home/micbun/MicBun/sdk-py/examples/main.py", line 2, in <module> from trufnetwork_sdk_py.client import TNClient File "/home/micbun/MicBun/sdk-py/.venv/lib/python3.12/site-packages/trufnetwork_sdk_py/__init__.py", line 1, in <module> from .client import ( File "/home/micbun/MicBun/sdk-py/.venv/lib/python3.12/site-packages/trufnetwork_sdk_py/client.py", line 2, in <module> import trufnetwork_sdk_c_bindings.exports as truf_sdk File "/home/micbun/MicBun/sdk-py/.venv/lib/python3.12/site-packages/trufnetwork_sdk_c_bindings/exports.py", line 17, in <module> from . import _trufnetwork_sdk_c_bindings ImportError: trufnetwork_sdk_c_bindings_go.so: cannot open shared object file: No such file or directory 

Building that tries to supports both os seems break things(?)
@outerlook can you confirm with Linux too?

Step I use

  1. Release on my fork
  2. Pip install
  3. try to run examples/main
pip install --force-reinstall https://github.com/MicBun/sdk-py/releases/download/v0.3.3/trufnetwork_sdk_py-0.3.3-py3-none-any.whl python main.py 

The fork https://github.com/MicBun/sdk-py/releases/tag/v0.3.3

@MicBun
Copy link
Member

MicBun commented Jun 18, 2025

Let's pause this in favor of higher priority tasks

@MicBun MicBun requested a review from williamrusdyputra June 23, 2025 15:30
@MicBun
Copy link
Member

MicBun commented Jun 23, 2025

@williamrusdyputra could you help here if there are no higher priority tasks? I can't test the Mac part.
Feel free to create PR to this branch if needed

@williamrusdyputra
Copy link
Contributor

@MicBun I got the error trying to install from released wheel, when I see George's commands, the reason he doesn't get this error is he used pip install . not the released wheel.

 File "/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/zipfile/__init__.py", line 989, in read data = self._read1(n) ^^^^^^^^^^^^^^ File "/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/zipfile/__init__.py", line 1079, in _read1 self._update_crc(data) File "/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/zipfile/__init__.py", line 1007, in _update_crc raise BadZipFile("Bad CRC-32 for file %r" % self.name) zipfile.BadZipFile: Bad CRC-32 for file 'trufnetwork_sdk_c_bindings/_trufnetwork_sdk_c_bindings.so' 
@williamrusdyputra
Copy link
Contributor

log: investigating

@williamrusdyputra williamrusdyputra self-assigned this Jun 24, 2025
@williamrusdyputra
Copy link
Contributor

@MicBun @georgeciubotaru

Cause

the root cause is that during publishing wheel, it fails silently because we rely on compiled extension (gopy build).


Actual vs Expected

the wrong result caused this wheel distribution: trufnetwork_sdk_py-0.3.3-py3-none-any.whl

notice that the platform specific string is not there, instead we got none-any, it should be something like this

Screenshot 2025-06-24 at 17 31 02

Fix

Modified setup.py

class BinaryDistribution(Distribution): def has_ext_modules(self): return True setup( distclass=BinaryDistribution, zip_safe=False, # for packages that include compiled extensions 
@williamrusdyputra
Copy link
Contributor

williamrusdyputra commented Jun 24, 2025

@MicBun could you try again, using this PR changes to your forked repo

note: you must add this change to your released version, so it uses the latest setup file from this PR

@williamrusdyputra williamrusdyputra requested a review from MicBun June 24, 2025 10:45
@williamrusdyputra williamrusdyputra force-pushed the feat/multiple-os-release branch from db5ecf7 to a3f7450 Compare June 24, 2025 12:26
@MicBun
Copy link
Member

MicBun commented Jun 24, 2025

Let me test one more times

@MicBun MicBun merged commit e2859bc into main Jun 24, 2025
3 checks passed
@MicBun MicBun changed the title feat: multiple os release setup chore: multiple os release setup Jun 24, 2025
MicBun pushed a commit that referenced this pull request Jun 26, 2025
## Description This PR resolves a shared library loading issue on Linux and introduces a robust testing framework to prevent future regressions. * **Fixes Linux `ImportError`**: The SDK's compiled Go library (`.so` file) is now built with an embedded `RPATH`. This makes the library self-contained and removes the need for users to manually configure `LD_LIBRARY_PATH`, simplifying installation. * **Adds Distribution Testing**: A new GitHub Actions workflow has been added to test the package distribution on Linux and macOS. This workflow builds the wheel in a clean Docker environment and runs a smoke test to ensure it installs and imports correctly, directly verifying the fix. * **Removes Documentation**: The `README.md` section detailing the `LD_LIBRARY_PATH` workaround has been removed as it is no longer necessary. ## Related Problem - related to #63 ## How Has This Been Tested? This change is validated by a new, automated CI workflow (`distribution-test.yml`). For every pull request, this workflow: 1. Builds the Python wheel from source inside a clean Docker container. 2. Installs the wheel into a lightweight, final Docker image. 3. Runs a test script (`get_account_test.py`) that confirms the SDK can be imported and used without any manual environment setup.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

4 participants