File: tox.ini

package info (click to toggle)
python-cheroot 11.1.2%2Bds1-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 1,236 kB
  • sloc: python: 6,969; makefile: 10
file content (584 lines) | stat: -rw-r--r-- 17,443 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
[tox]
envlist = python
minversion = 4

[python-cli-options]
byte-warnings = -b
byte-errors = -bb
max-isolation = -E -s -I
# some-isolation = -I
# FIXME: Python 2 shim. Is this equivalent to the above?
some-isolation = -E -s
warnings-to-errors = -Werror


[testenv]
deps =
  -rdependencies{/}tests.in
commands_pre =
  {envpython} \
    {[python-cli-options]byte-errors} \
    {[python-cli-options]some-isolation} \
    -m \
      OpenSSL.debug
commands =
  {envpython} \
    {[python-cli-options]byte-errors} \
    {[python-cli-options]some-isolation} \
    -m pytest \
      {tty:--color=yes} \
      {posargs:--cov-report=html:{envtmpdir}{/}htmlcov{/}}
commands_post =
  -{envpython} \
    {[python-cli-options]byte-errors} \
    {[python-cli-options]max-isolation} \
    {[python-cli-options]warnings-to-errors} \
    -c \
      'import atexit, os, sys; \
      os.getenv("GITHUB_ACTIONS") == "true" or sys.exit(); \
      import coverage; \
      gh_summary_fd = open(\
        os.environ["GITHUB_STEP_SUMMARY"], encoding="utf-8", mode="a",\
      ); \
      atexit.register(gh_summary_fd.close); \
      cov = coverage.Coverage(); \
      cov.load(); \
      cov.report(file=gh_summary_fd, output_format="markdown")'
  {envpython} \
    {[python-cli-options]byte-errors} \
    {[python-cli-options]max-isolation} \
    {[python-cli-options]warnings-to-errors} \
    -c \
      'import os, pathlib, sys; \
      os.getenv("GITHUB_ACTIONS") == "true" or sys.exit(); \
      cov_report_arg_prefix = "--cov-report=xml:"; \
      test_report_arg_prefix = "--junitxml="; \
      cov_reports = [\
        arg[len(cov_report_arg_prefix):] for arg in sys.argv \
        if arg.startswith(cov_report_arg_prefix)\
      ]; \
      test_reports = [\
        arg[len(test_report_arg_prefix):] for arg in sys.argv \
        if arg.startswith(test_report_arg_prefix)\
      ]; \
      cov_report_file = cov_reports[-1] if cov_reports else None; \
      test_report_file = test_reports[-1] if test_reports else None; \
      gh_output_fd = open(\
        os.environ["GITHUB_OUTPUT"], encoding="utf-8", mode="a",\
      ); \
      cov_report_file and \
        print(f"cov-report-files={cov_report_file !s}", file=gh_output_fd); \
      test_report_file and \
        print(f"test-result-files={test_report_file !s}", file=gh_output_fd); \
      print("codecov-flags=pytest", file=gh_output_fd); \
      gh_output_fd.close()' \
    {posargs}
  # Print out the output coverage dir and a way to serve html:
  {envpython} \
    {[python-cli-options]byte-errors} \
    {[python-cli-options]max-isolation} \
    {[python-cli-options]warnings-to-errors} \
    -c\
      'import pathlib, shlex, sys; \
      cov_html_report_arg_prefix = "--cov-report=html:"; \
      cov_html_reports = [\
        arg[len(cov_html_report_arg_prefix):] for arg in sys.argv \
        if arg.startswith(cov_html_report_arg_prefix)\
      ]; \
      cov_html_reports or sys.exit(); \
      cov_html_report_dir = pathlib.Path(cov_html_reports[-1]); \
      index_file = cov_html_report_dir / "index.html";\
      index_file.exists() or sys.exit(); \
      html_url = f"file://\{index_file\}";\
      browse_cmd = shlex.join(("python3", "-Im", "webbrowser", html_url)); \
      serve_cmd = shlex.join((\
        "python3", "-Im", "http.server", \
        "--directory", str(cov_html_report_dir), "0", \
      )); \
      print(f"\nTo open the HTML coverage report, run\n\n\
      \t\{browse_cmd !s\}\n");\
      print(f"To serve \
      the HTML coverage report with a local web server, use\n\n\
      \t\{serve_cmd !s\}\n")' \
    {posargs:--cov-report=html:{envtmpdir}{/}htmlcov{/}}
