I tried to use PyPy3 and the available helper scripts, but faced quite quickly difficulties. Please do find below smallish flake.nix
that shows the problem.
{
description = "Try pypy3";
outputs = { self, nixpkgs }:
let
system = "x86_64-linux";
pkgs = nixpkgs.legacyPackages.${system};
py3pkgs = pkgs.python3.pkgs;
in {
# For the following, use: nix run
# Fails, because doesn't find the requests module.
packages.${system}.default = pkgs.writers.writePyPy3Bin "say_foo" { libraries = [ py3pkgs.requests ]; } ''
import requests
status = requests.get("https://www.example.com").status_code
print(status)
'';
# The following works (with `nix run`)
# This works fine.
# packages.${system}.default = pkgs.writers.writePython3Bin "say_foo" { libraries = [ py3pkgs.requests ]; } ''
# import requests
# status = requests.get("https://www.example.com").status_code
# print(status)
# '';
};
}
There are couple of discussions that (almost) refer to this, like Basic flake: run existing (python, bash) script - #6 by n8henrie. Further, Python - NixOS Wiki says that
you can use the same example with other versions of Python by replacing
python3
withpython2
orpypy3
Apparently it is quite that easy with PyPy3. Do we have PyPy3 users here & if yes, how have you solved the dependency issues? Could you please share?
My hunch says that maybe some path needs to be set, but I’m novice w.r.t. PyPy3: it could be that pypy3 needs to somehow compile or install the libs on its own way?? Not sure.
Late additions.
Docs at https://doc.pypy.org/en/latest/install.html say
Installing more modules¶
If you want to install 3rd party libraries, the most convenient way is to install pip using ensurepip (unless you want to install virtualenv as explained below; then you can directly use pip inside virtualenvs):
./pypy-xxx/bin/pypy -m ensurepip
./pypy-xxx/bin/pypy -mpip install -U pip wheel # to upgrade to the latest versions
./pypy-xxx/bin/pypy -mpip install pygments # for example
Third party libraries will be installed in pypy-xxx/site-packages. As with CPython, scripts on linux and macOS will be in pypy-xxx/bin, and on windows they will be in pypy-xxx/Scripts