prisma-client-py icon indicating copy to clipboard operation
prisma-client-py copied to clipboard

Move binaries outside of `/tmp` by default

Open Leon0824 opened this issue 2 years ago • 8 comments

Problem

Currently, the downloaded binaries are placed in /tmp/ on Linux. However, /tmp/ directory is cleared on boot everytime.

Suggested solution

Placing the binaries in /var/tmp/ on Linux. See Temporary folder.

Alternatives

Placing the binaries in site-packages/prisma/

Leon0824 avatar May 31 '22 01:05 Leon0824

Placing binaries in /var/tmp would be great for multiple projects. Also looking forward to this implementation on Macs.

donny-son avatar May 31 '22 01:05 donny-son

The reason they're placed in /var/tmp/ is to avoid unnecessarily bloating user storage with version upgrades as the engine binaries are quite large.

I now understand that the Prisma TypeScript Client stores them in ~/.cache/prisma/ so I'm considering switching the default to match that.

I think the best solution for this is to support configuring the binaries directory through an env variable or an entry in a pyproject.toml file, for example:

[tool.prisma]
binaries_dir = "~/.cache/prisma-binaries"

Apologies for the duplicated comments, my internet connection dropped while I was posting.

RobertCraigie avatar May 31 '22 19:05 RobertCraigie

This has created issues for me when deploying to Heroku. Heroku's Python build pack doesn't copy the binaries to the production app and so it is left without the binaries. Had to go through various hoops to make it work. Would be great if I could have just sourced the binaries from site_packages or another directory that Heroku copies by default.

iddan avatar Jun 05 '22 21:06 iddan

Yeah this is something I'd really like to have, in terms of the direct site-packages binaries this would be solved with #55.

A more feasible solution that could be implemented soon would be the environment variable support which would mean that you could set the environment variable to point to your site-packages.

RobertCraigie avatar Jun 07 '22 22:06 RobertCraigie

You can now configure the location of the binaries through either a pyproject.toml file:

[tool.prisma]
binary_cache_dir = '.binaries'

Or through an environment variable, e.g.

PRISMA_BINARY_CACHE_DIR=".binaries"

The default location is still in a temporary directory, however I plan on changing that soon.

RobertCraigie avatar Jul 02 '22 11:07 RobertCraigie

You can now configure the location of the binaries through either a pyproject.toml file:

[tool.prisma]
binary_cache_dir = '.binaries'

Or through an environment variable, e.g.

PRISMA_BINARY_CACHE_DIR=".binaries"

The default location is still in a temporary directory, however I plan on changing that soon.

I tried adding the custom env variable and also using the pyproject.toml file too. But it always downloads in the /tmp folder image

max-programming avatar Aug 01 '22 18:08 max-programming

@max-programming The aforementioned feature has not been released yet. You can try it out by installing from github like so:

pip install -U git+https://github.com/RobertCraigie/prisma-client-py

RobertCraigie avatar Aug 02 '22 12:08 RobertCraigie

Thanks @RobertCraigie. Had a hard time finding out this exact command.

max-programming avatar Aug 02 '22 12:08 max-programming