Skip to content

Commit

Permalink
Merge branch 'main' into type-win32timezone
Browse files Browse the repository at this point in the history
  • Loading branch information
Avasam authored Nov 13, 2024
2 parents 9281921 + 0023fd3 commit d17de98
Show file tree
Hide file tree
Showing 423 changed files with 85,183 additions and 28,032 deletions.
2 changes: 1 addition & 1 deletion .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ indent_size = 4
max_line_length = 120 # Same as .clang-format

[*.py]
max_line_length = 88 # Same as Black
max_line_length = 88 # Same as Ruff's default
[*.md]
trim_trailing_whitespace = false
Expand Down
3 changes: 3 additions & 0 deletions .git-blame-ignore-revs
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,6 @@

# 2024-05-28 formatted c++ source with clang-format
637448f8252ab142eedd539ddf9b08259b73eecc

# 2024-10-14 formatted Python source with Ruff format
2b5191d8fc6f1d1fbde01481b49278c1957ef8f1
32 changes: 17 additions & 15 deletions .github/workflows/docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,18 @@ name: docs
on:
create:
tags:
# https://docs.github.com/en/actions/learn-github-actions/workflow-syntax-for-github-actions#filter-pattern-cheat-sheet
# https://docs.github.com/en/actions/learn-github-actions/workflow-syntax-for-github-actions#filter-pattern-cheat-sheet
- b[0-9][0-9][0-9]
- publish-docs*
push:
branches:
- main
pull_request: # Temporary just for test
branches:
- main

jobs:
decompile:
generate:
runs-on: windows-latest

steps:
Expand All @@ -22,44 +25,43 @@ jobs:
with:
python-version: '3.9'

# We still need to install pywin32 because
# AutoDuck/py2d.py currently relies on runtime imports for introspection
# Downloading latest release is faster than re-building
- name: Install latest release
run: pip install --user --upgrade pywin32

- name: Set Python user site directory
run: python -c "import os,site;open(os.environ['GITHUB_ENV'], 'a').write(f'USER_DIR={site.USER_SITE}\n')"
- name: Generate PyWin32.chm help file
run: python AutoDuck/make.py

- name: Decompile shipped help file
run: hh -decompile site ${env:USER_DIR}\PyWin32.chm
- name: Decompile help file into HTML
run: hh -decompile site PyWin32.chm

- name: Rename root HTML file
run: mv site\PyWin32.HTML site\index.html

# Compress first to avoid slowly uploading thousands of individual files
- name: Create archive
run: python -m zipfile -c site.zip site

- uses: actions/upload-artifact@v3
- uses: actions/upload-artifact@v4
with:
name: documentation
path: site.zip
path: site/

publish:
runs-on: ubuntu-latest
needs:
- decompile
- generate

# Only publish tags
if: github.event_name == 'create' && github.event.ref_type == 'tag'

steps:
- uses: actions/download-artifact@v3
- uses: actions/download-artifact@v4
with:
name: documentation

- name: Unpack archive
run: python -m zipfile -e site.zip .

- uses: peaceiris/actions-gh-pages@v3
- uses: peaceiris/actions-gh-pages@v4
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: site
Expand Down
24 changes: 15 additions & 9 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,13 @@ jobs:
run: |
python setup.py install --user
# This needs to happen *after* installing pywin32 since
# AutoDuck/py2d.py currently relies on runtime imports for introspection
# This isn't included in the wheel (TODO: could we?)
# and only servces as a PR test for the docs.yaml workflow
- name: Generate PyWin32.chm help file
run: python AutoDuck/make.py

