antkit 0.0.1__tar.gz → 0.0.3__tar.gz

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.
antkit-0.0.3/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 lqxnjk
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.
antkit-0.0.3/PKG-INFO ADDED
@@ -0,0 +1,88 @@
1
+ Metadata-Version: 2.5
2
+ Name: antkit
3
+ Version: 0.0.3
4
+ Summary: Cryptographically secure tokens and passwords.
5
+ Project-URL: Homepage, https://pypi.org/project/antkit/
6
+ Author-email: lqxnjk <lqxnjk@qq.com>
7
+ License: MIT
8
+ License-File: LICENSE
9
+ Keywords: password,random,secrets,security,token
10
+ Classifier: Development Status :: 3 - Alpha
11
+ Classifier: Intended Audience :: Developers
12
+ Classifier: License :: OSI Approved :: MIT License
13
+ Classifier: Operating System :: OS Independent
14
+ Classifier: Programming Language :: Python :: 3
15
+ Classifier: Programming Language :: Python :: 3 :: Only
16
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
17
+ Classifier: Typing :: Typed
18
+ Requires-Python: >=3.10
19
+ Description-Content-Type: text/markdown
20
+
21
+ # antkit
22
+
23
+ [English](#english) | 中文
24
+
25
+ 密码学安全的随机 token 与口令生成。
26
+
27
+ ## 安装
28
+
29
+ ```console
30
+ pip install antkit
31
+ ```
32
+
33
+ ## 用法
34
+
35
+ ```python
36
+ from antkit import password, token
37
+
38
+ token() # 22 字符,16 字节熵
39
+ token(n_bytes=32)
40
+ token(n_urlsafe=False) # hex
41
+
42
+ password() # 16 位,四类字符全用
43
+ password(24, n_symbols=False)
44
+ password(12, n_lower=False, n_upper=False)
45
+ ```
46
+
47
+ ## 说明
48
+
49
+ 全部基于 `secrets`,不用 `random`(它的种子可预测,不能用于任何不该被猜到的值)。口令保证每个启用的字符类至少出现一次,然后整体打乱,避免保底字符堆在开头。请求不可能满足时抛 `ValueError`。
50
+
51
+ ## 许可证
52
+
53
+ MIT
54
+
55
+ ---
56
+
57
+ <a id="english"></a>
58
+ ## English
59
+
60
+ Cryptographically secure tokens and passwords.
61
+
62
+ ## Install
63
+
64
+ ```console
65
+ pip install antkit
66
+ ```
67
+
68
+ ## Usage
69
+
70
+ ```python
71
+ from antkit import password, token
72
+
73
+ token() # 22 字符,16 字节熵
74
+ token(n_bytes=32)
75
+ token(n_urlsafe=False) # hex
76
+
77
+ password() # 16 位,四类字符全用
78
+ password(24, n_symbols=False)
79
+ password(12, n_lower=False, n_upper=False)
80
+ ```
81
+
82
+ ## Notes
83
+
84
+ Built on `secrets`, never `random`. Passwords always contain at least one character from every enabled class, then get shuffled so the guaranteed characters are not stuck at the front. Impossible requests raise `ValueError`.
85
+
86
+ ## License
87
+
88
+ MIT
antkit-0.0.3/README.md ADDED
@@ -0,0 +1,68 @@
1
+ # antkit
2
+
3
+ [English](#english) | 中文
4
+
5
+ 密码学安全的随机 token 与口令生成。
6
+
7
+ ## 安装
8
+
9
+ ```console
10
+ pip install antkit
11
+ ```
12
+
13
+ ## 用法
14
+
15
+ ```python
16
+ from antkit import password, token
17
+
18
+ token() # 22 字符,16 字节熵
19
+ token(n_bytes=32)
20
+ token(n_urlsafe=False) # hex
21
+
22
+ password() # 16 位,四类字符全用
23
+ password(24, n_symbols=False)
24
+ password(12, n_lower=False, n_upper=False)
25
+ ```
26
+
27
+ ## 说明
28
+
29
+ 全部基于 `secrets`,不用 `random`(它的种子可预测,不能用于任何不该被猜到的值)。口令保证每个启用的字符类至少出现一次,然后整体打乱,避免保底字符堆在开头。请求不可能满足时抛 `ValueError`。
30
+
31
+ ## 许可证
32
+
33
+ MIT
34
+
35
+ ---
36
+
37
+ <a id="english"></a>
38
+ ## English
39
+
40
+ Cryptographically secure tokens and passwords.
41
+
42
+ ## Install
43
+
44
+ ```console
45
+ pip install antkit
46
+ ```
47
+
48
+ ## Usage
49
+
50
+ ```python
51
+ from antkit import password, token
52
+
53
+ token() # 22 字符,16 字节熵
54
+ token(n_bytes=32)
55
+ token(n_urlsafe=False) # hex
56
+
57
+ password() # 16 位,四类字符全用
58
+ password(24, n_symbols=False)
59
+ password(12, n_lower=False, n_upper=False)
60
+ ```
61
+
62
+ ## Notes
63
+
64
+ Built on `secrets`, never `random`. Passwords always contain at least one character from every enabled class, then get shuffled so the guaranteed characters are not stuck at the front. Impossible requests raise `ValueError`.
65
+
66
+ ## License
67
+
68
+ MIT
@@ -0,0 +1,37 @@
1
+ [build-system]
2
+ requires = ["hatchling"]
3
+ build-backend = "hatchling.build"
4
+
5
+ [project]
6
+ name = "antkit"
7
+ version = "0.0.3"
8
+ description = "Cryptographically secure tokens and passwords."
9
+ readme = "README.md"
10
+ requires-python = ">=3.10"
11
+ license = { text = "MIT" }
12
+ authors = [{ name = "lqxnjk", email = "lqxnjk@qq.com" }]
13
+ keywords = ["token", "password", "secrets", "random", "security"]
14
+ classifiers = [
15
+ "Development Status :: 3 - Alpha",
16
+ "Intended Audience :: Developers",
17
+ "License :: OSI Approved :: MIT License",
18
+ "Operating System :: OS Independent",
19
+ "Programming Language :: Python :: 3",
20
+ "Programming Language :: Python :: 3 :: Only",
21
+ "Topic :: Software Development :: Libraries :: Python Modules",
22
+ "Typing :: Typed",
23
+ ]
24
+ dependencies = []
25
+
26
+ [project.urls]
27
+ Homepage = "https://pypi.org/project/antkit/"
28
+
29
+ [tool.pytest.ini_options]
30
+ pythonpath = ["src"]
31
+ testpaths = ["tests"]
32
+
33
+ [tool.hatch.build.targets.wheel]
34
+ packages = ["src/antkit"]
35
+
36
+ [tool.hatch.build.targets.sdist]
37
+ include = ["src/antkit", "tests", "README.md", "LICENSE"]
@@ -0,0 +1,67 @@
1
+ """
2
+ Author: lqxnjk <lqxnjk@qq.com>
3
+ Created: 2026-10-23 10:55
4
+ Modified: 2026-10-23 11:22
5
+ Python Version: 3.10
6
+ Secure random tokens and passwords.
7
+ """
8
+ from __future__ import annotations
9
+
10
+ import secrets
11
+ import string
12
+
13
+ __all__ = ["token", "password"]
14
+
15
+ _LOWER = string.ascii_lowercase
16
+ _UPPER = string.ascii_uppercase
17
+ _DIGITS = string.digits
18
+ _SYMBOLS = "!@#$%^&*()-_=+[]{};:,.?"
19
+
20
+
21
+ def token(n_bytes: int = 16, n_urlsafe: bool = True) -> str:
22
+ """Return a URL-safe token carrying ``n_bytes`` of entropy.
23
+
24
+ Built on :mod:`secrets`, so it is suitable for session IDs, API keys and
25
+ reset links. Length is longer than ``n_bytes`` because base64 expands.
26
+ """
27
+ if n_bytes < 1:
28
+ raise ValueError(f"n_bytes must be >= 1, got {n_bytes}")
29
+ if n_urlsafe:
30
+ return secrets.token_urlsafe(n_bytes)
31
+ return secrets.token_hex(n_bytes)
32
+
33
+
34
+ def password(
35
+ n_length: int = 16,
36
+ n_lower: bool = True,
37
+ n_upper: bool = True,
38
+ n_digits: bool = True,
39
+ n_symbols: bool = True,
40
+ ) -> str:
41
+ """Return a random password that is guaranteed to use every enabled class.
42
+
43
+ At least one character from each enabled class is always present, then the
44
+ result is shuffled with :func:`secrets.randbelow` so the guaranteed
45
+ characters are not stuck at the front.
46
+ """
47
+ pools: list[str] = []
48
+ if n_lower:
49
+ pools.append(_LOWER)
50
+ if n_upper:
51
+ pools.append(_UPPER)
52
+ if n_digits:
53
+ pools.append(_DIGITS)
54
+ if n_symbols:
55
+ pools.append(_SYMBOLS)
56
+ if not pools:
57
+ raise ValueError("at least one character class must be enabled")
58
+ if n_length < len(pools):
59
+ raise ValueError(f"n_length must be >= {len(pools)} for {len(pools)} class(es)")
60
+
61
+ alphabet = "".join(pools)
62
+ chars = [secrets.choice(pool) for pool in pools]
63
+ chars.extend(secrets.choice(alphabet) for _ in range(n_length - len(chars)))
64
+ for index in range(len(chars) - 1, 0, -1):
65
+ swap = secrets.randbelow(index + 1)
66
+ chars[index], chars[swap] = chars[swap], chars[index]
67
+ return "".join(chars)
File without changes
@@ -0,0 +1,53 @@
1
+ """
2
+ Author: lqxnjk <lqxnjk@qq.com>
3
+ Created: 2026-10-23 10:55
4
+ Modified: 2026-10-23 11:22
5
+ Python Version: 3.10
6
+ """
7
+ import string
8
+
9
+ import pytest
10
+
11
+ from antkit import password, token
12
+
13
+
14
+ def test_token_length_and_charset() -> None:
15
+ value = token(16)
16
+ assert len(value) >= 16
17
+ assert all(char in string.ascii_letters + string.digits + "-_" for char in value)
18
+
19
+
20
+ def test_token_uniqueness() -> None:
21
+ assert len({token() for _ in range(200)}) == 200
22
+
23
+
24
+ def test_token_hex() -> None:
25
+ value = token(8, n_urlsafe=False)
26
+ assert len(value) == 16
27
+ int(value, 16)
28
+
29
+
30
+ def test_password_uses_all_classes() -> None:
31
+ value = password(16)
32
+ assert any(char in string.ascii_lowercase for char in value)
33
+ assert any(char in string.ascii_uppercase for char in value)
34
+ assert any(char in string.digits for char in value)
35
+ assert any(not char.isalnum() for char in value)
36
+
37
+
38
+ def test_password_respects_disabled_classes() -> None:
39
+ value = password(12, n_symbols=False)
40
+ assert value.isalnum()
41
+
42
+
43
+ def test_password_length() -> None:
44
+ assert len(password(24)) == 24
45
+
46
+
47
+ def test_impossible_requests() -> None:
48
+ with pytest.raises(ValueError):
49
+ password(4, n_lower=False, n_upper=False, n_digits=False, n_symbols=False)
50
+ with pytest.raises(ValueError):
51
+ password(1)
52
+ with pytest.raises(ValueError):
53
+ token(0)
antkit-0.0.1/MANIFEST.in DELETED
@@ -1 +0,0 @@
1
- include requirements.txt
antkit-0.0.1/PKG-INFO DELETED
@@ -1,59 +0,0 @@
1
- Metadata-Version: 2.4
2
- Name: antkit
3
- Version: 0.0.1
4
- Summary: A Python package for intelligent information bagging system
5
- Home-page: https://github.com/lqxnjk/antkit
6
- Author: lqxnjk
7
- Author-email: lqxnjk@qq.com
8
- License: MIT
9
- Project-URL: Bug Reports, https://github.com/lqxnjk/antkit/issues
10
- Project-URL: Source, https://github.com/lqxnjk/antkit
11
- Keywords: ii,etls,lqxnjk,data
12
- Classifier: Development Status :: 3 - Alpha
13
- Classifier: Intended Audience :: Developers
14
- Classifier: Intended Audience :: Science/Research
15
- Classifier: Programming Language :: Python :: 3.7
16
- Classifier: License :: OSI Approved :: MIT License
17
- Classifier: Operating System :: OS Independent
18
- Classifier: Topic :: Software Development :: Libraries
19
- Classifier: Topic :: Scientific/Engineering
20
- Requires-Python: >=3.7
21
- Description-Content-Type: text/markdown
22
- Requires-Dist: typing-extensions; python_version < "3.8"
23
- Provides-Extra: dev
24
- Provides-Extra: plot
25
- Provides-Extra: gpu
26
- Provides-Extra: all
27
- Requires-Dist: antkit[dev]; extra == "all"
28
- Requires-Dist: antkit[plot]; extra == "all"
29
- Dynamic: author
30
- Dynamic: author-email
31
- Dynamic: classifier
32
- Dynamic: description
33
- Dynamic: description-content-type
34
- Dynamic: home-page
35
- Dynamic: keywords
36
- Dynamic: license
37
- Dynamic: project-url
38
- Dynamic: provides-extra
39
- Dynamic: requires-python
40
- Dynamic: summary
41
-
42
- ## 构建依赖包
43
-
44
- ```基础命令
45
- python -m pip install twine -i https://mirrors.tencent.com/pypi/simple
46
- pip install wheel setuptools -i https://mirrors.tencent.com/pypi/simple
47
- python setup.py sdist bdist_wheel
48
- python -m build
49
- pip install .
50
- pip install -e .
51
- pip install -e .[dev]
52
- ```
53
-
54
- ```shell 构建命令
55
- #rm -rf './dist'
56
- #python -m build
57
- python setup.py sdist bdist_wheel
58
- python -m twine upload dist/*
59
- ```
antkit-0.0.1/README.md DELETED
@@ -1,18 +0,0 @@
1
- ## 构建依赖包
2
-
3
- ```基础命令
4
- python -m pip install twine -i https://mirrors.tencent.com/pypi/simple
5
- pip install wheel setuptools -i https://mirrors.tencent.com/pypi/simple
6
- python setup.py sdist bdist_wheel
7
- python -m build
8
- pip install .
9
- pip install -e .
10
- pip install -e .[dev]
11
- ```
12
-
13
- ```shell 构建命令
14
- #rm -rf './dist'
15
- #python -m build
16
- python setup.py sdist bdist_wheel
17
- python -m twine upload dist/*
18
- ```
@@ -1,5 +0,0 @@
1
- """
2
- lqxnjk lqxnjk@qq.com
3
- """
4
- __version__ = "0.0.1"
5
- __all__ = []
@@ -1,59 +0,0 @@
1
- Metadata-Version: 2.4
2
- Name: antkit
3
- Version: 0.0.1
4
- Summary: A Python package for intelligent information bagging system
5
- Home-page: https://github.com/lqxnjk/antkit
6
- Author: lqxnjk
7
- Author-email: lqxnjk@qq.com
8
- License: MIT
9
- Project-URL: Bug Reports, https://github.com/lqxnjk/antkit/issues
10
- Project-URL: Source, https://github.com/lqxnjk/antkit
11
- Keywords: ii,etls,lqxnjk,data
12
- Classifier: Development Status :: 3 - Alpha
13
- Classifier: Intended Audience :: Developers
14
- Classifier: Intended Audience :: Science/Research
15
- Classifier: Programming Language :: Python :: 3.7
16
- Classifier: License :: OSI Approved :: MIT License
17
- Classifier: Operating System :: OS Independent
18
- Classifier: Topic :: Software Development :: Libraries
19
- Classifier: Topic :: Scientific/Engineering
20
- Requires-Python: >=3.7
21
- Description-Content-Type: text/markdown
22
- Requires-Dist: typing-extensions; python_version < "3.8"
23
- Provides-Extra: dev
24
- Provides-Extra: plot
25
- Provides-Extra: gpu
26
- Provides-Extra: all
27
- Requires-Dist: antkit[dev]; extra == "all"
28
- Requires-Dist: antkit[plot]; extra == "all"
29
- Dynamic: author
30
- Dynamic: author-email
31
- Dynamic: classifier
32
- Dynamic: description
33
- Dynamic: description-content-type
34
- Dynamic: home-page
35
- Dynamic: keywords
36
- Dynamic: license
37
- Dynamic: project-url
38
- Dynamic: provides-extra
39
- Dynamic: requires-python
40
- Dynamic: summary
41
-
42
- ## 构建依赖包
43
-
44
- ```基础命令
45
- python -m pip install twine -i https://mirrors.tencent.com/pypi/simple
46
- pip install wheel setuptools -i https://mirrors.tencent.com/pypi/simple
47
- python setup.py sdist bdist_wheel
48
- python -m build
49
- pip install .
50
- pip install -e .
51
- pip install -e .[dev]
52
- ```
53
-
54
- ```shell 构建命令
55
- #rm -rf './dist'
56
- #python -m build
57
- python setup.py sdist bdist_wheel
58
- python -m twine upload dist/*
59
- ```
@@ -1,11 +0,0 @@
1
- MANIFEST.in
2
- README.md
3
- requirements.txt
4
- setup.py
5
- antkit/__init__.py
6
- antkit.egg-info/PKG-INFO
7
- antkit.egg-info/SOURCES.txt
8
- antkit.egg-info/dependency_links.txt
9
- antkit.egg-info/entry_points.txt
10
- antkit.egg-info/requires.txt
11
- antkit.egg-info/top_level.txt
@@ -1,2 +0,0 @@
1
- [hello]
2
- antkit_version = antkit.__init__:version
@@ -1,13 +0,0 @@
1
-
2
- [:python_version < "3.8"]
3
- typing-extensions
4
-
5
- [all]
6
- antkit[dev]
7
- antkit[plot]
8
-
9
- [dev]
10
-
11
- [gpu]
12
-
13
- [plot]
@@ -1 +0,0 @@
1
- antkit
@@ -1,5 +0,0 @@
1
- --extra-index-url https://mirrors.tencent.com/pypi/simple
2
- # python 3.7.9
3
- # pip install -r ./requirements.txt -i https://mirrors.tencent.com/pypi/simple
4
- # --default-timeout=100
5
- #------------------------------------------------------------------------------------------------------------
antkit-0.0.1/setup.cfg DELETED
@@ -1,4 +0,0 @@
1
- [egg_info]
2
- tag_build =
3
- tag_date = 0
4
-
antkit-0.0.1/setup.py DELETED
@@ -1,190 +0,0 @@
1
- import os.path
2
-
3
- from setuptools import setup, find_packages
4
- from pathlib import Path
5
- import re
6
-
7
- # ========== Configuration Variables ==========
8
- # Basic package info
9
- ROOT_DIR = Path(__file__).absolute().parent
10
- PACKAGE_NAME = Path(__file__).absolute().parent.name.split("_")[-1].split("-")[-1]
11
-
12
- AUTHOR = "lqxnjk"
13
- AUTHOR_EMAIL = "lqxnjk@qq.com"
14
- DESCRIPTION = "A Python package for intelligent information bagging system"
15
- LICENSE = "MIT"
16
- PYTHON_REQUIRES = ">=3.7"
17
- URL = f"https://github.com/lqxnjk/{PACKAGE_NAME}"
18
- PROJECT_URLS = {
19
- 'Bug Reports': f'{URL}/issues',
20
- 'Source': URL,
21
- }
22
-
23
- # Package discovery
24
- PACKAGE_EXCLUDES = ['tests*', 'docs*', 'examples*']
25
-
26
- # Classifiers
27
- CLASSIFIERS = [
28
- "Development Status :: 3 - Alpha",
29
- "Intended Audience :: Developers",
30
- "Intended Audience :: Science/Research",
31
- "Programming Language :: Python :: 3.7",
32
- "License :: OSI Approved :: MIT License",
33
- "Operating System :: OS Independent",
34
- "Topic :: Software Development :: Libraries",
35
- "Topic :: Scientific/Engineering",
36
- ]
37
-
38
- # Keywords
39
- KEYWORDS = ["ii", "etls", "lqxnjk", "data"]
40
-
41
- # Package data
42
- PACKAGE_DATA = {
43
- PACKAGE_NAME: ['data/*.json', 'data/*.csv'],
44
- }
45
- # Entry points
46
- ENTRY_POINTS = {
47
- 'hello': [
48
- f'{PACKAGE_NAME}_version = {PACKAGE_NAME}.__init__:version',
49
- ],
50
- }
51
-
52
-
53
- # ========== Dynamic Value Functions ==========
54
- def get_long_description():
55
- """Read README.md content as long description."""
56
- with open('README.md', 'r', encoding='utf-8') as f:
57
- return f.read()
58
-
59
-
60
- def get_version():
61
- """Read version from package __init__.py file."""
62
- init_file = f"./{PACKAGE_NAME}/__init__.py"
63
- if not os.path.exists(init_file):
64
- init_file = f"./demo/__init__.py"
65
- with open(init_file, 'r', encoding='utf-8') as f:
66
- version_match = re.search(r"^__version__ = ['\"]([^'\"]*)['\"]", f.read(), re.M)
67
- if version_match:
68
- return version_match.group(1)
69
- raise RuntimeError("Unable to find version string.")
70
-
71
-
72
- def get_requirements():
73
- """Read requirements from requirements.txt."""
74
- with open(ROOT_DIR / 'requirements.txt', 'r', encoding='utf-8') as f:
75
- return [
76
- line.strip() for line in f
77
- if line.strip()
78
- and not line.startswith('#')
79
- and not line.startswith('--')
80
- ]
81
-
82
-
83
- REQUIREMENTS = get_requirements()
84
-
85
- # Optional dependencies
86
- EXTRAS_REQUIRE = {
87
- ':python_version < "3.8"': ['typing-extensions'],
88
- 'dev': [
89
- # 'pytest>=6.0',
90
- # 'pytest-cov>=2.0',
91
- # 'flake8>=3.9',
92
- # 'mypy>=0.910',
93
- # 'sphinx>=4.0',
94
- ],
95
- 'plot': [
96
- # 'matplotlib>=3.0',
97
- # 'seaborn>=0.11',
98
- ],
99
- 'gpu': [
100
- # 'cupy>=10.0'
101
- ],
102
- 'all': [f'{PACKAGE_NAME}[dev]', f'{PACKAGE_NAME}[plot]']
103
- }
104
-
105
- # ========== Setup Configuration ==========
106
- setup(
107
- name=PACKAGE_NAME,
108
- version=get_version(),
109
- packages=find_packages(exclude=PACKAGE_EXCLUDES),
110
- install_requires=REQUIREMENTS,
111
- extras_require=EXTRAS_REQUIRE,
112
- include_package_data=True,
113
- package_data=PACKAGE_DATA,
114
- author=AUTHOR,
115
- author_email=AUTHOR_EMAIL,
116
- description=DESCRIPTION,
117
- long_description=get_long_description(),
118
- long_description_content_type='text/markdown',
119
- url=URL,
120
- project_urls=PROJECT_URLS,
121
- classifiers=CLASSIFIERS,
122
- python_requires=PYTHON_REQUIRES,
123
- entry_points=ENTRY_POINTS,
124
- license=LICENSE,
125
- keywords=KEYWORDS,
126
- )
127
-
128
-
129
- # ========== Pyproject.toml Generation ==========
130
- def generate_pyproject_toml():
131
- """Generate pyproject.toml from extracted variables."""
132
- # Format project URLs for TOML
133
- urls_toml = "\n".join(
134
- f'{key.replace(" ", "-").lower()} = "{value}"'
135
- for key, value in PROJECT_URLS.items()
136
- )
137
-
138
- # Format extras_require for TOML
139
- extras_toml = []
140
- for key, deps in EXTRAS_REQUIRE.items():
141
- if key.startswith(':python_version'):
142
- # Handle conditional dependencies
143
- condition = key.split('"')[1]
144
- extras_toml.append(
145
- f'python_version_lt_{condition.replace(".", "_")} = {deps}'
146
- )
147
- else:
148
- extras_toml.append(f'{key} = {deps}')
149
- extras_toml_str = "\n".join(extras_toml)
150
- PACKAGE_DATA_STR = "{" + ",\n".join([f'"{k}" = {v}' for k, v in PACKAGE_DATA.items()]) + "}"
151
- pyproject_content = f"""[build-system]
152
- requires = ["setuptools>=42", "wheel"]
153
- build-backend = "setuptools.build_meta"
154
-
155
- [project]
156
- name = "{PACKAGE_NAME}"
157
- version = "{get_version()}"
158
- description = "{DESCRIPTION}"
159
- readme = "README.md"
160
- requires-python = "{PYTHON_REQUIRES}"
161
- authors = [
162
- {{ name = "{AUTHOR}", email = "{AUTHOR_EMAIL}" }},
163
- ]
164
- license = {{ text = "{LICENSE}" }}
165
- keywords = {KEYWORDS}
166
- classifiers = {CLASSIFIERS}
167
- dependencies = {REQUIREMENTS}
168
-
169
- [project.urls]
170
- homepage = "{URL}"
171
- {urls_toml}
172
-
173
- [project.optional-dependencies]
174
- {extras_toml_str}
175
-
176
- [tool.setuptools]
177
- packages = {find_packages(exclude=PACKAGE_EXCLUDES)}
178
- package-data = {PACKAGE_DATA_STR}
179
- include-package-data = true
180
-
181
- [tool.setuptools.dynamic]
182
- version = {{ attr = "{PACKAGE_NAME}.__version__" }}
183
- readme = {{ file = ["README.md"] }}
184
- """
185
-
186
- with open("pyproject.toml", "w", encoding="utf-8") as f:
187
- f.write(pyproject_content)
188
- print("pyproject.toml generated successfully!")
189
-
190
- # generate_pyproject_toml()