Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RequirementParse error on cryptography? #3495

Closed
dsethi opened this issue Apr 6, 2017 · 16 comments
Closed

RequirementParse error on cryptography? #3495

dsethi opened this issue Apr 6, 2017 · 16 comments

Comments

@dsethi
Copy link

dsethi commented Apr 6, 2017

I am using paramiko (2.0.1) with cryptography (1.3.1) on my mac. I get the following requirements parse error:

ERROR - Unknown exception: Invalid requirement, parse error at "''"
ERROR - Traceback (most recent call last):
ERROR - File "/usr/lib/python2.7/site-packages/paramiko/transport.py", line 1774, in run
ERROR - self.kex_engine.parse_next(ptype, m)
ERROR - return self._parse_kexdh_reply(m)
ERROR - File "/usr/lib/python2.7/site-packages/paramiko/kex_group1.py", line 111, in _parse_kexdh_reply
ERROR - self.transport._verify_key(host_key, sig)
ERROR - File "/usr/lib/python2.7/site-packages/paramiko/transport.py", line 1619, in _verify_key
ERROR - key = self._key_infoself.host_key_type
ERROR - File "/usr/lib/python2.7/site-packages/paramiko/rsakey.py", line 58, in init
ERROR - ).public_key(default_backend())
ERROR - File "/usr/lib64/python2.7/site-packages/cryptography/hazmat/backends/init.py", line 35, in default_backend
ERROR - _default_backend = MultiBackend(_available_backends())
ERROR - File "/usr/lib64/python2.7/site-packages/cryptography/hazmat/backends/init.py", line 22, in _available_backends
ERROR - “cryptography.backends"
ERROR - File "/usr/lib/python2.7/site-packages/pkg_resources/init.py", line 706, in iter_entry_points
ERROR - entries = dist.get_entry_map(group)
ERROR - File "/usr/lib/python2.7/site-packages/pkg_resources/init.py", line 2578, in get_entry_map
ERROR - self._get_metadata('entry_points.txt'), self
ERROR - File "/usr/lib/python2.7/site-packages/pkg_resources/init.py", line 2316, in parse_map
ERROR - maps[group] = cls.parse_group(group, lines, dist)
ERROR - File "/usr/lib/python2.7/site-packages/pkg_resources/init.py", line 2294, in parse_group
ERROR - ep = cls.parse(line, dist)
ERROR - File "/usr/lib/python2.7/site-packages/pkg_resources/init.py", line 2276, in parse
ERROR - return cls(res['name'], res['module'], attrs, extras, dist)
ERROR - File "/usr/lib/python2.7/site-packages/pkg_resources/init.py", line 2203, in init
ERROR - self.extras = Requirement.parse(("x[%s]" % ','.join(extras))).extras
ERROR - File "/usr/lib/python2.7/site-packages/pkg_resources/init.py", line 2858, in parse
ERROR - req, = parse_requirements(s)
ERROR - File "/usr/lib/python2.7/site-packages/pkg_resources/init.py", line 2806, in parse_requirements
ERROR - yield Requirement(line)
ERROR - File "/usr/lib/python2.7/site-packages/pkg_resources/init.py", line 2815, in init
ERROR - raise RequirementParseError(str(e))
ERROR - RequirementParseError: Invalid requirement, parse error at "’'"
@alex
Copy link
Member

alex commented Apr 6, 2017

What version of setuptools are you using?

@dsethi
Copy link
Author

dsethi commented Apr 6, 2017

Hi Alex,
I am using 21.0.0
(easy_install --version
setuptools 21.0.0 from /usr/local/lib/python2.7/site-packages (Python 2.7))

@alex
Copy link
Member

alex commented Apr 6, 2017 via email

@dsethi
Copy link
Author

dsethi commented Apr 6, 2017

Thanks. I upgraded. New version: easy_install --version
setuptools 34.3.3 from /usr/local/lib/python2.7/site-packages (Python 2.7)

