Pip install from git repository, errors due to wrong quotes
Asked Answered
M

2

2

Problem Description

Using Python 3.7.6 on Windows 10, I'm trying to upgrade a package installed directly from a git repository:

pip install --upgrade git+https://url.of.my/py/package.git

The installation then fails:

...
error: file 'C:\Users\myuser\AppData\Local\Temp\pip-req-build-ip4k0pfs\bin\some-script' does not exist
...

As far as I've been able to work out, for the following reason: early on, pip calls

git clone -q https://url.of.my/py/package.git 'C:\Users\myuser\AppData\Local\Temp\pip-req-build-ip4k0pfs'

i.e. it checks out the repository into a temporary directory. However, the directory isn't created and no sources are checked out. Indeed, when I run the command on the Windows command line (I've also tried Git Bash and MSYS2 Bash, same problem), I get an error:

C:\Users\myuser>git clone -q https://url.of.my/py/package.git 'C:\Users\myuser\AppData\Local\Temp\pip-req-build-ip4k0pfs'
fatal: could not create leading directories of ''C:\Users\myuser\AppData\Local\Temp\pip-req-build-ip4k0pfs'': Invalid argument

The problem are the single quotes around the path to the temporary directory. Changing them to double quotes makes the error disappear:

C:\Users\myuser>git clone -q https://url.of.my/py/package.git "C:\Users\myuser\AppData\Local\Temp\pip-req-build-ip4k0pfs"

Question

Is there any way to tell pip to use double instead of single quotes? Any other ideas for how to overcome this problem?

Edits

  1. In the meantime, I've also tried Python 3.8.2 with pip 20.1, and got the same error
Mohock answered 29/4, 2020 at 21:9 Comment(4)
you may spin an instance of linux on aws and see if your package is broken, or is it just windows problemUsa
I doubt the issue lies in the quotes. I would rather look into the issue with the error: file 'C:\...\bin\some-script' does not exist. What is this script, is it part of the project being installed? Is it properly packaged? Is it in the git repository?Inventor
@Inventor You were right, the quotes — or rather, the fact that the logged git command doesn't work if directly executed — were a red herring, and the actual problem was that my setup.py had a typo in one of the scripts it claimed to publish. Feel free to post a short, corresponding answer, I'll accept it then. If not, I'll answer my own question.Mohock
Glad, a solution was found. I'm fine with you answering your own question, I wouldn't know what to write exactly, since it was a typo.Inventor
M
3

As @sinoroc suspected, the quotes — or rather, the fact that the logged git command doesn't work if directly executed — were a red herring, and the actual problem was that my setup.py had a typo: the scripts list included a file named bin/some-script, which was actually named bin/some-script.py, and thus couldn't be found.

Mohock answered 30/4, 2020 at 19:36 Comment(1)
Same root issue, different symptoms: https://mcmap.net/q/1811620/-python-setup-py-sdist-bdist_wheelInventor
H
2

I had the same problem and did not have the same underlying issue. The issue is resolved by using git bash (MINGW), which handles the quotes correctly.

Hindenburg answered 11/3, 2021 at 11:1 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.