ofek / pyapp

Runtime installer for Python applications
https://ofek.dev/pyapp/
1.1k stars 24 forks source link

Management command for deleting installation files #112

Closed johannesloibl closed 2 months ago

johannesloibl commented 2 months ago

Currently i can only use app.exe self restore to re-create the distribution, which itself is also removing the old one.

Can we get a management command like app.exe self remove to only delete the installation files?

ofek commented 2 months ago

Is this only happening when you do PYAPP_FULL_ISOLATION=true? In that case the installation is the unpacked distribution which would be the correct behavior.

johannesloibl commented 2 months ago

Maybe i was not clear, sorry. I'm basically just requesting a self remove command.

This should be easy to implement since self restore is already doing half the job ;) So why not derive a remove command from it to also delete the installation if it's not needed anymore. This removes the need to manually delete the folder under %APPDATA%, which is painfully slow on Windows (if you don't know how to delete faster - which the typical user does not :P )

ofek commented 2 months ago

Okay that makes sense but please I would like to confirm that the full isolation option I mentioned when enabled does what you want, is that right? Also how do you delete faster? We could certainly use that method here if feasible!

johannesloibl commented 2 months ago

The full isolation option is doing what it should, a standalone Python interpreter is unpacked 👍

For deleting i'm typically using this, which is blazingly fast or plain rm -rf. I was just referring to the typical users deleting (v)envs via Windows Explorer 🐌. PyApps env removal is fast enough, no need to optimize here IMHO when you're used to lame Windows^^.

ofek commented 2 months ago

Thanks for the link! If you don't mind, I'm so sorry, can you please explain in very basic terms what restore currently does/should do from your point of view and what the proposed remove should do? I'm having a long day lol

johannesloibl commented 2 months ago

NP 👍🏻 restore is doing what it should: deleting the interpreter and reinstalling it, sorry about focusing on it too much. I was just using it as an example for a remove command, which should ONLY remove the interpreter. Basically the same code as in https://github.com/ofek/pyapp/blob/master/src/commands/self_cmd/restore.rs:

impl Cli {
    pub fn exec(self) -> Result<()> {
        if app::install_dir().is_dir() {
            let spinner = terminal::spinner("Removing installation".to_string());
            let result = fs::remove_dir_all(app::install_dir());
            spinner.finish_and_clear();
            result?;
        }
        /// that's not needed --> distribution::ensure_ready()?;

        Ok(())
    }
}

I would contribute this if i would have any clue about Rust and the toolchain, but it's probably done by you in 5min 😄

ofek commented 2 months ago

Ohhh okay sure, thank you, I will do this tonight

johannesloibl commented 2 months ago

Awesome thanks! Speaking of tonight, it's midnight here, so good night 😄

johannesloibl commented 2 months ago

It's working as expected, thanks!