Repository: pypa/pip

Issue:
setup_requires with python_version conflicts with identical pyproject.toml build-system.requires
### Description

If I create a new directory with two files, setup.cfg
```ini
[options]
setup_requires=
    cython >= 0.26, <0.27; python_version == "3.2"
    cython >= 0.29, <3.0; python_version >= "3.3"
```
and pyproject.toml
```toml
[build-system]
requires = [
    "setuptools", "wheel",
    'cython >= 0.26, < 0.27; python_version == "3.2"',
    'cython >= 0.29, < 3.0; python_version >= "3.3"'
]
build-backend = "setuptools.build_meta"
```
then run `pip wheel .` in that directory, I expect pip to be able to install the build requirements without issue, since the two lists are identical.  Instead, I get `ERROR: Some build dependencies for file:///tmp/pip-test conflict with the backend dependencies: cython==0.29.27 is incompatible with cython<0.27,>=0.26; python_version == "3.2".`

### Expected behavior

If I delete the `python_version == "3.2"` lines (which I expect to be irrelevant since I haven't had a python 3.2 install in over a decade), I get
```
pip3.9 wheel .
Looking in links: /usr/share/python-wheels
Processing /tmp/pip-test
  Installing build dependencies ... done
  Getting requirements to build wheel ... done
  Preparing metadata (pyproject.toml) ... done
Building wheels for collected packages: UNKNOWN
  Building wheel for UNKNOWN (pyproject.toml) ... done
  Created wheel for UNKNOWN: filename=UNKNOWN-0.0.0-py3-none-any.whl size=955 sha256=65847eee8c84ea91b423c7b48fdd4406883d9f5c2c59ea8592342e9645fd9f64
  Stored in directory: /home/Daniel/.cache/pip/wheels/d0/70/2e/359a080dcdc25044fcb688184e51cb13e8f616d18dab4c4843
Successfully built UNKNOWN
```

### pip version

21.3.1

### Python version

3.9.10, but the problem shows up with python 3.5-3.10 (not 2.7)

### OS

Cygwin (original example was on Windows and Linux)

### How to Reproduce

```bash
rm -rf /tmp/pip-test
mkdir -p /tmp/pip-test
cd /tmp/pip-test
cat >setup.cfg <<EOF
[options]
setup_requires=
    cython >= 0.26, <0.27; python_version == "3.2"
    cython >= 0.29, <3.0; python_version >= "3.3"
EOF
cat >pyproject.toml <<EOF
[build-system]
requires = [
    "setuptools", "wheel",
    'cython >= 0.26, < 0.27; python_version == "3.2"',
    'cython >= 0.29, < 3.0; python_version >= "3.3"'
]
build-backend = "setuptools.build_meta"
EOF
pip3.9 wheel .
```

### Output

```sh-session
Looking in links: /usr/share/python-wheels
Processing /tmp/pip-test
  Installing build dependencies ... done
  Getting requirements to build wheel ... done
ERROR: Some build dependencies for file:///tmp/pip-test conflict with the backend dependencies: cython==0.29.27 is incompatible with cython<0.27,>=0.26; python_version == "3.2".
```


### Code of Conduct

- [X] I agree to follow the [PSF Code of Conduct](https://www.python.org/psf/conduct/).


Discussion:
This is possibly due to setup_requires and how setuptools handles setup_requires. 
> This is possibly due to setup_requires and how setuptools handles setup_requires.

In that case, I would expect `python -c "from setuptools import setup; setup()" sdist bdist_wheel` to fail in the same way.  Instead I get warnings about missing metadata and a pair of distribution files in the dist/ directory (with Cython 0.29.25 installed).

EDIT: Perhaps more relevant to `pip`: `python -m build` also succeeds.

Resolving patch:
diff --git a/src/pip/_internal/build_env.py b/src/pip/_internal/build_env.py
--- a/src/pip/_internal/build_env.py
+++ b/src/pip/_internal/build_env.py
@@ -175,6 +175,8 @@ def check_requirements(
             )
             for req_str in reqs:
                 req = Requirement(req_str)
+                if req.marker is not None and not req.marker.evaluate():
+                    continue  # FIXME: Consider extras?
                 dist = env.get_distribution(req.name)
                 if not dist:
                     missing.add(req_str)


Test patch:
diff --git a/tests/functional/test_build_env.py b/tests/functional/test_build_env.py
--- a/tests/functional/test_build_env.py
+++ b/tests/functional/test_build_env.py
@@ -165,6 +165,25 @@ def test_build_env_requirements_check(script: PipTestEnvironment) -> None:
         """,
     )
 
+    run_with_build_env(
+        script,
+        """
+        build_env.install_requirements(
+            finder,
+            ["bar==3.0"],
+            "normal",
+            kind="installing bar in normal",
+        )
+        r = build_env.check_requirements(
+            [
+                "bar==2.0; python_version < '3.0'",
+                "bar==3.0; python_version >= '3.0'",
+            ],
+        )
+        assert r == (set(), set()), repr(r)
+        """,
+    )
+
 
 def test_build_env_overlay_prefix_has_priority(script: PipTestEnvironment) -> None:
     create_basic_wheel_for_package(script, "pkg", "2.0")