From f6ffda93964dcaa47c378b0b562afcaf6d0bfeab Mon Sep 17 00:00:00 2001
From: Henry Schreiner <henryschreineriii@gmail.com>
Date: Fri, 26 Mar 2021 09:52:05 -0400
Subject: [PATCH] setup.cfg: require minimum versions of dependencies
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

This fixes issues where an old version of requirements are cached on a
users system, causing build to break on install. Testing by manually
loading old versions of packages in tox.

Co-authored-by: Bernát Gábor <gaborjbernat@gmail.com>
Co-authored-by: layday <layday@protonmail.com>
---
 .github/workflows/check.yml |  3 +++
 CHANGELOG.rst               |  7 +++++--
 setup.cfg                   | 10 +++++-----
 tests/constraints.txt       |  6 ++++++
 tox.ini                     |  9 ++++++++-
 5 files changed, 27 insertions(+), 8 deletions(-)
 create mode 100644 tests/constraints.txt

diff --git a/.github/workflows/check.yml b/.github/workflows/check.yml
index be799b5ec..11bd5b005 100644
--- a/.github/workflows/check.yml
+++ b/.github/workflows/check.yml
@@ -86,6 +86,9 @@ jobs:
       - name: Run test suite via wheel
         run: tox -e ${{env.BASE}}-wheel --skip-pkg-install
 
+      - name: Run minimum version test
+        run: tox -e ${{env.BASE}}-min
+
       - name: Rename coverage report file
         run: |
           import os; os.rename('.tox/coverage.{}.xml'.format(os.environ['BASE']), '.tox/coverage.xml')
diff --git a/CHANGELOG.rst b/CHANGELOG.rst
index f025405e7..8e4557253 100644
--- a/CHANGELOG.rst
+++ b/CHANGELOG.rst
@@ -3,12 +3,15 @@ Changelog
 +++++++++
 
 
-0.3.2 (XX-XX-2021)
-==================
+Unreleased
+==========
 
 - Validate that the supplied source directory is valid (`PR #260`_, Fixes `#259`_)
+- Set and test minimum versions of build's runtime dependencies (`PR #267`_, Fixes `#263`_)
 
+.. _PR #267: https://github.com/pypa/build/pull/260
 .. _PR #260: https://github.com/pypa/build/pull/260
+.. _#263: https://github.com/pypa/build/issues/259
 .. _#259: https://github.com/pypa/build/issues/259
 
 
diff --git a/setup.cfg b/setup.cfg
index e14e3b637..f3831d6cc 100644
--- a/setup.cfg
+++ b/setup.cfg
@@ -27,11 +27,11 @@ project_urls =
 [options]
 packages = find:
 install_requires =
-    packaging
-    pep517>=0.9
-    toml
-    importlib-metadata;python_version < "3.8"
-    typing;python_version<"3"
+    packaging>=19.0
+    pep517>=0.9.1
+    toml>=0.10.0
+    importlib-metadata>=0.22;python_version < "3.8"
+    typing>=3.5.2;python_version < "3"
     virtualenv>=20.0.35;python_version < "3"
 python_requires = >=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*
 package_dir =
diff --git a/tests/constraints.txt b/tests/constraints.txt
new file mode 100644
index 000000000..5712fd38f
--- /dev/null
+++ b/tests/constraints.txt
@@ -0,0 +1,6 @@
+importlib-metadata==0.22;python_version < "3.8"
+packaging==19.0
+pep517==0.9.1
+toml==0.10.0
+typing==3.5.2.2;python_version < "3"
+virtualenv==20.0.35;python_version < "3"
diff --git a/tox.ini b/tox.ini
index ed813f61a..a51665ec5 100644
--- a/tox.ini
+++ b/tox.ini
@@ -3,7 +3,7 @@ envlist =
     fix
     type
     docs
-    {py39, py38, py37, py36, py35, py27, pypy3, pypy2}{, -path, -sdist, -wheel}
+    {py39, py38, py37, py36, py35, py27, pypy3, pypy2}{, -path, -sdist, -wheel, -min}
 isolated_build = true
 skip_missing_interpreters = true
 minversion = 3.14
@@ -55,6 +55,13 @@ commands =
     mypy --python-version 3.5 src/build
     mypy --python-version 2.7 src/build
 
+[testenv:{py39, py38, py37, py36, py35, py27, pypy3, pypy2}-min]
+description = check minimum versions required of all dependencies
+skip_install = true
+commands =
+    pip install .[test] -c tests/constraints.txt
+    pytest -rsx tests {posargs:-n auto}
+
 [testenv:docs]
 description = build documentations
 basepython = python3.8