hython-lang 2.0.0__py3-none-any.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.
- hython/__init__.py +15 -0
- hython/__main__.py +3 -0
- hython/bytecode.py +368 -0
- hython/cli.py +449 -0
- hython/compiler.py +870 -0
- hython/compiler_manager.py +227 -0
- hython/diagnostics.py +158 -0
- hython/environment.py +48 -0
- hython/exe_builder.py +330 -0
- hython/frontend.py +870 -0
- hython/hir.py +93 -0
- hython/importer.py +76 -0
- hython/package_manager.py +343 -0
- hython/phonetics.py +49 -0
- hython/runtime.py +110 -0
- hython/runtime_manager.py +83 -0
- hython/translator.py +244 -0
- hython/updater.py +93 -0
- hython/vm.py +2409 -0
- hython/vocabulary.py +132 -0
- hython_lang-2.0.0.dist-info/METADATA +327 -0
- hython_lang-2.0.0.dist-info/RECORD +26 -0
- hython_lang-2.0.0.dist-info/WHEEL +5 -0
- hython_lang-2.0.0.dist-info/entry_points.txt +2 -0
- hython_lang-2.0.0.dist-info/licenses/LICENSE +22 -0
- hython_lang-2.0.0.dist-info/top_level.txt +1 -0
hython/vocabulary.py
ADDED
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
"""Canonical Hython vocabulary.
|
|
2
|
+
|
|
3
|
+
The spellings deliberately follow pronunciation rather than Korean meaning.
|
|
4
|
+
Aliases can be accepted, but reverse translation always emits the canonical form.
|
|
5
|
+
"""
|
|
6
|
+
|
|
7
|
+
import builtins as _python_builtins
|
|
8
|
+
|
|
9
|
+
from .phonetics import pronounce_identifier
|
|
10
|
+
|
|
11
|
+
KEYWORDS: dict[str, str] = {
|
|
12
|
+
"False": "폴스", "None": "넌", "True": "트루",
|
|
13
|
+
"and": "앤드", "as": "애즈", "assert": "어설트",
|
|
14
|
+
"async": "어싱크", "await": "어웨이트", "break": "브레이크",
|
|
15
|
+
"class": "클래스", "continue": "컨티뉴", "def": "데프",
|
|
16
|
+
"del": "델", "elif": "엘리프", "else": "엘스",
|
|
17
|
+
"except": "익셉트", "finally": "파이널리", "for": "포",
|
|
18
|
+
"from": "프롬", "global": "글로벌", "if": "이프",
|
|
19
|
+
"import": "인폴트", "in": "인", "is": "이즈",
|
|
20
|
+
"lambda": "람다", "nonlocal": "논로컬", "not": "낫",
|
|
21
|
+
"or": "오어", "pass": "패스", "raise": "레이즈",
|
|
22
|
+
"return": "리턴", "try": "트라이", "while": "와일",
|
|
23
|
+
"with": "위드", "yield": "일드", "match": "매치",
|
|
24
|
+
"case": "케이스", "type": "타입",
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
BUILTINS: dict[str, str] = {
|
|
28
|
+
"print": "프린트", "input": "인풋", "len": "렌",
|
|
29
|
+
"range": "레인지", "str": "스트링", "int": "인트",
|
|
30
|
+
"float": "플로트", "bool": "불", "list": "리스트",
|
|
31
|
+
"dict": "딕트", "set": "셋", "tuple": "튜플",
|
|
32
|
+
"open": "오픈", "enumerate": "이뉴머레이트", "zip": "집",
|
|
33
|
+
"map": "맵", "filter": "필터", "sum": "썸", "min": "민",
|
|
34
|
+
"max": "맥스", "abs": "앱스", "round": "라운드",
|
|
35
|
+
"sorted": "소티드", "reversed": "리버스드", "super": "수퍼",
|
|
36
|
+
"object": "오브젝트", "property": "프로퍼티",
|
|
37
|
+
"staticmethod": "스태틱메서드", "classmethod": "클래스메서드",
|
|
38
|
+
"isinstance": "이즈인스턴스", "issubclass": "이즈서브클래스",
|
|
39
|
+
"getattr": "겟애트리뷰트", "setattr": "셋애트리뷰트", "hasattr": "해즈애트리뷰트",
|
|
40
|
+
"metaclass": "메타클래스",
|
|
41
|
+
"Exception": "익셉션", "ExceptionGroup": "익셉션그룹", "BaseExceptionGroup": "베이스익셉션그룹", "ValueError": "밸류에러",
|
|
42
|
+
"TypeError": "타입에러", "NameError": "네임에러",
|
|
43
|
+
"AssertionError": "어설션에러",
|
|
44
|
+
"next": "넥스트",
|
|
45
|
+
"any": "애니", "all": "올",
|
|
46
|
+
"aiter": "에이터", "anext": "에이넥스트",
|
|
47
|
+
"ascii": "아스키", "bin": "빈", "breakpoint": "브레이크포인트",
|
|
48
|
+
"bytearray": "바이트어레이", "bytes": "바이츠", "callable": "콜러블",
|
|
49
|
+
"chr": "씨에이치알", "compile": "컴파일", "complex": "컴플렉스",
|
|
50
|
+
"delattr": "델애트리뷰트", "dir": "디어", "divmod": "디브모드",
|
|
51
|
+
"eval": "이밸", "exec": "이그젝", "format": "포맷",
|
|
52
|
+
"frozenset": "프로즌셋", "globals": "글로벌스", "hash": "해시",
|
|
53
|
+
"help": "헬프", "hex": "헥스", "id": "아이디", "iter": "이터",
|
|
54
|
+
"locals": "로컬스", "memoryview": "메모리뷰", "oct": "옥트",
|
|
55
|
+
"ord": "오드", "pow": "파우", "repr": "레퍼", "slice": "슬라이스",
|
|
56
|
+
"vars": "바스",
|
|
57
|
+
"BaseException": "베이스익셉션", "ArithmeticError": "어리스메틱에러",
|
|
58
|
+
"AttributeError": "애트리뷰트에러", "ImportError": "인폴트에러",
|
|
59
|
+
"ModuleNotFoundError": "모듈낫파운드에러", "IndexError": "인덱스에러",
|
|
60
|
+
"KeyError": "키에러", "LookupError": "룩업에러", "MemoryError": "메모리에러",
|
|
61
|
+
"NotImplementedError": "낫임플리멘티드에러", "OSError": "오에스에러",
|
|
62
|
+
"OverflowError": "오버플로에러", "RecursionError": "리커전에러",
|
|
63
|
+
"ReferenceError": "레퍼런스에러", "RuntimeError": "런타임에러",
|
|
64
|
+
"StopIteration": "스톱이터레이션", "SyntaxError": "신택스에러",
|
|
65
|
+
"SystemError": "시스템에러", "SystemExit": "시스템엑시트",
|
|
66
|
+
"UnboundLocalError": "언바운드로컬에러", "UnicodeError": "유니코드에러",
|
|
67
|
+
"ZeroDivisionError": "제로디비전에러", "GeneratorExit": "제너레이터엑시트",
|
|
68
|
+
"KeyboardInterrupt": "키보드인터럽트", "NotImplemented": "낫임플리멘티드",
|
|
69
|
+
"asyncio_run": "어싱크실행",
|
|
70
|
+
"StopAsyncIteration": "스톱어싱크이터레이션",
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
# Frequently used standard-library and GUI API names. Package dictionaries
|
|
74
|
+
# extend this table, but these spellings are available immediately after a
|
|
75
|
+
# fresh Hython installation. They also make a tkinter program contain no
|
|
76
|
+
# mandatory English identifiers.
|
|
77
|
+
LIBRARY_NAMES: dict[str, str] = {
|
|
78
|
+
"tkinter": "티킨터", "Tk": "티케이", "Tcl": "티클",
|
|
79
|
+
"ttk": "티티케이", "messagebox": "메시지박스",
|
|
80
|
+
"filedialog": "파일다이얼로그", "colorchooser": "컬러추저",
|
|
81
|
+
"simpledialog": "심플다이얼로그",
|
|
82
|
+
"mainloop": "메인루프", "title": "타이틀", "geometry": "지오메트리",
|
|
83
|
+
"destroy": "디스트로이", "withdraw": "위드드로우",
|
|
84
|
+
"configure": "컨피겨", "config": "컨피그",
|
|
85
|
+
"pack": "팩", "grid": "그리드", "place": "플레이스",
|
|
86
|
+
"Label": "레이블", "Button": "버튼", "Entry": "엔트리",
|
|
87
|
+
"Frame": "프레임", "Canvas": "캔버스", "Text": "텍스트",
|
|
88
|
+
"StringVar": "스트링바", "IntVar": "인트바",
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
# Python data-model spellings. The underscores retain their structural
|
|
92
|
+
# meaning, while the English body can be written entirely in Hangul.
|
|
93
|
+
SPECIAL_NAMES: dict[str, str] = {
|
|
94
|
+
"__name__": "__네임__", "__main__": "__메인__", "__file__": "__파일__",
|
|
95
|
+
"__package__": "__패키지__", "__cached__": "__캐시드__",
|
|
96
|
+
"__builtins__": "__빌트인스__", "__all__": "__올__",
|
|
97
|
+
"__doc__": "__도크__", "__module__": "__모듈__",
|
|
98
|
+
"__annotations__": "__애노테이션스__", "__dict__": "__딕트__",
|
|
99
|
+
"__class__": "__클래스__", "__bases__": "__베이시스__",
|
|
100
|
+
"__init__": "__이니트__", "__new__": "__뉴__", "__del__": "__델__",
|
|
101
|
+
"__repr__": "__레퍼__", "__str__": "__스트링__",
|
|
102
|
+
"__bytes__": "__바이츠__", "__format__": "__포맷__",
|
|
103
|
+
"__len__": "__렌__", "__iter__": "__이터__", "__next__": "__넥스트__",
|
|
104
|
+
"__getitem__": "__겟아이템__", "__setitem__": "__셋아이템__",
|
|
105
|
+
"__delitem__": "__델아이템__", "__contains__": "__컨테인스__",
|
|
106
|
+
"__enter__": "__엔터__", "__exit__": "__엑시트__",
|
|
107
|
+
"__aenter__": "__에이엔터__", "__aexit__": "__에이엑시트__",
|
|
108
|
+
"__call__": "__콜__", "__getattr__": "__겟애트리뷰트__",
|
|
109
|
+
"__setattr__": "__셋애트리뷰트__", "__delattr__": "__델애트리뷰트__",
|
|
110
|
+
"__getattribute__": "__겟애트리뷰트전체__",
|
|
111
|
+
"__eq__": "__이큐__", "__ne__": "__엔이__", "__lt__": "__엘티__",
|
|
112
|
+
"__le__": "__엘이__", "__gt__": "__지티__", "__ge__": "__지이__",
|
|
113
|
+
"__hash__": "__해시__", "__bool__": "__불__",
|
|
114
|
+
"__add__": "__애드__", "__sub__": "__서브__", "__mul__": "__멀__",
|
|
115
|
+
"__truediv__": "__트루디브__", "__floordiv__": "__플로어디브__",
|
|
116
|
+
"__mod__": "__모드__", "__pow__": "__파우__",
|
|
117
|
+
"__await__": "__어웨이트__", "__aiter__": "__에이터__",
|
|
118
|
+
"__anext__": "__에이넥스트__", "__match_args__": "__매치_아그스__",
|
|
119
|
+
"__slots__": "__슬롯스__", "__mro__": "__엠알오__",
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
# Explicit spellings remain canonical. Public builtins introduced by newer
|
|
123
|
+
# Python releases automatically receive a deterministic phonetic spelling.
|
|
124
|
+
for _name in dir(_python_builtins):
|
|
125
|
+
if not _name.startswith("_") and _name not in KEYWORDS:
|
|
126
|
+
BUILTINS.setdefault(_name, pronounce_identifier(_name))
|
|
127
|
+
|
|
128
|
+
PYTHON_TO_HYTHON = KEYWORDS | BUILTINS | LIBRARY_NAMES | SPECIAL_NAMES
|
|
129
|
+
HYTHON_TO_PYTHON = {spoken: python for python, spoken in PYTHON_TO_HYTHON.items()}
|
|
130
|
+
|
|
131
|
+
# Accepted conveniences which are not emitted by to_hython().
|
|
132
|
+
HYTHON_TO_PYTHON.update({"임포트": "import", "널": "None"})
|
|
@@ -0,0 +1,327 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: hython-lang
|
|
3
|
+
Version: 2.0.0
|
|
4
|
+
Summary: Python, pronounced in Hangul
|
|
5
|
+
Author: Hython contributors
|
|
6
|
+
License-Expression: MIT
|
|
7
|
+
Keywords: python,korean,esoteric-language,compiler,virtual-machine
|
|
8
|
+
Classifier: Development Status :: 5 - Production/Stable
|
|
9
|
+
Classifier: Programming Language :: Python :: 3.14
|
|
10
|
+
Classifier: Topic :: Software Development :: Compilers
|
|
11
|
+
Requires-Python: >=3.14
|
|
12
|
+
Description-Content-Type: text/markdown
|
|
13
|
+
License-File: LICENSE
|
|
14
|
+
Provides-Extra: exe
|
|
15
|
+
Requires-Dist: pyinstaller>=6.16; extra == "exe"
|
|
16
|
+
Provides-Extra: native
|
|
17
|
+
Requires-Dist: nuitka>=2.8; extra == "native"
|
|
18
|
+
Requires-Dist: ordered-set>=4.1; extra == "native"
|
|
19
|
+
Requires-Dist: zstandard>=0.23; extra == "native"
|
|
20
|
+
Provides-Extra: publish
|
|
21
|
+
Requires-Dist: build>=1.3; extra == "publish"
|
|
22
|
+
Requires-Dist: twine>=6.2; extra == "publish"
|
|
23
|
+
Dynamic: license-file
|
|
24
|
+
|
|
25
|
+
# 하이썬 (Hython)
|
|
26
|
+
|
|
27
|
+
**Python, pronounced in Hangul.** Python의 의미를 번역하지 않고 발음을 한글로 적는
|
|
28
|
+
난해한 프로그래밍 언어입니다.
|
|
29
|
+
|
|
30
|
+
```hython
|
|
31
|
+
데프 인사(이름):
|
|
32
|
+
프린트(f"안녕, {이름}!")
|
|
33
|
+
|
|
34
|
+
포 번호 인 레인지(3):
|
|
35
|
+
인사(번호)
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
## 설치와 실행
|
|
39
|
+
|
|
40
|
+
```console
|
|
41
|
+
python -m pip install -e .
|
|
42
|
+
python -m pip install -e ".[exe]"
|
|
43
|
+
hython init
|
|
44
|
+
hython run examples/안녕.hy
|
|
45
|
+
hython module 내패키지
|
|
46
|
+
hython repl
|
|
47
|
+
hython doctor
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
### 독립 Hython 실행 파일 빌드
|
|
51
|
+
|
|
52
|
+
Windows에서 저장소의 `build-hython.bat`을 실행하면 전체 테스트 후 다음 파일을 만듭니다.
|
|
53
|
+
|
|
54
|
+
```text
|
|
55
|
+
release/hython.exe
|
|
56
|
+
release/hython.exe.sha256
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
`hython.exe`는 Nuitka로 Hython 모듈을 C 소스로 변환하고 MSVC로 컴파일한 Hython
|
|
60
|
+
compiler·HBC VM·런타임/컴파일러 업데이트·패키지·EXE 배포 one-file CLI입니다.
|
|
61
|
+
처음 실행한 PC에 Python이 없더라도
|
|
62
|
+
기본 compile/run/execute는 바로 동작하며, 패키지 설치·런타임 업데이트처럼 외부 Python이
|
|
63
|
+
필요한 명령은 공식 Python install manager를 사용합니다. 설치 패키지는 실행 파일을
|
|
64
|
+
수정하지 않고 `~/.hython/packages/python-X.Y`에 저장됩니다.
|
|
65
|
+
|
|
66
|
+
용량과 공격 표면을 줄이기 위해 C 빌드에는 Tkinter/Tcl/Tk를 기본 포함하지 않습니다.
|
|
67
|
+
Tkinter는 pip 패키지가 아니므로 `package install tkinter` 대상이 아닙니다. GUI가 필요하면
|
|
68
|
+
공식 Python 런타임을 설치·선택하거나 PyPI판 Hython을 전체 Python 환경에 설치합니다.
|
|
69
|
+
|
|
70
|
+
```console
|
|
71
|
+
hython runtime install default
|
|
72
|
+
hython runtime use default
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
```hython
|
|
76
|
+
인폴트 tkinter 애즈 tk
|
|
77
|
+
창 = tk.Tk()
|
|
78
|
+
tk.Label(창, text="안녕하세요, 하이썬!").pack(padx=40, pady=40)
|
|
79
|
+
창.mainloop()
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
### pip 설치와 PyPI 게시
|
|
83
|
+
|
|
84
|
+
게시 후 사용자는 다음 한 줄로 설치합니다.
|
|
85
|
+
|
|
86
|
+
```console
|
|
87
|
+
py -3.14 -m pip install hython-lang
|
|
88
|
+
hython --version
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
배포 담당자는 `publish-pypi.bat`으로 wheel과 sdist를 만들고 검사합니다. 실제 업로드는
|
|
92
|
+
`TWINE_PASSWORD`에 `pypi-` API token을 설정한 경우에만 수행됩니다.
|
|
93
|
+
|
|
94
|
+
```console
|
|
95
|
+
publish-pypi.bat
|
|
96
|
+
publish-pypi.bat testpypi
|
|
97
|
+
publish-pypi.bat pypi
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
### Windows 전용 설치 프로그램
|
|
101
|
+
|
|
102
|
+
WiX가 설치된 빌드 PC에서 다음 명령으로 x64 MSI와 체크섬을 생성합니다.
|
|
103
|
+
|
|
104
|
+
```console
|
|
105
|
+
build-installer.bat
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
MSI는 Hython을 Program Files에 설치하고 시스템 PATH와 시작 메뉴 REPL 바로가기를
|
|
109
|
+
등록하며 Windows 앱 제거 화면을 통한 업그레이드·제거를 지원합니다.
|
|
110
|
+
|
|
111
|
+
```console
|
|
112
|
+
build-hython.bat
|
|
113
|
+
release\hython.exe doctor
|
|
114
|
+
release\hython.exe compile examples\컴파일.hy
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
### 한글 오류 진단
|
|
118
|
+
|
|
119
|
+
호환 실행, HBC VM, REPL과 독립 `hython.exe`는 이름·형식·문법·import·파일·키·인덱스·
|
|
120
|
+
0 나누기 등 표준 오류와 traceback 위치를 한국어로 출력합니다. 사용자 정의 예외 메시지와
|
|
121
|
+
파일명·줄 번호·소스 캐럿은 그대로 보존합니다.
|
|
122
|
+
|
|
123
|
+
```text
|
|
124
|
+
하이썬 추적 (가장 최근 호출이 마지막):
|
|
125
|
+
파일 "프로그램.hy", 줄 3, 함수 <module>
|
|
126
|
+
프린트(없는이름)
|
|
127
|
+
이름 오류: 이름 '없는이름'이 정의되지 않았습니다.
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
컴파일러 내부 디버깅을 위해 Python 원본 traceback이 필요하면 다음 환경 변수를 사용합니다.
|
|
131
|
+
|
|
132
|
+
```console
|
|
133
|
+
set HYTHON_TRACEBACK=python
|
|
134
|
+
hython run 프로그램.hy
|
|
135
|
+
```
|
|
136
|
+
|
|
137
|
+
Python 파일을 하이썬으로 바꾸거나 그 반대로 바꿀 수 있습니다.
|
|
138
|
+
|
|
139
|
+
```console
|
|
140
|
+
hython translate program.py --reverse -o program.hy
|
|
141
|
+
hython translate program.py --reverse --complete -o 완전한글.hy
|
|
142
|
+
hython translate program.hy -o program.py
|
|
143
|
+
hython audit 완전한글.hy
|
|
144
|
+
```
|
|
145
|
+
|
|
146
|
+
하이썬은 Python 호환 실행 모드와 독립 HBC 컴파일 모드를 함께 제공합니다.
|
|
147
|
+
따라서 문자열과 주석 안의 단어는 바뀌지 않습니다. Python 문법의 괄호, 연산자,
|
|
148
|
+
들여쓰기 규칙은 그대로 사용합니다.
|
|
149
|
+
|
|
150
|
+
`--complete`는 Python 키워드·내장 함수·등록 API뿐 아니라 사용자 영어 식별자와
|
|
151
|
+
`f`, `r`, `b` 같은 문자열 접두사도 발음형 한글로 바꿉니다. `audit`은 문자열 내용과
|
|
152
|
+
주석을 제외한 실행 코드에 영어 식별자가 남으면 위치와 권장 철자를 출력하고 종료 코드
|
|
153
|
+
1을 반환합니다. `에프"값={값}"`, `알"\n"`처럼 접두사도 한글로 쓸 수 있습니다.
|
|
154
|
+
|
|
155
|
+
터미널 명령도 한글 별칭을 제공합니다.
|
|
156
|
+
|
|
157
|
+
```console
|
|
158
|
+
hython 소스실행 프로그램.hy
|
|
159
|
+
hython 컴파일 프로그램.hy
|
|
160
|
+
hython 바이트실행 프로그램.hbc
|
|
161
|
+
hython 업데이트
|
|
162
|
+
hython 패키지 설치 requests
|
|
163
|
+
hython 패키지 제거 requests
|
|
164
|
+
hython 런타임 정보
|
|
165
|
+
hython 감사 .
|
|
166
|
+
```
|
|
167
|
+
|
|
168
|
+
Python 데이터 모델 특수 이름도 `__네임__`, `__파일__`, `__이니트__`, `__레퍼__`,
|
|
169
|
+
`__겟아이템__`처럼 쓸 수 있습니다. 문자열 내용, URL, 파일 경로와 환경 변수명은 외부
|
|
170
|
+
시스템에 전달되는 데이터이므로 철자를 변경하지 않습니다. 괄호와 연산자는 영문이 아니라
|
|
171
|
+
구문 구조를 표현하는 언어 기호입니다.
|
|
172
|
+
|
|
173
|
+
같은 폴더의 `계산기.hy`는 일반 모듈처럼 `인폴트 계산기`로 불러올 수 있습니다.
|
|
174
|
+
패키지는 `도구/__init__.hy` 형태로 만들며 상대 import도 지원합니다.
|
|
175
|
+
|
|
176
|
+
## Python 패키지와 발음 사전
|
|
177
|
+
|
|
178
|
+
```console
|
|
179
|
+
hython package install requests
|
|
180
|
+
hython package install beautifulsoup4 --module bs4
|
|
181
|
+
hython package uninstall beautifulsoup4 --module bs4
|
|
182
|
+
hython package scan pathlib
|
|
183
|
+
hython package scan 신뢰하지않는모듈 --static
|
|
184
|
+
```
|
|
185
|
+
|
|
186
|
+
설치는 현재 Python의 `pip`를 사용합니다. 그 뒤 배포판이 제공하는 모든 import 모듈을
|
|
187
|
+
자동 발견하고, `.py` 전체 정적 분석 결과와 격리된 자식 Python에서 확인한 C 확장·동적
|
|
188
|
+
공개 API를 합쳐 `~/.hython/dictionaries`에 발음 사전을 생성합니다. 신뢰하지 않는
|
|
189
|
+
모듈은 `scan --static`으로 실행 없는 분석만 선택할 수 있습니다.
|
|
190
|
+
사전은 JSON이므로 자동 발음이 마음에 들지 않으면 직접 고칠 수 있습니다.
|
|
191
|
+
설치·갱신은 임시 파일을 완성한 뒤 기존 사전을 원자적으로 교체합니다. 제거 명령과
|
|
192
|
+
`hython update`는 더 이상 설치되지 않은 모듈의 사전을 삭제하므로 낡은 발음이 남지 않습니다.
|
|
193
|
+
|
|
194
|
+
## Python 런타임 동기화
|
|
195
|
+
|
|
196
|
+
```console
|
|
197
|
+
hython init
|
|
198
|
+
hython update
|
|
199
|
+
hython update --no-runtime
|
|
200
|
+
hython runtime info
|
|
201
|
+
hython runtime sync
|
|
202
|
+
hython runtime check .
|
|
203
|
+
```
|
|
204
|
+
|
|
205
|
+
`init`은 최초 CLI 실행 때도 네트워크 접근 없이 자동 수행됩니다. `update`는 Windows의
|
|
206
|
+
공식 Python install manager로 최신 `default` 런타임을 설치한 다음, 새 런타임 안에서
|
|
207
|
+
문법 프로필, 표준 라이브러리 전체 공개 API와 설치 패키지 사전을 재생성하고 이후 Hython
|
|
208
|
+
실행에 그 런타임을 사용합니다.
|
|
209
|
+
`--no-runtime`은 다운로드 없이 현재 Python과 패키지 상태만 다시 분석합니다.
|
|
210
|
+
|
|
211
|
+
## HBC 컴파일러 자동 업데이트
|
|
212
|
+
|
|
213
|
+
```console
|
|
214
|
+
hython compiler info
|
|
215
|
+
hython compiler check
|
|
216
|
+
hython compiler update
|
|
217
|
+
hython compiler rollback
|
|
218
|
+
hython compiler remove
|
|
219
|
+
hython compiler remove 2.1.0
|
|
220
|
+
```
|
|
221
|
+
|
|
222
|
+
`compiler update`는 공식 PyPI에서 `hython-lang` wheel과 게시된 SHA-256을 조회합니다.
|
|
223
|
+
wheel 전체 해시와 압축 경로를 검증하고 임시 디렉터리에서 실제 Hython import·기본 문법
|
|
224
|
+
compile·HBC 직렬화 smoke test가 성공한 경우에만 활성화합니다. 새 컴파일러는 설치된 코어를
|
|
225
|
+
덮어쓰지 않고 `~/.hython/compilers/버전`에 보관되며 다음 명령부터 자동 사용됩니다.
|
|
226
|
+
실패 시 현재 컴파일러는 바뀌지 않으며 `rollback`은 직전 검증 버전, 이력이 없으면 내장
|
|
227
|
+
부트스트랩 컴파일러로 돌아갑니다. `remove`는 활성 또는 지정 버전과 그 문법을 삭제합니다.
|
|
228
|
+
|
|
229
|
+
`info`와 `sync`는 하드코딩된 버전 번호가 아니라 현재 Python의 `keyword` 모듈을
|
|
230
|
+
조사합니다. 새 키워드가 발견되면 발음 후보와 함께
|
|
231
|
+
`~/.hython/runtimes/python-버전.json`에 기록합니다. `check`는 코드를 실행하지 않고
|
|
232
|
+
모든 `.hy` 파일을 현재 Python 컴파일러로 문법 검사합니다.
|
|
233
|
+
|
|
234
|
+
외부 갱신은 키워드와 라이브러리의 공개 Python 식별자에 대한 발음 계층입니다. 패키지가
|
|
235
|
+
자체 import hook이나 문자열 DSL로 새로운 언어 문법을 구현한 경우에는 정적 사전의
|
|
236
|
+
대상이 아니며, Python 자체의 새로운 문법 구조를 HBC로 낮추는 작업은 새 HBC 컴파일러
|
|
237
|
+
릴리스가 필요합니다. Python 호환 실행 모드는 활성 최신 Python의 문법을 즉시 사용합니다.
|
|
238
|
+
|
|
239
|
+
### 공식 Python 런타임 관리 (Windows)
|
|
240
|
+
|
|
241
|
+
```console
|
|
242
|
+
hython runtime list
|
|
243
|
+
hython runtime online 3.14
|
|
244
|
+
hython runtime install 3.14 --dry-run
|
|
245
|
+
hython runtime install 3.14
|
|
246
|
+
hython runtime use 3.14
|
|
247
|
+
```
|
|
248
|
+
|
|
249
|
+
다운로드와 검증은 Python.org의 공식 Python install manager에 위임합니다. `use`는
|
|
250
|
+
프로젝트에 `.hython-runtime`을 만들고 이후 실행을 지정 버전으로 전환합니다.
|
|
251
|
+
|
|
252
|
+
## 독립 HBC 컴파일러와 VM
|
|
253
|
+
|
|
254
|
+
```console
|
|
255
|
+
hython compile examples/컴파일.hy -o 프로그램.hbc
|
|
256
|
+
hython compile examples/컴파일.hy --show-hir
|
|
257
|
+
hython compile examples/컴파일.hy --no-optimize
|
|
258
|
+
hython disassemble 프로그램.hbc
|
|
259
|
+
hython execute 프로그램.hbc
|
|
260
|
+
hython exe 프로그램.hbc -o 프로그램.exe
|
|
261
|
+
hython exe 프로그램.hbc -o 프로그램.exe --windowed --icon app.ico
|
|
262
|
+
hython exe dist --entry main.hbc --onedir -o release/app
|
|
263
|
+
hython exe dist --entry main.hbc --resource assets=assets --resource config.json=config/config.json
|
|
264
|
+
hython exe dist --entry main.hbc --product-name "내 프로그램" --file-version 1.2.0.0 --company "제작사"
|
|
265
|
+
hython exe dist --entry main.hbc --archive release.zip
|
|
266
|
+
hython build . -o dist
|
|
267
|
+
```
|
|
268
|
+
|
|
269
|
+
Windows의 `exe` 명령은 HBC, Python 런타임과 Hython VM을 PyInstaller one-file PE에
|
|
270
|
+
내장합니다. 생성된 EXE는 원본 `.hbc`나 별도 Python 설치 없이 실행됩니다. 입력 HBC와
|
|
271
|
+
같은 폴더의 다른 `.hbc` 모듈도 디렉터리 구조를 유지해 자동 포함하며, 다른 빌드 루트는
|
|
272
|
+
`--module-root dist`로 지정합니다. HBC가 import하는 설치 Python 패키지도 분석해
|
|
273
|
+
수집합니다. EXE 기능은 `pip install "hython-lang[exe]"`로 설치할 수 있습니다.
|
|
274
|
+
|
|
275
|
+
프로젝트 디렉터리는 `main.hbc`, `메인.hbc` 또는 유일한 최상위 HBC를 entry로 자동
|
|
276
|
+
선택하며 모호하면 `--entry`가 필요합니다. `--onedir`는 용량은 비슷하지만 시작이 빠른
|
|
277
|
+
폴더 배포를 만듭니다. `--resource SOURCE=DEST`는 파일·폴더를 원하는 경로에 포함하고,
|
|
278
|
+
프로그램에서는 환경 변수 `HYTHON_RESOURCE_ROOT` 아래에서 읽을 수 있습니다.
|
|
279
|
+
`--exclude-module`은 사용하지 않는 큰 모듈을 제외할 때 사용합니다.
|
|
280
|
+
|
|
281
|
+
Windows 파일 속성은 `--product-name`, `--file-version`, `--company`, `--description`,
|
|
282
|
+
`--copyright`로 설정합니다. Windows SDK의 `signtool`과 PFX가 있으면 다음처럼 최종
|
|
283
|
+
산출물에 Authenticode 서명을 적용할 수 있습니다.
|
|
284
|
+
|
|
285
|
+
```console
|
|
286
|
+
set HYTHON_PFX_PASSWORD=secret
|
|
287
|
+
hython exe dist --entry main.hbc --sign-pfx certificate.pfx --sign-password-env HYTHON_PFX_PASSWORD
|
|
288
|
+
```
|
|
289
|
+
|
|
290
|
+
`--archive release.zip`은 배포 ZIP과 동일 내용의 SHA-256 검증 파일
|
|
291
|
+
`release.zip.sha256`을 생성합니다.
|
|
292
|
+
|
|
293
|
+
HBC는 `HYBC` 헤더, 자체 스택 명령어, 압축 페이로드와 SHA-256 무결성 검사를
|
|
294
|
+
사용하며 `.pyc`나 CPython opcode가 아닙니다. 보존된 1.x 배포물은 초기 HBC를,
|
|
295
|
+
현재 2.0 개발판은 예외·비동기·패턴 매칭·generic·지연 주석과 Python 3.14 클래스
|
|
296
|
+
메타데이터와 순차 클래스 인자 조립까지 확장한 HBC v6를 사용합니다.
|
|
297
|
+
네이티브 컴파일 경로는 하이썬 소유 AST와 Pratt 표현식 파서를 사용하며 `ast.parse`에
|
|
298
|
+
의존하지 않습니다.
|
|
299
|
+
|
|
300
|
+
0.7부터 소스 프런트엔드와 HBC 사이에 독립 HIR 계층이 있습니다. 기본 최적화는 숫자,
|
|
301
|
+
문자열과 비교식의 안전한 상수 접기를 수행하며 명령어 위치를 유지해 분기 안정성을
|
|
302
|
+
보존합니다. `--show-hir`로 결과를 확인할 수 있습니다.
|
|
303
|
+
|
|
304
|
+
여러 `.hy` 파일은 `hython build`로 디렉터리 구조를 유지한 채 한 번에 컴파일할 수
|
|
305
|
+
있습니다. HBC의 `인폴트 모듈`은 같은 출력 폴더의 `모듈.hbc`를 직접 로드합니다.
|
|
306
|
+
|
|
307
|
+
지원 범위와 두 실행 모드의 차이는 [언어 안내](docs/LANGUAGE.md)를 참고하세요.
|
|
308
|
+
신뢰 경계와 HBC 검증 범위는 [보안 정책](SECURITY.md)에 설명되어 있습니다.
|
|
309
|
+
|
|
310
|
+
## 안정성 검사
|
|
311
|
+
|
|
312
|
+
```console
|
|
313
|
+
python -m unittest discover -s tests -v
|
|
314
|
+
python scripts/stability.py --cycles 10
|
|
315
|
+
```
|
|
316
|
+
|
|
317
|
+
안정성 검사는 호환/네이티브 차등 계산, 10만 회 반복, 반복 함수 호출, 재귀,
|
|
318
|
+
대용량 컬렉션, 모듈 캐시 및 HBC 절단·변조 입력을 검사합니다.
|
|
319
|
+
|
|
320
|
+
## 목표
|
|
321
|
+
|
|
322
|
+
- 설치된 Python 버전에서 문법/키워드를 자동 검사
|
|
323
|
+
- 더 정확한 발음 규칙과 패키지별 공식 사전
|
|
324
|
+
- 독립 HIR/HBC/VM 컴파일러 ([설계 문서](docs/COMPILER.md))
|
|
325
|
+
- Python 새 버전 문법에 대한 호환성 검사 및 사전 업데이트
|
|
326
|
+
|
|
327
|
+
자동으로 내려받은 코드나 패키지는 실행 전 출처와 해시를 검증하는 방향으로 설계합니다.
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
hython/__init__.py,sha256=CUcmPMEwc6cmYWXPaPZJUH_iodwaIjSpcg8OWyh09oY,366
|
|
2
|
+
hython/__main__.py,sha256=PIJIOolexzGnrOJz3yXWQZ6eCKD9h2LLAao-qtQ8HYE,60
|
|
3
|
+
hython/bytecode.py,sha256=8tWu7fp3WeKcfc1KKmh7-k1RfvuOmwN-jt-EEbQeGls,25903
|
|
4
|
+
hython/cli.py,sha256=ZNWnuXaWNV32Bibu7f8LYj-MK8HA5gBqAP_Mjv1xRLY,23303
|
|
5
|
+
hython/compiler.py,sha256=8tQK78T9LJ7F5gphSQFJDDLCYCg_bTVqMTW5BWCB0LI,59630
|
|
6
|
+
hython/compiler_manager.py,sha256=tHY0w89S1tVwsDTTditYvTgBikunTKtvLQScg6X2o2Y,9137
|
|
7
|
+
hython/diagnostics.py,sha256=GkHJ3NfV3NXtnThncZ7ncH_dyFpx2LYsgHgAYSX6gB0,9148
|
|
8
|
+
hython/environment.py,sha256=mr144hjtlxdeJ3JcU7sLmapoXHRRhwNKmO7JyexrqBc,1346
|
|
9
|
+
hython/exe_builder.py,sha256=u1mop5x5jYMNv5yqO13zuy-3pP7vnDItYVgObnj-xNM,15689
|
|
10
|
+
hython/frontend.py,sha256=inACdMY6_wRRUZJV-FA7ZP9CCwd1aBepiGVjJ_hhYuE,58984
|
|
11
|
+
hython/hir.py,sha256=05mFfcM_DzthfRiOwHGSYD0ZhV5qoGPXZZJ-agGozXA,4704
|
|
12
|
+
hython/importer.py,sha256=dp2-R7wpGmyhOeUPecobqWg3LhXMx5g4cWdGuG70lRA,2568
|
|
13
|
+
hython/package_manager.py,sha256=7juwAoC3exLPImvXE13E47qVUH5cmVVUMc7MDaI63ZE,13131
|
|
14
|
+
hython/phonetics.py,sha256=k89VivLMDlLH-cuZdQ-LC4UqO_75HpAPC5XwoMDmvCs,1926
|
|
15
|
+
hython/runtime.py,sha256=h0LaCWjCnVl9wIKoUZVrRq7eOjfkG3zQikv2kFkFd4k,4074
|
|
16
|
+
hython/runtime_manager.py,sha256=Lm84paE7t5qETmXU80TAJIbtXt31EFOt0kcCC9K9azA,3295
|
|
17
|
+
hython/translator.py,sha256=KCGm69tliqvjys8vW3YzrEigfECNqvjm4roMZ9bMzVI,9477
|
|
18
|
+
hython/updater.py,sha256=RKFgiX-CH4Vlzk3jiE7YbG9x2jKE7N0NQfWe_LfD5tw,3020
|
|
19
|
+
hython/vm.py,sha256=9G7WsYEu4yzRhjEV0LrlrGvFptrltwsZM83QtMq9md4,146846
|
|
20
|
+
hython/vocabulary.py,sha256=zfFXbyrYemvHCgDXURtJ-Vo5BZOOpWNyiLNJ042ci0w,7789
|
|
21
|
+
hython_lang-2.0.0.dist-info/licenses/LICENSE,sha256=qa_8C1PzI_b9jmG1KBeuBE3vJ83nRjf9vgGnxK83i7g,1077
|
|
22
|
+
hython_lang-2.0.0.dist-info/METADATA,sha256=c2h4-o4uyS35J9bshZY11e6ayTFiwDgt-6ISE-TBaGE,14496
|
|
23
|
+
hython_lang-2.0.0.dist-info/WHEEL,sha256=K260EYznzXsJYBQGqmI8VTxEdiZYNvDZwW9cBh9-_MA,91
|
|
24
|
+
hython_lang-2.0.0.dist-info/entry_points.txt,sha256=XOpC9qxHaZUKp_g5qXphs5xctre0hcMBRUJenrWFcKM,49
|
|
25
|
+
hython_lang-2.0.0.dist-info/top_level.txt,sha256=ClK96s8h-RLIuaXZcQNy8e4NrI1-9pNcfPIWnXlq4v0,7
|
|
26
|
+
hython_lang-2.0.0.dist-info/RECORD,,
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Hython contributors
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
22
|
+
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
hython
|