Skip to content

Commit fe179c5

Browse files
committed
fix: 🐛 loader loader_extension path in Windows
1 parent 01d5c4f commit fe179c5

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

pyencrypt/encrypt.py

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import os
2+
import sys
23
import re
34
from pathlib import Path
45
from typing import Optional
@@ -97,8 +98,18 @@ def generate_so_file(cipher_key: str, d: int, n: int, base_dir: Optional[Path] =
9798
script_args=['build_ext', '--build-lib', temp_dir.as_posix()],
9899
cmdclass={'build_ext': build_ext},
99100
)
100-
print(list(temp_dir.iterdir()))
101-
return list(temp_dir.glob('loader.cpython-*-*.so'))[0].absolute()
101+
if sys.platform.startswith('win'):
102+
# loader.cp36-win_amd64.pyd
103+
pattern = 'loader.cp*-*.pyd'
104+
else:
105+
# loader.cpython-36m-x86_64-linux-gnu.so
106+
# loader.cpython-36m-darwin.so
107+
pattern = "loader.cpython-*-*.so"
108+
109+
loader_extension = next(temp_dir.glob(pattern), None)
110+
if loader_extension is None:
111+
raise Exception(f"Can't find loader extension in {temp_dir.as_posix()}")
112+
return loader_extension.absolute()
102113

103114

104115
def encrypt_file(path: Path, key: str, delete_origin: bool = False, new_path: Optional[Path] = None):

0 commit comments

Comments
 (0)