check-manifest icon indicating copy to clipboard operation
check-manifest copied to clipboard

Fails on pre-commit.ci - missing ensurepip

Open takluyver opened this issue 2 years ago • 4 comments

Thanks for this tool, which we're using for h5py. :slightly_smiling_face:

We're running this inside pre-commit on https://pre-commit.ci/ (a dedicated CI platform for pre-commit). At the moment, we have version 0.39, which works. However, pre-commit is keen to upgrade to the latest (0.47), which fails with this message:

check-manifest...........................................................Failed
- hook id: check-manifest
- exit code: 2

['/pc/clone/G2JdS4VyRWO1npwWqn8cWA/py_env-python3/bin/python', '-m', 'build', '--sdist', '.', '--outdir', '/tmp/check-manifest-3l6quvt4-sdist'] failed (status 1):
* Creating venv isolated environment...
The virtual environment was not created successfully because ensurepip is not
available.  On Debian/Ubuntu systems, you need to install the python3-venv
package using the following command.

    apt install python3.8-venv

You may need to use sudo with that command.  After installing the python3-venv
package, recreate your virtual environment.

Failing command: ['/tmp/build-env-dkf2wbiu/bin/python', '-Im', 'ensurepip', '--upgrade', '--default-pip']

It looks like if you depend on build[virtualenv], build will prefer virtualenv to venv, which I think should fix this (https://github.com/pypa/build/blob/96f9188ad181907fbd3e0efdf32dd3dc959d39c3/src/build/env.py#L61-L71 ).

It's frustrating that Debian is willing to break things that we can otherwise assume are always available. :disappointed:

takluyver avatar Feb 09 '22 10:02 takluyver

TBH I would make sure my CI build environment is not broken by doing a sudo apt-get install -y python3-venv instead of trying to work around it.

(I also don't think a pip-installed virtualenv would work on a Debian-packaged Python 3 without python3-venv being installed. IIRC virtualenv depends on stdlib's venv on Python 3, or at least it used to at one point.)

mgedmin avatar Feb 09 '22 13:02 mgedmin

I don't think pre-commit.ci has any way to install extra apt packages - I'd be happy to hear that I'm wrong, but I think the idea is that it has minimal config and runs very fast because it just needs to run the pre-commit hooks, so it can use a standard image and heavy caching.

takluyver avatar Feb 09 '22 13:02 takluyver

I've tried filing an issue on pre-commit.ci itself - we'll see what comes of that: https://github.com/pre-commit-ci/runner-image/issues/114

takluyver avatar Feb 09 '22 14:02 takluyver

Anthony - the maintainer of pre-commit - pointed out that network access is disabled when hooks run, so installing stuff in a virtualenv wouldn't work anyway, and the only option for this hook on pre-commit.ci is to use the --no-build-isolation option, as mentioned in the Readme.

takluyver avatar Feb 09 '22 16:02 takluyver