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

Error when using -t mageia on Mageia Linux x86-64 v6 #104

Closed shlomif closed 7 years ago

shlomif commented 7 years ago

Hi!

When I run pyp2rpm 3.2.2 on Mageia with the -t mageia flag, I am getting this:

+ pyp2rpm -h
Usage: pyp2rpm [OPTIONS] PACKAGE

  Convert PyPI package to RPM specfile or SRPM.

  Arguments:
  PACKAGE             Provide PyPI name of the package or path to compressed source file.

Options:
  -t TEMPLATE             Template file (jinja2 format) to render (default:
                          "fedora").Search order is 1) filesystem, 2) default
                          templates.
  -o [fedora|mageia|pld]  Default distro whose conversion rules to use
                          (default:"fedora").Default templates have their
                          rules associated and ignore this.
  -b BASE_PYTHON          Base Python version to package for (default: "2").
  -p PYTHON_VERSIONS      Additional Python versions to include in the
                          specfile (e.g -p3 for %{?with_python3}).Can be
                          specified multiple times (default: "3"). Specify
                          additional version or use -b explicitly to disable
                          default.
  -s                      Spec file ~/rpmbuild/SPECS/python-package_name.spec
                          will be created (default: prints spec file to
                          stdout).
  --srpm                  When used pyp2rpm will produce srpm instead of
                          printing specfile into stdout.
  --proxy PROXY           Specify proxy in the form proxy.server:port.
  -r RPM_NAME             Name of rpm package (overrides calculated name).
  -d SAVE_PATH            Specify where to save package file, specfile and
                          generated SRPM (default: "/home/shlomif/rpmbuild").
  -v VERSION              Version of the package to download (ignored for
                          local files).
  --venv / --no-venv      Enable / disable metadata extraction from virtualenv
                          (default: enabled).
  -h, --help              Show this message and exit.
+ rpm -qi pyp2rpm
Name        : pyp2rpm
Version     : 3.2.2
Release     : 1.mga6
Architecture: noarch
Install Date: Thu 23 Mar 2017 22:24:11 IST
Group       : Development/Python
Size        : 333402
License     : MIT
Signature   : (none)
Source RPM  : pyp2rpm-3.2.2-1.mga6.src.rpm
Build Date  : Thu 23 Mar 2017 22:23:45 IST
Build Host  : telaviv1.shlomifish.org
Relocations : (not relocatable)
Packager    : Shlomi Fish <shlomif@shlomifish.org>
URL         : https://github.com/fedora-python/pyp2rpm
Summary     : Convert Python packages to RPM SPECFILES
Description :
Convert Python packages to RPM SPECFILES. The packages can be downloaded from
PyPI and the produced SPEC is in line with Fedora Packaging Guidelines or
Mageia Python Policy.Users can provide their own templates for rendering the
package metadata. Both the package source and metadata can be extracted from
PyPI or from local filesystem (local file doesn't provide that much information
though).
+ pyp2rpm -d /home/shlomif/progs/Rpms/ --srpm -t mageia Zenfilter
INFO  Pyp2rpm initialized.
INFO  Using /home/shlomif/progs/Rpms/ as directory to save source.
INFO  Downloaded package from PyPI: /home/shlomif/progs/Rpms//Zenfilter-0.1a0-py3-none-any.whl.
INFO  Getting metadata from wheel using WheelMetadataExtractor.
Traceback (most recent call last):
  File "/usr/bin/pyp2rpm", line 11, in <module>
    load_entry_point('pyp2rpm==3.2.2', 'console_scripts', 'pyp2rpm')()
  File "/usr/lib/python3.5/site-packages/click/core.py", line 716, in __call__
    return self.main(*args, **kwargs)
  File "/usr/lib/python3.5/site-packages/click/core.py", line 696, in main
    rv = self.invoke(ctx)
  File "/usr/lib/python3.5/site-packages/click/core.py", line 889, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/usr/lib/python3.5/site-packages/click/core.py", line 534, in invoke
    return callback(*args, **kwargs)
  File "/usr/lib/python3.5/site-packages/pyp2rpm/bin.py", line 98, in main
    converted = convertor.convert()
  File "/usr/lib/python3.5/site-packages/pyp2rpm/convertor.py", line 108, in convert
    data = self.metadata_extractor.extract_data(self.client)
  File "/usr/lib/python3.5/site-packages/pyp2rpm/convertor.py", line 210, in metadata_extractor
    self.name_convertor,
  File "/usr/lib/python3.5/site-packages/pyp2rpm/convertor.py", line 185, in name_convertor
    self._name_convertor = name_convertor.DandifiedNameConvertor(self.distro)
  File "/usr/lib/python3.5/site-packages/pyp2rpm/name_convertor.py", line 157, in __init__
    raise RuntimeError("DandifiedNameConvertor needs optional require dnf, and "
RuntimeError: DandifiedNameConvertor needs optional require dnf, and can be used for Fedora distro only.

Please look into fixing it.

mcyprian commented 7 years ago

Hello, thanks for reporting this. DandifiedNameConvertor relies on DNF repositories queries to find most possibly the correct name of dependencies. I removed the check of distro in DandifiedNameConvertor's init method, so the only requirement to use it is presence of dnf module.

Can you please test if this helped you?

shlomif commented 7 years ago

@mcyprian : thanks! It did seem to help and now I can prepare an .src.rpm . However, rpmbuild --rebuild of it fails:

shlomif[rpms]:$base$ rpmbuild --rebuild python3-zenfilter-0.1a0-1.mga6.src.rpm Installing python3-zenfilter-0.1a0-1.mga6.src.rpm
Executing(%prep): /bin/sh -e /var/tmp/rpm-tmp.6nYMO4
+ umask 022
+ cd /home/shlomif/progs/Rpms/BUILD
+ '[' 1 -eq 1 ']'
+ '[' 1 -eq 1 ']'
+ '[' 1 -eq 1 ']'
+ cd /home/shlomif/progs/Rpms/BUILD
+ rm -rf Zenfilter-0.1a0
+ /usr/bin/unzip -qq /home/shlomif/progs/Rpms/SOURCES/Zenfilter-0.1a0-py3-none-any.whl
+ STATUS=0
+ '[' 0 -ne 0 ']'
+ cd Zenfilter-0.1a0
/var/tmp/rpm-tmp.6nYMO4: line 39: cd: Zenfilter-0.1a0: No such file or directory
error: Bad exit status from /var/tmp/rpm-tmp.6nYMO4 (%prep)

RPM build errors:
    Bad exit status from /var/tmp/rpm-tmp.6nYMO4 (%prep)
shlomif[rpms]:$base$
mcyprian commented 7 years ago

It seems the sources of Zenfilter are missing on PyPI. Wheel can be used to get limited package metadata, but you need source tarball to build RPM. I am afraid pyp2rpm can't do much better job here, we should probably end with an error or warning in case neither tar* nor zip is present.

shlomif commented 7 years ago

@mcyprian : thanks for the comment.

shlomif commented 7 years ago

On Tue, 04 Apr 2017 06:50:53 -0700 Michal Cyprian notifications@github.com wrote:

Closed #104 via 8389e5d2dd2004f3b572fae91234890a3f88a85d.

Thanks!

--

Shlomi Fish http://www.shlomifish.org/ List of Text Editors and IDEs - http://shlom.in/IDEs

Chuck Norris knows what the gender of Great A’Tuin, the Discworld world turtle, is. — http://www.shlomifish.org/humour/bits/facts/Chuck-Norris/

Please reply to list if it's a mailing list post - http://shlom.in/reply .