-
Notifications
You must be signed in to change notification settings - Fork 190
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
feat: Enable global expose with nested paths #2362
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.
Thanks for the work! I've left some comments but the general implementation looks good.
- Could you add an integration test to
tests/integration/test_global
? - Could you add this case to the documentation in https://pixi.sh/latest/features/global_tools/#exposed
docs/features/global_tools.md
If you need help creating a dummy package let us know! It should be pretty straight forward to create your situation in a dummy package and test its logic in there.
src/global/project/manifest.rs
Outdated
executable_relname: Path::new(&executable_relname) | ||
.with_extension("") | ||
.to_str() | ||
.unwrap_or(&executable_relname) | ||
.to_string(), |
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.
with extention doesn't work for python3.12
as that will create python3
.
You can use pixi_utils::executable_from_path
here aswell.
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.
I've just changed new method, I've used strip_executable_extension (because executable_from_path drop nested directory)
@ruben-arts I tried to add an integration test.
I tried to run conda_build.bat but it failed too. |
@ruben-arts I've managed to update integration test channel by compiling them use debian in wsl. I ran integration tests on windows, the test I added ran successfully, but I got a fail for another test:
I don't get why it failed. |
``` | ||
you can also omit the extension | ||
``` | ||
pixi global install dotnet --expose dotnet=dotnet\dotnet |
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.
I tried this example on Linux but that package doesn't seem to work. Do you understand why the dotnet
setup is using a non bin/xx
setup for it's binaries?
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.
I have no Idea.
I had never tried to install dotnet on linux but you're right, it's installed in .pixi/envs/dotnet/lib/dotnet/dotnet
For some reason everything is painful with windows tools...
Maybe a more cross platform or generic tool would be better for the documentation.
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 contacted @dhirschfeld as he is a pixi user and the maintainer of dotnet
maybe he has some smart things to say about this.
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.
Not sure about smart - the TL;DR is that it's just a binary repackage of upstream and that seems to be the way it's packaged by Microsoft.
The package sets a number of env vars in an activation script, including the PATH. I'd like to port setting/unsetting the env vars to the JSON format (assuming that works with pixi
?) but haven't gotten around to 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.
Yes pixi supports that 👍
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.
Is there another example package, where this would be required, that does work on linux?
While reviewing I checked it out and did some small changes, here is the diff patch you could apply: diff --git a/src/global/project/manifest.rs b/src/global/project/manifest.rs
index cac1fa50..ecea5f4e 100644
--- a/src/global/project/manifest.rs
+++ b/src/global/project/manifest.rs
@@ -432,6 +432,8 @@ impl Manifest {
#[derive(Debug, Clone, Serialize, Deserialize, Hash, PartialEq, Eq)]
pub struct Mapping {
exposed_name: ExposedName,
+ // The executable_relname is a executable name possibly with a parts of a path in it to match on.
+ // e.g. `dotnet/dotnet` will find `$PREFIX/lib/dotnet/dotnet`
executable_relname: String,
}
@@ -450,13 +452,14 @@ impl Mapping {
pub fn executable_relname(&self) -> &str {
&self.executable_relname
}
+
+ // Splitting the executable_relname by the last '/' and taking the last part
+ // e.g. 'nested/test_executable' -> 'test_executable'
pub fn executable_name(&self) -> &str {
- if let Some(executable_file_name) = Path::new(&self.executable_relname).file_name() {
- return executable_file_name
- .to_str()
- .unwrap_or(&self.executable_relname);
- };
- &self.executable_relname
+ Path::new(&self.executable_relname)
+ .file_name()
+ .and_then(|name| name.to_str())
+ .unwrap_or(&self.executable_relname)
}
}
diff --git a/tests/integration/test_global.py b/tests/integration/test_global.py
index a5ab777e..93471054 100644
--- a/tests/integration/test_global.py
+++ b/tests/integration/test_global.py
@@ -308,12 +308,6 @@ def test_expose_basic(pixi: Path, tmp_path: Path, dummy_channel_1: str) -> None:
)
assert not dummy1.is_file()
assert not dummy3.is_file()
- # extension = "exe" if os.name == "nt" else "sh"
- # # Add nested dummy1
- # verify_cli_command(
- # [pixi, "global", "expose", f"nested_dummy=nested/dummy.{extension}"],
- # env=env,
- # )
def test_expose_revert_working(pixi: Path, tmp_path: Path, dummy_channel_1: str) -> None:
(END)
diff --git a/tests/integration/test_global.py b/tests/integration/test_global.py
index a5ab777e..93471054 100644
--- a/tests/integration/test_global.py
+++ b/tests/integration/test_global.py
@@ -308,12 +308,6 @@ def test_expose_basic(pixi: Path, tmp_path: Path, dummy_channel_1: str) -> None:
)
assert not dummy1.is_file()
assert not dummy3.is_file()
- # extension = "exe" if os.name == "nt" else "sh"
- # # Add nested dummy1
- # verify_cli_command(
- # [pixi, "global", "expose", f"nested_dummy=nested/dummy.{extension}"],
- # env=env,
- # )
def test_expose_revert_working(pixi: Path, tmp_path: Path, dummy_channel_1: str) -> None: |
My browser bugged out and closed this issue by accident. |
2d24894
to
b2b117d
Compare
Something is not working with python activation in integration test, I don't know why... Windows 10.0.26100 on D049 on main +/- is 📦 v0.34.0 🦀 v1.81.0
~\dev\pixi ➜ C:\Users\bahugo\dev\pixi\pytest-temp\popen-gw0\test_sync_dependencies0\bin\python-injected.bat --version
> No pyvenv.cfg file
Windows 10.0.26100 on D049 on main +/- is 📦 v0.34.0 🦀 v1.81.0
~\dev\pixi ❯ C:\Users\bahugo\dev\pixi\pytest-temp\popen-gw0\test_sync_dependencies0\envs\test\Lib\venv\scripts\nt\python.exe
> No pyvenv.cfg file |
I'll give this a go today! See if I can fix the issues |
I'm sorry you are experiencing such a crazy merge conflict train. The code works well, I hope you have another example we can use in the documentation. |
No problem, I'm enjoying learning a bit of the internals of pixi.
on linux:
For rebase conflicts, it might be better if dummy channels weren't in git index (they could be generated in CI). |
If fixed the merge issue, and tested some more. Your implementation allows to use the following command on both platforms:
However it doesn't run anything on my machine. I'm fine with skipping an useful example as I'm assuming its not a big set of users hitting this. And other wise we'll find a example through that. |
Closes #2350
I tried to be as explicit as I could, I modified Mapping attribute to executable_relname (relative path but with no extension), and executable_name() is now evaluated based on relname.