Repository: pypa/build
Pull request #527 (2022-10-26 15:47:21)

ci: move to final release of 3.11
It's out now.


henryiii: Is Python 3.11 triggering it's own deprecation warning on Windows?

```pytb
Traceback (most recent call last):
  File "D:\a\build\build\.tox\py311\Lib\site-packages\build\__main__.py", line 373, in main
    built = build_call(
            ^^^^^^^^^^^
  File "D:\a\build\build\.tox\py311\Lib\site-packages\build\__main__.py", line 233, in build_package_via_sdist
    sdist = _build(isolation, builder, outdir, 'sdist', config_settings, skip_dependency_check)
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "D:\a\build\build\.tox\py311\Lib\site-packages\build\__main__.py", line 143, in _build
    return _build_in_isolated_env(builder, outdir, distribution, config_settings)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "D:\a\build\build\.tox\py311\Lib\site-packages\build\__main__.py", line 107, in _build_in_isolated_env
    with _IsolatedEnvBuilder() as env:
  File "D:\a\build\build\.tox\py311\Lib\site-packages\build\env.py", line 103, in __enter__
    executable, scripts_dir = _create_isolated_env_venv(self._path)
                              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "D:\a\build\build\.tox\py311\Lib\site-packages\build\env.py", line 265, in _create_isolated_env_venv
    venv.EnvBuilder(with_pip=True, symlinks=symlinks).create(path)
  File "C:\hostedtoolcache\windows\Python\3.11.0\x64\Lib\venv\__init__.py", line 74, in create
    self.setup_python(context)
  File "C:\hostedtoolcache\windows\Python\3.11.0\x64\Lib\venv\__init__.py", line 321, in setup_python
    copier(src, os.path.join(binpath, suffix))
  File "C:\hostedtoolcache\windows\Python\3.11.0\x64\Lib\venv\__init__.py", line 257, in symlink_or_copy
    if sysconfig.is_python_build(True) or not os.path.isfile(srcfn):
       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\hostedtoolcache\windows\Python\3.11.0\x64\Lib\sysconfig.py", line 222, in is_python_build
    warnings.warn("check_home argument is deprecated and ignored.",
DeprecationWarning: check_home argument is deprecated and ignored.

ERROR check_home argument is deprecated and ignored.
```
henryiii: We would have caught the CPython bug before release if we had Windows 3.11 testing turned on, but we didn't because of - time I guess. Now 3.11.0 has the warning bug.
nanonyme: @henryiii did you already file a bug against CPython?
henryiii: Yes, bug https://github.com/python/cpython/issues/98741, PR https://github.com/python/cpython/pull/98743, already merged, though not backported from master yet.
hugovk: Also add 3.10 and 3.11 here?

https://github.com/pypa/build/blob/b1acadc25702fe055cc7434d16ed2a0d766f094d/pyproject.toml#L60-L63

Patch:
diff --git a/CHANGELOG.rst b/CHANGELOG.rst
index 8e9f768..aded137 100644
--- a/CHANGELOG.rst
+++ b/CHANGELOG.rst
@@ -6,10 +6,28 @@ Changelog
 Unreleased
 ==========
 
+- Hide a Python 3.11.0 unavoidable warning with venv (`PR #527`_)
+
 - Fix infinite recursion error in ``check_dependency`` with circular
   dependencies (`PR #512`_, Fixes `#511`_)
 
+- Only import colorama on Windows (`PR #494`_, Fixes `#493`_)
+
+- Flush output more often to reduce interleaved output (`PR #494`_)
+
+- Small API cleanup, like better ``__all__`` and srcdir being read only. (`PR #477`_)
+
+- Only use ``importlib_metadata`` when needed (`PR #401`_)
+
+- Clarify in printout when build dependencies are being installed (`PR #514`_)
+
+.. _PR #401: https://github.com/pypa/build/pull/401
+.. _PR #477: https://github.com/pypa/build/pull/477
+.. _PR #494: https://github.com/pypa/build/pull/494
 .. _PR #512: https://github.com/pypa/build/pull/512
