Skip to content

Specify classifiers in using lib directives #1752

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

Closed
sbrunk opened this issue Jan 6, 2023 · 2 comments · Fixed by #1892
Closed

Specify classifiers in using lib directives #1752

sbrunk opened this issue Jan 6, 2023 · 2 comments · Fixed by #1892
Assignees
Labels
documentation Improvements or additions to documentation enhancement New feature or request

Comments

@sbrunk
Copy link

sbrunk commented Jan 6, 2023

I'm working with machine learning training scripts, and scala-cli would be a great fit for writing them. These scripts require native libraries though, which are packaged as jars with classifiers, as they are os and arch dependent. They can also be available in different variants like CPU and GPU, again expressed through different classifiers.

In sbt for instance, it's possible to add a classifier to a dependency in the following way:

 "org.bytedeco"   % "pytorch"    % "1.12.1-1.5.8" classifier "linux-x86_64"
 "org.bytedeco"   % "pytorch"    % "1.12.1-1.5.8" classifier "linux-x86_64-gpu"

I'd like to be able to express dependencies with classifiers inside a using lib directive, to be able to work with these kinds of libraries from scala-cli.

@sbrunk sbrunk added the enhancement New feature or request label Jan 6, 2023
@lwronski
Copy link
Contributor

lwronski commented Jan 7, 2023

Hi @rdsr, Thanks for reporting

Coursier has a special syntax for classifiers: classifier=. Unfortunately, it isn't currently documented.

So I prepared short demo to show, how use it:

➜  scala-demo scala-cli compile Main.scala --print-class-path --dep "org.bytedeco:pytorch:1.12.1-1.5.8,classifier=linux-x86_64" 
Downloading 2 dependencies
Compiling project (Scala 2.13.10, JVM)
Compiled project (Scala 2.13.10, JVM)
/private/tmp/scala-demo/.scala-build/project_a3e3069be7-74c94e0a10/classes/main:
/Users/lwronski/Library/Caches/Coursier/v1/https/repo1.maven.org/maven2/org/scala-lang/scala-library/2.13.10/scala-library-2.13.10.jar:
/Users/lwronski/Library/Caches/Coursier/v1/https/repo1.maven.org/maven2/org/bytedeco/pytorch/1.12.1-1.5.8/pytorch-1.12.1-1.5.8-linux-x86_64.jar:
/Users/lwronski/Library/Caches/Coursier/v1/https/repo1.maven.org/maven2/org/bytedeco/javacpp/1.5.8/javacpp-1.5.8.jar:
/Users/lwronski/Library/Caches/Coursier/v1/https/repo1.maven.org/maven2/org/bytedeco/openblas/0.3.21-1.5.8/openblas-0.3.21-1.5.8.jar

I will keep this issue open because the functionality must be documented.

@lwronski lwronski added the documentation Improvements or additions to documentation label Jan 7, 2023
@sbrunk
Copy link
Author

sbrunk commented Jan 9, 2023

Thanks @lwronski!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation enhancement New feature or request
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

2 participants