anntzer / pypi2pkgbuild

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

Error when having multiple candidates for dependencies. #25

Open 4rozenwolves opened 2 years ago

4rozenwolves commented 2 years ago

When running pypi2pkgbuild.py -v pytorch-lightning, I received:

DEBUG:pypi2pkgbuild:This is pypi2pkgbuild 0.3.
DEBUG:pypi2pkgbuild:Running subprocess:
pkgfile pkgfile >/dev/null
DEBUG:pypi2pkgbuild:Running subprocess:
(shopt -s nocaseglob; pacman -Qo /usr/lib/python3.10/site-packages/pytorch_lightning[.-]*-info 2>/dev/null) | rev | cut -d' ' -f1,2 | rev
DEBUG:pypi2pkgbuild:Running subprocess:
pacman -Q python-pytorch-lightning 2>/dev/null
DEBUG:pypi2pkgbuild:Running subprocess:
pkgfile -riv '^/usr/lib/python3\.10/site-packages/pytorch_lightning-.*py3\.10\.egg-info' | cut -f1 | uniq | cut -d/ -f2
DEBUG:pypi2pkgbuild:Running subprocess:
pkgfile -riv '^/usr/lib/python3\.10/pytorch_lightning-.*py3\.10\.egg-info' | cut -f1 | uniq | cut -d/ -f2
DEBUG:pypi2pkgbuild:Running subprocess:
pkgfile -l python-pytorch-lightning 2>/dev/null | grep -Po '(?<=site-packages/)[^-/]*(?=.*\.egg-info/?$)'
INFO:pypi2pkgbuild:Packaging python-pytorch-lightning 1.6.3.
DEBUG:pypi2pkgbuild:Running subprocess:
(shopt -s nocaseglob; pacman -Qo /usr/lib/python3.10/site-packages/pip[.-]*-info 2>/dev/null) | rev | cut -d' ' -f1,2 | rev
DEBUG:pypi2pkgbuild:Running subprocess:
pkgfile -riv '^/usr/lib/python3\.10/site-packages/pip-.*py3\.10\.egg-info' | cut -f1 | uniq | cut -d/ -f2
DEBUG:pypi2pkgbuild:Running subprocess:
pkgfile -l python-pip 2>/dev/null | grep -Po '(?<=site-packages/)[^-/]*(?=.*\.egg-info/?$)'
DEBUG:pypi2pkgbuild:Running subprocess from /tmp/tmphhasgsmy:
makepkg --printsrcinfo | grep -Po '(?<=^\tmakedepends = ).*'
DEBUG:pypi2pkgbuild:Running subprocess:
pacman -Q python-pip >/dev/null 2>&1
DEBUG:pypi2pkgbuild:Running subprocess from /tmp/tmpwa37mdiu:
makepkg
DEBUG:pypi2pkgbuild:Running subprocess:

set -e
python -mvenv /tmp/tmp7xtyhojy
# Leave the source directory, which may contain wheels/sdists/etc.
cd /tmp/tmp7xtyhojy
. '/tmp/tmp7xtyhojy/bin/activate'
pip install --upgrade pip >/dev/null
install_cmd() {
    pip list --format=freeze | cut -d= -f1 | sort >'/tmp/tmp7xtyhojy/pre'
    if ! pip install --no-deps 'pytorch-lightning==1.6.3.*,<1.6.3.1'; then
        return 1
    fi
    pip list --format=freeze | cut -d= -f1 | sort >'/tmp/tmp7xtyhojy/post'
    # installed name, or real name if it doesn't appear
    # (setuptools, pip, Cython, numpy).
    install_name="$(comm -13 '/tmp/tmp7xtyhojy/pre' '/tmp/tmp7xtyhojy/post')"
    # the requirement can be 'req_name==version', or a path name.
    if [[ -z "$install_name" ]]; then
        if [[ -e 'pytorch-lightning==1.6.3.*,<1.6.3.1' ]]; then
            install_name="$(basename 'pytorch-lightning==1.6.3.*,<1.6.3.1' .git)"
        else
            install_name="$(echo 'pytorch-lightning==1.6.3.*,<1.6.3.1' | cut -d= -f1 -)"
        fi
    fi
}
show_cmd() {
    python - "$(pip show -v "$install_name")" <<EOF
from email.parser import Parser
import json
import sys
print(json.dumps(dict(Parser().parsestr(sys.argv[1]))))
EOF
}
if install_cmd >/tmp/tmpx54krhqc; then
    show_cmd
else
    pip install numpy >/dev/null
    echo numpy >>/tmp/tmpwlovggos
    install_cmd >/tmp/tmpx54krhqc
    show_cmd
fi