- name: Run tests
# Run the tests directly from the source dir so support files (eg, .wav files etc)
# can be found - they aren't installed into the Python tree.
Expand Down Expand Up @@ -110,23 +117,22 @@ jobs:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
# This job only needs to target the oldest version supported by our checkers
# (black>=24.10.0 supports Python >=3.9)
python-version: "3.9"
# This job only needs to target the oldest supported version
python-version: "3.8"
cache: pip
cache-dependency-path: .github/workflows/main.yml
- run: pip install clang-format pycln
- run: pycln . --config=pycln.toml --check
- uses: astral-sh/ruff-action@v1
with:
version: "0.4.5"
- uses: psf/black@stable
version: "0.4.9"
- uses: astral-sh/ruff-action@v1
with:
options: "--fast --check --diff --verbose"
version: "0.4.9"
args: "format --check"
- run: | # Too many files to fit in a single command, also exclude vendored Scintilla and MAPIStubLibrary
clang-format --Werror --dry-run $(git ls-files '*.cpp')
clang-format --Werror --dry-run $(git ls-files '*.h' ':!:Pythonwin/Scintilla/' ':!:com/win32comext/mapi/src/MAPIStubLibrary/')
shell: powershell
mypy:
runs-on: windows-2019
Expand All @@ -144,7 +150,7 @@ jobs:
cache: pip
cache-dependency-path: .github/workflows/main.yml
check-latest: true
- run: pip install types-regex types-setuptools PyOpenGL mypy==1.11
- run: pip install types-setuptools PyOpenGL mypy==1.11
- run: mypy . --python-version=${{ matrix.python-version }}

pyright:
Expand All @@ -163,7 +169,7 @@ jobs:
cache-dependency-path: .github/workflows/main.yml
check-latest: true
# pyright vendors typeshed, but let's make sure we have the most up to date stubs
- run: pip install types-regex types-setuptools PyOpenGL
- run: pip install types-setuptools PyOpenGL
- uses: jakebailey/pyright-action@v2
with:
python-version: ${{ matrix.python-version }}
Expand Down
6 changes: 1 addition & 5 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,7 @@ repos:
hooks:
- id: ruff # Run the linter.
args: [--fix]
- repo: https://github.com/psf/black-pre-commit-mirror
rev: 24.4.2
hooks:
- id: black
verbose: true
- id: ruff-format
- repo: https://github.com/pre-commit/mirrors-clang-format
rev: v18.1.5
hooks:
Expand Down
28 changes: 7 additions & 21 deletions AutoDuck/Dump2HHC.py
Original file line number Diff line number Diff line change
Expand Up @@ -293,9 +293,7 @@ def _genItemsFromDict(dict, cat, output, target, do_children=1):
<param name="ImageNumber" value="1">
<param name="Local" value="{CHM}{context}">
</OBJECT>
""".format(
**locals()
)
""".format(**locals())
)
if not do_children:
continue
Expand Down Expand Up @@ -339,9 +337,7 @@ def genTOC(cats, output, title, target):
<param name="Local" value="{CHM}{target}.html">
</OBJECT>
<UL>
""".format(
**locals()
)
""".format(**locals())
)

