Skip to content

Commit 5113659

Browse files
authored
Add all classes in stubs/pyinstaller/PyInstaller/utils/win32/versioninfo.pyi (#13833)
1 parent 9b23a54 commit 5113659

File tree

2 files changed

+121
-10
lines changed

2 files changed

+121
-10
lines changed
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
from PyInstaller.utils.win32.versioninfo import (
2+
FixedFileInfo,
3+
StringFileInfo,
4+
StringStruct,
5+
StringTable,
6+
VarFileInfo,
7+
VarStruct,
8+
VSVersionInfo,
9+
)
10+
11+
# Everything below this line is the content from running `pyi-grab_version python3`
12+
# ==============================================================================
13+
14+
# UTF-8
15+
#
16+
# For more details about fixed file info 'ffi' see:
17+
# http://msdn.microsoft.com/en-us/library/ms646997.aspx
18+
VSVersionInfo(
19+
ffi=FixedFileInfo(
20+
# filevers and prodvers should be always a tuple with four items: (1, 2, 3, 4)
21+
# Set not needed items to zero 0.
22+
filevers=(3, 13, 1150, 1013),
23+
prodvers=(3, 13, 1150, 1013),
24+
# Contains a bitmask that specifies the valid bits 'flags'r
25+
mask=0x3F,
26+
# Contains a bitmask that specifies the Boolean attributes of the file.
27+
flags=0x0,
28+
# The operating system for which this file was designed.
29+
# 0x4 - NT and there is no need to change it.
30+
OS=0x4,
31+
# The general type of file.
32+
# 0x1 - the file is an application.
33+
fileType=0x2,
34+
# The function of the file.
35+
# 0x0 - the function is not defined for this fileType
36+
subtype=0x0,
37+
# Creation date and time stamp.
38+
date=(0, 0),
39+
),
40+
kids=[
41+
StringFileInfo(
42+
[
43+
StringTable(
44+
"000004b0",
45+
[
46+
StringStruct("CompanyName", "Python Software Foundation"),
47+
StringStruct("FileDescription", "Python Core"),
48+
StringStruct("FileVersion", "3.13.1"),
49+
StringStruct("InternalName", "Python DLL"),
50+
StringStruct(
51+
"LegalCopyright",
52+
"Copyright © 2001-2024 Python Software Foundation. Copyright © 2000 BeOpen.com. Copyright © 1995-2001 CNRI. Copyright © 1991-1995 SMC.",
53+
),
54+
StringStruct("OriginalFilename", "python3.dll"),
55+
StringStruct("ProductName", "Python"),
56+
StringStruct("ProductVersion", "3.13.1"),
57+
],
58+
)
59+
]
60+
),
61+
VarFileInfo([VarStruct("Translation", [0, 1200])]),
62+
],
63+
)
Lines changed: 58 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,31 @@
1-
from _typeshed import SliceableBuffer
1+
from _typeshed import SliceableBuffer, Unused
22
from collections.abc import Sequence
3-
from typing import Literal, Protocol
3+
from typing import Any, Protocol, type_check_only
44
from typing_extensions import TypeAlias
55

66
_FourIntSequence: TypeAlias = Sequence[int]
77
_TwoIntSequence: TypeAlias = Sequence[int]
88

9+
@type_check_only
910
class _Kid(Protocol):
1011
def toRaw(self) -> bytes: ...
1112
def __str__(self, indent: str = "", /) -> str: ...
1213

13-
# Used by other types referenced in https://pyinstaller.org/en/stable/spec-files.html#spec-file-operation
14+
# All the classes below are used in version_file_info generated by `pyi-grab_version`
15+
# See: https://pyinstaller.org/en/stable/usage.html#capturing-windows-version-data
16+
17+
# VSVersionInfo is also by other types referenced in https://pyinstaller.org/en/stable/spec-files.html#spec-file-operation
1418
class VSVersionInfo:
1519
ffi: FixedFileInfo | None
1620
kids: list[_Kid]
1721
def __init__(self, ffi: FixedFileInfo | None = None, kids: list[_Kid] | None = None) -> None: ...
1822
def fromRaw(self, data: SliceableBuffer) -> int: ...
1923
def toRaw(self) -> bytes: ...
20-
def __eq__(self, other: object) -> bool: ...
2124
def __str__(self, indent: str = "") -> str: ...
2225

2326
class FixedFileInfo:
24-
sig: Literal[0xFEEF04BD]
25-
strucVersion: Literal[0x10000]
27+
sig: int
28+
strucVersion: int
2629
fileVersionMS: int
2730
fileVersionLS: int
2831
productVersionMS: int
@@ -36,16 +39,61 @@ class FixedFileInfo:
3639
fileDateLS: int
3740
def __init__(
3841
self,
39-
filevers: _FourIntSequence = ...,
40-
prodvers: _FourIntSequence = ...,
42+
filevers: _FourIntSequence = (0, 0, 0, 0),
43+
prodvers: _FourIntSequence = (0, 0, 0, 0),
4144
mask: int = 0x3F,
4245
flags: int = 0x0,
4346
OS: int = 0x40004,
4447
fileType: int = 0x1,
4548
subtype: int = 0x0,
46-
date: _TwoIntSequence = ...,
49+
date: _TwoIntSequence = (0, 0),
4750
) -> None: ...
4851
def fromRaw(self, data: SliceableBuffer, i: int) -> int: ...
4952
def toRaw(self) -> bytes: ...
50-
def __eq__(self, other: object) -> bool: ...
5153
def __str__(self, indent: str = "") -> str: ...
54+
55+
class StringFileInfo:
56+
name: str
57+
kids: list[_Kid]
58+
def __init__(self, kids: list[_Kid] | None = None) -> None: ...
59+
def fromRaw(self, sublen: Unused, vallen: Unused, name: str, data: SliceableBuffer, i: int, limit: int) -> int: ...
60+
def toRaw(self) -> bytes: ...
61+
def __str__(self, indent: str = "") -> str: ...
62+
63+
class StringTable:
64+
name: str
65+
kids: list[_Kid]
66+
def __init__(self, name: str | None = None, kids: list[_Kid] | None = None) -> None: ...
67+
def fromRaw(self, data: SliceableBuffer, i: int, limit: int) -> int: ...
68+
def toRaw(self) -> bytes: ...
69+
def __str__(self, indent: str = "") -> str: ...
70+
71+
class StringStruct:
72+
name: str
73+
val: str
74+
def __init__(self, name: str | None = None, val: str | None = None) -> None: ...
75+
def fromRaw(self, data: SliceableBuffer, i: int, limit: int) -> int: ...
76+
def toRaw(self) -> bytes: ...
77+
def __str__(self, indent: Unused = "") -> str: ...
78+
79+
class VarFileInfo:
80+
kids: list[_Kid]
81+
def __init__(self, kids: list[_Kid] | None = None) -> None: ...
82+
sublen: int
83+
vallen: int
84+
name: str
85+
def fromRaw(self, sublen: int, vallen: int, name: str, data: SliceableBuffer, i: int, limit: int) -> int: ...
86+
wType: int
87+
def toRaw(self) -> bytes: ...
88+
def __str__(self, indent: str = "") -> str: ...
89+
90+
class VarStruct:
91+
name: str
92+
kids: list[Any] # Whatever can be passed to struct.pack
93+
def __init__(self, name: str | None = None, kids: list[Any] | None = None) -> None: ...
94+
def fromRaw(self, data: SliceableBuffer, i: int, limit: Unused) -> int: ...
95+
wValueLength: int
96+
wType: int
97+
sublen: int
98+
def toRaw(self) -> bytes: ...
99+
def __str__(self, indent: Unused = "") -> str: ...

0 commit comments

Comments
 (0)