However, saw the issue again:

  • Unknown exception: Invalid requirement, parse error at "''"
    2017-04-06 14:16:50,601 - 4662317056 - ERROR - Traceback (most recent call last):
    2017-04-06 14:16:50,624 - 4662317056 - ERROR - File "/usr/local/lib/python2.7/site-packages/paramiko/transport.py", line 1772, in run
    2017-04-06 14:16:50,637 - 4662317056 - ERROR - self.kex_engine.parse_next(ptype, m)
    2017-04-06 14:16:50,647 - 4662317056 - ERROR - File "/usr/local/lib/python2.7/site-packages/paramiko/kex_group1.py", line 75, in parse_next
    2017-04-06 14:16:50,647 - 4662317056 - ERROR - return self._parse_kexdh_reply(m)
    2017-04-06 14:16:50,647 - 4662317056 - ERROR - File "/usr/local/lib/python2.7/site-packages/paramiko/kex_group1.py", line 111, in _parse_kexdh_reply
    2017-04-06 14:16:50,647 - 4662317056 - ERROR - self.transport._verify_key(host_key, sig)
    2017-04-06 14:16:50,647 - 4662317056 - ERROR - File "/usr/local/lib/python2.7/site-packages/paramiko/transport.py", line 1617, in _verify_key
    2017-04-06 14:16:50,647 - 4662317056 - ERROR - key = self._key_infoself.host_key_type
    2017-04-06 14:16:50,647 - 4662317056 - ERROR - File "/usr/local/lib/python2.7/site-packages/paramiko/rsakey.py", line 58, in init
    2017-04-06 14:16:50,647 - 4662317056 - ERROR - ).public_key(default_backend())
    2017-04-06 14:16:50,647 - 4662317056 - ERROR - File "/usr/local/lib/python2.7/site-packages/cryptography/hazmat/backends/init.py", line 35, in default_backend
    2017-04-06 14:16:50,647 - 4662317056 - ERROR - _default_backend = MultiBackend(_available_backends())
    2017-04-06 14:16:50,647 - 4662317056 - ERROR - File "/usr/local/lib/python2.7/site-packages/cryptography/hazmat/backends/init.py", line 22, in _available_backends
    2017-04-06 14:16:50,648 - 4662317056 - ERROR - "cryptography.backends"
    2017-04-06 14:16:50,648 - 4662317056 - ERROR - File "/usr/local/lib/python2.7/site-packages/pkg_resources/init.py", line 725, in iter_entry_points
    2017-04-06 14:16:50,648 - 4662317056 - ERROR - entries = dist.get_entry_map(group)
    2017-04-06 14:16:50,648 - 4662317056 - ERROR - File "/usr/local/lib/python2.7/site-packages/pkg_resources/init.py", line 2656, in get_entry_map
    2017-04-06 14:16:50,648 - 4662317056 - ERROR - self._get_metadata('entry_points.txt'), self
    2017-04-06 14:16:50,648 - 4662317056 - ERROR - File "/usr/local/lib/python2.7/site-packages/pkg_resources/init.py", line 2394, in parse_map
    2017-04-06 14:16:50,649 - 4662317056 - ERROR - maps[group] = cls.parse_group(group, lines, dist)
    2017-04-06 14:16:50,650 - 4662317056 - ERROR - File "/usr/local/lib/python2.7/site-packages/pkg_resources/init.py", line 2372, in parse_group
    2017-04-06 14:16:50,650 - 4662317056 - ERROR - ep = cls.parse(line, dist)
    2017-04-06 14:16:50,650 - 4662317056 - ERROR - File "/usr/local/lib/python2.7/site-packages/pkg_resources/init.py", line 2354, in parse
    2017-04-06 14:16:50,650 - 4662317056 - ERROR - return cls(res['name'], res['module'], attrs, extras, dist)
    2017-04-06 14:16:50,651 - 4662317056 - ERROR - File "/usr/local/lib/python2.7/site-packages/pkg_resources/init.py", line 2275, in init
    2017-04-06 14:16:50,652 - 4662317056 - ERROR - self.extras = Requirement.parse(("x[%s]" % ','.join(extras))).extras
    2017-04-06 14:16:50,655 - 4662317056 - ERROR - File "/usr/local/lib/python2.7/site-packages/pkg_resources/init.py", line 2935, in parse
    2017-04-06 14:16:50,658 - 4662317056 - ERROR - req, = parse_requirements(s)
    2017-04-06 14:16:50,660 - 4662317056 - ERROR - File "/usr/local/lib/python2.7/site-packages/pkg_resources/init.py", line 2883, in parse_requirements
    2017-04-06 14:16:50,661 - 4662317056 - ERROR - yield Requirement(line)
    2017-04-06 14:16:50,661 - 4662317056 - ERROR - File "/usr/local/lib/python2.7/site-packages/pkg_resources/init.py", line 2892, in init
    2017-04-06 14:16:50,694 - 4662317056 - ERROR - raise RequirementParseError(str(e))
    2017-04-06 14:16:50,706 - 4662317056 - ERROR - RequirementParseError: Invalid requirement, parse error at "''"

@alex
Copy link
Member

alex commented Apr 6, 2017 via email

@dsethi
Copy link
Author

dsethi commented Apr 6, 2017

Alex -- please see my edited comment above -- it re-occurred unfortunately for setup tools version 34.3.3. Thanks for the help!

@alex
Copy link
Member

alex commented Apr 6, 2017

Ok. Can you try with the latest version of cryptography?

@dsethi
Copy link
Author

dsethi commented Apr 6, 2017

Thanks Alex - upgraded -- will let you know if I hit it again (or not in some time).

@dsethi
Copy link
Author

dsethi commented Apr 6, 2017

Happened again -- using:
asn1crypto==0.22.0
cryptography==1.8.1
pycrypto==2.6.1

@alex
Copy link
Member

alex commented Apr 6, 2017

Huh. Ok. Is there some way I can reproduce this?

@dsethi
Copy link
Author

dsethi commented Apr 6, 2017

Let me try to construct a minimal version of the code which replicates this and get back on this. Problem is I also hit it intermittently (as using multiple threads)

@alex
Copy link
Member

alex commented Apr 6, 2017

Ok, I managed to reproduce. This happens on most runs:

import sys
import threading

from cryptography.hazmat.backends import default_backend


N_THREADS = 16

def main(argv):
    threads = []
    for i in range(N_THREADS):
        threads.append(threading.Thread(target=default_backend))
    for t in threads:
        t.start()
    for t in threads:
        t.join()

if __name__ == "__main__":
    main(sys.argv)

@alex
Copy link
Member

alex commented Apr 7, 2017

Ok, this appears to be a packaging bug. Going to close this in favor the bug there: pypa/packaging#104

@alex alex closed this as completed Apr 7, 2017
@dsethi
Copy link
Author

dsethi commented Apr 7, 2017

Alex - thanks a bunch for doing this! I will follow the packaging issue thread.

@alex
Copy link
Member

alex commented Apr 7, 2017 via email

@dsethi
Copy link
Author

dsethi commented Apr 7, 2017

Thanks Alex. Very helpful!
I looked into the code a bit and had a few questions on the fix -- please see comments on the commit.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Aug 9, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Development

No branches or pull requests

2 participants