Repository: pypa/build
Pull request #402 (2021-11-05 10:24:44)

Remove py workaround
https://github.com/pytest-dev/py/issues/273 has now been released so we can remove the workaround.

layday: I don't want to re-run an untold number of jobs because of one flake.  Can we force merge this?
hugovk: (Aside: GitHub will soon allow re-running single jobs: https://github.com/github/roadmap/issues/271)

Patch:
diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml
index 1637348..e367003 100644
--- a/.pre-commit-config.yaml
+++ b/.pre-commit-config.yaml
@@ -18,20 +18,20 @@ repos:
   - id: trailing-whitespace
   - id: double-quote-string-fixer
 - repo: https://github.com/asottile/pyupgrade
-  rev: v2.29.0
+  rev: v2.29.1
   hooks:
   - id: pyupgrade
     args: ["--py36-plus"]
 - repo: https://github.com/psf/black
-  rev: 21.10b0
+  rev: 21.11b1
   hooks:
   - id: black
 - repo: https://github.com/PyCQA/isort
-  rev: 5.9.3
+  rev: 5.10.1
   hooks:
   - id: isort
 - repo: https://github.com/asottile/setup-cfg-fmt
-  rev: v1.19.0
+  rev: v1.20.0
   hooks:
   - id: setup-cfg-fmt
 - repo: https://github.com/PyCQA/flake8
diff --git a/CHANGELOG.rst b/CHANGELOG.rst
index df1b447..be92d0b 100644
--- a/CHANGELOG.rst
+++ b/CHANGELOG.rst
@@ -29,7 +29,7 @@ Unreleased
 0.6.0.post1 (05-08-2021)
 ========================
 
-- Fix compability with Python 3.6 and 3.7 (`PR #339`_, Fixes `#338`_)
+- Fix compatibility with Python 3.6 and 3.7 (`PR #339`_, Fixes `#338`_)
 
 .. _PR #339: https://github.com/pypa/build/pull/339
 .. _#338: https://github.com/pypa/build/issues/338
@@ -40,7 +40,7 @@ Unreleased
 ==================
 
 - Improved output (`PR #333`_, Fixes `#142`_)
-- The CLI now honnors `NO_COLOR`_ (`PR #333`_)
+- The CLI now honors `NO_COLOR`_ (`PR #333`_)
 - The CLI can now be forced to colorize the output by setting the ``FORCE_COLOR`` environment variable (`PR #335`_)
 - Added logging to ``build`` and ``build.env`` (`PR #333`_)
 - Switch to a TOML v1 compliant parser (`PR #336`_, Fixes `#308`_)
@@ -126,7 +126,7 @@ Breaking Changes
 ----------------
 
 - As a side-effect of `PR #260`_, projects not containing either a ``pyproject.toml`` or ``setup.py`` will be reported as invalid. This affects projects specifying only a ``setup.cfg``, such projects are recommended to add a ``pyproject.toml``. The new behavior is on par with what pip currently does, so if you are affected by this, your project should not be pip installable.
-- The ``--skip-depencencies`` option has been renamed to ``--skip-dependency-check`` (`PR #297`_)
+- The ``--skip-dependencies`` option has been renamed to ``--skip-dependency-check`` (`PR #297`_)
 - The ``skip_dependencies`` argument of ``build.__main__.build_package`` has been renamed to ``skip_dependency_check`` (`PR #297`_)
 - ``build.ConfigSettings`` has been renamed to ``build.ConfigSettingsType`` (`PR #298`_)
 - ``build.ProjectBuilder.build_dependencies`` to ``build.ProjectBuilder.build_system_requires`` (`PR #284`_, Fixes `#182`_)
@@ -229,7 +229,7 @@ Breaking changes
 - Added --version/-V option to the CLI
 - Added support for Python 3.9
 - Added py.typed marker
-- Various miscelaneous fixes in the virtual environment creation
+- Various miscellaneous fixes in the virtual environment creation
 - Many general improvements in the documentation
 - Documentation moved to the furo theme
 - Updated the CoC to the PSF CoC, which PyPA has adopted
diff --git a/docs/installation.rst b/docs/installation.rst
index e57a6c5..e098c61 100644
--- a/docs/installation.rst
+++ b/docs/installation.rst
@@ -18,7 +18,7 @@ of the following keys:
 
 .. tip::
    If you prefer, or are already using virtualenv_ in your workflow, you can
-   install ``build`` with the optional ``virtualenv`` depedency:
+   install ``build`` with the optional ``virtualenv`` dependency:
 
    .. code-block:: sh
 
@@ -38,7 +38,7 @@ dependencies. The ``--skip-dependency-check`` flag should be used in this
 case.
 
 We have a dependency on tomli_, but toml_ can be used instead, which may make
-bootstraping easier.
+bootstrapping easier.
 
 
 Compatibility
diff --git a/docs/mission.rst b/docs/mission.rst
index 90cd50b..f83f60e 100644
--- a/docs/mission.rst
+++ b/docs/mission.rst
@@ -5,7 +5,7 @@ Mission Statement
 In the Python ecosystem, the build system tools and the package management
 are very intertwined. While it might be useful for user to be able to access
 all this capabilities in a single project (such as pip_), there are several
-usecases where this is not desirable. The main being custom environments
+use cases where this is not desirable. The main being custom environments
 (outside PyPI_) or situations where the user does its own package management,
 such as Linux distributions.
 
diff --git a/pyproject.toml b/pyproject.toml
index 62597b3..a193fb1 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -1,11 +1,56 @@
 [build-system]
-requires = ['setuptools >= 40.8.0', 'wheel']
-build-backend = 'setuptools.build_meta'
+requires = ["setuptools >= 40.8.0", "wheel"]
+build-backend = "setuptools.build_meta"
+
+[tool.coverage.run]
+source = [
+  "build",
+  "tests",
+]
+
+[tool.coverage.report]
+exclude_lines = [
+  '\#\s*pragma: no cover',
+  '^\s*raise NotImplementedError\b',
+]
+
+[tool.coverage.paths]
+build = [
+  "src",
+  "*/site-packages",
+  '*\site-packages',
+]
+
+[tool.coverage.html]
+show_contexts = true
+
+[tool.pytest.ini_options]
+addopts = "--strict-config --strict-markers"
+xfail_strict = true
+junit_family = "xunit2"
+norecursedirs = "tests/integration/*"
+markers = [
+  "isolated",
+]
+filterwarnings = [
+  "error",
+]
+
+[tool.mypy]
+strict = true
+
+[[tool.mypy.overrides]]
+module = [
+  "colorama",   # Optional dependency
+  "pep517.*",   # Untyped
+  "virtualenv", # Optional dependency
+]
+ignore_missing_imports = true
 
 [tool.black]
 line-length = 127
 skip-string-normalization = true
-target-version = ['py39', 'py38', 'py37', 'py36']
+target-version = ["py39", "py38", "py37", "py36"]
 
 [tool.isort]
 profile = "black"
diff --git a/setup.cfg b/setup.cfg
index dfcbb74..1621a4a 100644
--- a/setup.cfg
+++ b/setup.cfg
@@ -28,8 +28,8 @@ packages = find:
 install_requires =
     packaging>=19.0
     pep517>=0.9.1
-    tomli>=1.0.0 # toml can be used instead -- in case it makes bootstraping easier
-    colorama;os_name == "nt" # not actually a runtime dependency, only supplied as there is not "recomended dependency" support
+    tomli>=1.0.0 # toml can be used instead -- in case it makes bootstrapping easier
+    colorama;os_name == "nt" # not actually a runtime dependency, only supplied as there is not "recommended dependency" support
     importlib-metadata>=0.22;python_version < "3.8"
 python_requires = >=3.6
 package_dir =
@@ -53,7 +53,7 @@ docs =
 test =
     filelock>=3
     pytest>=6.2.4
-    pytest-cov>=2
+    pytest-cov>=2.12
     pytest-mock>=2
     pytest-rerunfailures>=9.1
     pytest-xdist>=1.34
@@ -71,42 +71,3 @@ virtualenv =
 [options.package_data]
 build =
     py.typed
-
-[tool:pytest]
-addopts = --strict-config --strict-markers
-xfail_strict = True
-junit_family = xunit2
-norecursedirs = tests/integration/*
-markers =
-    isolated
-filterwarnings = error
-
-[flake8]
-max-line-length = 127
-max-complexity = 10
-extend-ignore = E203
-
-[mypy]
-ignore_missing_imports = True
-strict = True
-
-[coverage:run]
-source = build, tests
-omit =
-    setup.py
-    *bin/pyproject-build
-    *bin\pyproject-build.exe
-
-[coverage:report]
-exclude_lines =
-    \#\s*pragma: no cover
-    ^\s*raise NotImplementedError\b
-
-[coverage:paths]
-source =
-    src
-    */site-packages
-    *\site-packages
-
-[coverage:html]
-show_contexts = true
diff --git a/src/build/__init__.py b/src/build/__init__.py
index 1078572..41adff7 100644
--- a/src/build/__init__.py
+++ b/src/build/__init__.py
@@ -459,7 +459,7 @@ class ProjectBuilder:
                     sys.exc_info(),
                 )
             except subprocess.CalledProcessError as exception:
