-
Notifications
You must be signed in to change notification settings - Fork 323
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
Add graalpy packages to the component directory #8351
Changes from all commits
9c80b90
08f30af
8ee9a28
a96ecf1
7386c3c
64f48df
d288df3
c645630
2c5c9a8
d63c0bd
84945b8
fd27b35
70bbf64
d35fa37
8e676dc
758ffcf
e6bf428
1f22461
1ed637a
009a54b
85cdd4b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,128 @@ | ||
use crate::prelude::*; | ||
use regex::Regex; | ||
|
||
use crate::cache::goodie; | ||
use crate::cache::goodie::Goodie; | ||
use crate::cache::Cache; | ||
use crate::env::known::PATH; | ||
use crate::github::RepoRef; | ||
use crate::programs::graalpy::GraalPy as GraalPyProgram; | ||
|
||
|
||
pub const CE_BUILDS_REPOSITORY: RepoRef = RepoRef { owner: "oracle", name: "graalpython" }; | ||
|
||
#[derive(Clone, Debug)] | ||
pub struct GraalPy { | ||
pub client: Octocrab, | ||
pub version: Version, | ||
pub os: OS, | ||
pub arch: Arch, | ||
} | ||
|
||
fn graalpy_version_from_str(version_string: &str) -> Result<Version> { | ||
let line = version_string.lines().find(|line| line.contains("GraalVM CE")).context( | ||
"There is a Java environment available but it is not recognizable as GraalVM one.", | ||
)?; | ||
let re = Regex::new(r"GraalPy.*\((.+)\)").unwrap(); | ||
let caps = re.captures(line).unwrap(); | ||
Version::find_in_text(caps.get(1).context("graalpy wrong version text").unwrap().as_str()) | ||
} | ||
|
||
async fn find_graalpy_version() -> Result<Version> { | ||
let text = GraalPyProgram.version_string().await?; | ||
graalpy_version_from_str(&text) | ||
} | ||
|
||
impl Goodie for GraalPy { | ||
fn get(&self, cache: &Cache) -> BoxFuture<'static, Result<PathBuf>> { | ||
goodie::download_try_future_url(self.url(), cache) | ||
} | ||
|
||
fn is_active(&self) -> BoxFuture<'static, Result<bool>> { | ||
let expected_graalpy_version = self.version.clone(); | ||
async move { | ||
let found_version = find_graalpy_version().await?; | ||
ensure!(found_version == expected_graalpy_version, "GraalPy version mismatch. Expected {expected_graalpy_version}, found {found_version}."); | ||
Ok(true) | ||
} | ||
.boxed() | ||
} | ||
|
||
fn activation_env_changes(&self, package_path: &Path) -> Result<Vec<crate::env::Modification>> { | ||
let dir_entries = package_path | ||
.read_dir() | ||
.context("Failed to read GraalPy cache directory")? | ||
.collect_vec(); | ||
let [graalpy_dir] = dir_entries.as_slice() else { | ||
bail!("GraalPy cache directory should contain exactly one directory"); | ||
}; | ||
let graalpy_dir = match graalpy_dir { | ||
Ok(dir_entry) => dir_entry, | ||
Err(err) => bail!("Failed to read GraalPy cache directory: {}", err), | ||
}; | ||
let dir_name = graalpy_dir.file_name(); | ||
let dir_name = dir_name.as_str(); | ||
ensure!(dir_name.contains("graalpy")); | ||
ensure!(dir_name.contains(self.version.to_string_core().as_str())); | ||
Ok(vec![crate::env::Modification::prepend_path(&PATH, graalpy_dir.path().join("bin"))]) | ||
} | ||
} | ||
|
||
impl GraalPy { | ||
pub fn url(&self) -> BoxFuture<'static, Result<Url>> { | ||
let this = self.clone(); | ||
let client = self.client.clone(); | ||
let arch_name = match self.arch { | ||
Arch::X86_64 => "amd64", | ||
Arch::AArch64 => "aarch64", | ||
_ => unimplemented!("Unsupported architecture: {}", self.arch.to_string()), | ||
}; | ||
async move { | ||
let repo = CE_BUILDS_REPOSITORY.handle(&client); | ||
let tag = format!("graal-{}", this.version); | ||
let release = repo.find_release_by_tag(tag.as_str()).await?; | ||
let asset_name = | ||
format!("graalpy-community-{}-{}-{}", this.version, this.os, arch_name); | ||
let asset = | ||
crate::github::find_asset_url_by_text(&release, asset_name.as_str()).cloned(); | ||
asset | ||
} | ||
.boxed() | ||
} | ||
} | ||
|
||
#[cfg(test)] | ||
mod tests { | ||
use crate::cache::goodie::graalpy::graalpy_version_from_str; | ||
use crate::cache::goodie::graalpy::GraalPy; | ||
use octocrab::Octocrab; | ||
use platforms::Arch; | ||
use platforms::OS; | ||
use semver::Version; | ||
|
||
#[test] | ||
fn version_recognize() { | ||
let expected_version = Version::new(23, 1, 0); | ||
let version_string = "GraalPy 3.10.8 (GraalVM CE Native 23.1.0)"; | ||
let found_version = graalpy_version_from_str(version_string).unwrap(); | ||
assert_eq!(found_version, expected_version); | ||
} | ||
|
||
#[test] | ||
fn fetch_correct_url() { | ||
let version = Version::new(23, 1, 0); | ||
let client = Octocrab::builder().build().unwrap(); | ||
let graalpy = GraalPy { client, version, os: OS::Linux, arch: Arch::X86_64 }; | ||
let found_url_opt = | ||
tokio::runtime::Runtime::new().unwrap().block_on(async { graalpy.url().await }); | ||
let found_url = match found_url_opt { | ||
Ok(url) => url, | ||
Err(err) => { | ||
unreachable!("URL not found: {}", err); | ||
} | ||
}; | ||
|
||
let expected_url = "https://github.com/oracle/graalpython/releases/download/graal-23.1.0/graalpy-community-23.1.0-linux-amd64.tar.gz"; | ||
assert_eq!(found_url.as_str(), expected_url); | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
use crate::prelude::*; | ||
|
||
#[derive(Clone, Copy, Debug)] | ||
pub struct GraalPy; | ||
|
||
impl Program for GraalPy { | ||
fn executable_name(&self) -> &'static str { | ||
"graalpy" | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -291,16 +291,31 @@ The license file can be found at `licenses/Bouncy_Castle_Licence.txt`. | |
Copyright notices related to this dependency can be found in the directory `org.bouncycastle.bcpkix-jdk15on-1.70`. | ||
|
||
|
||
'bcpkix-jdk18on', licensed under the Bouncy Castle Licence, is distributed with the engine. | ||
The license file can be found at `licenses/Bouncy_Castle_Licence.txt`. | ||
Copyright notices related to this dependency can be found in the directory `org.bouncycastle.bcpkix-jdk18on-1.76`. | ||
|
||
|
||
'bcprov-jdk15on', licensed under the Bouncy Castle Licence, is distributed with the engine. | ||
The license file can be found at `licenses/Bouncy_Castle_Licence.txt`. | ||
Copyright notices related to this dependency can be found in the directory `org.bouncycastle.bcprov-jdk15on-1.70`. | ||
|
||
|
||
'bcprov-jdk18on', licensed under the Bouncy Castle Licence, is distributed with the engine. | ||
The license file can be found at `licenses/Bouncy_Castle_Licence.txt`. | ||
Copyright notices related to this dependency can be found in the directory `org.bouncycastle.bcprov-jdk18on-1.76`. | ||
|
||
|
||
'bcutil-jdk15on', licensed under the Bouncy Castle Licence, is distributed with the engine. | ||
The license file can be found at `licenses/Bouncy_Castle_Licence.txt`. | ||
Copyright notices related to this dependency can be found in the directory `org.bouncycastle.bcutil-jdk15on-1.70`. | ||
|
||
|
||
'bcutil-jdk18on', licensed under the Bouncy Castle Licence, is distributed with the engine. | ||
The license file can be found at `licenses/Bouncy_Castle_Licence.txt`. | ||
Copyright notices related to this dependency can be found in the directory `org.bouncycastle.bcutil-jdk18on-1.76`. | ||
|
||
|
||
'checker-qual', licensed under the The MIT License, is distributed with the engine. | ||
The license information can be found along with the copyright notices. | ||
Copyright notices related to this dependency can be found in the directory `org.checkerframework.checker-qual-3.33.0`. | ||
|
@@ -316,11 +331,26 @@ The license file can be found at `licenses/MIT`. | |
Copyright notices related to this dependency can be found in the directory `org.graalvm.js.js-language-23.1.0`. | ||
|
||
|
||
'llvm-api', licensed under the New BSD License (3-clause BSD license), is distributed with the engine. | ||
The license file can be found at `licenses/BSD-3-Clause`. | ||
Copyright notices related to this dependency can be found in the directory `org.graalvm.llvm.llvm-api-23.1.0`. | ||
|
||
|
||
'polyglot', licensed under the Universal Permissive License, Version 1.0, is distributed with the engine. | ||
The license file can be found at `licenses/Universal_Permissive_License__Version_1.0`. | ||
Copyright notices related to this dependency can be found in the directory `org.graalvm.polyglot.polyglot-23.1.0`. | ||
|
||
|
||
'python-language', licensed under the MIT License, is distributed with the engine. | ||
The license file can be found at `licenses/MIT`. | ||
Copyright notices related to this dependency can be found in the directory `org.graalvm.python.python-language-23.1.0`. | ||
|
||
|
||
'python-resources', licensed under the MIT License, is distributed with the engine. | ||
The license file can be found at `licenses/MIT`. | ||
Copyright notices related to this dependency can be found in the directory `org.graalvm.python.python-resources-23.1.0`. | ||
|
||
|
||
'regex', licensed under the Universal Permissive License, Version 1.0, is distributed with the engine. | ||
The license file can be found at `licenses/Universal_Permissive_License__Version_1.0`. | ||
Copyright notices related to this dependency can be found in the directory `org.graalvm.regex.regex-23.1.0`. | ||
|
@@ -346,11 +376,31 @@ The license information can be found along with the copyright notices. | |
Copyright notices related to this dependency can be found in the directory `org.graalvm.shadowed.icu4j-23.1.0`. | ||
|
||
|
||
'json', licensed under the Universal Permissive License, Version 1.0, is distributed with the engine. | ||
The license file can be found at `licenses/Universal_Permissive_License__Version_1.0`. | ||
Copyright notices related to this dependency can be found in the directory `org.graalvm.shadowed.json-23.1.0`. | ||
|
||
|
||
'profiler-tool', licensed under the GNU General Public License, version 2, with the Classpath Exception, is distributed with the engine. | ||
The license file can be found at `licenses/GNU_General_Public_License__version_2__with_the_Classpath_Exception`. | ||
Copyright notices related to this dependency can be found in the directory `org.graalvm.tools.profiler-tool-23.1.0`. | ||
Comment on lines
+384
to
+386
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I have no idea if the way we distribute the If I understand correctly, we are distributing these files inside of our JAR, right? Or is it a separate JAR?
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
It is a separate JAR. We basically take those Jars from Maven central and just put it inside the
We have always distributed this tool. Just not as a separate Jar, but as part of the GraalVM distribution. It is only now that the legal review tool complains because it can actually discover the license in the Jar. I doubt that there were any major license changes in the community edition of Graal. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I had been in a legal battle about GPL+CP Exception with ASF and I won. That makes me believe I am qualified...
Good. Distributing GPL+CPEx JARs is certainly OK and we can even claim the whole thing is under Apache License. Radek is right that repackaging might be tricker - good that we are not doing it. |
||
|
||
|
||
'truffle-api', licensed under the Universal Permissive License, Version 1.0, is distributed with the engine. | ||
The license file can be found at `licenses/Universal_Permissive_License__Version_1.0`. | ||
Copyright notices related to this dependency can be found in the directory `org.graalvm.truffle.truffle-api-23.1.0`. | ||
|
||
|
||
'truffle-nfi', licensed under the Universal Permissive License, Version 1.0, is distributed with the engine. | ||
The license file can be found at `licenses/Universal_Permissive_License__Version_1.0`. | ||
Copyright notices related to this dependency can be found in the directory `org.graalvm.truffle.truffle-nfi-23.1.0`. | ||
|
||
|
||
'truffle-nfi-libffi', licensed under the Universal Permissive License, Version 1.0, is distributed with the engine. | ||
The license file can be found at `licenses/Universal_Permissive_License__Version_1.0`. | ||
Copyright notices related to this dependency can be found in the directory `org.graalvm.truffle.truffle-nfi-libffi-23.1.0`. | ||
|
||
|
||
'jline', licensed under the The BSD License, is distributed with the engine. | ||
The license file can be found at `licenses/BSD-3-Clause`. | ||
Copyright notices related to this dependency can be found in the directory `org.jline.jline-3.23.0`. | ||
|
@@ -406,6 +456,11 @@ The license file can be found at `licenses/MIT`. | |
Copyright notices related to this dependency can be found in the directory `org.slf4j.slf4j-api-2.0.9`. | ||
|
||
|
||
'xz', licensed under the Public Domain, is distributed with the engine. | ||
The license file can be found at `licenses/Public_Domain`. | ||
Copyright notices related to this dependency can be found in the directory `org.tukaani.xz-1.9`. | ||
|
||
|
||
'cats-core_2.13', licensed under the MIT, is distributed with the engine. | ||
The license file can be found at `licenses/MIT`. | ||
Copyright notices related to this dependency can be found in the directory `org.typelevel.cats-core_2.13-2.9.0`. | ||
|
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.
We are checking for Graal CE specifically.
I assume if someone runs GraalVM EE, the current message
There is a Java environment available but it is not recognizable as GraalVM one.
would be false (GraalVM EE is still GraalVM).