Skip to content

Commit

Permalink
fix: always pull versions from metadata (#782)
Browse files Browse the repository at this point in the history
Signed-off-by: Henry Schreiner <henryschreineriii@gmail.com>
  • Loading branch information
henryiii committed Feb 24, 2024
1 parent c248a76 commit 55e09cd
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 6 deletions.
11 changes: 9 additions & 2 deletions nox/tox_to_nox.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,16 +20,23 @@
import os
import pkgutil
import re
import sys
from configparser import ConfigParser
from pathlib import Path
from subprocess import check_output
from typing import Any, Iterable

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(
Expand Down
3 changes: 1 addition & 2 deletions tests/test_tox_to_nox.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(".", "")

Expand Down
8 changes: 6 additions & 2 deletions tests/test_virtualenv.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down

0 comments on commit 55e09cd

Please sign in to comment.