install_command =
  {envpython} \
    {[python-cli-options]byte-errors} \
    {[python-cli-options]some-isolation} \
    {toxinidir}{/}bin{/}pip-wrapper \
    '{envname}' \
    '{toxinidir}{/}dependencies{/}' \
    install {opts} {packages}
usedevelop = True

passenv =
  WEBTEST_INTERACTIVE
  CI
  TRAVIS
  TRAVIS_*
  APPVEYOR
  APPVEYOR_*
  CIRCLECI
  CIRCLE_*
  PYTHONDONTWRITEBYTECODE
  PYTHONTRACEMALLOC
  PYTEST_*
  SSH_AUTH_SOCK
  GITHUB_*
  CODECOV_TOKEN
setenv =
  CRYPTOGRAPHY_ALLOW_OPENSSL_102=x
  PYTHONDONTWRITEBYTECODE=x
  WEBTEST_INTERACTIVE=false


[dists]
setenv =
  PIP_CONSTRAINT = {toxinidir}{/}dependencies{/}dist-build-constraints.txt
  PEP517_OUT_DIR = {env:PEP517_OUT_DIR:{toxinidir}{/}dist}


[testenv:build-docs]
allowlist_externals =
  git
description = Build The Docs
changedir = docs
commands_pre =
  # Retrieve possibly missing commits:
  -git fetch --unshallow
  -git fetch --tags
commands =
  # Build docs site:
  {envpython} \
    {[python-cli-options]byte-errors} \
    {[python-cli-options]some-isolation} \
    -m sphinx \
      -j auto \
      -b html \
      {tty:--color} \
      -a \
      -n \
      -W --keep-going \
      -d "{temp_dir}{/}.doctrees" \
      . \
      "{envdir}{/}docs_out"

  # Print out the output docs dir and a way to serve html:
  -{envpython} \
  {[python-cli-options]byte-errors} \
  {[python-cli-options]some-isolation} \
  -c\
  'import pathlib;\
  docs_dir = pathlib.Path(r"{envdir}") / "docs_out";\
  index_file = docs_dir / "index.html";\
  print(f"\nDocumentation available under \
  `file://\{index_file\}`\n\nTo serve docs, use \
  `python3 -m http.server --directory \
  \N\{QUOTATION MARK\}\{docs_dir\}\N\{QUOTATION MARK\} 0`\n")'
commands_post =
depends =
  make-changelog
deps =
  -rdependencies{/}tox-docs.in
envdir = {toxworkdir}/build-docs

[testenv:doctest-docs]
allowlist_externals =
  {[testenv:build-docs]allowlist_externals}
description = Doctest The Docs
changedir = {[testenv:build-docs]changedir}
commands_pre =
commands =
  # Retrieve possibly missing commits:
  -git fetch --unshallow
  -git fetch --tags

  # Doctest docs site:
  {envpython} \
    {[python-cli-options]byte-errors} \
    {[python-cli-options]some-isolation} \
    -m sphinx \
      -j auto \
      -a -n -W \
      --keep-going \
      -b doctest --color \
      -d "{temp_dir}{/}.doctrees" \
      . "{toxworkdir}{/}docs_out"
commands_post =
deps =
  -rdependencies{/}tox-doctest-docs.in
envdir = {[testenv:build-docs]envdir}

[testenv:linkcheck-docs]
allowlist_externals =
  {[testenv:build-docs]allowlist_externals}
description = Linkcheck The Docs
changedir = {[testenv:build-docs]changedir}
commands_pre =
commands =
  # Retrieve possibly missing commits:
  -git fetch --unshallow
  -git fetch --tags

  # Linkcheck docs site:
  {envpython} \
    {[python-cli-options]byte-errors} \
    {[python-cli-options]some-isolation} \
    -m sphinx \
      -j auto \
      -a -n -W \
      --keep-going \
      -b linkcheck --color \
      -d "{temp_dir}{/}.doctrees" \
      . "{toxworkdir}{/}docs_out"
