fedora-python / pyp2rpm

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

Using this tools directly on wheels or setup.py #179

Open bioinfornatics opened 5 years ago

bioinfornatics commented 5 years ago

Dear,

I am interested in your tools seem really promising with rpm and scl support. Instead to grab the package form pypi is it possible to use it on a wheel directly or from the setup.py ?

Best regards

hroncok commented 5 years ago

You can use it on local sdist.

bioinfornatics commented 5 years ago

Thanks @hroncok

So I tried on a wheel:

$ wheel version
wheel 0.33.1
$ pyp2rpm dist/contatester-1.0.0-py2.py3-none-any.whl 
Unable to extract package metadata from .whl archive. This might be caused by an old .whl format version. You may ask the upstream to upload fresh wheels created with wheel >= 0.17.0 or to upload an sdist as well to workaround this problem.

That works fine with sdist

hroncok commented 5 years ago

Could you recreate the wheel?

bioinfornatics commented 5 years ago

Of course:

$ rm -fr dist build
$ python3 setup.py bdist_wheel
running bdist_wheel
running build
running build_py
running egg_info
…
…
$ ls dist/
contatester-1.0.0-py2.py3-none-any.whl
$ wheel version
wheel 0.33.1
$ pyp2rpm dist/contatester-1.0.0-py2.py3-none-any.whl 
Unable to extract package metadata from .whl archive. This might be caused by an old .whl format version. You may ask the upstream to upload fresh wheels created with wheel >= 0.17.0 or to upload an sdist as well to workaround this problem.

Extra info

$ wheel unpack dist/contatester-1.0.0-py2.py3-none-any.whl
Unpacking to: ./contatester-1.0.0...OK
$ ls contatester-1.0.0/
contatester-1.0.0.data  contatester-1.0.0.dist-info  fr
hroncok commented 5 years ago

no idea. is using sdist a viable option?

bioinfornatics commented 5 years ago

yes using sdist works as expected only wheel is broken

hroncok commented 5 years ago

Glad you have a workaround. This projet is in stasis, so a proper fix will probably not happen unless it gains a proper maintainer. Sorry about that.

bioinfornatics commented 5 years ago

ok, if I have some time I could try to use pdb to provides a better understanding.

Thanks @hroncok this tool is useful

gordonmessmer commented 5 years ago

It looks like metadata.json isn't included any more, since 0.31.0 (2018-04-01): https://wheel.readthedocs.io/en/latest/news.html

I interpret this comment from ncoghlan as an indication that metadata.json was never part of the formal spec: https://github.com/python/peps/issues/388#issuecomment-326959549

The wheel parser probably needs to be rewritten to support the METADATA file instead: https://packaging.python.org/specifications/core-metadata/

gordonmessmer commented 5 years ago

I have some questions about wheel support... I've run pyp2rpm on an old release of its own whl file in order to get a better idea of what the expected output look like. The output spec doesn't appear to be usable, so I suspect that I'm missing something.

The spec lists the whl file as its source archive, which Fedora guidelines suggest is not suitable: https://fedoraproject.org/wiki/PythonWheels The spec file loads build requires from json, and use "setup.py" in each stage, but wheel archives are a binary distribution format. They don't have build requires, and don't include a setup.py file.

It seems like supporting whl archives would require a different template, one that uses the %py2/3_install_wheel and parses the METADATA file. I'm willing to write that, but it seems like support for packaging binary distribution archives is anachronistic, and should be discouraged. A better solution might be to simply drop all support for wheel archives.

Either that or, as I said, I'm missing something fundamental.

hroncok commented 5 years ago

You are correct, repackaging wheels is not allowed like that in Fedora.

hroncok commented 5 years ago

The original idea maybe was to use a wheel to get the metadata and then use a custom source (such as a github tarball), but I'm not sure.

gordonmessmer commented 5 years ago

"The original idea maybe was to use a wheel to get the metadata"

If that's the case, then removing the feature is probably appropriate. JSON metadata is no longer included, and the METADATA that is included doesn't include any of the build/test requirements, etc. It only has information that's needed to install the built distribution.

hroncok commented 5 years ago

Sure! Go for it.

petersilva commented 11 months ago

279 problem is caused by the same problem.