Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Require build with virtualenv support #149

Closed
wants to merge 1 commit into from

Conversation

takluyver
Copy link

Fixes #148 (I hope) by allowing build to use virtualenv instead of venv.

Fixes mgedmin#148 (I hope) by allowing build to use virtualenv instead of venv.
@takluyver
Copy link
Author

Not fixed yet. Failing differently, though: https://results.pre-commit.ci/run/github/5894962/1644404494.yO_juaRrSimZFO2auygsMg

['/pc/clone/ImWRUb3OSjaZduclo6JKxQ/py_env-python3/bin/python', '-m', 'build', '--sdist', '.', '--outdir', '/tmp/check-manifest-iq1ub5_6-sdist'] failed (status 1):
* Creating virtualenv isolated environment...

Traceback (most recent call last):
  File "/pc/clone/ImWRUb3OSjaZduclo6JKxQ/py_env-python3/lib/python3.8/site-packages/build/__main__.py", line 372, in main
    built = build_call(
  File "/pc/clone/ImWRUb3OSjaZduclo6JKxQ/py_env-python3/lib/python3.8/site-packages/build/__main__.py", line 202, in build_package
    out = _build(isolation, builder, outdir, distribution, config_settings, skip_dependency_check)
  File "/pc/clone/ImWRUb3OSjaZduclo6JKxQ/py_env-python3/lib/python3.8/site-packages/build/__main__.py", line 140, in _build
    return _build_in_isolated_env(builder, outdir, distribution, config_settings)
  File "/pc/clone/ImWRUb3OSjaZduclo6JKxQ/py_env-python3/lib/python3.8/site-packages/build/__main__.py", line 104, in _build_in_isolated_env
    with _IsolatedEnvBuilder() as env:
  File "/pc/clone/ImWRUb3OSjaZduclo6JKxQ/py_env-python3/lib/python3.8/site-packages/build/env.py", line 101, in __enter__
    executable, scripts_dir = _create_isolated_env_virtualenv(self._path)
  File "/pc/clone/ImWRUb3OSjaZduclo6JKxQ/py_env-python3/lib/python3.8/site-packages/build/env.py", line 224, in _create_isolated_env_virtualenv
    result = virtualenv.cli_run(cmd, setup_logging=False)
  File "/pc/clone/ImWRUb3OSjaZduclo6JKxQ/py_env-python3/lib/python3.8/site-packages/virtualenv/run/__init__.py", line 32, in cli_run
    of_session.run()
  File "/pc/clone/ImWRUb3OSjaZduclo6JKxQ/py_env-python3/lib/python3.8/site-packages/virtualenv/run/session.py", line 47, in run
    self._seed()
  File "/pc/clone/ImWRUb3OSjaZduclo6JKxQ/py_env-python3/lib/python3.8/site-packages/virtualenv/run/session.py", line 60, in _seed
    self.seeder.run(self.creator)
  File "/pc/clone/ImWRUb3OSjaZduclo6JKxQ/py_env-python3/lib/python3.8/site-packages/virtualenv/seed/embed/via_app_data/via_app_data.py", line 71, in run
    raise RuntimeError("\n".join(messages))
RuntimeError: failed to build image pip because:
Traceback (most recent call last):
  File "/pc/clone/ImWRUb3OSjaZduclo6JKxQ/py_env-python3/lib/python3.8/site-packages/virtualenv/seed/embed/via_app_data/via_app_data.py", line 56, in _install
    installer.build_image()
  File "/pc/clone/ImWRUb3OSjaZduclo6JKxQ/py_env-python3/lib/python3.8/site-packages/virtualenv/seed/embed/via_app_data/pip_install/symlink.py", line 54, in build_image
    super(SymlinkPipInstall, self).build_image()
  File "/pc/clone/ImWRUb3OSjaZduclo6JKxQ/py_env-python3/lib/python3.8/site-packages/virtualenv/seed/embed/via_app_data/pip_install/base.py", line 52, in build_image
    zip_ref.extractall(str(self._image_dir))
  File "/usr/lib/python3.8/zipfile.py", line 1647, in extractall
    self._extract_member(zipinfo, path, pwd)
  File "/usr/lib/python3.8/zipfile.py", line 1693, in _extract_member
    os.makedirs(upperdirs)
  File "/usr/lib/python3.8/os.py", line 213, in makedirs
    makedirs(head, exist_ok=exist_ok)
  File "/usr/lib/python3.8/os.py", line 223, in makedirs
    mkdir(name, mode)
PermissionError: [Errno 13] Permission denied: '/opt/virtualenv/cache/wheel/3.8/image/1/SymlinkPipInstall/pip-22.0.3-py3-none-any'

ERROR failed to build image pip because:
Traceback (most recent call last):
  File "/pc/clone/ImWRUb3OSjaZduclo6JKxQ/py_env-python3/lib/python3.8/site-packages/virtualenv/seed/embed/via_app_data/via_app_data.py", line 56, in _install
    installer.build_image()
  File "/pc/clone/ImWRUb3OSjaZduclo6JKxQ/py_env-python3/lib/python3.8/site-packages/virtualenv/seed/embed/via_app_data/pip_install/symlink.py", line 54, in build_image
    super(SymlinkPipInstall, self).build_image()
  File "/pc/clone/ImWRUb3OSjaZduclo6JKxQ/py_env-python3/lib/python3.8/site-packages/virtualenv/seed/embed/via_app_data/pip_install/base.py", line 52, in build_image
    zip_ref.extractall(str(self._image_dir))
  File "/usr/lib/python3.8/zipfile.py", line 1647, in extractall
    self._extract_member(zipinfo, path, pwd)
  File "/usr/lib/python3.8/zipfile.py", line 1693, in _extract_member
    os.makedirs(upperdirs)
  File "/usr/lib/python3.8/os.py", line 213, in makedirs
    makedirs(head, exist_ok=exist_ok)
  File "/usr/lib/python3.8/os.py", line 223, in makedirs
    mkdir(name, mode)
PermissionError: [Errno 13] Permission denied: '/opt/virtualenv/cache/wheel/3.8/image/1/SymlinkPipInstall/pip-22.0.3-py3-none-any'

@takluyver
Copy link
Author

Ugh, this is messy. I think it's because pre-commit.ci is using (or running in) a virtualenv, there are some virtualenv related environment variables set:

  VIRTUALENV_ACTIVATORS=bash
  VIRTUALENV_NO_PERIODIC_UPDATE=1
  VIRTUALENV_OVERRIDE_APP_DATA=/opt/virtualenv/cache
  VIRTUALENV_PIP=embed
  VIRTUALENV_READ_ONLY_APP_DATA=1
  VIRTUALENV_SETUPTOOLS=embed
  VIRTUALENV_SYMLINK_APP_DATA=1
  VIRTUALENV_WHEEL=embed
  VIRTUAL_ENV=/pc/clone/O7LOQoQeQ9yWRgFEoWOzSA/py_env-python3

It seems that when build tries to use virtualenv, it picks up some of them but not all. Specifically, it seems to notice VIRTUALENV_OVERRIDE_APP_DATA but not VIRTUALENV_READ_ONLY_APP_DATA.

My best guess at the moment is that this is because build is importing virtualenv and calling it as a Python function, rather than running it in a subprocess - some bit of application-ness may not be getting set up correctly. But I can't see exactly what, and I might be on the wrong path. 😕

@takluyver takluyver closed this Feb 9, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Fails on pre-commit.ci - missing ensurepip
1 participant