for cat in cats:
Expand All @@ -355,9 +351,7 @@ def genTOC(cats, output, title, target):
<param name="Local" value="{CHM}{cat_id}.html">
</OBJECT>
<UL>
""".format(
**locals()
)
""".format(**locals())
)
# Next write the overviews for this category
output.write(
Expand All @@ -368,9 +362,7 @@ def genTOC(cats, output, title, target):
<param name="Local" value="{CHM}{cat_id}_overview.html">
</OBJECT>
<UL>
""".format(
**locals()
)
""".format(**locals())
)
_genItemsFromDict(cat.overviewTopics, cat, output, target)
_genItemsFromDict(cat.extOverviewTopics, cat, output, target)
Expand All @@ -387,9 +379,7 @@ def genTOC(cats, output, title, target):
<param name="Local" value="{CHM}{cat_id}_modules.html">
</OBJECT>
<UL>
""".format(
**locals()
)
""".format(**locals())
)
_genItemsFromDict(cat.modules, cat, output, target)
output.write(
Expand All @@ -404,9 +394,7 @@ def genTOC(cats, output, title, target):
<param name="ImageNumber" value="1">
<param name="Local" value="{CHM}{cat_id}_objects.html">
</OBJECT>
<UL>""".format(
**locals()
)
<UL>""".format(**locals())
)
# Don't show 'children' for objects - params etc don't need their own child nodes!
_genItemsFromDict(cat.objects, cat, output, target, do_children=0)
Expand All @@ -423,9 +411,7 @@ def genTOC(cats, output, title, target):
<param name="Local" value="{CHM}{cat_id}_constants.html">
</OBJECT>
<UL>
""".format(
**locals()
)
""".format(**locals())
)
_genItemsFromDict(cat.constants, cat, output, target)
output.write(
Expand Down
2 changes: 1 addition & 1 deletion AutoDuck/README → AutoDuck/README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Just run MAKE.BAT to build the documentation.
Just run [make.py](./make.py) to build the documentation.

Main focus these days is on the .chm file - a single .chm
provides the best documentation solution. We don't even
Expand Down
17 changes: 8 additions & 9 deletions AutoDuck/common_top.mak
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
# Common AutoDuck make file

AD = bin\autoduck.exe /Spythonwin.fmt
AD = bin\autoduck.exe /Spythonwin.fmt
ADHTMLFMT = bin\autoduck.exe /Spyhtml.fmt
ADHTMLLOG = /R html "/L$(GENDIR)\$(TARGET).HHLOG" /N
ADLOG = /R help "/L$(GENDIR)\$(TARGET).HLOG" /N
ADHTML = /R html "/G$(GENDIR)\$(TARGET).DUMP" "/C$(GENDIR)\$(TARGET).HHLOG" "/I$(GENDIR)\$(TARGET).IDX" "/O$(GENDIR)\$(TARGET).HTML" /D "title=$(TITLE)"
ADHLP = /R help "/C$(GENDIR)\$(TARGET).HLOG" "/O$(GENDIR)\$(TARGET).RTF" /D "title=$(TITLE)"
ADDOC = /RD "/O$(GENDIR)\$(TARGET).DOC" /D "doc_header=$(DOCHDR)"
ADTAB = 8
HC = hcw /a /c /e
HHC = hhc
PYTHON = py -2.7
ADLOG = /R help "/L$(GENDIR)\$(TARGET).HLOG" /N
ADHTML = /R html "/G$(GENDIR)\$(TARGET).DUMP" "/C$(GENDIR)\$(TARGET).HHLOG" "/I$(GENDIR)\$(TARGET).IDX" "/O$(GENDIR)\$(TARGET).HTML" /D "title=$(TITLE)"
ADHLP = /R help "/C$(GENDIR)\$(TARGET).HLOG" "/O$(GENDIR)\$(TARGET).RTF" /D "title=$(TITLE)"
ADDOC = /RD "/O$(GENDIR)\$(TARGET).DOC" /D "doc_header=$(DOCHDR)"
ADTAB = 8
HC = hcw /a /c /e
HHC = hhc
4 changes: 3 additions & 1 deletion AutoDuck/make.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,5 +26,7 @@
).splitlines()[-1]

subprocess.run(
[nmake, "-E", "-f", "pywin32.mak"], cwd=os.path.dirname(sys.argv[0]), check=True
[nmake, f'PYTHON="{sys.executable}"', "-E", "-f", "pywin32.mak"],
cwd=os.path.dirname(sys.argv[0]),
check=True,
)
2 changes: 1 addition & 1 deletion AutoDuck/makedfromi.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ def GetComments(line, lineNo, lines):
if len(data) != 2:
break
if data[0].strip():
break # Not a continutation!
break # Not a continuation!
if data[1].strip().startswith("@"):
# new command
break
Expand Down
31 changes: 14 additions & 17 deletions AutoDuck/py2d.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,6 @@ def ad_escape(s):
return re.sub(r"([^<]*)<([^>]*)>", r"\g<1>\\<\g<2>\\>", s)


