Errors, maybe uWSGI-related, while pip-installing in virtualenv

I documented the problem here.

That folder has three files. The README tells the story, which I’ll duplicate below. The other two files contain the output (stderr and stdout combined in one file) from running pip install -r requirements.txt. One of them is what I get if I run nix-shell first, and the other is what I get without it.

The story

I’m trying to run agora-server. The README for that project says to do this:

python3 -m venv venv
. venv/bin/activate
pip install -r requirements.txt

The NixOS wiki page on Python suggests in one place a nearly-identical passage:

python -m venv .venv
source .venv/bin/activate
pip install -r requirements.txt

Those two passages only differ in that the second creates a folder called .venv instead of venv, and that the second uses python instead of python3. So I tried this (teeing stdout and stderr to a file because it’s a few pages long):

python3 -m venv venv
. venv/bin/activate
pip install -r requirements.txt 2>&1 | tee error.txt

That produces these errors. They involve the term “uWSGI”, which I didn’t think I’d installed so I installed uwsgi, the package with the most similar name I could find. I then created a shell.nix file containing the following:

with import <nixpkgs> { };
mkShell {
  buildInputs = [
    uwsgi
  ];
}
(venv)

ran nix-shell, and tried again. That created similar but not identical errors.

The errors say to “Check the logs for full command output” but I don’t know what logs it’s talking about.

In both cases, the error looks like a failure to find ncurses:

This is happening when pip is trying to build the pip/python uwsgi package. The uwsgi in nixpkgs is a more traditional ~distro build of uwsgi that pip likely won’t recognize.

You can probably advance a little by adding ncurses, though there may be additional things missing.

That helped a lot! Thanks, @abathur.

Once I added ncurses, a few other errors happened, but they were much more obvious than the ncurses one, and I was able to defeat them by adding more packages to shell.nix.

tree/fb0f8f94481ffa54ab64ed36640c8c050e9b6f25

But now I’m stuck at an error involving something (a Python package, I believe) called METADATA. I documented the problem here, which I’ve duplicated below. I have not put the full error message in this post but it’s online here.

The situation

To run agora-server
I’m using a nix-shell generated from the following shell.nix file:

with import <nixpkgs> { };
mkShell {
  buildInputs = [
    memcached libmemcached
    ncurses
    uwsgi
    zlib
    python39Packages.setuptools
    python39Packages.markupsafe
    python39Packages.importlib-metadata
  ];
}

I then run

. venv/bin/activate
pip install -r requirements.txt 2>&1 | tee error.txt

and the second of those commands fails with

ERROR: Could not install packages due to an OSError: [Errno 30] Read-only file
 system: 'METADATA'

The full output + error is here.

METADATA must refer to Python’s importlib-metadata.

The only place in the project that I can find (via grep) the term METADATA is in venv/, which makes me believe it’s referring to Python’s importlib-metadata, which is one of the nix-shell's buildInputs. But if I comment out that build input and start a new nix-shell, I get the same error.

Putting that requirement in shell.nix vs. requirements.txt

importlib-metadata is also one of the requirements listed in the project’s requirements.txt, which would lead me to believe I don’t need to include it in shell.nix – except that so is MarkupSafe, and if I don’t include that in shell.nix I get this error about it:

Read-only file system: '/nix/store/y3inmdhijqkb4qj36yphj4cbllljhqzz-python3-3.9.6/lib/python3.9/site-packages/MarkupSafe-1.1.1.dist-info'