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

Packages with dash in their name are incorrectly mangled #86

Closed jwmullally closed 7 years ago

jwmullally commented 7 years ago

Python packages like "my-package" will be incorrectly translated as "my_package" in the generated SPEC.

This looks like a minor edge case but I recall having seen other packages with '-' in the past...

$ pyp2rpm --srpm PyVISA-py
$ rpmbuild -bb ~/rpmbuild/SPECS/python-PyVISA-py.spec
...
RPM build errors:
    File not found: (...)/BUILDROOT/python-PyVISA-py-0.2-1.fc25.x86_64/usr/lib/python2.7/site-packages/pyvisa_py

$ ls ~/rpmbuild/BUILDROOT/python-PyVISA-py-0.2-1.fc25.x86_64/usr/lib/python2.7/site-packages/
pyvisa-py  PyVISA_py-0.2-py2.7.egg-info

$ grep "'packages': " /tmp/pyp2rpm-$USER.log
 'packages': {'pyvisa-py'},

$ grep -A2 packages ~/rpmbuild/BUILD/PyVISA-py-0.2/setup.py
      packages=['pyvisa-py',
                'pyvisa-py.protocols',
                'pyvisa-py.testsuite'],

(Even though this is a bad package name and can't be loaded with "import", its still used here: https://github.com/hgrecco/pyvisa/blob/1.8/pyvisa/highlevel.py#L1413 )

Should the function in commit 7db699a just do return package instead? Given package='pyvisa-py' in this case came directly from setup.py (or from the dir itself) it should be assumed correct, so maybe the .replace() is sanitization that is in the wrong place...

mcyprian commented 7 years ago

Thank you for reporting the issue, also my mass copr builds of pypi packages showed that this is very frequent problem. I am afraid it wil be not enough to return package from filter function package_to_path. Dash in the name of the package is sometimes replaced with underscore in directory name.