codecin 7.22.10__py3-none-win_amd64.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- codecin/__init__.py +27 -0
- codecin/aot.py +1057 -0
- codecin/assembler.py +619 -0
- codecin/cbackend.py +3024 -0
- codecin/cin.py +4265 -0
- codecin/cli.py +670 -0
- codecin/codecin_native.dll +0 -0
- codecin/config.py +50 -0
- codecin/console.py +183 -0
- codecin/cpu.py +312 -0
- codecin/crom.py +449 -0
- codecin/cvm.py +708 -0
- codecin/disasm.py +149 -0
- codecin/environment.py +176 -0
- codecin/errors.py +54 -0
- codecin/isa.py +560 -0
- codecin/lib/array/pic.toml +10 -0
- codecin/lib/array/src/array.cin +103 -0
- codecin/lib/bigint/pic.toml +10 -0
- codecin/lib/bigint/src/bigint.cin +589 -0
- codecin/lib/bits/pic.toml +10 -0
- codecin/lib/bits/src/bits.cin +143 -0
- codecin/lib/bitset/pic.toml +10 -0
- codecin/lib/bitset/src/bitset.cin +374 -0
- codecin/lib/codec/pic.toml +10 -0
- codecin/lib/codec/src/codec.cin +563 -0
- codecin/lib/combin/pic.toml +10 -0
- codecin/lib/combin/src/combin.cin +414 -0
- codecin/lib/conv/pic.toml +10 -0
- codecin/lib/conv/src/conv.cin +151 -0
- codecin/lib/cppstd/pic.toml +10 -0
- codecin/lib/cppstd/src/cppstd.cin +418 -0
- codecin/lib/cstd/pic.toml +10 -0
- codecin/lib/cstd/src/cstd.cin +424 -0
- codecin/lib/csv/pic.toml +10 -0
- codecin/lib/csv/src/csv.cin +405 -0
- codecin/lib/dp/pic.toml +10 -0
- codecin/lib/dp/src/dp.cin +325 -0
- codecin/lib/ffi/pic.toml +10 -0
- codecin/lib/ffi/src/ffi.cin +163 -0
- codecin/lib/fmt/pic.toml +10 -0
- codecin/lib/fmt/src/fmt.cin +325 -0
- codecin/lib/frac/pic.toml +10 -0
- codecin/lib/frac/src/frac.cin +252 -0
- codecin/lib/gostd/pic.toml +10 -0
- codecin/lib/gostd/src/gostd.cin +415 -0
- codecin/lib/graph/pic.toml +10 -0
- codecin/lib/graph/src/graph.cin +367 -0
- codecin/lib/gui/pic.toml +10 -0
- codecin/lib/gui/src/gui.cin +218 -0
- codecin/lib/hash/pic.toml +10 -0
- codecin/lib/hash/src/hash.cin +67 -0
- codecin/lib/heap/pic.toml +10 -0
- codecin/lib/heap/src/heap.cin +199 -0
- codecin/lib/io/pic.toml +10 -0
- codecin/lib/io/src/io.cin +141 -0
- codecin/lib/json/pic.toml +10 -0
- codecin/lib/json/src/json.cin +84 -0
- codecin/lib/key/pic.toml +10 -0
- codecin/lib/key/src/key.cin +78 -0
- codecin/lib/math/pic.toml +10 -0
- codecin/lib/math/src/math.cin +50 -0
- codecin/lib/matrix/pic.toml +10 -0
- codecin/lib/matrix/src/matrix.cin +155 -0
- codecin/lib/net/pic.toml +10 -0
- codecin/lib/net/src/net.cin +171 -0
- codecin/lib/path/pic.toml +10 -0
- codecin/lib/path/src/path.cin +372 -0
- codecin/lib/queue/pic.toml +10 -0
- codecin/lib/queue/src/queue.cin +112 -0
- codecin/lib/rand/pic.toml +10 -0
- codecin/lib/rand/src/rand.cin +46 -0
- codecin/lib/set/pic.toml +10 -0
- codecin/lib/set/src/set.cin +269 -0
- codecin/lib/sort/pic.toml +10 -0
- codecin/lib/sort/src/sort.cin +93 -0
- codecin/lib/stat/pic.toml +10 -0
- codecin/lib/stat/src/stat.cin +138 -0
- codecin/lib/str/pic.toml +10 -0
- codecin/lib/str/src/str.cin +54 -0
- codecin/lib/termux/pic.toml +10 -0
- codecin/lib/termux/src/termux.cin +118 -0
- codecin/lib/test/pic.toml +10 -0
- codecin/lib/test/src/test.cin +74 -0
- codecin/lib/text/pic.toml +10 -0
- codecin/lib/text/src/text.cin +323 -0
- codecin/lib/time/pic.toml +10 -0
- codecin/lib/time/src/time.cin +54 -0
- codecin/lib/token/pic.toml +10 -0
- codecin/lib/token/src/token.cin +183 -0
- codecin/lib/tree/pic.toml +10 -0
- codecin/lib/tree/src/tree.cin +256 -0
- codecin/lib/unionfind/pic.toml +10 -0
- codecin/lib/unionfind/src/unionfind.cin +115 -0
- codecin/lib/validate/pic.toml +10 -0
- codecin/lib/validate/src/validate.cin +148 -0
- codecin/lib/vec/pic.toml +10 -0
- codecin/lib/vec/src/vec.cin +88 -0
- codecin/logger.py +145 -0
- codecin/memory.py +306 -0
- codecin/mkn.py +916 -0
- codecin/native/aot/aot.go +114 -0
- codecin/native/aot/stub_main.go.txt +23 -0
- codecin/native/build.ps1 +33 -0
- codecin/native/build.sh +48 -0
- codecin/native/cmd/cincc/main.go +66 -0
- codecin/native/compiler/codegen.go +2238 -0
- codecin/native/compiler/compile_test.go +1069 -0
- codecin/native/compiler/parser.go +1331 -0
- codecin/native/compiler/syscalls.go +166 -0
- codecin/native/compiler/tokenizer.go +394 -0
- codecin/native/compiler/types.go +217 -0
- codecin/native/engine/args.go +37 -0
- codecin/native/engine/audio.go +402 -0
- codecin/native/engine/audio_other.go +105 -0
- codecin/native/engine/audio_test.go +279 -0
- codecin/native/engine/audio_windows.go +190 -0
- codecin/native/engine/canvas.go +271 -0
- codecin/native/engine/console_other.go +9 -0
- codecin/native/engine/console_windows.go +43 -0
- codecin/native/engine/crom.go +86 -0
- codecin/native/engine/encode.go +93 -0
- codecin/native/engine/engine_test.go +198 -0
- codecin/native/engine/ffi_nocgo.go +20 -0
- codecin/native/engine/ffi_registry.go +69 -0
- codecin/native/engine/ffi_unix.go +109 -0
- codecin/native/engine/ffi_windows.go +117 -0
- codecin/native/engine/gui.go +209 -0
- codecin/native/engine/gui_stub.go +13 -0
- codecin/native/engine/gui_test.go +148 -0
- codecin/native/engine/gui_windows.go +604 -0
- codecin/native/engine/gui_x11.go +723 -0
- codecin/native/engine/host_test.go +139 -0
- codecin/native/engine/hostcrypto.go +30 -0
- codecin/native/engine/hostdesktop.go +173 -0
- codecin/native/engine/hostnet.go +127 -0
- codecin/native/engine/isa_gen.go +689 -0
- codecin/native/engine/keyboard.go +432 -0
- codecin/native/engine/keyboard_other.go +94 -0
- codecin/native/engine/keyboard_stub.go +17 -0
- codecin/native/engine/keyboard_termios_darwin.go +9 -0
- codecin/native/engine/keyboard_termios_linux.go +9 -0
- codecin/native/engine/keyboard_test.go +246 -0
- codecin/native/engine/keyboard_windows.go +208 -0
- codecin/native/engine/keyboard_windows_test.go +123 -0
- codecin/native/engine/lineedit.go +262 -0
- codecin/native/engine/lineedit_test.go +105 -0
- codecin/native/engine/lineint_unix.go +17 -0
- codecin/native/engine/lineint_windows.go +19 -0
- codecin/native/engine/mem_other.go +37 -0
- codecin/native/engine/mem_windows.go +33 -0
- codecin/native/engine/native.go +640 -0
- codecin/native/engine/netsock.go +321 -0
- codecin/native/engine/ops_ext.go +515 -0
- codecin/native/engine/stdin.go +72 -0
- codecin/native/engine/stdin_other.go +9 -0
- codecin/native/engine/stdin_windows.go +60 -0
- codecin/native/engine/system.go +313 -0
- codecin/native/engine/termux.go +180 -0
- codecin/native/engine/version_gen.go +7 -0
- codecin/native/engine/vkb_darwin.go +62 -0
- codecin/native/engine/vkb_linux.go +95 -0
- codecin/native/engine/vkb_stub.go +11 -0
- codecin/native/engine/vm.go +1677 -0
- codecin/native/go.mod +3 -0
- codecin/native/ir/ir.go +48 -0
- codecin/native/main.go +448 -0
- codecin/native/mc/aarch64.go +165 -0
- codecin/native/mc/aarch64_test.go +30 -0
- codecin/native/mc/elf.go +88 -0
- codecin/native/mc/print_test.go +52 -0
- codecin/native/mc/x86_64.go +1262 -0
- codecin/native/mc/x86_64_test.go +102 -0
- codecin/native.py +432 -0
- codecin/native_codegen.py +987 -0
- codecin/nativegen.py +786 -0
- codecin/object.py +539 -0
- codecin/optimizer.py +236 -0
- codecin/packaging/__init__.py +46 -0
- codecin/packaging/archive.py +177 -0
- codecin/packaging/model.py +519 -0
- codecin/packaging/spec.py +193 -0
- codecin/packaging/store.py +372 -0
- codecin/packaging/toml.py +541 -0
- codecin/packaging/vcs.py +215 -0
- codecin/pic.py +1917 -0
- codecin/pic_api.py +374 -0
- codecin/pic_login.py +519 -0
- codecin/pic_registry.py +515 -0
- codecin/registers.py +130 -0
- codecin/sdgcc.py +493 -0
- codecin/stats.py +230 -0
- codecin/stdlib.py +138 -0
- codecin/toolchain.py +396 -0
- codecin/toolkit.py +26 -0
- codecin/version.py +260 -0
- codecin-7.22.10.dist-info/METADATA +1077 -0
- codecin-7.22.10.dist-info/RECORD +202 -0
- codecin-7.22.10.dist-info/WHEEL +5 -0
- codecin-7.22.10.dist-info/entry_points.txt +5 -0
- codecin-7.22.10.dist-info/licenses/LICENSE +7 -0
- codecin-7.22.10.dist-info/top_level.txt +1 -0
codecin/packaging/vcs.py
ADDED
|
@@ -0,0 +1,215 @@
|
|
|
1
|
+
"""Git 操作封装 (克隆 / 标签 / 工作区检查)。
|
|
2
|
+
|
|
3
|
+
只依赖命令行 ``git``: 不引入 GitPython, 保持工具轻量; 所有调用都显式
|
|
4
|
+
禁用交互式凭据提示 (``GIT_TERMINAL_PROMPT=0``), 避免 CI/工具里卡住。
|
|
5
|
+
"""
|
|
6
|
+
|
|
7
|
+
import os
|
|
8
|
+
import re
|
|
9
|
+
import shutil
|
|
10
|
+
import subprocess
|
|
11
|
+
from typing import List, Optional, Tuple
|
|
12
|
+
|
|
13
|
+
__all__ = [
|
|
14
|
+
'VcsError', 'clone', 'commit_all', 'create_tag', 'current_rev',
|
|
15
|
+
'git_available', 'git_init', 'is_clean', 'is_git_spec', 'is_repo',
|
|
16
|
+
'list_tags', 'push_tag', 'remote_url', 'split_git_spec',
|
|
17
|
+
]
|
|
18
|
+
|
|
19
|
+
_SHA_RE = re.compile(r'^[0-9a-f]{7,40}$')
|
|
20
|
+
_URL_PREFIXES = ('git+', 'git@', 'http://', 'https://', 'ssh://', 'git://',
|
|
21
|
+
'file://')
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
class VcsError(RuntimeError):
|
|
25
|
+
"""Git 命令失败或仓库状态不满足要求。"""
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
def git_available() -> bool:
|
|
29
|
+
return shutil.which('git') is not None
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
def _run(args: List[str], cwd: Optional[str] = None,
|
|
33
|
+
timeout: int = 300) -> subprocess.CompletedProcess:
|
|
34
|
+
env = dict(os.environ)
|
|
35
|
+
env.setdefault('GIT_TERMINAL_PROMPT', '0')
|
|
36
|
+
env.setdefault('GIT_ASKPASS', 'echo')
|
|
37
|
+
env.setdefault('GCM_INTERACTIVE', 'never')
|
|
38
|
+
try:
|
|
39
|
+
proc = subprocess.run(['git', *args], cwd=cwd, env=env,
|
|
40
|
+
capture_output=True, text=True,
|
|
41
|
+
encoding='utf-8', errors='replace',
|
|
42
|
+
timeout=timeout)
|
|
43
|
+
except FileNotFoundError as e:
|
|
44
|
+
raise VcsError('未找到 git 命令; 请安装 Git 后重试') from e
|
|
45
|
+
except subprocess.TimeoutExpired as e:
|
|
46
|
+
raise VcsError(f'git 命令超时 ({timeout}s): git {" ".join(args)}') from e
|
|
47
|
+
if proc.returncode != 0:
|
|
48
|
+
detail = (proc.stderr or proc.stdout or '').strip()
|
|
49
|
+
raise VcsError(
|
|
50
|
+
f'git {" ".join(args)} 失败 (exit {proc.returncode}):\n{detail}')
|
|
51
|
+
return proc
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
def is_git_spec(spec: str) -> bool:
|
|
55
|
+
"""字符串是否像 Git 地址 (而不是包名)。"""
|
|
56
|
+
text = str(spec or '').strip()
|
|
57
|
+
if not text:
|
|
58
|
+
return False
|
|
59
|
+
low = text.lower()
|
|
60
|
+
# 本地已存在的目录由调用方决定是否作为路径依赖; 这里不臆测
|
|
61
|
+
return low.startswith(_URL_PREFIXES) or low.endswith('.git')
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
def split_git_spec(spec: str) -> Tuple[str, Optional[str]]:
|
|
65
|
+
"""拆出 ``URL@ref``; 兼容 ``git@host:user/repo.git`` 形式。"""
|
|
66
|
+
text = str(spec or '').strip()
|
|
67
|
+
if text.lower().startswith('git+'):
|
|
68
|
+
text = text[4:]
|
|
69
|
+
ref: Optional[str] = None
|
|
70
|
+
if text.startswith('git@'):
|
|
71
|
+
# scp 风格: 只有最后一个 @ 之后不含 / 或 : 时才视为 ref
|
|
72
|
+
head, sep, tail = text.rpartition('@')
|
|
73
|
+
if sep and tail and '/' not in tail and ':' not in tail:
|
|
74
|
+
text, ref = head, tail
|
|
75
|
+
return text, ref
|
|
76
|
+
if '@' in text:
|
|
77
|
+
head, tail = text.rsplit('@', 1)
|
|
78
|
+
if tail and '/' not in tail and ':' not in tail:
|
|
79
|
+
text, ref = head, tail
|
|
80
|
+
return text, ref
|
|
81
|
+
|
|
82
|
+
|
|
83
|
+
def _local_repo_path(url: str) -> Optional[str]:
|
|
84
|
+
"""把本地路径 / file:// URL 归一化为本地 Git 仓库目录。"""
|
|
85
|
+
text = str(url or '').strip()
|
|
86
|
+
if text.lower().startswith('file://'):
|
|
87
|
+
text = text[7:]
|
|
88
|
+
if re.match(r'^/[A-Za-z]:', text): # file:///C:/...
|
|
89
|
+
text = text[1:]
|
|
90
|
+
if os.path.isdir(text) and is_repo(text):
|
|
91
|
+
return os.path.abspath(text)
|
|
92
|
+
return None
|
|
93
|
+
|
|
94
|
+
|
|
95
|
+
def clone(url: str, dest: str, ref: Optional[str] = None,
|
|
96
|
+
depth: Optional[int] = 1) -> str:
|
|
97
|
+
"""克隆到 ``dest``; ``ref`` 可为标签/分支/提交。
|
|
98
|
+
|
|
99
|
+
本地仓库走文件复制 + ``reset --hard``, 避免受限环境里
|
|
100
|
+
``git-upload-pack``/``sh`` 的命名管道限制; 远端仓库走浅克隆。
|
|
101
|
+
"""
|
|
102
|
+
url, inline_ref = split_git_spec(url)
|
|
103
|
+
ref = ref or inline_ref
|
|
104
|
+
dest = os.path.abspath(dest)
|
|
105
|
+
parent = os.path.dirname(dest)
|
|
106
|
+
os.makedirs(parent, exist_ok=True)
|
|
107
|
+
# 不用 tempfile.mkdtemp: 受限环境可能让该目录不可写; 普通 makedirs 目录
|
|
108
|
+
# 继承父目录 ACL, 克隆到其子目录后再原子改名。
|
|
109
|
+
tmp = os.path.join(parent, f'.clone-{os.getpid()}-{os.urandom(4).hex()}')
|
|
110
|
+
os.makedirs(tmp, exist_ok=True)
|
|
111
|
+
work = os.path.join(tmp, 'repo')
|
|
112
|
+
try:
|
|
113
|
+
local = _local_repo_path(url)
|
|
114
|
+
if local is not None:
|
|
115
|
+
shutil.copytree(local, work)
|
|
116
|
+
# reset 已同时更新 HEAD / 索引 / 工作区; 不要再 checkout 同一个
|
|
117
|
+
# ref, 否则在部分 Git/文件系统组合上会偶发 pathspec 错误。
|
|
118
|
+
_run(['reset', '--hard', '--quiet', ref or 'HEAD'], cwd=work)
|
|
119
|
+
_run(['clean', '-fdxq'], cwd=work)
|
|
120
|
+
if os.path.exists(dest):
|
|
121
|
+
shutil.rmtree(dest)
|
|
122
|
+
os.replace(work, dest)
|
|
123
|
+
return dest
|
|
124
|
+
|
|
125
|
+
attempt: List[str] = ['clone', '--quiet']
|
|
126
|
+
if depth and not (ref and _SHA_RE.match(ref)):
|
|
127
|
+
attempt += ['--depth', str(depth)]
|
|
128
|
+
if ref and not _SHA_RE.match(ref):
|
|
129
|
+
attempt += ['--branch', ref]
|
|
130
|
+
attempt += [url, work]
|
|
131
|
+
try:
|
|
132
|
+
_run(attempt)
|
|
133
|
+
except VcsError:
|
|
134
|
+
# 浅克隆/指定分支失败时退回完整克隆, 再 checkout
|
|
135
|
+
shutil.rmtree(work, ignore_errors=True)
|
|
136
|
+
_run(['clone', '--quiet', url, work])
|
|
137
|
+
if ref:
|
|
138
|
+
_run(['checkout', '--quiet', ref], cwd=work)
|
|
139
|
+
else:
|
|
140
|
+
if ref and _SHA_RE.match(ref):
|
|
141
|
+
_run(['checkout', '--quiet', ref], cwd=work)
|
|
142
|
+
if os.path.exists(dest):
|
|
143
|
+
shutil.rmtree(dest)
|
|
144
|
+
os.replace(work, dest)
|
|
145
|
+
return dest
|
|
146
|
+
finally:
|
|
147
|
+
if os.path.exists(tmp):
|
|
148
|
+
shutil.rmtree(tmp, ignore_errors=True)
|
|
149
|
+
|
|
150
|
+
|
|
151
|
+
def is_repo(path: str) -> bool:
|
|
152
|
+
"""目录是否位于 Git 工作区中 (支持 monorepo 子目录)。"""
|
|
153
|
+
if os.path.isdir(os.path.join(path, '.git')) or (
|
|
154
|
+
os.path.isfile(os.path.join(path, '.git'))):
|
|
155
|
+
return True
|
|
156
|
+
if not git_available():
|
|
157
|
+
return False
|
|
158
|
+
try:
|
|
159
|
+
proc = _run(['rev-parse', '--is-inside-work-tree'], cwd=path)
|
|
160
|
+
except VcsError:
|
|
161
|
+
return False
|
|
162
|
+
return proc.stdout.strip() == 'true'
|
|
163
|
+
|
|
164
|
+
|
|
165
|
+
def git_init(path: str) -> None:
|
|
166
|
+
os.makedirs(path, exist_ok=True)
|
|
167
|
+
if not is_repo(path):
|
|
168
|
+
_run(['init', '--quiet'], cwd=path)
|
|
169
|
+
|
|
170
|
+
|
|
171
|
+
def current_rev(path: str) -> str:
|
|
172
|
+
return _run(['rev-parse', 'HEAD'], cwd=path).stdout.strip()
|
|
173
|
+
|
|
174
|
+
|
|
175
|
+
def is_clean(path: str) -> bool:
|
|
176
|
+
"""工作区是否干净 (含未跟踪文件)。"""
|
|
177
|
+
return not _run(['status', '--porcelain'], cwd=path).stdout.strip()
|
|
178
|
+
|
|
179
|
+
|
|
180
|
+
def remote_url(path: str, remote: str = 'origin') -> Optional[str]:
|
|
181
|
+
proc = _run(['remote', 'get-url', remote], cwd=path)
|
|
182
|
+
value = proc.stdout.strip()
|
|
183
|
+
return value or None
|
|
184
|
+
|
|
185
|
+
|
|
186
|
+
def list_tags(path: Optional[str] = None, url: Optional[str] = None) -> List[str]:
|
|
187
|
+
if url is not None and path is None:
|
|
188
|
+
path = _local_repo_path(url)
|
|
189
|
+
if path:
|
|
190
|
+
out = _run(['tag', '--list'], cwd=path).stdout
|
|
191
|
+
elif url:
|
|
192
|
+
out = _run(['ls-remote', '--tags', '--refs', url]).stdout
|
|
193
|
+
return [line.split('refs/tags/', 1)[1] for line in out.splitlines()
|
|
194
|
+
if 'refs/tags/' in line]
|
|
195
|
+
else:
|
|
196
|
+
raise VcsError('list_tags 需要 path 或 url')
|
|
197
|
+
return [line.strip() for line in out.splitlines() if line.strip()]
|
|
198
|
+
|
|
199
|
+
|
|
200
|
+
def create_tag(path: str, tag: str, message: Optional[str] = None) -> bool:
|
|
201
|
+
"""创建带注释标签; 已存在且指向同一提交时返回 False。"""
|
|
202
|
+
exists = _run(['tag', '--list', tag], cwd=path).stdout.strip()
|
|
203
|
+
if exists:
|
|
204
|
+
return False
|
|
205
|
+
_run(['tag', '-a', tag, '-m', message or tag], cwd=path)
|
|
206
|
+
return True
|
|
207
|
+
|
|
208
|
+
|
|
209
|
+
def push_tag(path: str, tag: str, remote: str = 'origin') -> None:
|
|
210
|
+
_run(['push', remote, tag], cwd=path, timeout=600)
|
|
211
|
+
|
|
212
|
+
|
|
213
|
+
def commit_all(path: str, message: str) -> None:
|
|
214
|
+
_run(['add', '-A'], cwd=path)
|
|
215
|
+
_run(['commit', '-m', message], cwd=path)
|