python: [3-alpine] shutil.copytree fail to copy a tree with a broken symbolic link
When trying to use pre-commit hock from this repo: https://github.com/pre-commit/pre-commit-hooks
pip failed when using the shutil.copytree
I’ve narrowed it to this example, it passed on 2.7-alpine, but fails on 3.5-alpine and 3.6-alpine
FROM python:3.6-alpine
RUN apk update
RUN apk add git
RUN mkdir /bug
RUN cd /bug && ln -s /broken_path/to_nowhere broken
RUN python -c "import shutil; shutil.copytree('/bug', '/temp', symlinks=True)"
EDIT: After playing around, I’ve nailed it to this command failing
>>> os.chmod('/bug/broken', 511, follow_symlinks=False)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
OSError: [Errno 95] Not supported: '/bug/broken'
shutil was expecting NotImplementedError
this seems related https://bugs.python.org/issue17076
About this issue
- Original URL
- State: closed
- Created 8 years ago
- Reactions: 2
- Comments: 17 (1 by maintainers)
@asottile’s new patch https://github.com/python/cpython/pull/4783 seems to fix tox inside python alpine, yay!
Here’s a Dockerfile which recreates this error.
Running above Dockerfile confirms that we get the copytree error:
Now if we change the FROM in above dockerfile to
jacobsvante/python:3.7.0a3-alpine3.6-with-bpo-31940-lchown-fix
the error doesn’t appear. Thanks @asottile!I’ve submitted a patch to cpython: https://github.com/python/cpython/pull/4267