commands_post =
deps =
  -rdependencies{/}tox-docs-linkcheck.in
envdir = {[testenv:build-docs]envdir}

[testenv:spellcheck-docs]
allowlist_externals =
  {[testenv:build-docs]allowlist_externals}
description = Spellcheck The Docs
changedir = {[testenv:build-docs]changedir}
commands_pre =
commands =
  # Retrieve possibly missing commits:
  -git fetch --unshallow
  -git fetch --tags

  # Spellcheck docs site:
  {envpython} \
    {[python-cli-options]byte-errors} \
    {[python-cli-options]some-isolation} \
    -m sphinx \
      -j auto \
      -a -n -W \
      --keep-going \
      -b spelling --color \
      -d "{temp_dir}{/}.doctrees" \
      . "{toxworkdir}{/}docs_out"
commands_post =
deps =
  -rdependencies{/}tox-docs-spellcheck.in
envdir = {[testenv:build-docs]envdir}

[testenv:watch]
commands = ptw --runner=pytest
commands_post =


[testenv:check-changelog]
basepython = {[testenv:make-changelog]basepython}
description =
  Check Towncrier change notes
commands_pre =
commands =
  {envpython} \
    {[python-cli-options]byte-errors} \
    {[python-cli-options]some-isolation} \
    -m towncrier.check \
      --compare-with origin/devel {posargs:}
commands_post =
deps =
  {[testenv:make-changelog]deps}
envdir = {[testenv:make-changelog]envdir}
isolated_build = {[testenv:make-changelog]isolated_build}
skip_install = {[testenv:make-changelog]skip_install}


[testenv:make-changelog]
basepython = python3
depends =
  check-changelog
description =
  Generate a changelog from fragments using Towncrier. Getting an
  unreleased changelog preview does not require extra arguments.
  When invoking to update the changelog, pass the desired version as an
  argument after `--`. For example, `tox -e {envname} -- 1.3.2`.
envdir = {[testenv:build-docs]envdir}
commands_pre =
commands =
  {envpython} \
    {[python-cli-options]byte-errors} \
    {[python-cli-options]some-isolation} \
    -m towncrier.build \
      --version \
      {posargs:'[UNRELEASED DRAFT]' --draft}
commands_post =
deps =
  {[testenv:build-docs]deps}
  # -r{toxinidir}/docs/requirements.txt
  # FIXME: re-enable the "-r" + "-c" paradigm once the pip bug is fixed.
  # Ref: https://github.com/pypa/pip/issues/9243
  # towncrier
  # -r{toxinidir}/docs/requirements.in
  # -c{toxinidir}/docs/requirements.txt
isolated_build = true
skip_install = true


[testenv:draft-changelog]
allowlist_externals =
  sh
basepython = {[testenv:make-changelog]basepython}
description =
  Print out the Towncrier-managed change notes
  draft for the next release to stdout
commands_pre =
commands =
  # NOTE: `sh` invocation is required to suppress stderr from
  # NOTE: towncrier since it does not have own CLI flags for
  # NOTE: doing this.
  sh -c "2>/dev/null \
    {envpython} \
    {[python-cli-options]byte-errors} \
    {[python-cli-options]some-isolation} \
    -m towncrier.build \
      --version '[UNRELEASED DRAFT]' \
      --draft"
commands_post =
envdir = {[testenv:make-changelog]envdir}
deps =
  {[testenv:make-changelog]deps}
isolated_build = {[testenv:make-changelog]isolated_build}
skip_install = {[testenv:make-changelog]skip_install}


[testenv:cleanup-dists]
description =
  Wipe the the dist{/} folder
usedevelop = false
skip_install = true
deps =
setenv =
  {[dists]setenv}
commands_pre =
commands =
  {envpython} \
  {[python-cli-options]byte-errors} \
  {[python-cli-options]some-isolation} \
  -c \
    'import os, shutil, sys; dists_dir = os.getenv("PEP517_OUT_DIR"); shutil.rmtree(dists_dir, ignore_errors=True); sys.exit(os.path.exists(dists_dir))'
commands_post =


