Python virtual env on silverblue

python

#1

So, just because it puzzled me a bit. I am doing python developement, and since python is already there, I just used a virtual env. Easy peasy, on python 3, that’s one command away:

python3 -mvenv /tmp/myvenv

But on a silverblue system, it result into that:

$     python3 -mvenv /tmp/myvenv
Error: Command '['/tmp/myvenv/bin/python3', '-Im', 'ensurepip', '--upgrade', '--default-pip']' returned non-zero exit status 1.

Digging further, I run the command:

$ /tmp/myvenv/bin/python3 -Im ensurepip --upgrade --default-pip 
Traceback (most recent call last):
  File "/usr/lib64/python3.6/runpy.py", line 193, in _run_module_as_main
    "__main__", mod_spec)
  File "/usr/lib64/python3.6/runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "/usr/lib64/python3.6/ensurepip/__main__.py", line 5, in <module>
    sys.exit(ensurepip._main())
  File "/usr/lib64/python3.6/ensurepip/__init__.py", line 232, in _main
    default_pip=args.default_pip,
  File "/usr/lib64/python3.6/ensurepip/__init__.py", line 111, in _bootstrap
    new_whl = rewheel.rewheel_from_record(dr, rewheel_dir.name)
  File "/usr/lib64/python3.6/ensurepip/rewheel/__init__.py", line 75, in rewheel_from_record
    new_wheel.write(os.path.join(site_dir, f), arcname=f)
  File "/usr/lib64/python3.6/zipfile.py", line 1594, in write
    zinfo = ZipInfo.from_file(filename, arcname)
  File "/usr/lib64/python3.6/zipfile.py", line 496, in from_file
    zinfo = cls(arcname, date_time)
  File "/usr/lib64/python3.6/zipfile.py", line 338, in __init__
    raise ValueError('ZIP does not support timestamps before 1980')
ValueError: ZIP does not support timestamps before 1980

Digging even further, I found that venv try to create a wheel from installed packages, and those have a date in the past, because ostree generate reproductible images. I searched around, and stumbled on the following bug: https://www.bugs.python.org/issue34097 . I couldn’t find more information, but I am going to ask around.

So I guess for now, my advice is to use venv in a container, since the venv generate on ostree is not functional, or rather do not have pip (due to the aformentioned issue), so slightly useful for my purpose of developing.


#2

I’ve only used virtualenvs via virtualenvwrapper - does that work on Silverblue?


#3

That’s likely, since that’s a wrapper. But again, using podman to create a container can sidestep the problem, and in fact, you do not even need the venv in the first place, since that’s already in a container, you can install system wide all kind of stuff since this is isolated from the system already.


#4

See https://pagure.io/teamsilverblue/issue/21