Skip to content

Commit

Permalink
feat: 🎸 support Python 3.12
Browse files Browse the repository at this point in the history
  • Loading branch information
ZhaoQi99 committed Aug 27, 2024
1 parent 71c3897 commit 823f84b
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 10 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:
fail-fast: false
matrix:
os: [ubuntu-20.04, macos-12, windows-2022]
python-version: ["3.6", "3.7", "3.8", "3.9", "3.10", "3.11"]
python-version: ["3.6", "3.7", "3.8", "3.9", "3.10", "3.11", "3.12"]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
Expand Down
2 changes: 1 addition & 1 deletion pyencrypt/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ def encrypt_command(
if key is None:
key = generate_aes_key().decode()
click.echo(
f'Your randomly encryption 🔑 is {click.style(key,underline=True, fg="yellow")}'
f'Your randomly encryption 🔑 is {click.style(key, underline=True, fg="yellow")}'
)

if before > after:
Expand Down
20 changes: 14 additions & 6 deletions pyencrypt/encrypt.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,16 @@
import os
import sys
import re
import sys
from pathlib import Path
from typing import Optional

import python_minifier
try:
import python_minifier
except ImportError as exc:
if sys.version_info.minor < 12:
raise ImportError("Couldn't import python_minifier.") from exc

python_minifier = None

from pyencrypt.aes import aes_encrypt
from pyencrypt.generate import generate_rsa_number
Expand Down Expand Up @@ -93,10 +99,12 @@ def generate_so_file(
f"{decrypt_source}\n{loader_source}", encoding="utf-8"
)

loader_file_path.write_text(
python_minifier.minify(loader_origin_file_path.read_text(encoding="utf-8")),
encoding="utf-8",
)
minified_code = loader_origin_file_path.read_text(encoding="utf-8")

if python_minifier:
minified_code = python_minifier.minify(minified_code)

loader_file_path.write_text(minified_code, encoding="utf-8")

from setuptools import setup # isort:skip
from Cython.Build import cythonize
Expand Down
5 changes: 3 additions & 2 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ classifiers =
Programming Language :: Python :: 3.9
Programming Language :: Python :: 3.10
Programming Language :: Python :: 3.11
Programming Language :: Python :: 3.12
Programming Language :: Python :: Implementation :: CPython
Environment :: Console
license_files = LICENSE
Expand All @@ -32,9 +33,9 @@ keywords = python-encrypt, import-hook
install_requires =
Cython >= 0.29.30
pycryptodome >= 3.14.1
python-minifier >= 2.6.0
python-minifier >= 2.6.0; python_version < '3.12'
click
python_requires = >=3.6,<3.12
python_requires = >=3.6,<3.13
packages = find:
# package_dir =
# = src
Expand Down

0 comments on commit 823f84b

Please sign in to comment.