pypa/pip

installing via "git+file" fails under Windows when url point to different drive-letter

SvenRoederer opened this issue · 1 comments

Description

I clone an existing git-repo to Windows $TMP unsing src = tempfile.mkdtemp(prefix = 'thrift-src_') and tried to install this via PIP pip install f'thrift@git+file://{src}@@v0.18.1#subdirectory=lib/py'. This will fail, as long as my cwd is on a different drive than $TMP

The git command will not get the correct folder passed and tries to use the cloned one with the tag-name appended.

When I change to src = tempfile.mkdtemp(prefix = 'thrift-src_', dir = '\\source\\project'), the package gets installed without worries. The difference seems only the absence of specifying the drive-letter.

Expected behavior

Pip should be able the install via "git+file://" from any drive / any location

pip version

24.0

Python version

3.11.9

OS

Windows 10

How to Reproduce

  1. change to project folder on different drive than C: (cd d:\test)
  2. git clone https://github.com/apache/thrift C:\sven\AppData\Local\Temp\thrift
  3. pip install thrift@git+file://C:\sven\AppData\Local\Temp\thrift@v0.18.1#subdirectory=lib/py'

Output

D:\source\project> python tests\automated\test-02_integration-test.py --build-dir build\x64-Debug --keep-env

checking out thrift source to C:\Users\SVEN-B~1\AppData\Local\Temp\thrift-src_ily166m5
Cloning into 'C:\Users\SVEN-B~1\AppData\Local\Temp\thrift-src_ily166m5'...
remote: Enumerating objects: 76881, done.
remote: Counting objects: 100% (62/62), done.
remote: Compressing objects: 100% (47/47), done.
remote: Total 76881 (delta 18), reused 50 (delta 12), pack-reused 76819
Receiving objects: 100% (76881/76881), 32.17 MiB | 5.21 MiB/s, done.
Resolving deltas: 100% (53813/53813), done.
Updating files: 100% (2631/2631), done.
ensure required python dependencies are installed ...
caling pip inside venv: ['D:\\source\\project\\tests\\venv\\Scripts\\pip', 'install', '--use-pep517', '-vvv', 'behave', 'tomli-w', 'thrift@git+file://C:\\Users\\SVEN-B~1\\AppData\\Local\\Temp\\thrift-src_ily166m5@v0.18.1#subdirectory=lib/py']
Using pip 24.0 from D:\sven\source\halo\tests\venv\Lib\site-packages\pip (python 3.11)
Non-user install because user site-packages disabled
Created temporary directory: C:\Users\sven-build\AppData\Local\Temp\pip-build-tracker-bgphca_m
Initialized build tracking at C:\Users\sven-build\AppData\Local\Temp\pip-build-tracker-bgphca_m
Created build tracker: C:\Users\sven-build\AppData\Local\Temp\pip-build-tracker-bgphca_m
Entered build tracker: C:\Users\sven-build\AppData\Local\Temp\pip-build-tracker-bgphca_m
Created temporary directory: C:\Users\sven-build\AppData\Local\Temp\pip-install-8zsiaw5k
Created temporary directory: C:\Users\sven-build\AppData\Local\Temp\pip-ephem-wheel-cache-9m1_ina3
Collecting thrift@ git+file://C:****@v0.18.1
  Cloning file://C:****@v0.18.1 -  to c:\users\sven-build\appdata\local\temp\pip-install-8zsiaw5k\thrift_21b80a19cef34137a47bc63f7c58fc15
  Running command git version
  git version 2.45.0.windows.1
  17:25:34.810748 exec-cmd.c:243          trace: resolved executable dir: C:/Program Files/Git/mingw64/bin
  17:25:34.821955 git.c:465               trace: built-in: git version
  Running command git clone --filter=blob:none --verbose --progress 'file://C:****@v0.18.1' 'C:\Users\sven-build\AppData\Local\Temp\pip-install-8zsiaw5k\thrift_21b80a19cef34137a47bc63f7c58fc15'
  17:25:34.867245 exec-cmd.c:243          trace: resolved executable dir: C:/Program Files/Git/mingw64/bin
  17:25:34.878977 git.c:465               trace: built-in: git clone --filter=blob:none --verbose --progress 'file://C:\Users\SVEN-B~1\AppData\Local\Temp\thrift-src_ily166m5@v0.18.1' 'C:\Users\sven-build\AppData\Local\Temp\pip-install-8zsiaw5k\thrift_21b80a19cef34137a47bc63f7c58fc15'
  17:25:35.717641 run-command.c:657       trace: run_command: unset GIT_DIR; GIT_PROTOCOL=version=2 'git-upload-pack '\''C:\Users\SVEN-B~1\AppData\Local\Temp\thrift-src_ily166m5@v0.18.1'\'''
  Cloning into 'C:\Users\sven-build\AppData\Local\Temp\pip-install-8zsiaw5k\thrift_21b80a19cef34137a47bc63f7c58fc15'...
  17:25:35.843430 exec-cmd.c:243          trace: resolved executable dir: C:/Program Files/Git/mingw64/bin
  17:25:35.845459 git.c:465               trace: built-in: git upload-pack 'C:\Users\SVEN-B~1\AppData\Local\Temp\thrift-src_ily166m5@v0.18.1'
  fatal: 'C:\Users\SVEN-B~1\AppData\Local\Temp\thrift-src_ily166m5@v0.18.1' does not appear to be a git repository
  fatal: Could not read from remote repository.

D:\source\project>

Code of Conduct

While writing this I found that PIP fails, as soon as a dive-letter is supplied. Cloning to D:\test-folder and giving the full path to pip, will fail too.