DEBUG:pypi2pkgbuild:Running subprocess:
(shopt -s nocaseglob; pacman -Qo /usr/lib/python3.10/site-packages/fsspec[.-]*-info 2>/dev/null) | rev | cut -d' ' -f1,2 | rev
DEBUG:pypi2pkgbuild:Running subprocess:
pkgfile -riv '^/usr/lib/python3\.10/site-packages/fsspec-.*py3\.10\.egg-info' | cut -f1 | uniq | cut -d/ -f2
DEBUG:pypi2pkgbuild:Running subprocess:
pkgfile -l python-fsspec 2>/dev/null | grep -Po '(?<=site-packages/)[^-/]*(?=.*\.egg-info/?$)'
DEBUG:pypi2pkgbuild:Running subprocess:
(shopt -s nocaseglob; pacman -Qo /usr/lib/python3.10/site-packages/numpy[.-]*-info 2>/dev/null) | rev | cut -d' ' -f1,2 | rev
DEBUG:pypi2pkgbuild:Running subprocess:
pkgfile -riv '^/usr/lib/python3\.10/site-packages/numpy-.*py3\.10\.egg-info' | cut -f1 | uniq | cut -d/ -f2
DEBUG:pypi2pkgbuild:Running subprocess:
pkgfile -l python-numpy 2>/dev/null | grep -Po '(?<=site-packages/)[^-/]*(?=.*\.egg-info/?$)'
DEBUG:pypi2pkgbuild:Running subprocess:
(shopt -s nocaseglob; pacman -Qo /usr/lib/python3.10/site-packages/packaging[.-]*-info 2>/dev/null) | rev | cut -d' ' -f1,2 | rev
DEBUG:pypi2pkgbuild:Running subprocess:
pkgfile -riv '^/usr/lib/python3\.10/site-packages/packaging-.*py3\.10\.egg-info' | cut -f1 | uniq | cut -d/ -f2
DEBUG:pypi2pkgbuild:Running subprocess:
pkgfile -l python-packaging 2>/dev/null | grep -Po '(?<=site-packages/)[^-/]*(?=.*\.egg-info/?$)'
DEBUG:pypi2pkgbuild:Running subprocess:
(shopt -s nocaseglob; pacman -Qo /usr/lib/python3.10/site-packages/pydeprecate[.-]*-info 2>/dev/null) | rev | cut -d' ' -f1,2 | rev
DEBUG:pypi2pkgbuild:Running subprocess:
pacman -Q python-pydeprecate 2>/dev/null
DEBUG:pypi2pkgbuild:Running subprocess:
pkgfile -riv '^/usr/lib/python3\.10/site-packages/pydeprecate-.*py3\.10\.egg-info' | cut -f1 | uniq | cut -d/ -f2
DEBUG:pypi2pkgbuild:Running subprocess:
pkgfile -riv '^/usr/lib/python3\.10/pydeprecate-.*py3\.10\.egg-info' | cut -f1 | uniq | cut -d/ -f2
DEBUG:pypi2pkgbuild:Running subprocess:
pkgfile -l python-pydeprecate 2>/dev/null | grep -Po '(?<=site-packages/)[^-/]*(?=.*\.egg-info/?$)'
DEBUG:pypi2pkgbuild:Running subprocess:
(shopt -s nocaseglob; pacman -Qo /usr/lib/python3.10/site-packages/pyyaml[.-]*-info 2>/dev/null) | rev | cut -d' ' -f1,2 | rev
DEBUG:pypi2pkgbuild:Running subprocess:
pkgfile -riv '^/usr/lib/python3\.10/site-packages/pyyaml-.*py3\.10\.egg-info' | cut -f1 | uniq | cut -d/ -f2
DEBUG:pypi2pkgbuild:Running subprocess:
pkgfile -l python-yaml 2>/dev/null | grep -Po '(?<=site-packages/)[^-/]*(?=.*\.egg-info/?$)'
DEBUG:pypi2pkgbuild:Running subprocess:
(shopt -s nocaseglob; pacman -Qo /usr/lib/python3.10/site-packages/tensorboard[.-]*-info 2>/dev/null) | rev | cut -d' ' -f1,2 | rev
DEBUG:pypi2pkgbuild:Running subprocess:
pkgfile -riv '^/usr/lib/python3\.10/site-packages/tensorboard-.*py3\.10\.egg-info' | cut -f1 | uniq | cut -d/ -f2
DEBUG:pypi2pkgbuild:Running subprocess:
pkgfile -l tensorboard 2>/dev/null | grep -Po '(?<=site-packages/)[^-/]*(?=.*\.egg-info/?$)'
DEBUG:pypi2pkgbuild:Running subprocess:
(shopt -s nocaseglob; pacman -Qo /usr/lib/python3.10/site-packages/torch[.-]*-info 2>/dev/null) | rev | cut -d' ' -f1,2 | rev
DEBUG:pypi2pkgbuild:Running subprocess:
pkgfile -riv '^/usr/lib/python3\.10/site-packages/torch-.*py3\.10\.egg-info' | cut -f1 | uniq | cut -d/ -f2
ERROR:pypi2pkgbuild:Multiple candidates for torch: python-pytorch 1.11.0-2, python-pytorch-cuda 1.11.0-2.
anntzer commented 2 years ago

Sounds reasonable to add a -d/--depends python-pytorch or similar flag to allow the end user to 1) manually specify additional depends and 2) resolve such ambiguities. A patch would be welcome.

fengwang commented 2 years ago

@anntzer Maybe you we can skip all the candidates from here without breaking the pipeline, and remind the user to install it afterwards?

anntzer commented 2 years ago

Sure, that seems fine too, but I would prefer protecting that under a --skip-ambiguous-deps option.