anntzer / pypi2pkgbuild

A PyPI to PKGBUILD converter.
MIT License
71 stars 6 forks source link

Doesn't work for me #5

Closed andischan closed 7 years ago

andischan commented 7 years ago

I use the version from git: python pypi2pkgbuild.py habanero

INFO:pypi2pkgbuild:Packaging python-habanero 0.3.0.
Traceback (most recent call last):
  File "pypi2pkgbuild.py", line 1318, in <module>
    sys.exit(main())
  File "pypi2pkgbuild.py", line 1297, in main
    create_package(name, Options(**vars(args), is_dep=False))
  File "pypi2pkgbuild.py", line 1105, in create_package
    pkg = dispatch_package_builder(name, get_config(), options)
  File "pypi2pkgbuild.py", line 1081, in dispatch_package_builder
    return cls(ref, config, options)
  File "pypi2pkgbuild.py", line 784, in __init__
    self._find_arch_makedepends(options)
  File "pypi2pkgbuild.py", line 888, in _find_arch_makedepends
    map(PackageRef, ["pip", *options.setup_requires]))
  File "pypi2pkgbuild.py", line 624, in __init__
    self.pypi_normed_name, ignore_vendored=True)
  File "pypi2pkgbuild.py", line 566, in _find_installed_name_version
    return pkgname, ArchVersion.parse(version)
  File "pypi2pkgbuild.py", line 276, in parse
    re.fullmatch(r"(?:(.*):)?(.*)-(.*)", s).groups())
AttributeError: 'NoneType' object has no attribute 'groups'
anntzer commented 7 years ago

What does

$ sh -c 'shopt -s nocaseglob; ls /usr/lib/python3.6/site-packages/habanero-*-info; pacman -Qo /usr/lib/python3.6/site-packages/habanero-*-info'

give you?

anntzer commented 7 years ago

@andischan This looks easy enough to fix, but I'd like to know why you are hitting this issue, so please address my question above.

matedealer commented 7 years ago

This error comes from wrong/outdated/language depended parsing of pacman -Qo. With german language cut -d' ' -f2,3 is the correct command. Since I'm not sure if this depend on language or any thing else I didn't created a pull request.

_run_shell(
            "(shopt -s nocaseglob; pacman -Qo {}/{}-*-info 2>/dev/null) "
            "| rev | cut -d' ' -f1,2 | rev".format(
                _get_site_packages_location(),
                to_wheel_name(pypi_normed_name)),
            stdout=PIPE).stdout[:-1].split()
anntzer commented 7 years ago

Can you confirm that

diff --git a/pypi2pkgbuild.py b/pypi2pkgbuild.py
index 8291935..0ea3e07 100755
--- a/pypi2pkgbuild.py
+++ b/pypi2pkgbuild.py
@@ -251,6 +251,7 @@ def _run_shell(args, **kwargs):
     """
     kwargs = {"shell": isinstance(args, str),
               "env": {**os.environ,
+                      "LC_ALL": "C",  # So that text outputs can be parsed.
                       "PYTHONNOUSERSITE": "1",
                       "PIP_CONFIG_FILE": "/dev/null"},
               "check": True,

(i.e. forcing the locale for subprocesses) fixes the issue?

anntzer commented 7 years ago

Committed the fix. Feel free to request a reopen if it still doesn't work.

ZWindL commented 4 years ago

Now I meet the same issue, tried to export LANG=C but didn't work, original LANG is zh_CN.UTF-8. I'm trying to make gdbgui's PKGBUILD file.