Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ruby 3.3 #4

Merged
merged 10 commits into from
Dec 26, 2023
Merged

Ruby 3.3 #4

merged 10 commits into from
Dec 26, 2023

Conversation

judy
Copy link
Collaborator

@judy judy commented Dec 26, 2023

  • Update magnus for ruby-head compatibility
  • Enable stable-api-compiled-fallback
  • Bump version to 0.0.6
  • INTERNAL: Update libraries (INTERNAL: Update libraries #1)
  • Set up a fork with native builds
  • Update README.md
  • Re-cargo

byroot and others added 10 commits September 4, 2023 16:21
Older versions of magnus fail to compile on Ruby 3.3.0-dev with:

```
Compiling tiktoken-rs v0.3.2
(https://github.com/IAPark/tiktoken-rs.git#5231fbf4)
error[E0609]: no field `len` on type `RString__bindgen_ty_1__bindgen_ty_1`
-->
/tmp/bundle/ruby/3.3.0+0/gems/tiktoken_ruby-0.0.5/ext/tiktoken_ruby/.rb-sys/stable/cargo/registry/src/index.crates.io-6f17d22bba15001f/magnus-0.4.4/src/r_string.rs:366:57
    |
366 |             slice::from_raw_parts(h.ptr as *const u8, h.len as usize)
    |                                                         ^^^ unknown field
    |
    = note: available fields are: `ptr`, `aux`
error[E0609]: no field `len` on type `RString__bindgen_ty_1__bindgen_ty_1`
-->
/tmp/bundle/ruby/3.3.0+0/gems/tiktoken_ruby-0.0.5/ext/tiktoken_ruby/.rb-sys/stable/cargo/registry/src/index.crates.io-6f17d22bba15001f/magnus-0.4.4/src/r_string.rs:954:19
    |
954 |                 h.len as usize
    |                   ^^^ unknown field
    |
    = note: available fields are: `ptr`, `aux`
error[E0609]: no field `len` on type `RString__bindgen_ty_1__bindgen_ty_2`
-->
/tmp/bundle/ruby/3.3.0+0/gems/tiktoken_ruby-0.0.5/ext/tiktoken_ruby/.rb-sys/stable/cargo/registry/src/index.crates.io-6f17d22bba15001f/magnus-0.4.4/src/r_string.rs:996:44
    |
996 |     value.as_internal().as_ref().as_.embed.len
    |                                            ^^^ unknown field
    |
    = note: available fields are: `ary`
For more information about this error, try `rustc --explain E0609`.
error: could not compile `magnus` (lib) due to 3 previous errors
warning: build failed, waiting for other jobs to finish...
make: *** [Makefile:564: target/release/libtiktoken_ruby.so] Error 101
```
Update magnus for ruby-head compatibility
This should solve an issue with compiling on Ruby 3.3.0-dev
* bundle update && cargo update

* Update rb_sys in gemspec

* Change to original tiktoken-rs library

@IAPark's fork was originally created to remove async-openai as an added
library, due to unnecessary build issues. The upstream library has since
made that library optional.

---------

Co-authored-by: Clinton Judy <[email protected]>
I've had a number of compilation issues with this gem on different platforms. I don't want us to have to install Rust everywhere as an additional dependency for a single gem. So I created this fork that does cross-compilation in Github Actions.

There's one other problem I discovered, which is that Github's package management appears to ignore platforms when uploading gems. When you upload a gem with the same version number but a different platform, Github says you can't upload it since that version has already been uploaded. Rubygems.org doesn't have this problem.

HOWEVER, I don't want to push the same gem name to Rubygems.org and get it confused with the upstream project. This is why I renamed the gem to rz_tiktoken_ruby. Please don't confuse it for the original (but do try it out if you need a version pre-built for your platform.)
@judy judy self-assigned this Dec 26, 2023
@judy judy merged commit f62fb22 into main Dec 26, 2023
18 checks passed
@judy judy deleted the ruby-3.3 branch December 26, 2023 17:02
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.

5 participants