fedora-python / pyp2rpm

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

Do not interpret python2 setup.py using python3 #47

Closed xsuchy closed 7 years ago

xsuchy commented 8 years ago

I am getting this traceback:

$ pyp2rpm buildkit --srpm -d /tmp/tmp42J8em -b 2
INFO  Pyp2rpm initialized.
INFO  Using /tmp/tmp42J8em as directory to save source.
INFO  Downloaded package from PyPI: /tmp/tmp42J8em/buildkit-0.2.2.tar.gz.
INFO  Getting metadata from setup.py using DistMetadataExtractor.
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/convertor.py", line 174, in metadata_extractor
    self.base_python_version)
  File "/usr/lib/python3.4/site-packages/pyp2rpm/metadata_extractors.py", line 404, in __init__
    extract_distribution.run_setup(setup_py, 'bdist_rpm')
  File "/usr/lib/python3.4/site-packages/pyp2rpm/extract_distribution.py", line 80, in run_setup
    runpy.run_module(filename, run_name='__main__', alter_sys=True)
  File "/usr/lib64/python3.4/runpy.py", line 178, in run_module
    mod_name, mod_spec, code = _get_module_details(mod_name)
  File "/usr/lib64/python3.4/runpy.py", line 126, in _get_module_details
    code = loader.get_code(mod_name)
  File "<frozen importlib._bootstrap>", line 1572, in get_code
  File "<frozen importlib._bootstrap>", line 1532, in source_to_code
  File "<frozen importlib._bootstrap>", line 321, in _call_with_frames_removed
  File "/tmp/tmpyanhvf6x/buildkit-0.2.2/setup.py", line 4
    print "You need to install the setuptools module to install this software"

It is probably not correct to interpret python2-like setup.py (especially when run with -b 2) with python3.

mcyprian commented 8 years ago

I see what is the problem, but it doesn't seem that it is possible to switch interpret using runpy. It will be necessary to redesign extract_distribution module a bit more. I will take a look at this before some of the following releases.

xsuchy commented 7 years ago

Thank you.