-
Notifications
You must be signed in to change notification settings - Fork 64
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
Incorporating Gradle tasks for automatically installing JEP #1400
Incorporating Gradle tasks for automatically installing JEP #1400
Conversation
…ng JEP binaries for the Python frontend ### What's Done: 1) Introduced the `installJep` task to facilitate the automatic installation of JEP from [https://github.com/icemachined/jep-distro/](https://github.com/icemachined/jep-distro/). 2) Centralized and encapsulated the logic for JEP search and installation: all the relevant logic has been relocated to the Gradle task, separating it from the main code. The main code will now simply utilize the JEP stored in the `build/jep` directory.
) | ||
} | ||
// try system-wide paths, too | ||
// TODO: is this still needed? |
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.
No, it is not... Except your GitHub CI:
find /opt/hostedtoolcache/Python/ -name libjep.so -exec sudo cp '{}' /usr/lib/ \;
And actually you do the same with usr/lib
that I did with build/jep
Please check @oxisto |
Thanks for your contribution! (And signing the CLA ;) Looks like an interesting idea, I will have some time between Christmas and New Years to look at this as well. |
Thanks! Happy holidays! Please also approve a workflow (I added 1 commit, trying to fix build with JEP) |
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.
In general, I like that idea of using the jep-distro files, but I wonder if moving the logic from runtime to compile time is a good idea for non-distro-supported systems.
MainInterpreter.setJepLibraryPath(it.toString()) | ||
// To understand how JEP is installed under the hood, check `installJep` task in | ||
// build.gradle.kts. But the main idea is that it is always copied to `build/jep` directory. | ||
val jepLocation = FileSystems.getDefault().getPath("build", "jep") |
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.
Since you moved the detection logic from runtime to build-time I wonder what happens in the following scenario:
I am running on darwin/arm64 and if I use the CPG library as a dependency, I have no way of "injecting" my JEP into the jar that I am using. Do I then need to place my JEP locally somewhere in a build/jep
folder? This seems counter-intuitive to me.
What was the reasoning behind moving this logic to the build-stage?
| Your system architecture, identified as <${System.getProperty("os.arch")}>, is not supported in icemachined/jep-distro. | ||
| Consequently, you are required to install it manually. Here are the potential solutions: | ||
| 1. Utilize Homebrew/pip package manager to facilitate the JEP installation process; | ||
| 2. Create a virtual environment with the specified environment variable CPG_PYTHON_VIRTUALENV set to /(user.home)/.virtualenv/CPG_PYTHON_VIRTUALENV; |
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.
sometimes its .virtualenv
and sometimes .virtualenvs
Hi @akuleshov7 ,
We will discuss testing this with some other projects and see if anything breaks. Any improvement in the JEP install logic is very welcome to us. |
@icemachined, Dima, how well do you maintain JEP-distro? 😄 |
MainInterpreter.setJepLibraryPath(it.toString()) | ||
// To understand how JEP is installed under the hood, check `installJep` task in | ||
// build.gradle.kts. But the main idea is that it is always copied to `build/jep` directory. | ||
val jepLocation = FileSystems.getDefault().getPath("build", "jep") |
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.
it's better to put jep in jep-distro/jep and then put jep-distro to include path.
// Based on the host OS we will determine the extension for the JEP binary | ||
val os = System.getProperty("os.name") | ||
val jepBinary = "libjep." + when { | ||
os.contains("Mac") -> "jnilib" |
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.
more common approach
os.contains("win")
os.contains("nix") || os.contains("nux") || os.contains("aix")
os.contains("mac")
else -> throw IllegalStateException("Cannot install JEP for this operating system: [$os]") | ||
} | ||
|
||
// If JEP already exists on the current host machine, there's no need to copy it from the distribution archive. |
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.
what if you want to install jep for different python version or distro version?
jepLocation / | ||
("libjep." + | ||
when { | ||
os.contains("Mac") -> "jnilib" |
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.
more common approach
os.contains("win")
os.contains("nix") || os.contains("nux") || os.contains("aix")
os.contains("mac")
config.redirectStdErr(System.err) | ||
config.redirectStdout(System.out) | ||
|
||
System.getenv("CPG_JEP_LIBRARY")?.let { |
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.
need to keep possibility to use jep from custom location
I'm not modifying jep I just perform jep build on github and publish it on maven, you can see the code here https://github.com/icemachined/jep-distro. If there will be any issues I can fix it or accept your fix. |
Is there any update on these two points? @oxisto, if I remember correctly, we can live without the ARM support (although we would like to keep it as some of our team work on ARM machines), but the second point is a deal breaker for us, right? |
Hi @maximiliankaul , jep-distro currently support ARM, latest release have ARM libraries tested on M2. so if you need we can update pr with ARM support |
That's great to hear :) When we first checked this PR, there was no support / we missed this. |
Yes you are right seems like this is not achievable in this pr. But it is achievable in general, because jep-distro contains builds for all architectures and versions of python starting from 3.6 till 3.12. You could include all required versions in distro (the size is not very big) and unpack one of them in runtime to tmp depending on current version of python. |
Hello everyone, we are cleaning up old PRs and have decided to close this one as it does not really fit our target use case, as discussed above. Thank you for contributing! Best regards, |
What's Done:
Introduced the
installJep
task to facilitate the automatic installation of JEP from https://github.com/icemachined/jep-distro/.Centralized and encapsulated the logic for JEP search and installation: all the relevant logic has been relocated to the Gradle task, separating it from the main code. The main code will now simply utilize the JEP stored in the
build/jep
directory.