Giter Club home page Giter Club logo

pyencrypt-pye's Introduction

pyencrypt-pye's People

Contributors

zhaoqi99 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

pyencrypt-pye's Issues

加密multiprocessing

大佬,写了一个多进程py代码,加密后执行一直停留在Process ForkPoolWorker这里,后面的代码都不继续执行了。
有没有解决的办法呢?

不使用subprocess生成loader文件

setup(
    ext_modules=cythonize([file_name], quiet=True, language_level=3),
    script_args=["build_ext", "-t", td, "--inplace"],
)

今天看到的一段代码...
似乎可以不使用subprocss

加密后生成的loader文件的路径不对

Encryption completed successfully.
Please copy encrypted/loader.cpython-39m-darwin.so into your encrypted directory.
And then remove `encrypted` directory.
Finally, add `import loader` at the top of your entry file.

加密后提示生成的loader文件在encrypted/loader.cpython-39m-darwin.so
但是实际上loader文件的路径是encrypted/loader.cpython-39-darwin.so,没有m了
Python版本

~ $ python -V
Python 3.9.6

AttributeError: 'PosixPath' object has no attribute 'rpartition'

  File "main.pye", line 2, in <module>
  File "<frozen importlib._bootstrap>", line 971, in _find_and_load
  File "<frozen importlib._bootstrap>", line 951, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 894, in _find_spec
  File "encrypted/loader.py", line 280, in loader.QospGExaJCABDzhRFNSt.find_spec
  File "<frozen importlib._bootstrap>", line 441, in spec_from_loader
  File "<frozen importlib._bootstrap_external>", line 574, in spec_from_file_location
  File "<frozen importlib._bootstrap_external>", line 664, in is_package
  File "<frozen importlib._bootstrap_external>", line 66, in _path_split
AttributeError: 'PosixPath' object has no attribute 'rpartition'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/lib/python3.6/tokenize.py", line 390, in find_cookie
    line_string = line.decode('utf-8')
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xad in position 1: invalid start byte

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/usr/local/lib/python3.6/multiprocessing/spawn.py", line 105, in spawn_main
    exitcode = _main(fd)
  File "/usr/local/lib/python3.6/multiprocessing/spawn.py", line 118, in _main
    return self._bootstrap()
  File "/usr/local/lib/python3.6/multiprocessing/process.py", line 274, in _bootstrap
    traceback.print_exc()
  File "/usr/local/lib/python3.6/traceback.py", line 163, in print_exc
    print_exception(*sys.exc_info(), limit=limit, file=file, chain=chain)
  File "/usr/local/lib/python3.6/traceback.py", line 104, in print_exception
    type(value), value, tb, limit=limit).format(chain=chain):
  File "/usr/local/lib/python3.6/traceback.py", line 509, in __init__
    capture_locals=capture_locals)
  File "/usr/local/lib/python3.6/traceback.py", line 364, in extract
    f.line
  File "/usr/local/lib/python3.6/traceback.py", line 286, in line
    self._line = linecache.getline(self.filename, self.lineno).strip()
  File "/usr/local/lib/python3.6/linecache.py", line 16, in getline
    lines = getlines(filename, module_globals)
  File "/usr/local/lib/python3.6/linecache.py", line 47, in getlines
    return updatecache(filename, module_globals)
  File "/usr/local/lib/python3.6/linecache.py", line 136, in updatecache
    with tokenize.open(fullname) as fp:
  File "/usr/local/lib/python3.6/tokenize.py", line 454, in open
    encoding, lines = detect_encoding(buffer.readline)
  File "/usr/local/lib/python3.6/tokenize.py", line 431, in detect_encoding
    encoding = find_cookie(first)
  File "/usr/local/lib/python3.6/tokenize.py", line 395, in find_cookie
    raise SyntaxError(msg)
SyntaxError: invalid or missing encoding declaration for 'main.pye'

TypeError: '_NamespacePath' object does not support indexing

报错如下

Traceback (most recent call last):
  File "a.py", line 3, in <module>
    from test.test2.abc import *
  File "<frozen importlib._bootstrap>", line 971, in _find_and_load
  File "<frozen importlib._bootstrap>", line 951, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 894, in _find_spec
  File "/Users/zhaoqi219/Code/python_encrypt/encrypted/loader.py", line 411, in find_spec
    file_path = Path(path[0]) / f'{fullname.rsplit(".",1)[-1]}.pye'
TypeError: '_NamespacePath' object does not support indexing

目录结构是

test
├── __init__.py
└── test2
    └── abc.py

代码是

import loader
from test.test2.abc import *

pyencrypt cli --with-license option not passed on

看起来 with-license 参数没有传递到 generate_so_file ,导致:--width-license 失效。

我简单添加了一下,
encrypt_command::generate_so_file(..., license=with_license)

简单从测试了一下,通过

新增一个check命令

inspired by #5
可以再自定义一个Finder,走一遍EncryptFileFinderfind_spec函数中获取file_path的逻辑

自定义KeyParamType

class KeyParamType(ParamType):
    name = '🔑'

    def convert(self, value, param, ctx):
        if not _check_key(value):
            self.fail(INVALID_KEY_MSG, param, ctx)
        return value

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.