Falldog / pyconcrete

Protect your python script, encrypt it as .pye and decrypt when import it
Apache License 2.0
692 stars 149 forks source link

error: option --single-version-externally-managed not recognized #75

Closed NeroAdvents closed 4 years ago

NeroAdvents commented 4 years ago

Hello,

I'm having some issues when installing pyconcrete with pip.This is the returned errors:

(venv) ➜  pye_web git:(master) ✗ pip install pyconcrete --install-option="--passphrase=MyParaphrasse"
DEPRECATION: Python 2.7 reached the end of its life on January 1st, 2020. Please upgrade your Python as Python 2.7 is no longer maintained. pip 21.0 will drop support for Python 2.7 in January 2021. More details about Python 2 support in pip, can be found at https://pip.pypa.io/en/latest/development/release-process/#python-2-support
/home/nordine/PycharmProjects/pyconcrete/venv/lib/python2.7/site-packages/pip-20.2b1-py2.7.egg/pip/_internal/commands/install.py:243: UserWarning: Disabling all use of wheels due to the use of --build-option / --global-option / --install-option.
  cmdoptions.check_install_build_global(options)
Collecting pyconcrete
  Using cached pyconcrete-0.12.1.tar.gz (46 kB)
Skipping wheel build for pyconcrete, due to binaries being disabled for it.
Installing collected packages: pyconcrete
    Running setup.py install for pyconcrete ... error
    ERROR: Command errored out with exit status 1:
     command: /home/nordine/PycharmProjects/pyconcrete/venv/bin/python2.7 -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-aEp4Tn/pyconcrete/setup.py'"'"'; __file__='"'"'/tmp/pip-install-aEp4Tn/pyconcrete/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record /tmp/pip-record-C02e6b/install-record.txt --single-version-externally-managed --compile --install-headers /home/nordine/PycharmProjects/pyconcrete/venv/include/site/python2.7/pyconcrete --passphrase=MyParaphrasse
         cwd: /tmp/pip-install-aEp4Tn/pyconcrete/
    Complete output (6 lines):
    usage: setup.py [global_opts] cmd1 [cmd1_opts] [cmd2 [cmd2_opts] ...]
       or: setup.py --help [cmd1 cmd2 ...]
       or: setup.py --help-commands
       or: setup.py cmd --help

    error: option --single-version-externally-managed not recognized
    ----------------------------------------
ERROR: Command errored out with exit status 1: /home/nordine/PycharmProjects/pyconcrete/venv/bin/python2.7 -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-aEp4Tn/pyconcrete/setup.py'"'"'; __file__='"'"'/tmp/pip-install-aEp4Tn/pyconcrete/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record /tmp/pip-record-C02e6b/install-record.txt --single-version-externally-managed --compile --install-headers /home/nordine/PycharmProjects/pyconcrete/venv/include/site/python2.7/pyconcrete --passphrase=MyParaphrasse Check the logs for full command output.

When i'm adding the flag egg like in the tutorial this is what it returns:

(venv) ➜  django git:(master) ✗ pip install pyconcrete --egg --install-option="--passphrase=MyPassphrase"

Usage:   
  pip install [options] <requirement specifier> [package-index-options] ...
  pip install [options] -r <requirements file> [package-index-options] ...
  pip install [options] [-e] <vcs project url> ...
  pip install [options] [-e] <local project path> ...
  pip install [options] <archive url/path> ...

no such option: --egg

Can someone help me with this ? Thank you.

Falldog commented 4 years ago

Which pip version do you use? Maybe you can try git clone pyconcrete and execute setup.py install directly

NeroAdvents commented 4 years ago

Hi,

First, here is my pip version:

pip 20.1.1 from /home/nordine/.local/lib/python3.6/site-packages/pip (python 3.6)

I did install the module with the setup file and it seems to be working now that I have .pye generated in my project directory. I'm actually using it on a simple django project that I made to test it and I wanted to ask you what was I supposed to do after generating those .pye files.

Now that I have my .pye files generated, I did delete all my .py and tried to run the manage file like so:

➜  myapp git:(master) ✗ python3 manage.pye runserver
  File "manage.pye", line 1
SyntaxError: Non-UTF-8 code starting with '\xc5' in file manage.pye on line 1, but no encoding declared; see http://python.org/dev/peps/pep-0263/ for details

Maybe I'm wrong on how to proceed, then I wouldn't be against a little help on how to make my app running. Thank you !

Falldog commented 4 years ago

Please reference README https://github.com/Falldog/pyconcrete#partial-encrypted-pyconcrete-as-lib For your case, please leave manage.py as plant script file

NeroAdvents commented 4 years ago

Hi again,

Well I did install pyconcrete as a lib like so:

python3 setup.py install --install-lib=/home/nordine/PycharmProjects/Pyconcrete/django-tutorial/myapp --install-scripts=/home/nordine/PycharmProjects/Pyconcrete/django-tutorial/myapp

In order to have the same project layout like it was mentioned in the tutorial:

main.py       # import pyconcrete and your lib
pyconcrete/*  # put pyconcrete lib in project root, keep it as original files
src/*.pye     # your libs
-------- my project --------
manage.py
pyconcrete/*
all my pckg/*.pye

Then I did import pyconcrete inside my manage.py but still it's not working properly:

(venv) ➜  myapp git:(master) ✗ python3 manage.py runserver                                                                                                                                                           
Traceback (most recent call last):
  File "manage.py", line 5, in <module>
    import pyconcrete
  File "/home/nordine/PycharmProjects/Pyconcrete/django-tutorial/myapp/pyconcrete/__init__.py", line 29, in <module>
    from . import _pyconcrete
ImportError: cannot import name '_pyconcrete' from partially initialized module 'pyconcrete' (most likely due to a circular import) (/home/nordine/PycharmProjects/Pyconcrete/django-tutorial/myapp/pyconcrete/__init__.py)

Here is my project folder structure:

.
├── core
├── db.sqlite3
├── __init__.py
├── manage.py
├── myapp
├── polls
├── pyconcrete
├── pyconcrete-0.12.1.egg-info
├── pyconcrete-admin.py
├── pyconcrete.pth
├── reviews
├── static
├── todolis
└── upload

I think I did something wrong but I don't know what so if you have the answer to my problem it would be great. Thank you.

Falldog commented 4 years ago

After you install pyconcrete, there should be a _pyconcrete.so, that's why the exception told you cannot import _pyconcrete. Please make sure pyconcrete files under your import path