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

Refactoring of metadata extractors #77

Closed mcyprian closed 7 years ago

mcyprian commented 8 years ago

In this PR:

mcyprian commented 8 years ago

If runpy fails to run extract_dist command (Syntax or Runtime error occurs), command is run using external python2 interpreter with --output option. Extracted metadata are sent to standard output in json format, read and deserialized in metadata extractor.

At this moment string "extracted json data:\n" is at the beginning of json metadata, because other messages from setup.py script or command can appear on stdout. Maybe some more sophisticated separator could be used.

hroncok commented 8 years ago

Does it also work the other way around (as described here)?

mcyprian commented 8 years ago

No it doesn't. I was focused at the original issue #72. Do you suggest to try running python3 in the subprocess in this case or can we expect that package is python2 incompatible and fail? At the moment when ImportError occurs we don't have any metadata of the package. I am not sure if there is deterministic way to find out if package is python2 compatible or not (classifiers are usually not very confident) even if we had needed metadata.

hroncok commented 8 years ago

Simply try the other interpreter. (I.e. 2 on 3 and 3 on 2).

mcyprian commented 8 years ago

Now it works for both cases.