Skip to content

Commit

Permalink
Merge branch 'main' into Bump-GitHub-actions-and-checkers
Browse files Browse the repository at this point in the history
  • Loading branch information
Avasam authored Nov 12, 2024
2 parents 2ddbb22 + b64bccb commit 8177d74
Show file tree
Hide file tree
Showing 41 changed files with 125 additions and 116 deletions.
26 changes: 14 additions & 12 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,31 +25,30 @@ 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@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'
Expand Down
7 changes: 7 additions & 0 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
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,
)
29 changes: 13 additions & 16 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 @@ -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
2 changes: 2 additions & 0 deletions CHANGES.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ https://mhammond.github.io/pywin32_installers.html.
Coming in build 309, as yet unreleased
--------------------------------------

* Fixed `ddeclient` and `ddeserver` demos import error (#2290, @Avasam)
* The `EvtSubscribe_push` demo now actually demonstrates the callback action and the event context being filled. (#2281, @Avasam)
* Fixed Pythonwin's editor failing due to invalid regex import (#2419, @Avasam)
* Last error wrongly set by some modules (#2302, @CristiFati)
* Dropped support for Python 3.7 (#2207, @Avasam)
Expand Down
5 changes: 2 additions & 3 deletions Pythonwin/pywin/framework/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

from __future__ import annotations

import builtins
import os
import sys
import traceback
Expand Down Expand Up @@ -393,9 +394,7 @@ def Win32Input(prompt=None):


def HookInput():
import code

sys.modules["builtins"].input = Win32Input
builtins.input = Win32Input


def HaveGoodGUI():
Expand Down
2 changes: 1 addition & 1 deletion Pythonwin/win32win.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ generates Windows .hlp files.
#include "win32cmdui.h"
#include "win32rgn.h"
#include "reswin32ui.h"
#include "AFXSTAT_.H"
#include "afxstat_.h"

static char *szErrMsgBadHandle = "The window handle does not specify a valid window";
#define CHECK_HWND_VALID(pWnd) \
Expand Down
3 changes: 2 additions & 1 deletion com/win32com/client/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
#
# OleItem, DispatchItem, MapEntry, BuildCallList() is used by makepy

import builtins
import datetime
import string
from itertools import chain
Expand Down Expand Up @@ -656,7 +657,7 @@ def MakePublicAttributeName(className, is_global=False):
if ret == className:
ret = ret.upper()
return ret
elif is_global and hasattr(__builtins__, className):
elif is_global and hasattr(builtins, className):
# builtins may be mixed case. If capitalizing it doesn't change it,
# force to all uppercase (eg, "None", "True" become "NONE", "TRUE"
ret = className.capitalize()
Expand Down
4 changes: 2 additions & 2 deletions com/win32com/makegw/makegw.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
any result values.
This module automates the generation of such code. It has the ability to
parse a .H file generated by the MIDL tool (ie, almost all COM .h files)
parse a .h file generated by the MIDL tool (ie, almost all COM .h files)
and build almost totally complete C++ code.
The module understands some of the well known data types, and how to
Expand Down Expand Up @@ -61,7 +61,7 @@ def make_framework_support(
):
"""Generate C++ code for a Python Interface and Gateway
header_file_name -- The full path to the .H file which defines the interface.
header_file_name -- The full path to the .h file which defines the interface.
interface_name -- The name of the interface to search for, and to generate.
bMakeInterface = 1 -- Should interface (ie, client) support be generated.
bMakeGatewayInterface = 1 -- Should gateway (ie, server) support be generated.
Expand Down
2 changes: 1 addition & 1 deletion com/win32com/olectl.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
"""Constants used by COM Controls
Hand created version of OLECTL.H constants.
Hand created version of olectl.h constants.
"""

import winerror
Expand Down
2 changes: 1 addition & 1 deletion com/win32com/src/ErrorUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1115,7 +1115,7 @@ LPCTSTR GetFacilityString(HRESULT hr)
_T("FACILITY_0x06"),
_T("FACILITY_WIN32"),
_T("FACILITY_WINDOWS"),
_T("FACILITY_SSPI/FACILITY_MQ"), // SSPI from ADSERR.H, MQ from mq.h
_T("FACILITY_SSPI/FACILITY_MQ"), // SSPI from AdsErr.h, MQ from mq.h
_T("FACILITY_CONTROL"),
_T("FACILITY_EDK"),
_T("FACILITY_INTERNET"),
Expand Down
6 changes: 2 additions & 4 deletions com/win32com/test/GenTestScripts.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
#
import os
import sys
import traceback

import pythoncom
import win32com
Expand Down Expand Up @@ -60,10 +61,7 @@ def GenerateAll():

def CleanAll():
print("Cleaning generated test scripts...")
try: # Clear exceptions!
1 / 0
except:
pass
traceback.clear_frames(sys.exc_info()[2]) # Clear exceptions!
genPath = GetGenPath()
for args in genList:
try:
Expand Down
5 changes: 2 additions & 3 deletions com/win32com/test/testPippo.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,8 @@ def testNumpyArrays(self):
self._testArray(numpy.array([-3.14, -2, -0.1, 0.0, 1.1, 2.5, 3]))

def testByteArrays(self):
if "bytes" in dir(__builtins__):
self._testArray(b"abcdef")
self._testArray(bytearray(b"abcdef"))
self._testArray(b"abcdef")
self._testArray(bytearray(b"abcdef"))

def _testArray(self, inArray):
outArray = self.object.Method3(inArray)
Expand Down
4 changes: 2 additions & 2 deletions com/win32comext/adsi/src/PyADSIUtil.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -672,11 +672,11 @@ BOOL PyADSIObject_AsADS_SEARCHPREF_INFOs(PyObject *ob, ADS_SEARCHPREF_INFO **ppr
//
// Error string utility.
//
// ADSERR.h is built from a message file.
// AdsErr.h is built from a message file.
// Therefore, there _must_ be a DLL around we can call
// FormatMessage with.
// However, it's not obvious, and this code was cut directly from MSDN.
#include "adserr.h"
#include "AdsErr.h"
typedef struct tagADSERRMSG {
HRESULT hr;
LPCWSTR pszError;
Expand Down
8 changes: 2 additions & 6 deletions com/win32comext/axdebug/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

import os
import sys
import traceback

import win32api
import win32com.server.dispatcher
Expand Down Expand Up @@ -43,13 +44,8 @@ def RaiseNotImpl(who=None):
print(f"********* Function {who} Raising E_NOTIMPL ************")

# Print a sort-of "traceback", dumping all the frames leading to here.
try:
1 / 0
except:
frame = sys.exc_info()[2].tb_frame
while frame:
for frame, i in traceback.walk_stack(sys._getframe()):
print(f"File: {frame.f_code.co_filename}, Line: {frame.f_lineno}")
frame = frame.f_back

# and raise the exception for COM
raise COMException(scode=winerror.E_NOTIMPL)
Expand Down
7 changes: 1 addition & 6 deletions com/win32comext/axscript/client/debug.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,12 +125,7 @@ def _query_interface_for_debugger_(self, iid):

def OnEnterScript(self):
trace("OnEnterScript")
try:
1 / 0
except:
# Bit of a hack - reach into engine.
baseFrame = sys.exc_info()[2].tb_frame.f_back
self.adb.SetupAXDebugging(baseFrame)
self.adb.SetupAXDebugging(sys._getframe().f_back)

def OnLeaveScript(self):
trace("OnLeaveScript")
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
/*
* FILENAME:
* guids.cpp
* GUIDs.cpp
*
* DESCRIPTION:
* Define the guids used by the project. Both internally defined
* guids as well as guids from external sources.
* Define the GUIDs used by the project. Both internally defined
* GUIDs as well as GUIDs from external sources.
*/
#include <objbase.h>
#pragma data_seg(".text")
Expand All @@ -17,7 +17,7 @@
#endif

// === Project Guids ===
#include "GUIDS.H"
#include "GUIDs.h"
// NOTE - The standard "activscp.h" header is not good enough -
// need to use IE4 SDK or MSVC6 etc
#include "activscp.h"
Expand Down
Loading

0 comments on commit 8177d74

Please sign in to comment.