[testenv:build-dists]
allowlist_externals =
  env
description =
  Build dists and put them into
  the `{env:PEP517_OUT_DIR}{/}` folder
depends =
  cleanup-dists
platform = darwin|linux
# NOTE: The custom command is here to allow resetting the global
# NOTE: pip constraints env var.
install_command =
  env PIP_CONSTRAINT= \
    {envpython} \
    {[python-cli-options]byte-errors} \
    {[python-cli-options]some-isolation} \
    {toxinidir}{/}bin{/}pip-wrapper \
    '{envname}' \
    '{toxinidir}{/}dependencies{/}' \
    install {opts} {packages}
isolated_build = true
# `usedevelop = true` overrides `skip_install` instruction, it's unwanted
usedevelop = false
skip_install = true
deps =
  -rdependencies{/}tox-build-dists.in
passenv =
  PEP517_BUILD_ARGS
setenv =
  {[dists]setenv}
commands_pre =
commands =
  # Starting with build v0.5.0, it builds wheel from sdist
  # if no format arguments are passed. This makes sure that
  # wheels are not dependent on the Git repo or anything
  # external what may be missing from sdist.
  {envpython} \
    {[python-cli-options]byte-errors} \
    {[python-cli-options]some-isolation} \
    -m build \
      --outdir '{env:PEP517_OUT_DIR}{/}' \
      {posargs:{env:PEP517_BUILD_ARGS:}} \
      '{toxinidir}'
commands_post =


[testenv:pre-commit]
description =
  Run the quality checks under {basepython}; run as
  `SKIP=check-id1,check-id2 tox r -e pre-commit` to instruct the underlying
  `pre-commit` invocation avoid running said checks; Use
  `tox r -e pre-commit -- check-id1 --all-files` to select checks matching IDs
  aliases{:} `tox r -e pre-commit -- mypy --all-files` will run 3 MyPy
  invocations, but `tox r -e pre-commit -- mypy-py313 --all-files` runs one.
commands_pre =
commands =
  {envpython} \
    {[python-cli-options]byte-errors} \
    {[python-cli-options]max-isolation} \
    {[python-cli-options]warnings-to-errors} \
    -m pre_commit \
      run \
      --color=always \
      --show-diff-on-failure \
      {posargs:--all-files}