-                raise BuildBackendException(exception, f'Backend subproccess exited when trying to invoke {hook}')
+                raise BuildBackendException(exception, f'Backend subprocess exited when trying to invoke {hook}')
             except Exception as exception:
                 raise BuildBackendException(exception, exc_info=sys.exc_info())
 
diff --git a/src/build/env.py b/src/build/env.py
index e6d22b5..80c42d8 100644
--- a/src/build/env.py
+++ b/src/build/env.py
@@ -92,7 +92,12 @@ class IsolatedEnvBuilder:
 
         :return: The isolated build environment
         """
-        self._path = tempfile.mkdtemp(prefix='build-env-')
+        # Call ``realpath`` to prevent spurious warning from being emitted
+        # that the venv location has changed on Windows. The username is
+        # DOS-encoded in the output of tempfile - the location is the same
+        # but the representation of it is different, which confuses venv.
+        # Ref: https://bugs.python.org/issue46171
+        self._path = os.path.realpath(tempfile.mkdtemp(prefix='build-env-'))
         try:
             # use virtualenv when available (as it's faster than venv)
             if _should_use_virtualenv():
diff --git a/src/build/util.py b/src/build/util.py
index f8231ca..be93eee 100644
--- a/src/build/util.py
+++ b/src/build/util.py
@@ -31,11 +31,11 @@ def project_wheel_metadata(
     """
     Return the wheel metadata for a project.
 
