nix-community / pip2nix

Freeze pip-installable packages into Nix expressions [maintainer=@datakurre]
175 stars 26 forks source link

`git+url` dependencies won't work (?) #97

Open turbotimon opened 2 months ago

turbotimon commented 2 months ago

Wit a requirements.txt including a git+url, like e.g.

# requirements.txt
requests
git+https://github.com/pypa/pip

i got the following error:

$ pip2nix generate -r requirements.txt 
Collecting git+https://github.com/pypa/pip (from -r requirements.txt (line 2))
  Cloning https://github.com/pypa/pip to /tmp/pip-req-build-towc0u3o
  Running command git clone -q https://github.com/pypa/pip /tmp/pip-req-build-towc0u3o
  Installing build dependencies ... done
  Getting requirements to build wheel ... done
    Preparing wheel metadata ... done
Collecting requests
  Using cached requests-2.32.3-py3-none-any.whl (64 kB)
Collecting urllib3<3,>=1.21.1
  Downloading urllib3-2.2.2-py3-none-any.whl (121 kB)
     |████████████████████████████████| 121 kB 6.3 MB/s 
Collecting certifi>=2017.4.17
  Downloading certifi-2024.8.30-py3-none-any.whl (167 kB)
     |████████████████████████████████| 167 kB 52.8 MB/s 
Collecting idna<4,>=2.5
  Downloading idna-3.8-py3-none-any.whl (66 kB)
     |████████████████████████████████| 66 kB 21.3 MB/s 
Collecting charset-normalizer<4,>=2
  Using cached charset_normalizer-3.3.2-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (142 kB)
Prefetching https://files.pythonhosted.org/packages/12/90/3c9ff0512038035f59d279fddeb79f5f1eccd8859f06d6163c58798b9487/certifi-2024.8.30-py3-none-any.whl.
path is '/nix/store/m5r5inpx1zgzrb6ki4y0h1m2yfj5gyn3-certifi-2024.8.30-py3-none-any.whl'
Prefetching https://files.pythonhosted.org/packages/63/09/c1bc53dab74b1816a00d8d030de5bf98f724c52c1635e07681d312f20be8/charset-normalizer-3.3.2.tar.gz.
path is '/nix/store/kbjnbfa56fv99h6b1y4830mflk6656nk-charset-normalizer-3.3.2.tar.gz'
Prefetching https://files.pythonhosted.org/packages/22/7e/d71db821f177828df9dea8c42ac46473366f191be53080e552e628aad991/idna-3.8-py3-none-any.whl.
path is '/nix/store/szlkqwm9h6hn71z7gyjvv9a4fpx2yz2n-idna-3.8-py3-none-any.whl'
ERROR: Exception:
Traceback (most recent call last):
  File "/nix/store/y3hkqsfvf4kidvvqabr1vsl59r747hmb-python3.9-pip-20.1.1/lib/python3.9/site-packages/pip/_internal/cli/base_command.py", line 188, in _main
    status = self.run(options, args)
  File "/home/user/pip2nix/pip2nix/generate.py", line 347, in run
    return requirement_set
  File "/nix/store/q3d21ys27dn3byyb9vsb55bcx5s68l8w-python3.9-contexter-0.1.4/lib/python3.9/site-packages/contexter.py", line 96, in __exit__
    reraise(exc)
  File "/nix/store/q3d21ys27dn3byyb9vsb55bcx5s68l8w-python3.9-contexter-0.1.4/lib/python3.9/site-packages/contexter.py", line 26, in reraise
    raise exc[1].with_traceback(exc[2])
  File "/home/user/pip2nix/pip2nix/generate.py", line 346, in run
    requirement_set = self.super_run(options, args)
  File "/home/user/pip2nix/pip2nix/generate.py", line 325, in super_run
    self.process_requirements(
  File "/home/user/pip2nix/pip2nix/generate.py", line 169, in process_requirements
    f.write('  ' + indent(2, '\n'.join(
  File "/home/user/pip2nix/pip2nix/generate.py", line 171, in <genexpr>
    pkg.to_nix(include_lic=include_lic,
  File "/home/user/pip2nix/pip2nix/models/package.py", line 195, in to_nix
    src=link_to_nix(self.source, cache=cache),
  File "/home/user/pip2nix/pip2nix/models/package.py", line 360, in link_to_nix
    url, branch = url.rsplit('@', 1)
ValueError: not enough values to unpack (expected 2, got 1)

However, I'm not sure if this is a bug or git+url are generally not supported by pip2nix (but i couldn't find anything in the README about it)