From 611746edc91e202ddd92f97e560d670054458f7b Mon Sep 17 00:00:00 2001 From: "Paul J. Dorn" Date: Thu, 7 Dec 2023 20:02:47 +0100 Subject: [PATCH] CI: check entry points Fixes: fdd23e82926d7d10ec4a8e65e42b5184a4ee20ce --- .github/workflows/tox.yml | 1 + appveyor.yml | 5 +++++ pyproject.toml | 8 ++++++++ requirements_dev.txt | 5 +++++ tox.ini | 9 +++++++-- 5 files changed, 26 insertions(+), 2 deletions(-) diff --git a/.github/workflows/tox.yml b/.github/workflows/tox.yml index c188a4dba..053b8d920 100644 --- a/.github/workflows/tox.yml +++ b/.github/workflows/tox.yml @@ -28,4 +28,5 @@ jobs: python -m pip install --upgrade pip python -m pip install tox - run: tox -e run-module + - run: tox -e run-entrypoint - run: tox -e py diff --git a/appveyor.yml b/appveyor.yml index 5eb48e9cd..85feb4dc3 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -7,6 +7,11 @@ environment: PYTHON: "C:\\Python38-x64" - TOXENV: pycodestyle PYTHON: "C:\\Python38-x64" + # Windows cannot even import the module when they unconditionally import, see below. + #- TOXENV: run-module + # PYTHON: "C:\\Python38-x64" + #- TOXENV: run-entrypoint + # PYTHON: "C:\\Python38-x64" # Windows is not ready for testing!!! # Python's fcntl, grp, pwd, os.geteuid(), and socket.AF_UNIX are all Unix-only. #- TOXENV: py35 diff --git a/pyproject.toml b/pyproject.toml index ffe20515a..3ef076cc7 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -62,6 +62,14 @@ testing = [ "pytest-cov", ] +[project.scripts] +# duplicates "python -m gunicorn" handling in __main__.py +gunicorn = "gunicorn.app.wsgiapp:run" + +# note the quotes around "paste.server_runner" to escape the dot +[project.entry-points."paste.server_runner"] +main = "gunicorn.app.pasterapp:serve" + [tool.pytest.ini_options] # # can override these: python -m pytest --override-ini="addopts=" norecursedirs = ["examples", "lib", "local", "src"] diff --git a/requirements_dev.txt b/requirements_dev.txt index a36971d58..1d8c01291 100644 --- a/requirements_dev.txt +++ b/requirements_dev.txt @@ -1,4 +1,9 @@ -r requirements_test.txt +# setuptools v68.0 fails hard on invalid pyproject.toml +# which a developer would want to know +# otherwise, oldest known-working version is 61.2 +setuptools>=68.0 + sphinx sphinx_rtd_theme diff --git a/tox.ini b/tox.ini index 83ce3374e..b299a5a46 100644 --- a/tox.ini +++ b/tox.ini @@ -1,5 +1,5 @@ [tox] -envlist = py{37,38,39,310,311,py3}, lint, docs-lint, pycodestyle, run-module +envlist = py{37,38,39,310,311,py3}, lint, docs-lint, pycodestyle, run-entrypoint, run-module skipsdist = false ; Can't set skipsdist and use_develop in tox v4 to true due to https://github.com/tox-dev/tox/issues/2730 @@ -9,8 +9,13 @@ commands = pytest --cov=gunicorn {posargs} deps = -rrequirements_test.txt +[testenv:run-entrypoint] +# entry point: console script (provided by setuptools from pyproject.toml) +commands = python -c 'import subprocess; cmd_out = subprocess.check_output(["gunicorn", "--version"])[:79].decode("utf-8", errors="replace"); print(cmd_out); assert cmd_out.startswith("gunicorn ")' + [testenv:run-module] -commands = python3 -m gunicorn --version +# runpy (provided by module.__main__) +commands = python -c 'import sys,subprocess; cmd_out = subprocess.check_output([sys.executable, "-m", "gunicorn", "--version"])[:79].decode("utf-8", errors="replace"); print(cmd_out); assert cmd_out.startswith("gunicorn ")' [testenv:lint] commands =