-    Uses the ``prepare_metadata_for_build_wheel`` hook if availablable,
+    Uses the ``prepare_metadata_for_build_wheel`` hook if available,
     otherwise ``build_wheel``.
 
     :param srcdir: Project source directory
-    :param isolated: Wether or not to run invoke the backend in the current
+    :param isolated: Whether or not to run invoke the backend in the current
                      environment or to create an isolated one and invoke it
                      there.
     """
diff --git a/tox.ini b/tox.ini
index c7e8ea0..f5a11d2 100644
--- a/tox.ini
+++ b/tox.ini
@@ -28,11 +28,8 @@ setenv =
     wheel: TEST_MODE = wheel
 extras =
     test
-;TODO Remove once https://github.com/pytest-dev/py/issues/273 released.
-deps =
-     py@git+https://github.com/pytest-dev/py@master;python_version>="3.11"
 commands =
-    pytest -rsx --cov --cov-config setup.cfg \
+    pytest -rsx --cov --cov-config pyproject.toml \
       --cov-report=html:{envdir}/htmlcov --cov-context=test \
       --cov-report=xml:{toxworkdir}/coverage.{envname}.xml \
       tests {posargs:-n auto}
@@ -77,8 +74,6 @@ description = generate a DEV environment
 usedevelop = true
 deps =
     virtualenv>=20.0.34
-;TODO Remove once https://github.com/pytest-dev/py/issues/273 released.
-     py@git+https://github.com/pytest-dev/py@master;python_version>="3.11"
 
 extras =
     doc
@@ -105,3 +100,8 @@ commands =
     coverage html -d {toxworkdir}/htmlcov -i
     python -m diff_cover.diff_cover_tool --compare-branch {env:DIFF_AGAINST:origin/main} {toxworkdir}/coverage.xml
 depends = {py311, py310, py39, py38, py37, py36, pypy3}{, -path, -sdist, -wheel}
+
+[flake8]
+max-line-length = 127
+max-complexity = 10
+extend-ignore = E203


Test patch:
diff --git a/tests/constraints.txt b/tests/constraints.txt
index 3212f7a..b073bd9 100644
--- a/tests/constraints.txt
+++ b/tests/constraints.txt
@@ -1,10 +1,9 @@
-importlib-metadata==0.22;python_version < "3.8"
+importlib-metadata==0.22
 packaging==19.0
 pep517==0.9.1
+setuptools==42.0.0; python_version < "3.10"
+setuptools==56.0.0; python_version >= "3.10"
 toml==0.10.0
 tomli==1.0.0
-typing==3.5.3.0;python_version < "3"
-virtualenv==20.0.35;python_version < "3"
-setuptools==42.0.0;python_version < "3.10"
-setuptools==56.0.0;python_version >= "3.10"
+virtualenv==20.0.35
 wheel==0.36.0
diff --git a/tests/test_env.py b/tests/test_env.py
index 9b5506f..831d725 100644
--- a/tests/test_env.py
+++ b/tests/test_env.py
@@ -112,7 +112,7 @@ def test_isolated_env_log(mocker, caplog, package_test_flit):
         ('INFO', 'Installing packages in isolated environment... (something)'),
     ]
     if sys.version_info >= (3, 8):  # stacklevel
-        assert [(record.lineno) for record in caplog.records] == [105, 102, 193]
+        assert [(record.lineno) for record in caplog.records] == [105, 107, 198]
 
 
 @pytest.mark.isolated