-
-
Notifications
You must be signed in to change notification settings - Fork 83
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
Support for ARM? #195
Comments
It would be difficult for us to provide binaries for the raspberry pi architecture as our current setup relies completely on the precompiled binaries that Prisma provides, of which the raspberry pi architecture is not included (prisma/prisma#5379 (comment)). However we can provide a better error message for this case, I will create a separate issue to track this. However you can build the binaries yourself by following these steps:
It should be noted that I have not tested these steps so please let me know if you encounter any issues or have any other questions! |
I have just realised I have misread your original issue, the error is due to the CLI binary, not the engine binaries. The CLI binary path is actually not configurable, I should fix this. Here's the bash script used to build the CLI: #!/bin/sh
set -eux
v="3.4.0"
mkdir -p build
cd build
npm init --yes
npm i "pkg" --dev
npm i "prisma@$v" --dev
npm i "@prisma/client@$v"
npx prisma version
mkdir -p node_modules/prisma/node_modules/@prisma/engines
cp -R node_modules/@prisma/engines/* node_modules/prisma/node_modules/@prisma/engines
npx pkg -t node12-linux node_modules/prisma However, I am doubtful that this will work due to the explicit target passed to Hopefully you can get this to work for you and then you can replace the CLI binary that is already downloaded with the one you just built. I do not know if this is something that can be easily solved by us, I will look into it further. |
@RobertCraigie thanks for the help here, I ended up doing both suggestions: building the engine binaries myself (and setting the corresponding env vars) and building the cli using Also I came across this comment (prisma/prisma#861 (comment)) but I wasn't able to find the pre-built binaries for the engines in My issue seems resolved, I'm able to run my scripts now in the RPI so we can close this but I agree it could be helpful to have a clearer error message if possible. Thank you! |
@richin13 I'm glad you could get it to work! Could you please let me know what the following script outputs? I don't have access to an arm64 machine which makes testing difficult. import platform
print(platform.architecture())
print(platform.system())
print(platform.machine()) |
@RobertCraigie Sure, here's the output:
|
Thank you! |
I was trying to run prisma python on a docker container in M1 mac (arm64 container by default) I ended up with this solution (posting here for anyone who is in the same situation)
#!/bin/sh
set -eux
export PRISMA_VERSION="3.13.0" # Set it to the prisma client version used by prisma python
export TARGE_DIRECTORY="$PRISMA_BINARY_CACHE_DIR"
function install_dependencies() {
apt update && apt install -y curl
curl -fsSL https://deb.nodesource.com/setup_16.x | bash -
apt install -y nodejs
}
function build_prisma_cli() {
# Package CLI: https://github.com/RobertCraigie/prisma-client-py/issues/195#issuecomment-1001287195
export PRISMA_CLI_QUERY_ENGINE_TYPE=binary
mkdir -p /tmp/prisma_cli
cd /tmp/prisma_cli
npm init --yes
npm i "pkg" --dev
npm i "prisma@$PRISMA_VERSION" --dev
npm i "@prisma/client@$PRISMA_VERSION"
npx prisma version
# Build cli executable
npx pkg -t node16-linux node_modules/prisma -o prisma-cli-linux
# Copy to correct path where prisma expects the binaries to be
mkdir -p $TARGE_DIRECTORY
mv prisma-cli-linux $TARGE_DIRECTORY/prisma-cli-linux
mv node_modules/@prisma/engines/introspection-engine-linux-arm64-openssl-1.1.x $TARGE_DIRECTORY/prisma-introspection-engine-debian-openssl-1.1.x
mv node_modules/@prisma/engines/query-engine-linux-arm64-openssl-1.1.x $TARGE_DIRECTORY/prisma-query-engine-debian-openssl-1.1.x
mv node_modules/@prisma/engines/migration-engine-linux-arm64-openssl-1.1.x $TARGE_DIRECTORY/prisma-migration-engine-debian-openssl-1.1.x
mv node_modules/@prisma/engines/prisma-fmt-linux-arm64-openssl-1.1.x $TARGE_DIRECTORY/prisma-prisma-fmt-debian-openssl-1.1.x
# Cleanup
rm -rf /tmp/prisma_cli
}
function install_prisma_cli() {
# Only run the script in arm64 arch since prisma cli by default doesnt package binaries in arm64
CURRENT_ARCH=$(dpkg --print-architecture)
if [[ "$CURRENT_ARCH" != "arm64" ]]; then
return
fi
install_dependencies
build_prisma_cli
}
install_prisma_cli
FROM python:3.11-slim
ENV PRISMA_BINARY_CACHE_DIR="/tmp/.prisma-cache"
COPY ./setup-prisma-arm64.sh /setup-prisma-arm64.sh
RUN bash /setup-prisma-arm64.sh
...
...
... Essentially, the custom script would only run in cases where the architecture is arm64 and it would download the binaries to the folder where prisma client python is expecting the binaries to be. For x86_64 things will run as usual |
Hey @a7ul! Sorry I should've commented on this issue more recently.... Support for ARM is now in Sorry to have caused you more work than was necessary. |
Wow thats amazing @RobertCraigie 🙌🏽 |
Any clue when this would be released (or which version it would be?)? This would add support for running it on a raspberry pi? |
Hey @pimmesz, this feature was included in the latest release. However, I'm unsure of the support for raspberry pi. There is this open issue which references this workaround which has now been archived stating that it's recommended to use a 64 bit pi, would that be possible for you to use? |
Hi @RobertCraigie. I've opened an issue at the Prisma repo as well. I am currently running 64 bit pi. If I run |
Hey @pimmesz, sorry I missed your latest comment but it looks like the folks over at Prisma managed to resolve the issue for you! Let me know if you have any more questions :) |
Bug description
Hello, I'm trying to run the
prisma
commands and to use the client on a raspberry pi that uses ARM64, I noticed the binaries that get downloaded are built for x86. Is there any way I can generate those binaries myself? Or download the appropriate version for my system?How to reproduce
Run an application on an ARM64 machine, running any command or attempting to use the client will result int:
Downloaded binary
file
result:Expected behavior
Ideally, to download the appropriate version for my system arch but pointing to instructions on how to build these binaries myself can suffice.
Prisma information
Worth noting that
npx prisma@3.4.0 db push
worked fine but the issue appears again when I try to run my python script where I use theClient
from prisma.Environment & setup
Linux ubuntu 5.13.0-1011-raspi #13-Ubuntu SMP PREEMPT Fri Nov 19 18:40:23 UTC 2021 aarch64 aarch64 aarch64
GNU/Linuxsqlite
3.9.6
0.4.2
The text was updated successfully, but these errors were encountered: