-
Notifications
You must be signed in to change notification settings - Fork 55
Allow users to create a requirements.txt to install missing packages #68
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
Allow users to create a requirements.txt to install missing packages #68
Conversation
5ddb7b6
to
013be73
Compare
013be73
to
40d0d18
Compare
0921689
to
30db0dc
Compare
As I was thinking through this, there is a "slicker" way to do this, which would be to add the logic to install the module during import time (https://github.com/custom-components/pyscript/blob/master/custom_components/pyscript/eval.py#L843 and https://github.com/custom-components/pyscript/blob/master/custom_components/pyscript/eval.py#L876). The advantage of this approach is that the user doesn't have to add a |
I think I prefer the requirements.txt approach. Not only does it allow pinning a version, but, if we're installing a module, it's best to be explicit about that. This approach will provide the least amount of surprise. Especially if someone requests a module that takes forever to build (like numpy) and doesn't have a prebuilt binary available. |
I definitely like this approach using I added a few comments to the PR, which is looking good. One request is to support multiple
The motivation for the last two is it allows apps or modules to be self-contained and they will just do the right thing when installed. As an example, you can see how |
This all looks great. Merging. Thanks! |
As I mentioned in #66, it would be nice to be able to have
pyscript
install packages to be used in imports in cases where the user doesn't have the ability to install the packages themselves (in my case, I am using a Docker container for HomeAssistant so it would be cumbersome to install these requirements on every container rebuild).I went ahead and implemented the functionality in this PR for your consideration. The way it works is that users can add a
requirements.txt
file topyscript/
. For any packages that are already installed, the version will be ignored so as not to mess with HomeAssistant functionality, and for any packages that aren't already installed, the package will be installed via a Home Assistant function. Since I am leveraging the Home Assistant function, the actual work being done within pyscript is fairly minimal.This activity to install requirements will be done on initialization and on reload.
Resolves #66