Giter VIP home page Giter VIP logo

Comments (7)

holzschu avatar holzschu commented on July 16, 2024

From Apple's point of view, the extension and the app are two different apps, with different downloads and directories. The extension does not have access to what has been installed in the app, the app cannot access the extension main directory. Both have access to a shared directory, which is where the extension runs by default (it's ~shortcuts or $GROUP).

To answer your main question: you need to install packages in a place where the extension can access them, ~shortcuts/Library/lib/python3.11/site-packages.

To do this:

  • either copy ~/Library/lib/python3.11 to ~shortcuts/Library/lib/python3.11 (pro: fast and easy, con: you might be copying a lot of packages you don't need), or:
  • set the environment variable PYTHONUSERBASE to ~shortcuts/Library, then re-install the packages you need.

When the extension runs, it uses the Python packages in ~shortcuts/Library.

from a-shell.

dragoncoder047 avatar dragoncoder047 commented on July 16, 2024

Ok, seems simple enough. Do you know if it is possible in iOS to make a symlink so I don't have to keep copying files over?

from a-shell.

holzschu avatar holzschu commented on July 16, 2024

Symlinks won't work over different apps (for security reasons), hard links will work (use ln instead of ln -s) but you can only hard link files, not directories. However, if you don't want to keep copying files over, you can set PYTHONUSERBASE to ~shortcuts/Library in the app (using the .profile or .bashrc files) and have both the app and the extension access the same shared directory.

from a-shell.

dragoncoder047 avatar dragoncoder047 commented on July 16, 2024

Symlinks won't work over different apps (for security reasons), hard links will work (use ln instead of ln -s) but you can only hard link files, not directories. However, if you don't want to keep copying files over, you can set PYTHONUSERBASE to ~shortcuts/Library in the app (using the .profile or .bashrc files) and have both the app and the extension access the same shared directory.

Ok, I added export PYTHONUSERBASE= ~shortcuts/Library to my .profile and restarted a-Shell then reinstalled yt-dlp but now when I run the shortcut it says "problem communicating with the app".

image

from a-shell.

holzschu avatar holzschu commented on July 16, 2024

In-extension Shortcuts have a hard time limit of 5 seconds (enforced by the system). "There was a problem communicating with the app" usually means: the Shortcut went over the time limit, and the system terminated it (it could also mean that the shortcut went over the memory limit or the CPU usage limit, but the time limit is much more likely).

You can also run yt-dlp inside the app, then call the command open shortcuts:// to go back to the shortcut and execute more actions. There are already several shortcuts running yt-dlp that use this trick.

from a-shell.

dragoncoder047 avatar dragoncoder047 commented on July 16, 2024

In-extension Shortcuts have a hard time limit of 5 seconds (enforced by the system). "There was a problem communicating with the app" usually means: the Shortcut went over the time limit, and the system terminated it (it could also mean that the shortcut went over the memory limit or the CPU usage limit, but the time limit is much more likely).

It's not the time limit because I get that error after about half a second.

Also, I can't run the command in the app because I need this shortcut to run as an automation, completely in the background.

from a-shell.

Emasoft avatar Emasoft commented on July 16, 2024

@holzschu Setting the python userbase path is not helpful. Many shortcuts need to access different folders at different times, both in extension mode and in app mode in the same shortcut. A more efficient and simple way would be to add to the a-shell shortcuts commands the option to explicitly set the folder where do you want to execute the action or load/save a file. If the folder has not been authorized by the user yet, you can explicitly ask for permissions to the user the first time a certain folder is asked access. Can you do it?

from a-shell.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.