commands_post =
  # Print out the advice on how to install pre-commit from this env into Git:
  -{envpython} \
    {[python-cli-options]byte-errors} \
    {[python-cli-options]max-isolation} \
    {[python-cli-options]warnings-to-errors} \
    -c \
      'cmd = "{envpython} -m pre_commit install"; \
      scr_width = len(cmd) + 10; \
      sep = "=" * scr_width; \
      cmd_str = "    $ \{cmd\}";' \
      'print(f"\n\{sep\}\nTo install pre-commit hooks into the Git repo, run:\
      \n\n\{cmd_str\}\n\n\{sep\}\n")'
  {envpython} \
    {[python-cli-options]byte-errors} \
    {[python-cli-options]max-isolation} \
    {[python-cli-options]warnings-to-errors} \
    -c \
      'import os, pathlib, sys; \
      os.getenv("GITHUB_ACTIONS") == "true" or sys.exit(); \
      project_root_path = pathlib.Path(r"{toxinidir}"); \
      test_results_dir = pathlib.Path(r"{temp_dir}") / ".test-results"; \
      coverage_result_files = ",".join(\
        str(xml_path.relative_to(project_root_path)) \
        for xml_path in test_results_dir.glob("mypy--py-*{/}cobertura.xml")\
      ); \
      gh_output_fd = open(\
        os.environ["GITHUB_OUTPUT"], encoding="utf-8", mode="a",\
      ); \
      print(\
        f"cov-report-files={coverage_result_files !s}", file=gh_output_fd\
      ); \
      print("codecov-flags=MyPy", file=gh_output_fd); \
      gh_output_fd.close()'
  {envpython} \
    {[python-cli-options]byte-errors} \
    {[python-cli-options]max-isolation} \
    {[python-cli-options]warnings-to-errors} \
    -c \
      'import itertools, os, pathlib, shlex, sys; \
      os.getenv("GITHUB_ACTIONS") == "true" or sys.exit(); \
      test_results_dir = pathlib.Path(r"{temp_dir}") / ".test-results"; \
      text_and_json_reports = itertools.chain( \
        test_results_dir.glob("mypy--py-*{/}*.json"), \
        test_results_dir.glob("mypy--py-*{/}*.txt"), \
      ); \
      report_contents = { \
        report{:} report.read_text() \
        for report in text_and_json_reports \
      }; \
      reports_summary_text_blob = "\n\n".join( \
        f"\N\{NUMBER SIGN\}\N\{NUMBER SIGN\} {report_path.parent.name}{:} " \
        f"`{report_path.name}`\n\n" \
        f"```{report_path.suffix[1:]}\n{report_text}\n```\n" \
        for report_path, report_text in report_contents.items() \
      ); \
      gh_summary_fd = open( \
        os.environ["GITHUB_STEP_SUMMARY"], encoding="utf-8", mode="a", \
      ); \
      print(reports_summary_text_blob, file=gh_summary_fd); \
      gh_summary_fd.close()'
  # Print out the output coverage dir and a way to serve html:
  {envpython} \
    {[python-cli-options]byte-errors} \
    {[python-cli-options]max-isolation} \
    {[python-cli-options]warnings-to-errors} \
    -c\
      'import os, pathlib, sys; \
      os.getenv("GITHUB_ACTIONS") == "true" and sys.exit(); \
      len(sys.argv) >= 3 and all(\
        arg != "mypy" and not arg.startswith("mypy-py3") \
        for arg in sys.argv \
      ) and sys.exit(); \
      project_root_path = pathlib.Path(r"{toxinidir}"); \
      test_results_dir = pathlib.Path(r"{temp_dir}") / ".test-results"; \
      coverage_html_report_urls = [\
        f"file://\{xml_path !s\}" \
        for xml_path in test_results_dir.glob("mypy--py-*{/}index.html")\
      ]; \
      coverage_html_report_open_cmds = [\
      f"python3 -Im webbrowser \N\{QUOTATION MARK\}\{html_url !s\}\N\{QUOTATION MARK\}" \
      for html_url in coverage_html_report_urls\
      ]; \
      coverage_html_report_open_cmds_blob = "\n\n\t".join(\
        coverage_html_report_open_cmds,\
      ); \
      print(\
        f"\nTo open the HTML coverage reports, run\n\n\
        \t\{coverage_html_report_open_cmds_blob !s\}\n"\
      ); \
      print(\
        f"[*] Find rest of JSON and text reports, are in the same directories."\
      )\
      ' \
    {posargs:--all-files}
deps =
  -rdependencies{/}tox-pre-commit.in
package = skip
pass_env =
  {[testenv]pass_env}
  SKIP  # set this variable
skip_install = true


[testenv:metadata-validation]
description =
  Verify that dists under the `{env:PEP517_OUT_DIR}{/}` dir
  have valid metadata
depends =
  build-dists
deps =
  setuptools-scm
  twine
usedevelop = false
skip_install = true
commands_pre =
  {envpython} \
    {[python-cli-options]byte-errors} \
    {[python-cli-options]some-isolation} \
    -m setuptools_scm ls
setenv =
  {[dists]setenv}
commands =
  {envpython} \
    {[python-cli-options]byte-errors} \
    {[python-cli-options]some-isolation} \
    -m twine check \
      --strict \
      {env:PEP517_OUT_DIR}{/}*
commands_post =

[testenv:release]
skip_install = True
deps =
  pep517>=0.5
  twine>=1.13
  path.py
passenv =
  TWINE_PASSWORD
setenv =
  TWINE_USERNAME = {env:TWINE_USERNAME:__token__}
commands_pre =
commands =
  {envpython} \
    {[python-cli-options]byte-errors} \
    {[python-cli-options]some-isolation} \
    -c "import path; path.Path('dist').rmtree_p()"
  {envpython} \
    {[python-cli-options]byte-errors} \
    {[python-cli-options]some-isolation} -m pep517.build .
  {envpython} \
    {[python-cli-options]byte-errors} \
    {[python-cli-options]some-isolation} -m twine upload dist{/}*
commands_post =