+.. _PR #514: https://github.com/pypa/build/pull/514
+.. _PR #527: https://github.com/pypa/build/pull/527
+.. _#493: https://github.com/pypa/build/issues/493
 .. _#511: https://github.com/pypa/build/issues/511
 
 
diff --git a/pyproject.toml b/pyproject.toml
index baafe0a..a4f7f4d 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -39,6 +39,7 @@ markers = [
 filterwarnings = [
   "error",
   "ignore:path is deprecated.:DeprecationWarning",
+  "ignore:The --rsyncdir command line argument and rsyncdirs config variable are deprecated.:DeprecationWarning",
 ]
 
 [tool.mypy]
diff --git a/src/build/env.py b/src/build/env.py
index 101aadd..b4a90a9 100644
--- a/src/build/env.py
+++ b/src/build/env.py
@@ -11,6 +11,7 @@ import subprocess
 import sys
 import sysconfig
 import tempfile
+import warnings
 
 from types import TracebackType
 from typing import Callable, Collection, List, Optional, Tuple, Type
@@ -262,7 +263,10 @@ def _create_isolated_env_venv(path: str) -> Tuple[str, str]:
 
     symlinks = _fs_supports_symlink()
     try:
-        venv.EnvBuilder(with_pip=True, symlinks=symlinks).create(path)
+        with warnings.catch_warnings():
+            if sys.version_info[:3] == (3, 11, 0):
+                warnings.filterwarnings('ignore', 'check_home argument is deprecated and ignored.', DeprecationWarning)
+            venv.EnvBuilder(with_pip=True, symlinks=symlinks).create(path)
     except subprocess.CalledProcessError as exc:
         raise build.FailedProcessError(exc, 'Failed to create venv. Maybe try installing virtualenv.') from None
 


Test patch:
diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml
index 1dec886..21e1321 100644
--- a/.github/workflows/test.yml
+++ b/.github/workflows/test.yml
@@ -36,7 +36,7 @@ jobs:
           - "pypy-3.7"
           - "pypy-3.8"
           - "pypy-3.9"
-          - "3.11-dev"
+          - "3.11"
           - "3.10"
           - "3.9"
           - "3.8"
@@ -45,9 +45,6 @@ jobs:
         tox-target:
           - "tox"
           - "min"
-        exclude:
-          - { py: "3.11-dev", os: macos }
-          - { py: "3.11-dev", os: windows }
 
     steps:
       - uses: actions/checkout@v3
diff --git a/tests/test_env.py b/tests/test_env.py
index 7f683c4..f6f381a 100644
--- a/tests/test_env.py
+++ b/tests/test_env.py
@@ -119,8 +119,8 @@ def test_isolated_env_log(mocker, caplog, package_test_flit):
     if sys.version_info >= (3, 8):  # stacklevel
         assert [(record.lineno) for record in caplog.records] == [
             frameinfo.lineno + 1,
-            frameinfo.lineno - 7,
-            frameinfo.lineno + 84,
+            frameinfo.lineno - 6,
+            frameinfo.lineno + 85,
         ]
 
 
diff --git a/tests/test_projectbuilder.py b/tests/test_projectbuilder.py
index 170ee73..57ff9f9 100644
--- a/tests/test_projectbuilder.py
+++ b/tests/test_projectbuilder.py
@@ -576,6 +576,7 @@ def mock_tomli_not_available(mocker):
         importlib.reload(build)
 
 
+@pytest.mark.skipif(sys.version_info >= (3, 11), reason='No need to test old toml support on 3.11+')
 def test_toml_instead_of_tomli(mocker, mock_tomli_not_available, tmp_dir, package_test_flit):
     mocker.patch('pep517.wrappers.Pep517HookCaller', autospec=True)
 
@@ -609,7 +610,7 @@ def test_log(mocker, caplog, package_test_flit):
         ('INFO', 'something'),
     ]
     if sys.version_info >= (3, 8):  # stacklevel
-        assert caplog.records[-1].lineno == 601
+        assert caplog.records[-1].lineno == 602
 
 
 @pytest.mark.parametrize(