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

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

Closed
hroncok opened this issue Nov 28, 2023 · 7 comments · Fixed by #2673
Closed
Labels

Comments

@hroncok
Copy link
Contributor

hroncok commented Nov 28, 2023

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 #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:

  • OS: Fedora Linux 37 or 40
  • pip list of the host python where virtualenv is installed:
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 hroncok added the bug label Nov 28, 2023
@hroncok
Copy link
Contributor Author

hroncok commented Nov 28, 2023

The related Python 3.13 change is python/cpython#108125

@hroncok
Copy link
Contributor Author

hroncok commented Nov 28, 2023

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?

@hroncok hroncok changed the title tests/unit/create/test_creator.py::test_create_no_seed fails on Python 3.13 tests/unit/create/test_creator.py::test_create_no_seed --creator venv fails on Python 3.13 Nov 28, 2023
@gaborbernat
Copy link
Contributor

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
Copy link
Contributor Author

hroncok commented Nov 28, 2023

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
Copy link
Contributor Author

hroncok commented Nov 28, 2023

86deb12

@gaborbernat
Copy link
Contributor

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 added a commit to hroncok/virtualenv that referenced this issue Nov 29, 2023
hroncok added a commit to hroncok/virtualenv that referenced this issue Nov 29, 2023
…venv

Since Python 3.13, the .gitignore file is created by venv:
python/cpython#108125

Fixes pypa#2670
@hroncok
Copy link
Contributor Author

hroncok commented Nov 29, 2023

I started by #2672

The files only differ by the comment.

hroncok added a commit to hroncok/virtualenv that referenced this issue Nov 29, 2023
…venv

Since Python 3.13, the .gitignore file is created by venv:
python/cpython#108125

Fixes pypa#2670
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
2 participants