Skip to content

Commit f9e61b1

Browse files
authored
Merge pull request #3108 from pajod/patch-githubactions
restore, and from now on CI-test for entry point
2 parents b5d78e8 + 611746e commit f9e61b1

File tree

9 files changed

+49
-8
lines changed

9 files changed

+49
-8
lines changed

.github/workflows/lint.yml

+5-1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@ name: lint
22
on: [push, pull_request]
33
permissions:
44
contents: read # to fetch code (actions/checkout)
5+
env:
6+
# note that some tools care only for the name, not the value
7+
FORCE_COLOR: 1
58
jobs:
69
lint:
710
name: tox-${{ matrix.toxenv }}
@@ -14,9 +17,10 @@ jobs:
1417
steps:
1518
- uses: actions/checkout@v4
1619
- name: Using Python ${{ matrix.python-version }}
17-
uses: actions/setup-python@v4
20+
uses: actions/setup-python@v5
1821
with:
1922
python-version: ${{ matrix.python-version }}
23+
cache: pip
2024
- name: Install Dependencies
2125
run: |
2226
python -m pip install --upgrade pip

.github/workflows/tox.yml

+9-1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@ name: tox
22
on: [push, pull_request]
33
permissions:
44
contents: read # to fetch code (actions/checkout)
5+
env:
6+
# note that some tools care only for the name, not the value
7+
FORCE_COLOR: 1
58
jobs:
69
tox:
710
name: ${{ matrix.os }} / ${{ matrix.python-version }}
@@ -14,11 +17,16 @@ jobs:
1417
steps:
1518
- uses: actions/checkout@v4
1619
- name: Using Python ${{ matrix.python-version }}
17-
uses: actions/setup-python@v4
20+
uses: actions/setup-python@v5
1821
with:
1922
python-version: ${{ matrix.python-version }}
23+
cache: pip
24+
cache-dependency-path: requirements_test.txt
25+
check-latest: true
2026
- name: Install Dependencies
2127
run: |
2228
python -m pip install --upgrade pip
2329
python -m pip install tox
30+
- run: tox -e run-module
31+
- run: tox -e run-entrypoint
2432
- run: tox -e py

appveyor.yml

+5
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,11 @@ environment:
77
PYTHON: "C:\\Python38-x64"
88
- TOXENV: pycodestyle
99
PYTHON: "C:\\Python38-x64"
10+
# Windows cannot even import the module when they unconditionally import, see below.
11+
#- TOXENV: run-module
12+
# PYTHON: "C:\\Python38-x64"
13+
#- TOXENV: run-entrypoint
14+
# PYTHON: "C:\\Python38-x64"
1015
# Windows is not ready for testing!!!
1116
# Python's fcntl, grp, pwd, os.geteuid(), and socket.AF_UNIX are all Unix-only.
1217
#- TOXENV: py35

gunicorn/__main__.py

+5-1
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,8 @@
44
# See the NOTICE for more information.
55

66
from gunicorn.app.wsgiapp import run
7-
run()
7+
8+
if __name__ == "__main__":
9+
# see config.py - argparse defaults to basename(argv[0]) == "__main__.py"
10+
# todo: let runpy.run_module take care of argv[0] rewriting
11+
run(prog="gunicorn")

gunicorn/app/wsgiapp.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -58,13 +58,13 @@ def load(self):
5858
return self.load_wsgiapp()
5959

6060

61-
def run():
61+
def run(prog=None):
6262
"""\
6363
The ``gunicorn`` command line runner for launching Gunicorn with
6464
generic WSGI applications.
6565
"""
6666
from gunicorn.app.wsgiapp import WSGIApplication
67-
WSGIApplication("%(prog)s [OPTIONS] [APP_MODULE]").run()
67+
WSGIApplication("%(prog)s [OPTIONS] [APP_MODULE]", prog=prog).run()
6868

6969

7070
if __name__ == '__main__':

pyproject.toml

+9-1
Original file line numberDiff line numberDiff line change
@@ -57,13 +57,21 @@ setproctitle = ["setproctitle"]
5757
testing = [
5858
"gevent",
5959
"eventlet",
60-
"cryptography",
6160
"coverage",
6261
"pytest",
6362
"pytest-cov",
6463
]
6564

65+
[project.scripts]
66+
# duplicates "python -m gunicorn" handling in __main__.py
67+
gunicorn = "gunicorn.app.wsgiapp:run"
68+
69+
# note the quotes around "paste.server_runner" to escape the dot
70+
[project.entry-points."paste.server_runner"]
71+
main = "gunicorn.app.pasterapp:serve"
72+
6673
[tool.pytest.ini_options]
74+
# # can override these: python -m pytest --override-ini="addopts="
6775
norecursedirs = ["examples", "lib", "local", "src"]
6876
testpaths = ["tests/"]
6977
addopts = "--assert=plain --cov=gunicorn --cov-report=xml"

requirements_dev.txt

+5
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,9 @@
11
-r requirements_test.txt
22

3+
# setuptools v68.0 fails hard on invalid pyproject.toml
4+
# which a developer would want to know
5+
# otherwise, oldest known-working version is 61.2
6+
setuptools>=68.0
7+
38
sphinx
49
sphinx_rtd_theme

requirements_test.txt

-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
gevent
22
eventlet
3-
cryptography
43
coverage
54
pytest
65
pytest-cov

tox.ini

+9-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[tox]
2-
envlist = py{37,38,39,310,311,py3}, lint, docs-lint, pycodestyle
2+
envlist = py{37,38,39,310,311,py3}, lint, docs-lint, pycodestyle, run-entrypoint, run-module
33
skipsdist = false
44
; Can't set skipsdist and use_develop in tox v4 to true due to https://github.com/tox-dev/tox/issues/2730
55

@@ -9,6 +9,14 @@ commands = pytest --cov=gunicorn {posargs}
99
deps =
1010
-rrequirements_test.txt
1111

12+
[testenv:run-entrypoint]
13+
# entry point: console script (provided by setuptools from pyproject.toml)
14+
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 ")'
15+
16+
[testenv:run-module]
17+
# runpy (provided by module.__main__)
18+
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 ")'
19+
1220
[testenv:lint]
1321
commands =
1422
pylint -j0 \

0 commit comments

Comments
 (0)