black: Installing black 19.10b0 without gcc installed causes an error
Installing black version 19.10b0 in an environment without gcc causes an error.
To Reproduce:
- Build a docker image (
docker build .) using this Dockerfile:
FROM python:3.7-slim
RUN pip install black
- See error:
Building wheels for collected packages: pathspec, regex
Building wheel for pathspec (setup.py): started
Building wheel for pathspec (setup.py): finished with status 'done'
Stored in directory: /root/.cache/pip/wheels/62/b8/e1/e2719465b5947c40cd85d613d6cb33449b86a1ca5a6c574269
Building wheel for regex (setup.py): started
Building wheel for regex (setup.py): finished with status 'error'
ERROR: Complete output from command /usr/local/bin/python -u -c 'import setuptools, tokenize;__file__='"'"'/tmp/pip-install-t05gdu90/regex/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' bdist_wheel -d /tmp/pip-wheel-2uuo3rjn --python-tag cp37:
ERROR: BASE_DIR is /tmp/pip-install-t05gdu90/regex
/usr/local/lib/python3.7/site-packages/setuptools/dist.py:472: UserWarning: Normalizing '2019.08.19' to '2019.8.19'
normalized_version,
running bdist_wheel
running build
running build_py
creating build
creating build/lib.linux-x86_64-3.7
creating build/lib.linux-x86_64-3.7/regex
copying regex_3/regex/__init__.py -> build/lib.linux-x86_64-3.7/regex
copying regex_3/regex/regex.py -> build/lib.linux-x86_64-3.7/regex
copying regex_3/regex/_regex_core.py -> build/lib.linux-x86_64-3.7/regex
creating build/lib.linux-x86_64-3.7/regex/test
copying regex_3/regex/test/__init__.py -> build/lib.linux-x86_64-3.7/regex/test
copying regex_3/regex/test/test_regex.py -> build/lib.linux-x86_64-3.7/regex/test
running build_ext
building 'regex._regex' extension
creating build/temp.linux-x86_64-3.7
creating build/temp.linux-x86_64-3.7/regex_3
gcc -pthread -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -fPIC -I/usr/local/include/python3.7m -c regex_3/_regex.c -o build/temp.linux-x86_64-3.7/regex_3/_regex.o
unable to execute 'gcc': No such file or directory
error: command 'gcc' failed with exit status 1
----------------------------------------
ERROR: Failed building wheel for regex
Running setup.py clean for regex
Successfully built pathspec
Failed to build regex
Expected behavior:
We should be able to install black without needing to have gcc installed separately.
Environment (please complete the following information):
- Version: 19.10b0
- OS and Python version: Docker image (python:3.7-slim) running on MacOS/Linux hosts
About this issue
- Original URL
- State: closed
- Created 5 years ago
- Reactions: 25
- Comments: 23 (8 by maintainers)
Commits related to this issue
- pre-build: fix CI black breakage by pinning it to 19.3b0 Black seems to have dependencies on musl-dev and gcc past 19.3b0 version. Hopefully this is just temporary. If we wanted to continue using th... — committed to ynezz/openwrt-ci by ynezz 5 years ago
- Pin Black to a version that does not require gcc Recent versions of black require gcc to build a new regex dependency. This may go away, so we'll just pin to a specific version black (which is best p... — committed to packethost/packet-python by mmlb 5 years ago
- Added tests and locked black on version 19.3b0. I added tests for the functions in __main___. Also added pytest-mock as depedencies. I had to pin black to version 19.3b0 because the newer version com... — committed to cognitedata/cognite-replicator by eventh 5 years ago
- Configure config file path with environment variable COGNITE_CONFIG_FILE (#103) * Configure config file path with environment variable COGNITE_CONFIG_FILE Signed-off-by: Even Wiik Thomassen <even.... — committed to cognitedata/cognite-replicator by eventh 5 years ago
- [Tests] Pin black to 19.3b0 Black version 19.10b0 has a new `regex` dependency which requires building from source on Linux. Until this is fixed pin to earlier version. See: https://github.com/psf/b... — committed to cas--/Deluge by cas-- 5 years ago
- bump regex version, providing wheels (#1232) Close #1112 — committed to psf/black by deleted user 4 years ago
- Fix black installation According to https://github.com/psf/black/issues/1112, black > 19.10b0 needs gcc installed. Installing build-essential and python3-dev solves the issue. TT26059 — committed to Tecnativa/doodba-qa by joao-p-marques 4 years ago
- Fix black installation (#20) According to https://github.com/psf/black/issues/1112, black > 19.10b0 needs gcc installed. Installing build-essential and python3-dev solves the issue. TT26059 C... — committed to Tecnativa/doodba-qa by joao-p-marques 4 years ago
There should be an alternative to a hard dependency of
regexfor a year old low priority bug that causes widespread disruption to users. Also relying on third-party library in pull requests and packaging availability must be questioned.The author of
regexis not going to provide wheels:https://bitbucket.org/mrabarnett/mrab-regex/issues/343/wheel-for-linux
Why not revert the fix and dependency to reconsider a better solution?
This makes using black pretty hard on modern CI/CD which usually uses docker. Can we please find a better tool other than regex or MR something into that library, so that it builds binary linux wheels
Instead of looking for an alternative to
regexitself, I would offer to make it better by contributing a CI pipeline to it that builds wheels on all platforms.There’s a pull request merged that will soon produce linux wheels for regex.
Everywhere in code
regexcan be safely replaced byre, so regex can be imported with a fallback to re and installed as an extra.I ran into this issue in an image that uses
continuumio/miniconda3:latestwhich in turn usesdebian:latest. I addressed it by adding the following line:I didn’t need to install all of
build-essential. In any case, this resolution is now going to stress the debian repositories.FWIW, I’ve just asked @ambv to revert the change again given the low priority nature of the bug and the impact it has on many people.
@impredicative I have a library that generates Python source code from
jinjatemplates and then formats it withblack, so it is a direct dependency.For people looking for a compact Alpine Docker image with Black 19.10b0, installing Black with GCC can be done in a separate build stage to reduce the final image size. Example (see original Dockerfile):
This one results in an image of about 64.8MB in size. I hope this helps.
If an example of the problematic Unicode pattern and input string is known, perhaps it could be shared here so someone could report it to https://bugs.python.org/ in the hopes that is could be improved in the re module.
The
regexauthor doesn’t seem to be willing to add pre-built linux wheels. We also find that requiring a source build is inconvenient, both in terms of added complexity and build times.