pypa / virtualenv

Virtual Python Environment builder
https://virtualenv.pypa.io
MIT License
4.8k stars 1.03k forks source link

tests/unit/create/test_creator.py::test_create_no_seed --creator venv fails on Python 3.13 #2670

Closed hroncok closed 9 months ago

hroncok commented 9 months ago

Issue

When I try to run the tests with Python 3.13.0a2, I see the following 8 failures:

FAILED tests/unit/create/test_creator.py::test_create_no_seed[venv-venv-symlinks-global] - AssertionError: assert ['# Created b...nv.html', '*'] == ['# created b...tically', '*']
FAILED tests/unit/create/test_creator.py::test_create_no_seed[venv-venv-symlinks-isolated] - AssertionError: assert ['# Created b...nv.html', '*'] == ['# created b...tically', '*']
FAILED tests/unit/create/test_creator.py::test_create_no_seed[venv-venv-copies-isolated] - AssertionError: assert ['# Created b...nv.html', '*'] == ['# created b...tically', '*']
FAILED tests/unit/create/test_creator.py::test_create_no_seed[venv-venv-copies-global] - AssertionError: assert ['# Created b...nv.html', '*'] == ['# created b...tically', '*']
FAILED tests/unit/create/test_creator.py::test_create_no_seed[root-venv-symlinks-isolated] - AssertionError: assert ['# Created b...nv.html', '*'] == ['# created b...tically', '*']
FAILED tests/unit/create/test_creator.py::test_create_no_seed[root-venv-copies-global] - AssertionError: assert ['# Created b...nv.html', '*'] == ['# created b...tically', '*']
FAILED tests/unit/create/test_creator.py::test_create_no_seed[root-venv-symlinks-global] - AssertionError: assert ['# Created b...nv.html', '*'] == ['# created b...tically', '*']
FAILED tests/unit/create/test_creator.py::test_create_no_seed[root-venv-copies-isolated] - AssertionError: assert ['# Created b...nv.html', '*'] == ['# created b...tically', '*']

The failure is:

        git_ignore = (dest / ".gitignore").read_text(encoding="utf-8")
>       assert git_ignore.splitlines() == ["# created by virtualenv automatically", "*"]
E       AssertionError: assert ['# Created b...nv.html', '*'] == ['# created b...tically', '*']
E         At index 0 diff: '# Created by venv; see https://docs.python.org/3/library/venv.html' != '# created by virtualenv automatically'
E         Full diff:
E         - ['# created by virtualenv automatically', '*']
E         + ['# Created by venv; see https://docs.python.org/3/library/venv.html', '*']

I'd like to investigate, but I have no idea what is happening here. Looks like venv is used on Python 3.13... ?

I've tied the main branch, I've tried from https://github.com/pypa/virtualenv/pull/2669

I've tried to add:

diff --git a/src/virtualenv/seed/wheels/embed/__init__.py b/src/virtualenv/seed/wheels/embed/__init__.py
index ed6027b..09ec8cb 100644
--- a/src/virtualenv/seed/wheels/embed/__init__.py
+++ b/src/virtualenv/seed/wheels/embed/__init__.py
@@ -36,6 +36,11 @@ BUNDLE_SUPPORT = {
         "setuptools": "setuptools-69.0.2-py3-none-any.whl",
         "wheel": "wheel-0.42.0-py3-none-any.whl",
     },
+    "3.13": {
+        "pip": "pip-23.3.1-py3-none-any.whl",
+        "setuptools": "setuptools-69.0.2-py3-none-any.whl",
+        "wheel": "wheel-0.42.0-py3-none-any.whl",
+    },
 }
 MAX = "3.7"

It still fails.

To reproduce, run tox -e py313 -- -k test_create_no_seed -v.

Full output: virtualenv.txt

Environment

Provide at least:

Package                    Version
-------------------------- -------------------------------
covdefaults                2.3.0
coverage                   7.3.2
coverage-enable-subprocess 1.0
distlib                    0.3.7
filelock                   3.13.1
flaky                      3.7.0
iniconfig                  2.0.0
packaging                  23.2
pip                        23.3.1
platformdirs               4.0.0
pluggy                     1.3.0
pytest                     7.4.3
pytest-env                 1.1.3
pytest-mock                3.12.0
pytest-randomly            3.15.0
pytest-timeout             2.2.0
python-dateutil            2.8.2
setuptools                 69.0.2
six                        1.16.0
time-machine               2.13.0
virtualenv                 20.24.7.dev9+g6fbe60b.d20231128
hroncok commented 9 months ago

The related Python 3.13 change is https://github.com/python/cpython/issues/108125

hroncok commented 9 months ago

Apparently:

$ virtualenv -p python3.13 testenv --no-seed --creator venv
created virtual environment CPython3.13.0.alpha.2-64 in 122ms
  creator Venv(dest=/home/churchyard/tmp/testenv, clear=False, no_vcs_ignore=False, global=False, describe=CPython3Posix)
  activators BashActivator,CShellActivator,FishActivator,NushellActivator,PowerShellActivator,PythonActivator

$ cat testenv/.gitignore 
# Created by venv; see https://docs.python.org/3/library/venv.html
*

This either breaks the test expectation or virtualenv behavior.

Either we want the .gitignore file contents to be consistent (and hence we need to override it and/or opt-out of this feature) or we need to adjust the test to allow the venv-generated comment in it.

Which one do you prefer?

gaborbernat commented 9 months ago

Either we want the .gitignore file contents to be consistent (and hence we need to override it and/or opt-out of this feature)

We want it to be consistent. Our ignore though should run after theirs, so we should overwrite what they create?

hroncok commented 9 months ago

https://virtualenv.pypa.io/en/20.0.24/changelog.html#bugfixes-20-0-24

Do not generate/overwrite .gitignore if it already exists at destination path - by @gaborbernat. (#1862)

hroncok commented 9 months ago

86deb12e7c2ad370802505f12d8181c371b94b61

gaborbernat commented 9 months ago

Huh! I think we should probably just adjust the test and also make sure that what we generate looks like what venv generates (mostly).

hroncok commented 9 months ago

I started by https://github.com/pypa/virtualenv/pull/2672

The files only differ by the comment.