Jump to content

Is it possible for an Alfred workflow to install Python libraries to my Mac system, systemwide?


Recommended Posts

Is it possible for Alfred workflow to install Python libraries to my Mac system, systemwide?

I don't mind them being installed in an isolated environment like virtual environments(honestly though, not even sure where the workflows are stored, once installed to the Alfred app, "Alfred.alfredpreferences"?), but after seeing how so many Alfred workflows online use Python, I'm starting to wonder whether they ever install python packages to my system systemwide, without me knowing about them.
Can this happen?

 

Also if they can, I assume they may cause issues in the future.

What are best practices, to prevent any future complications.

 

I also found some content on the forums that mention python libraries being installed in the workflows(links below).

I don't know whether this means they are installed in an isolated section for your workflows, and for that workflow only, or if it means that the libraries can be installed to the Mac for the whole system.

 

I'm just started learning, but not a programmer and no expert on these things. Only know enough to set up virtual environments.
If someone with more expertise can help me figure this out, that would be very much appreciated.

 

Thanks

Edited by iaLAR
Link to comment
2 hours ago, iaLAR said:

Is it possible for Alfred workflow to install Python libraries to my Mac system, systemwide? (…) Also if they can, I assume they may cause issues in the future.

 

It’s not possible for a Workflow to install libraries in a way that would mess up your system, because macOS’ System Integrity Protection (which you likely have not disabled) would prevent that. But even before that was implemented, doing stuff system-wide would require sudo (in other words, being asked for your password).

 

A Workflow can only install a library somewhere you as a user have access. And for it to be disruptive (unlikely) it would have to be a location which you specifically use/load, at which point you’d know and be able to trivially uninstall it anyway.

 

In a literal decade of frequenting this forum, I don’t recall that ever being an issue. Plus, recent macOS changes would only make that harder. Including the library with the Workflow is the way to go and the most convenient to users (and to developers, for debugging purposes).

 

2 hours ago, iaLAR said:

honestly though, not even sure where the workflows are stored, once installed to the Alfred app, "Alfred.alfredpreferences"?

 

Right click Alfred.alfredpreferences and choose “Show package contents”. From there, go into workflows. Or right click a Workflow in the preferences and “Open in Finder”.

 

A .alfredworkflow is a renamed zip which on install unpacks to that directory.

 

2 hours ago, iaLAR said:

What are best practices, to prevent any future complications.

 

I also found some content on the forums that mention python libraries being installed in the workflows(links below).

 

That’s how it should be done. In the second one you linked, @giovanni and I go into detail.

 

2 hours ago, iaLAR said:

I don't know whether this means they are installed in an isolated section for your workflows, and for that workflow only

 

Yes, they are installed in the Workflow’s directory. So if you delete the Workflow, so goes the library.

Link to comment

@vitor Thank you so much for getting back to me and helping me with this question.

 

6 hours ago, vitor said:

It’s not possible for a Workflow to install libraries in a way that would mess up your system, because macOS’ System Integrity Protection (which you likely have not disabled) would prevent that. But even before that was implemented, doing stuff system-wide would require sudo (in other words, being asked for your password).

Forgive me for maybe using the wrong terminology before. I am not a programmer, and still trying to learn these things.
"Globally", was probably the more proper term for what I was asking than "system-wide", although I am glad that Workflows cannot make changes system-wide.
When you say it cannot install the libraries system-wide, is that different from installing libraries globally, or global libraries/environments? (I may be wrong again, but would global usually mean locations like "/usr/local/bin/" for Mac?)
If different, will Workflows potentially be able to install libraries globally (again I apologize if my terminology is inaccurate)

 

6 hours ago, vitor said:

In a literal decade of frequenting this forum, I don’t recall that ever being an issue. Plus, recent macOS changes would only make that harder. Including the library with the Workflow is the way to go and the most convenient to users (and to developers, for debugging purposes).

I am very glad to hear that those things haven't happened.
Maybe I'm just paranoid, but when learning how to set up virtual environments, I was told repeatedly to be very careful with installing libraries globally.

 

6 hours ago, vitor said:

Right click Alfred.alfredpreferences and choose “Show package contents”. From there, go into workflows. Or right click a Workflow in the preferences and “Open in Finder”.

 

A .alfredworkflow is a renamed zip which on install unpacks to that directory.

Great to know this.
I should have thought to show package content. I have been able to locate it now, but the right clicking from Alfred preferences is actually a big help(to find the actual workflow, because the name can be scrambled)
Thank you very much! Very useful.

 

6 hours ago, vitor said:

Yes, they are installed in the Workflow’s directory. So if you delete the Workflow, so goes the library.

This is great. So it sounds like an isolated environment inside the workflow directory.
I'm glad that if setup this way It can simply be deleted with the workflow, also meaning the libraries shouldn't affect my system, and very easy to manage for users. Especially people like me that don't understand code as much.
You say "that's how it should be done" though, so a workflow may be setup another way? If so, is there a way to know if a Workflow has been setup this way? Or is the only way to know by going through the code and checking yourself?


Also this may be a little unrelated, but generally speaking, if the access permission of the Alfred app to the terminal disabled, will that affect how workflows work?

 

Thank you!

Link to comment
3 hours ago, iaLAR said:

If different, will Workflows potentially be able to install libraries globally (again I apologize if my terminology is inaccurate)


Maybe this helps: a Workflow can run a command you yourself would run in a Terminal.

 

3 hours ago, iaLAR said:

Maybe I'm just paranoid, but when learning how to set up virtual environments, I was told repeatedly to be very careful with installing libraries globally.


When you’re developing, a separation of concerns helps. Language version managers and virtual environments are tools in the box you can use. They also make it simple to throw everything away and start over, so don’t worry too much about it yet.

 

3 hours ago, iaLAR said:

to find the actual workflow, because the name can be scrambled


That’s for uniqueness. You can change the names of those directories at will (I do) and Alfred will pick it up.

 

3 hours ago, iaLAR said:

You say "that's how it should be done" though, so a workflow may be setup another way?


Yes, but it ends up being more cumbersome for the developer too, especially now with Apple removing languages. Other than packaging the dependencies with the Workflow, another thing authors may do is ask you to install them yourself (again, see second thread you linked).

 

3 hours ago, iaLAR said:

Or is the only way to know by going through the code and checking yourself?


Or asking someone else, yes. But those kinds of things are generally put front and centre in the Workflow’s instructions. Precisely so stuff doesn’t break and so both you and the developer have a frame of reference when debugging.

 

3 hours ago, iaLAR said:

Also this may be a little unrelated, but generally speaking, if the access permission of the Alfred app to the terminal disabled, will that affect how workflows work?


The terminal is an app which allows you to interface with a shell. They are separate things. Unless the Workflow specifically interacts with the Terminal, it shouldn’t be a problem.

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...