vpelletier / python-libusb1

Python ctype-based wrapper around libusb1
GNU Lesser General Public License v2.1
168 stars 65 forks source link

failed to instal version 1.9 from sdist. error: option --single-version-externally-managed not recognized #64

Closed SomberNight closed 3 years ago

SomberNight commented 3 years ago

I can't install libusb1 version 1.9 from sdist -- version 1.8 works. Any idea what is going on?

$ python --version
Python 3.8.5

$ pip list
Package       Version
------------- -------
pip           20.3.1
pkg-resources 0.0.0
setuptools    51.0.0
wheel         0.36.1

$ pip install libusb1==1.9 --no-binary :all:
Collecting libusb1==1.9
  Using cached libusb1-1.9.tar.gz (79 kB)
Skipping wheel build for libusb1, due to binaries being disabled for it.
Installing collected packages: libusb1
    Running setup.py install for libusb1 ... error
    ERROR: Command errored out with exit status 1:
     command: /home/user/wspace/tmp/tmp-venv/bin/python3 -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-0k22s29n/libusb1_4996cb72fe7547fa9623be2a334af9a9/setup.py'"'"'; __file__='"'"'/tmp/pip-install-0k22s29n/libusb1_4996cb72fe7547fa9623be2a334af9a9/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-8m2z6xqo/install-record.txt --single-version-externally-managed --compile --install-headers /home/user/wspace/tmp/tmp-venv/include/site/python3.8/libusb1
         cwd: /tmp/pip-install-0k22s29n/libusb1_4996cb72fe7547fa9623be2a334af9a9/
    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/user/wspace/tmp/tmp-venv/bin/python3 -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-0k22s29n/libusb1_4996cb72fe7547fa9623be2a334af9a9/setup.py'"'"'; __file__='"'"'/tmp/pip-install-0k22s29n/libusb1_4996cb72fe7547fa9623be2a334af9a9/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-8m2z6xqo/install-record.txt --single-version-externally-managed --compile --install-headers /home/user/wspace/tmp/tmp-venv/include/site/python3.8/libusb1 Check the logs for full command output.

$ pip install libusb1==1.8 --no-binary :all:
Collecting libusb1==1.8
  Using cached libusb1-1.8.tar.gz (78 kB)
Skipping wheel build for libusb1, due to binaries being disabled for it.
Installing collected packages: libusb1
    Running setup.py install for libusb1 ... done
Successfully installed libusb1-1.8
vpelletier commented 3 years ago

I confirm I can reproduce the issue here. 1.8.1 introduced quite some changes to setup.py, and it also fails to install.

I think I found it: one of the changes customises install, which is hence forcibly resolved to distutils'. But setup comes from setuptools, and setuptools/command/install.py does mention --single-version-externally-managed.

I changed the imports to pick from setuptools instead, and released as 1.9.1 (after testing on test.pypi.org).

This fixes the issue for me, could you check ?

$ virtualenv vclean
...
$ ./vclean/bin/pip install libusb1==1.9.1 --no-binary :all:
Collecting libusb1==1.9.1
  Downloading libusb1-1.9.1.tar.gz (79 kB)
     |████████████████████████████████| 79 kB 549 kB/s
Skipping wheel build for libusb1, due to binaries being disabled for it.
Installing collected packages: libusb1
    Running setup.py install for libusb1 ... done
Successfully installed libusb1-1.9.1

EDIT: I accidentally a sentence.

vpelletier commented 3 years ago

Also, just to spread the word, as I see the ping-back from electrum repository: python-libusb1 releases are now cryptographicaly signed. This was the reason of some changes to setup.py, although not the one which broke the install.

See KEYS for more details. Signature checking is not trivial, and if you want to properly check that only authorized keys signed a release and not just any key you trust, you have to create one gpg keyring per package... But it's probably better than nothing.

SomberNight commented 3 years ago

This fixes the issue for me, could you check ?

Works for me too. Thanks!

python-libusb1 releases are now cryptographicaly signed

Great; good to know. We will consider validating them.