8000 feat: add `rattler_menuinst` crate by wolfv · Pull Request #840 · conda/rattler · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

feat: add rattler_menuinst crate #840

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

Merged
merged 132 commits into from
Feb 25, 2025
Merged

feat: add rattler_menuinst crate #840

merged 132 commits into from
Feb 25, 2025

Conversation

wolfv
Copy link
Contributor
@wolfv wolfv commented Aug 31, 2024

TODO:

  • run precreate code if specified in the menuinst
  • fix the XML editing for Linux!
  • Windows activation running
  • add method that takes a prefix record, and installs or removes menus based on that (and writes new prefix record)

Serialization

  • use internally tagged enum for prefix record serialization
  • decide on writing to LinuxXML menu categories (and subsequent removal)

Testing

  • create a terminal_profile test package for windows
  • create a activation test package for windows, mac and linux (eg. using bash)
  • create a test for URL handlers on Windows
  • create a test for file association on Windows
  • create a test for pre-create code

Some notes:

  • on linux, there are no icons that are installed for mime types. I think it could be done relatively easily with something like https://stackoverflow.com/questions/30931/register-file-extensions-mime-types-in-linux
  • we call xdg-mime to install the xml file. This automatically also updates the mime database. But it makes it harder to test, because that installs to user directory we should test by overriding XDG_DATA_DIRECTORY and XDG_CONFIG_DIRECTORY 💡

@wolfv
Copy link
Contributor Author
wolfv commented Nov 8, 2024

Apparently the name can be a dict:

            "name": {
                "target_environment_is_base": "superspyder 1.2 ({{ DISTRIBUTION_NAME }})",
                "target_environment_is_not_base": "superspyder 1.2 ({{ ENV_NAME }})"
            },

@wolfv wolfv changed the title Start menuinst crate feat: add rattler_menuinst crate Nov 9, 2024
@Hofer-Julian
Copy link
Collaborator

Linux is now nearly working.

Running cargo run -- create napari-menu gives the following desktop file in .local/share/applications/napari (0.5.4).desktop

[Desktop Entry]
Type=Application
Encoding=UTF-8
Name=napari (0.5.4)
Exec=unset PYTHONHOME && unset PYTHONPATH && /var/home/julian/Projekte/github.com/conda/rattler/.prefix/bin/python -m napari
Terminal=false
Icon=/var/home/julian/Projekte/github.com/conda/rattler/.prefix/Menu/napari.png
Comment=a fast n-dimensional image viewer in Python
Categories=Graphics;Science;
StartupWMClass=napari

Exec doesn't support complicated expressions like this one. We should extract that to a script or trampoline.

@Hofer-Julian
Copy link
Collaborator

We went with directly calling the quoted command with bash -c instead.

One thing that still needs to be investigated if we need to run update-desktop-database after installing, my system gives unclear results. We could run it just to be sure. Mimetypes would be also great to have.

@wolfv wolfv force-pushed the menuinst branch 2 times, most recently from 69e6791 to 6a1ac81 Compare December 13, 2024 03:32
@dhirschfeld
Copy link

Cool! Super excited about this for pixi global install-ing applications

@dhirschfeld
Copy link

🎉

Comment on lines 124 to 192
8000
Tracker::MacOs(tracker) => {
#[cfg(target_os = "macos")]
macos::remove_menu_item(tracker).unwrap();
}
Tracker::Linux(tracker) => {
#[cfg(target_os = "linux")]
linux::remove_menu_item(tracker).unwrap();
}
Tracker::Windows(tracker) => {
#[cfg(target_os = "windows")]
windows::remove_menu_item(tracker)?;
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you want to just return one error here instead of an unwrap

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point! I think there is one more unwrap in the windows specific code that I marked with a TODO.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's align the return type with all the functions, and then also make this function return the removed paths. This is useful in pixi for logging.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's not just paths, though, it's also registry entries on Windows, for example, or entries in the terminal profile configuration file.

Might be more useful to just render the tracker information in pixi.

@wolfv wolfv marked this pull request as ready for review February 21, 2025 13:31
Copy link
Collaborator
@Hofer-Julian Hofer-Julian left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A small set of first comments :)

@@ -0,0 +1,68 @@
{
"id_": "https://schemas.conda.io/menuinst-1.schema.json",
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This link seems to be broken

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, why is this file needed? :)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We test that we can parse the defaults.json from upstream menuinst: https://github.com/conda/menuinst/blob/main/menuinst/data/menuinst-1-1-0.default.json

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can't seem to find that test. Can you point me to where it is? :)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

    #[test]
    fn test_deserialize_defaults() {
        let test_data = test_data();
        let schema_path = test_data.join("defaults/defaults.json");
        let schema_str = std::fs::read_to_string(schema_path).unwrap();
        let schema: super::MenuInstSchema = serde_json::from_str(&schema_str).unwrap();
        insta::assert_debug_snapshot!(schema);
    }

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That uses test-data/defaults/defaults.json, not data/menuinst.default.json

Hofer-Julian added a commit to Hofer-Julian/rattler that referenced this pull request Feb 24, 2025
Split out of conda#840 since it isn't used anywhere at the moment
@Hofer-Julian Hofer-Julian merged commit 02d0292 into conda:main Feb 25, 2025
16 checks passed
This was referenced Feb 24, 2025
travishathaway pushed a commit to travishathaway/rattler that referenced this pull request Feb 26, 2025
---------

Co-authored-by: Bas Zalmstra <bas@prefix.dev>
Co-authored-by: Julian Hofer <julianhofer@gnome.org>
Co-authored-by: Ruben Arts <ruben.arts@hotmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants
0