fedora-python / pyp2rpm

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

unhelpful error message when extract_dist fails #152

Open TomasTomecek opened 6 years ago

TomasTomecek commented 6 years ago
$ pyp2rpm ./dist/conu-0.0.1.dev0.tar.gz
Failed to extract data from setup.py script.

Ehm, that's not helpful.

So I tried -s switch and it produced more logs:

INFO  Pyp2rpm initialized.
INFO  Using /home/tt/rpmbuild/SOURCES as directory to save source.
INFO  Local file: ./dist/conu-0.0.1.dev0.tar.gz copyed to /home/tt/rpmbuild/SOURCES/conu-0.0.1.dev0.tar.gz.
INFO  Getting metadata from setup.py using SetupPyMetadataExtractor.
INFO  Running extract_dist command with: /usr/bin/python3
ERROR  Subprocess failed, stdout: , stderr: Traceback (most recent call last):
  File "setup.py", line 68, in <module>
    install_requires=get_requirements()
  File "setup.py", line 33, in get_requirements
    with open("./requirements.txt") as fd:
FileNotFoundError: [Errno 2] No such file or directory: './requirements.txt'

ERROR  Could not extract metadata with: /usr/bin/python3
INFO  Running extract_dist command with: /usr/bin/python2
ERROR  Subprocess failed, stdout: , stderr: Traceback (most recent call last):
  File "setup.py", line 68, in <module>
    install_requires=get_requirements()
  File "setup.py", line 33, in get_requirements
    with open("./requirements.txt") as fd:
IOError: [Errno 2] No such file or directory: './requirements.txt'

ERROR  Could not extract metadata with: /usr/bin/python2
Failed to extract data from setup.py script.

Would it be possible to either provide better error message or log more by default?

hroncok commented 6 years ago

Maybe when this happens, the stderr of the subprocess shall be printed by default.

TomasTomecek commented 6 years ago

That would be really helpful.

(I also don't understand why's requirements.txt mandatory, but that's probably a different issue)

mcyprian commented 6 years ago

You try to create list of install_requires by reading them from requirements.txt in setup.py script. pyp2rpm runs setup.py extract_dist command in a subprocess to extract the metadata, so get_requirements function is executed but requirements.txt is not included in tarball. You will get the same error if you try to runpip install . after tarball extraction. In my opinion install_requires should be listed explicitly in setup.py or the requirements.txt file has to be added to MANIFEST.

TomasTomecek commented 6 years ago

(giant facepalm, that traceback indeed comes from my setup.py and the issue really was that I had to add requirements.txt into MANIFEST.in)

relevant lines from the setup.py:

def get_requirements():
    with open("./requirements.txt") as fd:
        return fd.readlines()
...
setup(
    install_requires=get_requirements()
...
hroncok commented 6 years ago

I tough you know this and are only reporting to pyp2rpm that the error in such case is nonobvious, which still stands. I'm renaming the issue accordingly.

TomasTomecek commented 6 years ago

Yup, that's my point: pyp2rpm doesn't make it clear enough that the problem is indeed in the package and that I'm a fool.