Repository: wntrblm/nox (language: python)

Issue:
'virtualenv.version' has no attribute 'version' in test_virtualenv.py
### Current Behavior

running the tests for 2023.4.22, I get this error:
```
______________________________________________________________ ERROR collecting tests/test_virtualenv.py ______________________________________________________________
tests/test_virtualenv.py:35: in <module>
    VIRTUALENV_VERSION = virtualenv.version.version
E   AttributeError: module 'virtualenv.version' has no attribute 'version'
```

virtualenv.version doesn't have 'version', but does have '\_\_version\_\_'

### Expected Behavior

_No response_

### Steps To Reproduce

```python
$ /sw/bin/python3.10
Python 3.10.4 (main, Feb 18 2023, 04:48:29) [Clang 11.0.0 (clang-1100.0.33.17)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import virtualenv
>>> print(virtualenv.version.version)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
AttributeError: module 'virtualenv.version' has no attribute 'version'
>>> print(virtualenv.version.__version__)
20.13.0
>>> 
```

### Environment

```Markdown
- OS: macOS 10.14.6
- Python: 3.8 and 3.10
- Nox: 2023.4.22
```


### Anything else?

_No response_


Discussion / hints:
That seem fine in main, though we shouldn't be getting the version like that, we should be using `importlib.metadata.version`.

Fix patch:
diff --git a/nox/tox_to_nox.py b/nox/tox_to_nox.py
index 37e184f2..36df7ed7 100644
--- a/nox/tox_to_nox.py
+++ b/nox/tox_to_nox.py
@@ -20,6 +20,7 @@
 import os
 import pkgutil
 import re
+import sys
 from configparser import ConfigParser
 from pathlib import Path
 from subprocess import check_output
@@ -27,9 +28,15 @@
 
 import jinja2
 import tox.config
-from tox import __version__ as TOX_VERSION
 
-TOX4 = TOX_VERSION[0] == "4"
+if sys.version_info < (3, 8):
+    import importlib_metadata as metadata
+else:
+    from importlib import metadata
+
+TOX_VERSION = metadata.version("tox")
+
+TOX4 = int(TOX_VERSION.split(".")[0]) >= 4
 
 if TOX4:
     _TEMPLATE = jinja2.Template(


Test patch:
diff --git a/tests/test_tox_to_nox.py b/tests/test_tox_to_nox.py
index 11815b79..50ab4f25 100644
--- a/tests/test_tox_to_nox.py
+++ b/tests/test_tox_to_nox.py
@@ -18,11 +18,10 @@
 import textwrap
 
 import pytest
-from tox import __version__ as TOX_VERSION
 
 tox_to_nox = pytest.importorskip("nox.tox_to_nox")
 
-TOX4 = TOX_VERSION[0] == "4"
+TOX4 = tox_to_nox.TOX4
 PYTHON_VERSION = f"{sys.version_info.major}.{sys.version_info.minor}"
 PYTHON_VERSION_NODOT = PYTHON_VERSION.replace(".", "")
 
diff --git a/tests/test_virtualenv.py b/tests/test_virtualenv.py
index b5cf49a9..d3973b2a 100644
--- a/tests/test_virtualenv.py
+++ b/tests/test_virtualenv.py
@@ -24,16 +24,20 @@
 from unittest import mock
 
 import pytest
-import virtualenv
 from packaging import version
 
 import nox.virtualenv
 
+if sys.version_info < (3, 8):
+    import importlib_metadata as metadata
+else:
+    from importlib import metadata
+
 IS_WINDOWS = nox.virtualenv._SYSTEM == "Windows"
 HAS_CONDA = shutil.which("conda") is not None
 HAS_UV = shutil.which("uv") is not None
 RAISE_ERROR = "RAISE_ERROR"
-VIRTUALENV_VERSION = virtualenv.__version__
+VIRTUALENV_VERSION = metadata.version("virtualenv")
 
 
 class TextProcessResult(NamedTuple):