- some workarounds to get jars and shared libs in the right place for python
- add most ndbioimage python code and use rs code as bfread
This commit is contained in:
@@ -10,11 +10,51 @@ thread_local! {
|
||||
/// Ensure 1 jvm per thread
|
||||
fn jvm() -> Rc<Jvm> {
|
||||
JVM.with(|cell| {
|
||||
cell.get_or_init(move || Rc::new(JvmBuilder::new().build().expect("Failed to build JVM")))
|
||||
.clone()
|
||||
cell.get_or_init(move || {
|
||||
#[cfg(feature = "python")]
|
||||
let path = crate::py::ndbioimage_file().unwrap();
|
||||
|
||||
#[cfg(not(feature = "python"))]
|
||||
let path = std::env::current_exe()
|
||||
.unwrap()
|
||||
.parent()
|
||||
.unwrap()
|
||||
.to_path_buf();
|
||||
|
||||
let class_path = path.parent().unwrap();
|
||||
Rc::new(
|
||||
JvmBuilder::new()
|
||||
.with_base_path(class_path.to_str().unwrap())
|
||||
.build()
|
||||
.expect("Failed to build JVM"),
|
||||
)
|
||||
})
|
||||
.clone()
|
||||
})
|
||||
}
|
||||
|
||||
#[cfg(feature = "python")]
|
||||
pub(crate) fn download_bioformats(gpl_formats: bool) -> Result<()> {
|
||||
let path = crate::py::ndbioimage_file().unwrap();
|
||||
let class_path = path.parent().unwrap();
|
||||
let jvm = JvmBuilder::new()
|
||||
.with_base_path(class_path.to_str().unwrap())
|
||||
.with_maven_settings(j4rs::MavenSettings::new(vec![
|
||||
j4rs::MavenArtifactRepo::from(
|
||||
"openmicroscopy::https://artifacts.openmicroscopy.org/artifactory/ome.releases",
|
||||
),
|
||||
]))
|
||||
.build()?;
|
||||
|
||||
jvm.deploy_artifact(&j4rs::MavenArtifact::from("ome:bioformats_package:8.1.0"))?;
|
||||
|
||||
if gpl_formats {
|
||||
jvm.deploy_artifact(&j4rs::MavenArtifact::from("ome:formats-gpl:8.1.0"))?;
|
||||
}
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
macro_rules! method_return {
|
||||
($R:ty$(|c)?) => { Result<$R> };
|
||||
() => { Result<()> };
|
||||
@@ -113,7 +153,7 @@ impl ImageReader {
|
||||
Ok(jvm()
|
||||
.chain(&mds)?
|
||||
.cast("loci.formats.ome.OMEPyramidStore")?
|
||||
.invoke("dumpXML", &[])?
|
||||
.invoke("dumpXML", InvocationArg::empty())?
|
||||
.to_rust()?)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user