Print = __builtins__.__dict__["print"]


class DocInfo:
def __init__(self, name, ob):
self.name = name
Expand Down Expand Up @@ -75,7 +72,7 @@ def format_desc(desc):
# 'first_para_of_docstring'
# '@comm next para of docstring'
# '@comm next para of docstring' ... etc
# BUT - also handling enbedded doctests, where we write
# BUT - also handling embedded doctests, where we write
# '@iex >>> etc.'
if not desc:
return ""
Expand Down Expand Up @@ -112,30 +109,30 @@ def build_module(fp, mod_name):
elif name.upper() == name and isinstance(ob, (int, str)):
constants.append((name, ob))
info = BuildInfo(mod_name, mod)
Print(f"// @module {mod_name}|{format_desc(info.desc)}", file=fp)
print(f"// @module {mod_name}|{format_desc(info.desc)}", file=fp)
functions = [f for f in functions if should_build_function(f)]
for ob in functions:
Print(f"// @pymeth {ob.name}|{ob.short_desc}", file=fp)
print(f"// @pymeth {ob.name}|{ob.short_desc}", file=fp)
for ob in classes:
# only classes with docstrings get printed.
if not ob.ob.__doc__:
continue
ob_name = mod_name + "." + ob.name
Print(f"// @pyclass {ob.name}|{ob.short_desc}", file=fp)
print(f"// @pyclass {ob.name}|{ob.short_desc}", file=fp)
for ob in functions:
Print(
print(
f"// @pymethod |{mod_name}|{ob.name}|{format_desc(ob.desc)}",
file=fp,
)
for ai in BuildArgInfos(ob.ob):
Print(f"// @pyparm |{ai.name}|{ai.default}|{ai.short_desc}", file=fp)
print(f"// @pyparm |{ai.name}|{ai.default}|{ai.short_desc}", file=fp)

for ob in classes:
# only classes with docstrings get printed.
if not ob.ob.__doc__:
continue
ob_name = mod_name + "." + ob.name
Print(f"// @object {ob_name}|{format_desc(ob.desc)}", file=fp)
print(f"// @object {ob_name}|{format_desc(ob.desc)}", file=fp)
func_infos = []
# We need to iter the keys then to a getattr() so the funky descriptor
# things work.
Expand All @@ -146,20 +143,20 @@ def build_module(fp, mod_name):
if should_build_function(info):
func_infos.append(info)
for fi in func_infos:
Print(f"// @pymeth {fi.name}|{fi.short_desc}", file=fp)
print(f"// @pymeth {fi.name}|{fi.short_desc}", file=fp)
for fi in func_infos:
Print(
print(
f"// @pymethod |{ob_name}|{fi.name}|{format_desc(fi.desc)}",
file=fp,
)
if hasattr(fi.ob, "im_self") and fi.ob.im_self is ob.ob:
Print("// @comm This is a @classmethod.", file=fp)
Print(
print("// @comm This is a @classmethod.", file=fp)
print(
f"// @pymethod |{ob_name}|{fi.name}|{format_desc(fi.desc)}",
file=fp,
)
for ai in BuildArgInfos(fi.ob):
Print(
print(
f"// @pyparm |{ai.name}|{ai.default}|{ai.short_desc}",
file=fp,
)
Expand All @@ -168,11 +165,11 @@ def build_module(fp, mod_name):
desc = f"{name} = {val!r}"
if isinstance(val, int):
desc += f" (0x{val:x})"
Print(f"// @const {mod_name}|{name}|{desc}", file=fp)
print(f"// @const {mod_name}|{name}|{desc}", file=fp)


def main(fp, args):
Print("// @doc", file=fp)
print("// @doc", file=fp)
for arg in args:
build_module(sys.stdout, arg)

Expand Down
Loading

0 comments on commit d17de98

Please sign in to comment.