Release v3.2.0: pure-Python cryptography library (English docs/comments/errors)
- Zero-dependency pure-Python cryptography: SHA-2 / SHA-3 / SHAKE / BLAKE2b, HMAC, PBKDF2 / HKDF / scrypt / Argon2id, AES (ECB/CBC/CTR/CFB/OFB/GCM), AES-GCM-SIV, ChaCha20-Poly1305 / XChaCha20-Poly1305, X25519, Ed25519, RSA (keygen / OAEP / PSS / PEM), ASN.1 DER - Unified error system: PPYC_ERR fatal exception vs (code, message, suggestion) non-fatal 3-tuple return - Interactive TUI (Chinese / English i18n) + non-interactive CLI - v3.2.0 adds the encoding, rand and kdf2 modules - Documentation, code comments and error messages fully in English; the interactive TUI keeps its Chinese interface - Tests: RFC / FIPS / NIST test vectors, 639 passing
This commit is contained in:
@@ -0,0 +1,154 @@
|
||||
#!/usr/bin/env python3
|
||||
# -*- coding: utf-8 -*-
|
||||
"""
|
||||
purepycrypto — setup.py (legacy setuptools entry point)
|
||||
|
||||
Modern usage prefers pyproject.toml:
|
||||
pip install .
|
||||
pip install -e .
|
||||
python -m build
|
||||
|
||||
======================================================================
|
||||
Three usage modes provided after installation (important)
|
||||
======================================================================
|
||||
After installing this package, an executable command is created in the
|
||||
**Python Scripts directory**:
|
||||
|
||||
<Python>/Scripts/purepycrypto (Windows: purepycrypto.exe)
|
||||
|
||||
The command is registered via ``entry_points.console_scripts`` and points to
|
||||
``purepycrypto:main``; ``main()`` dispatches automatically based on whether
|
||||
arguments are given:
|
||||
|
||||
1) purepycrypto # no arguments -> launch [interactive TUI]
|
||||
2) purepycrypto hash --text abc --hex # with arguments -> [command-line mode]
|
||||
3) purepycrypto --help # show command-line help
|
||||
4) purepycrypto version / selftest # version / self-test
|
||||
|
||||
It can also be used as a library:
|
||||
|
||||
import purepycrypto
|
||||
purepycrypto.sha256(b"abc")
|
||||
|
||||
And the equivalent without installation:
|
||||
|
||||
python -m purepycrypto # TUI
|
||||
python -m purepycrypto hash --text abc --hex # command line
|
||||
|
||||
That is: **one single command — no arguments for the TUI, arguments for the command line**
|
||||
(no separate -args command required).
|
||||
|
||||
======================================================================
|
||||
Where CLI / TUI are implemented (for packaging and maintenance reference)
|
||||
======================================================================
|
||||
purepycrypto/cli.py TUI implementation (menus, self-test, CN/EN language switch)
|
||||
purepycrypto/cli_args.py command-line mode implementation (argparse subcommands)
|
||||
purepycrypto/__init__.py unified entry main() / run_tui() / run_cli()
|
||||
purepycrypto/__main__.py python -m purepycrypto entry point
|
||||
purepycrypto/single/ single-file bundle artifact (build_single.py --mode one)
|
||||
|
||||
Build the single file:
|
||||
python purepycrypto/scripts/build_single.py --mode one
|
||||
# generates purepycrypto/single/purepycrypto.py (no arguments = TUI, arguments = command line)
|
||||
======================================================================
|
||||
"""
|
||||
import os
|
||||
import sys
|
||||
|
||||
from setuptools import setup, find_packages
|
||||
|
||||
VERSION = "3.2.0"
|
||||
HERE = os.path.abspath(os.path.dirname(__file__))
|
||||
|
||||
|
||||
def _read(rel, fallback=""):
|
||||
try:
|
||||
with open(os.path.join(HERE, rel), "r", encoding="utf-8") as f:
|
||||
return f.read()
|
||||
except OSError:
|
||||
return fallback
|
||||
|
||||
|
||||
def write_version_file():
|
||||
"""Write the version into purepycrypto/_version.py (keeps the runtime and packaged versions in sync)."""
|
||||
path = os.path.join(HERE, "purepycrypto", "_version.py")
|
||||
os.makedirs(os.path.dirname(path), exist_ok=True)
|
||||
with open(path, "w", encoding="utf-8") as f:
|
||||
f.write('__version__ = "%s"\n' % VERSION)
|
||||
|
||||
|
||||
write_version_file()
|
||||
|
||||
long_description = _read("README.md", "purepycrypto - pure Python cryptography library")
|
||||
|
||||
# ----------------------------------------------------------------------
|
||||
# console_scripts entry point (installed into the Python Scripts directory)
|
||||
# ----------------------------------------------------------------------
|
||||
# Notes:
|
||||
# * Register only ONE command, `purepycrypto`, to avoid command sprawl;
|
||||
# * The target is `purepycrypto:main`, whose behavior is:
|
||||
# no arguments -> TUI
|
||||
# with arguments -> command-line mode
|
||||
# * After installation it can therefore be used directly:
|
||||
# purepycrypto (TUI)
|
||||
# purepycrypto hash --help (command line)
|
||||
CONSOLE_SCRIPTS = [
|
||||
"purepycrypto = purepycrypto:main",
|
||||
]
|
||||
|
||||
setup(
|
||||
name="purepycrypto",
|
||||
version=VERSION,
|
||||
description=("Pure-Python cryptography library (zero dependencies): "
|
||||
"SHA-2/SHA-3/BLAKE2b, AES-GCM(-SIV), ChaCha20-Poly1305, "
|
||||
"X25519/Ed25519, RSA-OAEP/PSS, with built-in TUI and command-line tool"),
|
||||
long_description=long_description,
|
||||
long_description_content_type="text/markdown",
|
||||
author="Dvs(DvsXT)",
|
||||
author_email="dvs6666@163.com",
|
||||
url="https://apds.top",
|
||||
license="MIT",
|
||||
packages=find_packages(include=[
|
||||
"purepycrypto", "purepycrypto.*",
|
||||
]),
|
||||
python_requires=">=3.7",
|
||||
install_requires=[],
|
||||
extras_require={
|
||||
"test": ["pytest>=7.0"],
|
||||
"dev": ["pytest>=7.0", "build", "twine"],
|
||||
"compare": ["pycryptodome", "cryptography>=45"],
|
||||
},
|
||||
# ---- key: register the executable command (no arguments = TUI, arguments = CLI) ----
|
||||
entry_points={
|
||||
"console_scripts": CONSOLE_SCRIPTS,
|
||||
},
|
||||
include_package_data=True,
|
||||
package_data={
|
||||
"purepycrypto": ["py.typed"],
|
||||
"purepycrypto.tests": ["vectors/*.json"],
|
||||
# Single-file bundle (if generated)
|
||||
"purepycrypto.single": ["*.py"],
|
||||
},
|
||||
zip_safe=False,
|
||||
classifiers=[
|
||||
"Development Status :: 5 - Production/Stable",
|
||||
"Intended Audience :: Developers",
|
||||
"License :: OSI Approved :: MIT License",
|
||||
"Operating System :: OS Independent",
|
||||
"Environment :: Console",
|
||||
"Programming Language :: Python :: 3",
|
||||
"Programming Language :: Python :: 3.7",
|
||||
"Programming Language :: Python :: 3.8",
|
||||
"Programming Language :: Python :: 3.9",
|
||||
"Programming Language :: Python :: 3.10",
|
||||
"Programming Language :: Python :: 3.11",
|
||||
"Programming Language :: Python :: 3.12",
|
||||
"Programming Language :: Python :: 3.13",
|
||||
"Topic :: Security :: Cryptography",
|
||||
"Topic :: Software Development :: Libraries :: Python Modules",
|
||||
],
|
||||
keywords=("cryptography crypto pure-python aes aes-gcm aes-gcm-siv "
|
||||
"chacha20 poly1305 x25519 ed25519 rsa oaep pss "
|
||||
"sha256 sha512 sha3 keccak shake blake2b argon2 scrypt hkdf pbkdf2 hmac "
|
||||
"cli tui"),
|
||||
)
|
||||
Reference in New Issue
Block a user