fedora-python / pyp2rpm

Tool to convert a package from PyPI to RPM SPECFILE or to generate SRPM.
MIT License
125 stars 39 forks source link

Unable to convert "entrypoints" package #51

Closed QuLogic closed 6 years ago

QuLogic commented 8 years ago

Trying to run pyp2rpm entrypoints fails with the following traceback:

Traceback (most recent call last):
  File "/usr/lib/python3.4/site-packages/pyp2rpm/archive.py", line 353, in json_wheel_metadata
    json_file = json.loads(self.get_content_of_file('metadata.json'))
  File "/usr/lib64/python3.4/json/__init__.py", line 312, in loads
    s.__class__.__name__))
TypeError: the JSON object must be str, not 'NoneType'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/bin/pyp2rpm", line 9, in <module>
    load_entry_point('pyp2rpm==3.0.2', 'console_scripts', 'pyp2rpm')()
  File "/usr/lib/python3.4/site-packages/click/core.py", line 716, in __call__
    return self.main(*args, **kwargs)
  File "/usr/lib/python3.4/site-packages/click/core.py", line 696, in main
    rv = self.invoke(ctx)
  File "/usr/lib/python3.4/site-packages/click/core.py", line 889, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/usr/lib/python3.4/site-packages/click/core.py", line 534, in invoke
    return callback(*args, **kwargs)
  File "/usr/lib/python3.4/site-packages/pyp2rpm/bin.py", line 98, in main
    converted = convertor.convert()
  File "/usr/lib/python3.4/site-packages/pyp2rpm/convertor.py", line 77, in convert
    data = self.metadata_extractor.extract_data(self.client)
  File "/usr/lib/python3.4/site-packages/pyp2rpm/metadata_extractors.py", line 36, in inner
    data = extraction_fce(self)
  File "/usr/lib/python3.4/site-packages/pyp2rpm/metadata_extractors.py", line 158, in extract_data
    data.set_from(self.data_from_archive)
  File "/usr/lib/python3.4/site-packages/pyp2rpm/metadata_extractors.py", line 555, in data_from_archive
    archive_data['license'] = self.license
  File "/usr/lib/python3.4/site-packages/pyp2rpm/metadata_extractors.py", line 508, in license
    return self.json_metadata.get('license', None)
  File "/usr/lib/python3.4/site-packages/pyp2rpm/metadata_extractors.py", line 476, in json_metadata
    self._json_metadata = self.archive.json_wheel_metadata
  File "/usr/lib/python3.4/site-packages/pyp2rpm/archive.py", line 355, in json_wheel_metadata
    json_file = json.loads(self.get_content_of_file('pydist.json'))
  File "/usr/lib64/python3.4/json/__init__.py", line 312, in loads
    s.__class__.__name__))
TypeError: the JSON object must be str, not 'NoneType'

Using pyp2rpm 3.0.2 in Fedora 23.

QuLogic commented 8 years ago

Maybe related to the fact there are no source packages on PyPI? See takluyver/entrypoints#5.

hroncok commented 8 years ago

Wow, that one is quite different, so even if it works trough this, it will find no setup.py etc. I wonder if this should be fixed, and if so then how. Maybe a proper solution would be just to produce a nicer error?

mcyprian commented 8 years ago

Tarball is not present so pyp2rpm tries to extract metadata from wheel. There is also something wrong with the wheel. I've downloaded it mannualy and tried to unpack it, this was the result:

$ wheel unpack entrypoints-0.1-py2.py3-none-any.whl

Unpacking to: ./entrypoints-0.1
Traceback (most recent call last):
  File "/usr/bin/wheel", line 11, in <module>
    sys.exit(main())
  File "/usr/lib/python2.7/site-packages/wheel/tool/__init__.py", line 358, in main
    args.func(args)
  File "/usr/lib/python2.7/site-packages/wheel/tool/__init__.py", line 292, in unpack_f
    unpack(args.wheelfile, args.dest)
  File "/usr/lib/python2.7/site-packages/wheel/tool/__init__.py", line 138, in unpack
    wf.zipfile.extractall(destination)
  File "/usr/lib64/python2.7/zipfile.py", line 1040, in extractall
    self.extract(zipinfo, path, pwd)
  File "/usr/lib64/python2.7/zipfile.py", line 1028, in extract
    return self._extract_member(member, path, pwd)
  File "/usr/lib64/python2.7/zipfile.py", line 1082, in _extract_member
    with self.open(member, pwd=pwd) as source, \
  File "/usr/lib/python2.7/site-packages/wheel/install.py", line 466, in open
    raise BadWheelFile("No expected hash for file %r" % ef.name)
wheel.install.BadWheelFile: No expected hash for file 'entrypoints.py'
QuLogic commented 8 years ago

That unpacking seems to work fine to the latest entrypoints-0.2.2-py2.py3-none-any.whl.

QuLogic commented 8 years ago

Also, I see no mention of the searched-for metadata.json or pydist.json in the Wheel spec.

mcyprian commented 8 years ago

Description of metadata files content is in PEP 426.

mcyprian commented 6 years ago

Nicer error in case of missing sources was implemented in ada77670, closing this.