-
Notifications
You must be signed in to change notification settings - Fork 94
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
Added Hub and Tokenizers libraries. #166
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
According to my tests, all the package dependencies are downloaded and resolved (so other dependencies are recursively pulled as well). However, they are not compiled if they don't participate in the targets used by the client package. (Actually, there's a pre-processing step where stubs and headers are generated, but no actual compilation happens).
I tested building with swift build
and Xcode, using a dependent package that uses the Tokenizers
library (without Models
).
Package.swift
Outdated
@@ -8,6 +8,8 @@ let package = Package( | |||
platforms: [.iOS(.v16), .macOS(.v13)], | |||
products: [ | |||
.library(name: "Transformers", targets: ["Tokenizers", "Generation", "Models"]), | |||
.library(name: "Hub", targets: ["Hub"]), | |||
.library(name: "Tokenizers", targets: ["Tokenizers", "Models"]), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
.library(name: "Tokenizers", targets: ["Tokenizers", "Models"]), | |
.library(name: "Tokenizers", targets: ["Tokenizers"]), |
This would pull most of the library, wouldn't it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, I was getting an error with tokenizers when I didn't have the Models target, but I think that was just an issue with the test. I implemented the above change and fixed the test, and re-tested it in the external project.
Added
Hub
andTokenizers
as separate library products inPackage.swift
. This change should enable selective compilation of specific components while maintaining a single project structure.Usage Example
Usage is pretty simple, I created an external project and all that was needed was to edit
Package.swift
.Specifically, Add the package dependency:
Then import specific products as dependencies of the desired target:
Testing
In the external project I copied and ran all the Tokenizer, and Hub tests from swift-transformers.