codekingpro commited on
Commit
3e16b7b
·
verified ·
1 Parent(s): 5debfc5

Add files using upload-large-folder tool

Browse files
This view is limited to 50 files because it contains too many changes.   See raw diff
Files changed (50) hide show
  1. python/Lib/site-packages/_yaml/__init__.py +33 -0
  2. python/Lib/site-packages/_yaml/__pycache__/__init__.cpython-313.pyc +0 -0
  3. python/Lib/site-packages/pip-26.1.1.dist-info/licenses/AUTHORS.txt +867 -0
  4. python/Lib/site-packages/pip-26.1.1.dist-info/licenses/LICENSE.txt +20 -0
  5. python/Lib/site-packages/pip-26.1.1.dist-info/licenses/src/pip/_vendor/cachecontrol/LICENSE.txt +13 -0
  6. python/Lib/site-packages/pip-26.1.1.dist-info/licenses/src/pip/_vendor/certifi/LICENSE +20 -0
  7. python/Lib/site-packages/pip-26.1.1.dist-info/licenses/src/pip/_vendor/distlib/LICENSE.txt +284 -0
  8. python/Lib/site-packages/pip-26.1.1.dist-info/licenses/src/pip/_vendor/distro/LICENSE +202 -0
  9. python/Lib/site-packages/pip-26.1.1.dist-info/licenses/src/pip/_vendor/idna/LICENSE.md +31 -0
  10. python/Lib/site-packages/pip-26.1.1.dist-info/licenses/src/pip/_vendor/msgpack/COPYING +14 -0
  11. python/Lib/site-packages/pip-26.1.1.dist-info/licenses/src/pip/_vendor/packaging/LICENSE +3 -0
  12. python/Lib/site-packages/pip-26.1.1.dist-info/licenses/src/pip/_vendor/packaging/LICENSE.APACHE +177 -0
  13. python/Lib/site-packages/pip-26.1.1.dist-info/licenses/src/pip/_vendor/packaging/LICENSE.BSD +23 -0
  14. python/Lib/site-packages/pip-26.1.1.dist-info/licenses/src/pip/_vendor/pkg_resources/LICENSE +17 -0
  15. python/Lib/site-packages/pip-26.1.1.dist-info/licenses/src/pip/_vendor/platformdirs/LICENSE +21 -0
  16. python/Lib/site-packages/pip-26.1.1.dist-info/licenses/src/pip/_vendor/pygments/LICENSE +25 -0
  17. python/Lib/site-packages/pip-26.1.1.dist-info/licenses/src/pip/_vendor/pyproject_hooks/LICENSE +21 -0
  18. python/Lib/site-packages/pip-26.1.1.dist-info/licenses/src/pip/_vendor/requests/LICENSE +175 -0
  19. python/Lib/site-packages/pip-26.1.1.dist-info/licenses/src/pip/_vendor/resolvelib/LICENSE +13 -0
  20. python/Lib/site-packages/pip-26.1.1.dist-info/licenses/src/pip/_vendor/rich/LICENSE +19 -0
  21. python/Lib/site-packages/pip-26.1.1.dist-info/licenses/src/pip/_vendor/tomli/LICENSE +21 -0
  22. python/Lib/site-packages/pip-26.1.1.dist-info/licenses/src/pip/_vendor/tomli_w/LICENSE +21 -0
  23. python/Lib/site-packages/pip-26.1.1.dist-info/licenses/src/pip/_vendor/truststore/LICENSE +21 -0
  24. python/Lib/site-packages/pip-26.1.1.dist-info/licenses/src/pip/_vendor/urllib3/LICENSE.txt +21 -0
  25. python/Lib/site-packages/pip/__pycache__/__init__.cpython-313.pyc +0 -0
  26. python/Lib/site-packages/pip/__pycache__/__main__.cpython-313.pyc +0 -0
  27. python/Lib/site-packages/pip/__pycache__/__pip-runner__.cpython-313.pyc +0 -0
  28. python/Lib/site-packages/pip/_internal/__init__.py +18 -0
  29. python/Lib/site-packages/pip/_internal/build_env.py +606 -0
  30. python/Lib/site-packages/pip/_internal/cache.py +291 -0
  31. python/Lib/site-packages/pip/_internal/configuration.py +396 -0
  32. python/Lib/site-packages/pip/_internal/exceptions.py +971 -0
  33. python/Lib/site-packages/pip/_internal/main.py +12 -0
  34. python/Lib/site-packages/pip/_internal/pyproject.py +123 -0
  35. python/Lib/site-packages/pip/_internal/self_outdated_check.py +246 -0
  36. python/Lib/site-packages/pip/_internal/wheel_builder.py +261 -0
  37. python/Lib/site-packages/pip/_vendor/README.rst +178 -0
  38. python/Lib/site-packages/pip/_vendor/__init__.py +117 -0
  39. python/Lib/site-packages/pip/_vendor/cachecontrol/LICENSE.txt +13 -0
  40. python/Lib/site-packages/pip/_vendor/cachecontrol/__init__.py +32 -0
  41. python/Lib/site-packages/pip/_vendor/cachecontrol/_cmd.py +70 -0
  42. python/Lib/site-packages/pip/_vendor/cachecontrol/adapter.py +167 -0
  43. python/Lib/site-packages/pip/_vendor/cachecontrol/cache.py +75 -0
  44. python/Lib/site-packages/pip/_vendor/cachecontrol/controller.py +511 -0
  45. python/Lib/site-packages/pip/_vendor/cachecontrol/filewrapper.py +121 -0
  46. python/Lib/site-packages/pip/_vendor/cachecontrol/heuristics.py +157 -0
  47. python/Lib/site-packages/pip/_vendor/cachecontrol/py.typed +0 -0
  48. python/Lib/site-packages/pip/_vendor/cachecontrol/serialize.py +146 -0
  49. python/Lib/site-packages/pip/_vendor/cachecontrol/wrapper.py +43 -0
  50. python/Lib/site-packages/pip/_vendor/certifi/LICENSE +20 -0
python/Lib/site-packages/_yaml/__init__.py ADDED
@@ -0,0 +1,33 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # This is a stub package designed to roughly emulate the _yaml
2
+ # extension module, which previously existed as a standalone module
3
+ # and has been moved into the `yaml` package namespace.
4
+ # It does not perfectly mimic its old counterpart, but should get
5
+ # close enough for anyone who's relying on it even when they shouldn't.
6
+ import yaml
7
+
8
+ # in some circumstances, the yaml module we imoprted may be from a different version, so we need
9
+ # to tread carefully when poking at it here (it may not have the attributes we expect)
10
+ if not getattr(yaml, '__with_libyaml__', False):
11
+ from sys import version_info
12
+
13
+ exc = ModuleNotFoundError if version_info >= (3, 6) else ImportError
14
+ raise exc("No module named '_yaml'")
15
+ else:
16
+ from yaml._yaml import *
17
+ import warnings
18
+ warnings.warn(
19
+ 'The _yaml extension module is now located at yaml._yaml'
20
+ ' and its location is subject to change. To use the'
21
+ ' LibYAML-based parser and emitter, import from `yaml`:'
22
+ ' `from yaml import CLoader as Loader, CDumper as Dumper`.',
23
+ DeprecationWarning
24
+ )
25
+ del warnings
26
+ # Don't `del yaml` here because yaml is actually an existing
27
+ # namespace member of _yaml.
28
+
29
+ __name__ = '_yaml'
30
+ # If the module is top-level (i.e. not a part of any specific package)
31
+ # then the attribute should be set to ''.
32
+ # https://docs.python.org/3.8/library/types.html
33
+ __package__ = ''
python/Lib/site-packages/_yaml/__pycache__/__init__.cpython-313.pyc ADDED
Binary file (856 Bytes). View file
 
python/Lib/site-packages/pip-26.1.1.dist-info/licenses/AUTHORS.txt ADDED
@@ -0,0 +1,867 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ @Switch01
2
+ A_Rog
3
+ Aakanksha Agrawal
4
+ Aarni Koskela
5
+ Abhinav Sagar
6
+ ABHYUDAY PRATAP SINGH
7
+ abs51295
8
+ AceGentile
9
+ Adam Chainz
10
+ Adam Tse
11
+ Adam Turner
12
+ Adam Wentz
13
+ admin
14
+ Adolfo Ochagavía
15
+ Adrien Morison
16
+ Agus
17
+ ahayrapetyan
18
+ Ahilya
19
+ AinsworthK
20
+ Akash Srivastava
21
+ Alan Yee
22
+ Albert Tugushev
23
+ Albert-Guan
24
+ albertg
25
+ Alberto Sottile
26
+ Aleks Bunin
27
+ Ales Erjavec
28
+ Alessandro Molina
29
+ Alethea Flowers
30
+ Alex Gaynor
31
+ Alex Grönholm
32
+ Alex Hedges
33
+ Alex Loosley
34
+ Alex Morega
35
+ Alex Stachowiak
36
+ Alexander Regueiro
37
+ Alexander Shtyrov
38
+ Alexandre Conrad
39
+ Alexey Popravka
40
+ Aleš Erjavec
41
+ Alli
42
+ Aman
43
+ Ami Fischman
44
+ Ananya Maiti
45
+ Anatoly Techtonik
46
+ Anders Kaseorg
47
+ Andre Aguiar
48
+ Andreas Lutro
49
+ Andrei Geacar
50
+ Andrew Gaul
51
+ Andrew Shymanel
52
+ Andrey Bienkowski
53
+ Andrey Bulgakov
54
+ Andrés Delfino
55
+ Andy Freeland
56
+ Andy Kluger
57
+ Ani Hayrapetyan
58
+ Aniruddha Basak
59
+ Anish Tambe
60
+ Anrs Hu
61
+ Anthony Sottile
62
+ Antoine Lambert
63
+ Antoine Musso
64
+ Anton Ovchinnikov
65
+ Anton Patrushev
66
+ Anton Zelenov
67
+ Antonio Alvarado Hernandez
68
+ Antony Lee
69
+ Antti Kaihola
70
+ Anubhav Patel
71
+ Anudit Nagar
72
+ Anuj Godase
73
+ AQNOUCH Mohammed
74
+ AraHaan
75
+ arena
76
+ arenasys
77
+ Arindam Choudhury
78
+ Armin Ronacher
79
+ Arnon Yaari
80
+ Artem
81
+ Arun Babu Neelicattu
82
+ Ashley Manton
83
+ Ashwin Ramaswami
84
+ atse
85
+ Atsushi Odagiri
86
+ Avinash Karhana
87
+ Avner Cohen
88
+ Awit (Ah-Wit) Ghirmai
89
+ Baptiste Mispelon
90
+ Barney Gale
91
+ barneygale
92
+ Bartek Ogryczak
93
+ Bastian Venthur
94
+ Ben Bodenmiller
95
+ Ben Darnell
96
+ Ben Hoyt
97
+ Ben Mares
98
+ Ben Rosser
99
+ Bence Nagy
100
+ Benjamin Peterson
101
+ Benjamin VanEvery
102
+ Benoit Pierre
103
+ Berker Peksag
104
+ Bernard
105
+ Bernard Tyers
106
+ Bernardo B. Marques
107
+ Bernhard M. Wiedemann
108
+ Bertil Hatt
109
+ Bhavam Vidyarthi
110
+ Blazej Michalik
111
+ Bogdan Opanchuk
112
+ BorisZZZ
113
+ Brad Erickson
114
+ Bradley Ayers
115
+ Bradley Reynolds
116
+ Branch Vincent
117
+ Brandon L. Reiss
118
+ Brandt Bucher
119
+ Brannon Dorsey
120
+ Brett Randall
121
+ Brett Rosen
122
+ Brian Cristante
123
+ Brian Rosner
124
+ briantracy
125
+ BrownTruck
126
+ Bruno Oliveira
127
+ Bruno Renié
128
+ Bruno S
129
+ Bstrdsmkr
130
+ Buck Golemon
131
+ burrows
132
+ Bussonnier Matthias
133
+ bwoodsend
134
+ c22
135
+ Caleb Brown
136
+ Caleb Martinez
137
+ Calvin Smith
138
+ Carl Meyer
139
+ Carlos Liam
140
+ Carol Willing
141
+ Carter Thayer
142
+ Cass
143
+ Chandrasekhar Atina
144
+ Charlie Marsh
145
+ charwick
146
+ Chih-Hsuan Yen
147
+ Chris Brinker
148
+ Chris Hunt
149
+ Chris Jerdonek
150
+ Chris Kuehl
151
+ Chris Markiewicz
152
+ Chris McDonough
153
+ Chris Pawley
154
+ Chris Pryer
155
+ Chris Wolfe
156
+ Christian Clauss
157
+ Christian Heimes
158
+ Christian Oudard
159
+ Christoph Reiter
160
+ Christopher Hunt
161
+ Christopher Snyder
162
+ chrysle
163
+ cjc7373
164
+ Clark Boylan
165
+ Claudio Jolowicz
166
+ Clay McClure
167
+ Cody
168
+ Cody Soyland
169
+ Colin Watson
170
+ Collin Anderson
171
+ Connor Osborn
172
+ Cooper Lees
173
+ Cooper Ry Lees
174
+ Cory Benfield
175
+ Cory Wright
176
+ Craig Kerstiens
177
+ Cristian Sorinel
178
+ Cristina
179
+ Cristina Muñoz
180
+ ctg123
181
+ Curtis Doty
182
+ cytolentino
183
+ Daan De Meyer
184
+ Dale
185
+ Damian
186
+ Damian Quiroga
187
+ Damian Shaw
188
+ Dan Black
189
+ Dan Savilonis
190
+ Dan Sully
191
+ Dane Hillard
192
+ daniel
193
+ Daniel Collins
194
+ Daniel Hahler
195
+ Daniel Hollas
196
+ Daniel Holth
197
+ Daniel Jost
198
+ Daniel Katz
199
+ Daniel Shaulov
200
+ Daniele Esposti
201
+ Daniele Nicolodi
202
+ Daniele Procida
203
+ Daniil Konovalenko
204
+ Danny Hermes
205
+ Danny McClanahan
206
+ Darren Kavanagh
207
+ Dav Clark
208
+ Dave Abrahams
209
+ Dave Jones
210
+ David Aguilar
211
+ David Black
212
+ David Bordeynik
213
+ David Caro
214
+ David D Lowe
215
+ David Evans
216
+ David Hewitt
217
+ David Linke
218
+ David Poggi
219
+ David Poznik
220
+ David Pursehouse
221
+ David Runge
222
+ David Tucker
223
+ David Wales
224
+ Davidovich
225
+ ddelange
226
+ Deepak Sharma
227
+ Deepyaman Datta
228
+ Denis Roussel (ACSONE)
229
+ Denise Yu
230
+ dependabot[bot]
231
+ derwolfe
232
+ Desetude
233
+ developer
234
+ Devesh Kumar
235
+ Devesh Kumar Singh
236
+ devsagul
237
+ Diego Caraballo
238
+ Diego Ramirez
239
+ DiegoCaraballo
240
+ Dimitri Merejkowsky
241
+ Dimitri Papadopoulos
242
+ Dimitri Papadopoulos Orfanos
243
+ Dirk Stolle
244
+ dkjsone
245
+ Dmitrii Sutiagin
246
+ Dmitry Gladkov
247
+ Dmitry Volodin
248
+ Domen Kožar
249
+ Dominic Davis-Foster
250
+ Donald Stufft
251
+ Dongweiming
252
+ doron zarhi
253
+ Dos Moonen
254
+ Douglas Thor
255
+ DrFeathers
256
+ Dustin Ingram
257
+ Dustin Rodrigues
258
+ Dwayne Bailey
259
+ Ed Morley
260
+ Edgar Ramírez
261
+ Edgar Ramírez Mondragón
262
+ Ee Durbin
263
+ Efflam Lemaillet
264
+ efflamlemaillet
265
+ Eitan Adler
266
+ ekristina
267
+ elainechan
268
+ Eli Schwartz
269
+ Elisha Hollander
270
+ Ellen Marie Dash
271
+ Emil Burzo
272
+ Emil Styrke
273
+ Emmanuel Arias
274
+ Endoh Takanao
275
+ enoch
276
+ Erdinc Mutlu
277
+ Eric Cousineau
278
+ Eric Gillingham
279
+ Eric Hanchrow
280
+ Eric Hopper
281
+ Erik M. Bray
282
+ Erik Rose
283
+ Erwin Janssen
284
+ Eugene Vereshchagin
285
+ everdimension
286
+ Federico
287
+ Felipe Peter
288
+ Felix Yan
289
+ fiber-space
290
+ Filip Kokosiński
291
+ Filipe Laíns
292
+ Finn Womack
293
+ finnagin
294
+ Flavio Amurrio
295
+ Florian Briand
296
+ Florian Rathgeber
297
+ Francesco
298
+ Francesco Montesano
299
+ Fredrik Orderud
300
+ Fredrik Roubert
301
+ Frost Ming
302
+ Gabriel Curio
303
+ Gabriel de Perthuis
304
+ Garry Polley
305
+ gavin
306
+ gdanielson
307
+ Gene Wood
308
+ Geoffrey Sneddon
309
+ George Margaritis
310
+ George Song
311
+ Georgi Valkov
312
+ Georgy Pchelkin
313
+ Gertjan van Zwieten
314
+ ghost
315
+ Giancarlo Cicellyn Comneno
316
+ Giftlin Rajaiah
317
+ gizmoguy1
318
+ gkdoc
319
+ Godefroid Chapelle
320
+ Gopinath M
321
+ GOTO Hayato
322
+ gousaiyang
323
+ gpiks
324
+ Greg Roodt
325
+ Greg Ward
326
+ Guido Diepen
327
+ Guilherme Espada
328
+ Guillaume Seguin
329
+ gutsytechster
330
+ Guy Rozendorn
331
+ Guy Tuval
332
+ gzpan123
333
+ Hanjun Kim
334
+ Hari Charan
335
+ Harsh Vardhan
336
+ Harsha Sai
337
+ harupy
338
+ Harutaka Kawamura
339
+ Hasan-8326
340
+ hauntsaninja
341
+ Henrich Hartzer
342
+ Henry Schreiner
343
+ Herbert Pfennig
344
+ Holly Stotelmyer
345
+ Honnix
346
+ Hsiaoming Yang
347
+ Hugo Lopes Tavares
348
+ Hugo van Kemenade
349
+ Hugues Bruant
350
+ Hynek Schlawack
351
+ iamsrp-deshaw
352
+ Ian Bicking
353
+ Ian Cordasco
354
+ Ian Lee
355
+ Ian Stapleton Cordasco
356
+ Ian Wienand
357
+ Igor Kuzmitshov
358
+ Igor Sobreira
359
+ Ikko Ashimine
360
+ Ilan Schnell
361
+ Illia Volochii
362
+ Ilya Abdolmanafi
363
+ Ilya Baryshev
364
+ Inada Naoki
365
+ Ionel Cristian Mărieș
366
+ Ionel Maries Cristian
367
+ Itamar Turner-Trauring
368
+ iTrooz
369
+ Ivan Pozdeev
370
+ J. Nick Koston
371
+ Jacob Kim
372
+ Jacob Walls
373
+ Jaime Sanz
374
+ Jake Lishman
375
+ jakirkham
376
+ Jakub Kuczys
377
+ Jakub Stasiak
378
+ Jakub Vysoky
379
+ Jakub Wilk
380
+ James
381
+ James Cleveland
382
+ James Curtin
383
+ James Firth
384
+ James Gerity
385
+ James Polley
386
+ Jan Pokorný
387
+ Jannis Leidel
388
+ Jarek Potiuk
389
+ jarondl
390
+ Jason Curtis
391
+ Jason R. Coombs
392
+ JasonMo
393
+ JasonMo1
394
+ Jay Graves
395
+ Jean Abou Samra
396
+ Jean-Christophe Fillion-Robin
397
+ Jeff Barber
398
+ Jeff Dairiki
399
+ Jeff Widman
400
+ Jelmer Vernooij
401
+ jenix21
402
+ Jeremy Fleischman
403
+ Jeremy Stanley
404
+ Jeremy Zafran
405
+ Jesse Rittner
406
+ Jiashuo Li
407
+ Jim Fisher
408
+ Jim Garrison
409
+ Jinzhe Zeng
410
+ Jiun Bae
411
+ Jivan Amara
412
+ Joa
413
+ Joe Bylund
414
+ Joe Michelini
415
+ Johannes Altmanninger
416
+ John Paton
417
+ John Sirois
418
+ John T. Wodder II
419
+ John-Scott Atlakson
420
+ johnthagen
421
+ Jon Banafato
422
+ Jon Dufresne
423
+ Jon Parise
424
+ Jonas Nockert
425
+ Jonathan Herbert
426
+ Joonatan Partanen
427
+ Joost Molenaar
428
+ Jorge Niedbalski
429
+ Joseph Bylund
430
+ Joseph Long
431
+ Josh Bronson
432
+ Josh Cannon
433
+ Josh Hansen
434
+ Josh Schneier
435
+ Joshua
436
+ JoshuaPerdue
437
+ Jost Migenda
438
+ Juan Luis Cano Rodríguez
439
+ Juanjo Bazán
440
+ Judah Rand
441
+ Julian Berman
442
+ Julian Gethmann
443
+ Julien Demoor
444
+ Julien Stephan
445
+ July Tikhonov
446
+ Jussi Kukkonen
447
+ Justin van Heek
448
+ jwg4
449
+ Jyrki Pulliainen
450
+ Kai Chen
451
+ Kai Mueller
452
+ Kamal Bin Mustafa
453
+ Karolina Surma
454
+ kasium
455
+ kaustav haldar
456
+ Kaz Nishimura
457
+ keanemind
458
+ Keith Maxwell
459
+ Kelsey Hightower
460
+ Kenneth Belitzky
461
+ Kenneth Reitz
462
+ Kevin Burke
463
+ Kevin Carter
464
+ Kevin Frommelt
465
+ Kevin R Patterson
466
+ Kevin Turcios
467
+ Kexuan Sun
468
+ Kit Randel
469
+ Klaas van Schelven
470
+ KOLANICH
471
+ konstin
472
+ kpinc
473
+ Krishan Bhasin
474
+ Krishna Oza
475
+ Kumar McMillan
476
+ Kuntal Majumder
477
+ Kurt McKee
478
+ Kyle Persohn
479
+ lakshmanaram
480
+ Laszlo Kiss-Kollar
481
+ Laurent Bristiel
482
+ Laurent LAPORTE
483
+ Laurie O
484
+ Laurie Opperman
485
+ layday
486
+ Leon Sasson
487
+ Lev Givon
488
+ Lincoln de Sousa
489
+ Lipis
490
+ lorddavidiii
491
+ Loren Carvalho
492
+ Lucas Cimon
493
+ Ludovic Gasc
494
+ Luis Medel
495
+ Lukas Geiger
496
+ Lukas Juhrich
497
+ Luke Macken
498
+ Luo Jiebin
499
+ luojiebin
500
+ luz.paz
501
+ László Kiss Kollár
502
+ M00nL1ght
503
+ MajorTanya
504
+ Malcolm Smith
505
+ Marc Abramowitz
506
+ Marc Tamlyn
507
+ Marcus Smith
508
+ Mariatta
509
+ Mark Kohler
510
+ Mark McLoughlin
511
+ Mark Williams
512
+ Markus Hametner
513
+ Martey Dodoo
514
+ Martin Fischer
515
+ Martin Häcker
516
+ Martin Pavlasek
517
+ Masaki
518
+ Masklinn
519
+ Matej Stuchlik
520
+ Mateusz Sokół
521
+ Mathew Jennings
522
+ Mathieu Bridon
523
+ Mathieu Kniewallner
524
+ Matt Bacchi
525
+ Matt Good
526
+ Matt Maker
527
+ Matt Robenolt
528
+ Matt Wozniski
529
+ matthew
530
+ Matthew Einhorn
531
+ Matthew Feickert
532
+ Matthew Gilliard
533
+ Matthew Hughes
534
+ Matthew Iversen
535
+ Matthew Treinish
536
+ Matthew Trumbell
537
+ Matthew Willson
538
+ Matthias Bussonnier
539
+ mattip
540
+ Maurits van Rees
541
+ Max W Chase
542
+ Maxim Kurnikov
543
+ Maxime Rouyrre
544
+ mayeut
545
+ mbaluna
546
+ Md Sujauddin Sekh
547
+ mdebi
548
+ Meet Vasita
549
+ memoselyk
550
+ meowmeowcat
551
+ Michael
552
+ Michael Aquilina
553
+ Michael E. Karpeles
554
+ Michael Klich
555
+ Michael Mintz
556
+ Michael Williamson
557
+ michaelpacer
558
+ Michał Górny
559
+ Mickaël Schoentgen
560
+ Miguel Araujo Perez
561
+ Mihir Singh
562
+ Mike
563
+ Mike Hendricks
564
+ Min RK
565
+ MinRK
566
+ Miro Hrončok
567
+ Monica Baluna
568
+ montefra
569
+ Monty Taylor
570
+ morotti
571
+ mrKazzila
572
+ Muha Ajjan
573
+ MUTHUSRIHEMADHARSHINI S A
574
+ Nadav Wexler
575
+ Nahuel Ambrosini
576
+ Nate Coraor
577
+ Nate Prewitt
578
+ Nathan Houghton
579
+ Nathaniel J. Smith
580
+ Nehal J Wani
581
+ Neil Botelho
582
+ Nguyễn Gia Phong
583
+ Nicholas Serra
584
+ Nick Coghlan
585
+ Nick Stenning
586
+ Nick Timkovich
587
+ Nicolas Bock
588
+ Nicole Harris
589
+ Nikhil Benesch
590
+ Nikhil Ladha
591
+ Nikita Chepanov
592
+ Nikolay Korolev
593
+ Nipunn Koorapati
594
+ Nitesh Sharma
595
+ Niyas Sait
596
+ Noah
597
+ Noah Gorny
598
+ Norbert Manthey
599
+ Nothing-991
600
+ Nowell Strite
601
+ NtaleGrey
602
+ nucccc
603
+ nvdv
604
+ OBITORASU
605
+ Ofek Lev
606
+ ofrinevo
607
+ Oleg Burnaev
608
+ Oliver Freund
609
+ Oliver Jeeves
610
+ Oliver Mannion
611
+ Oliver Tonnhofer
612
+ Olivier Girardot
613
+ Olivier Grisel
614
+ Ollie Rutherfurd
615
+ OMOTO Kenji
616
+ Omry Yadan
617
+ onlinejudge95
618
+ Oren Held
619
+ Oscar Benjamin
620
+ oxygen dioxide
621
+ Oz N Tiram
622
+ Pachwenko
623
+ Paresh Joshi
624
+ Patrick Dubroy
625
+ Patrick Jenkins
626
+ Patrick Lawson
627
+ patricktokeeffe
628
+ Patrik Kopkan
629
+ Paul Ganssle
630
+ Paul Kehrer
631
+ Paul Moore
632
+ Paul Nasrat
633
+ Paul Oswald
634
+ Paul van der Linden
635
+ Paulus Schoutsen
636
+ Pavel Safronov
637
+ Pavithra Eswaramoorthy
638
+ Pawel Jasinski
639
+ Paweł Szramowski
640
+ Pekka Klärck
641
+ Peter Gessler
642
+ Peter Lisák
643
+ Peter Shen
644
+ Peter Waller
645
+ Petr Viktorin
646
+ petr-tik
647
+ Phaneendra Chiruvella
648
+ Phil Elson
649
+ Phil Freo
650
+ Phil Pennock
651
+ Phil Whelan
652
+ Philip Jägenstedt
653
+ Philip Molloy
654
+ Philippe Ombredanne
655
+ Pi Delport
656
+ Pierre-Yves Rofes
657
+ Pieter Degroote
658
+ pip
659
+ Prabakaran Kumaresshan
660
+ Prabhjyotsing Surjit Singh Sodhi
661
+ Prabhu Marappan
662
+ Pradyun Gedam
663
+ Prashant Sharma
664
+ Pratik Mallya
665
+ pre-commit-ci[bot]
666
+ Preet Thakkar
667
+ Preston Holmes
668
+ Przemek Wrzos
669
+ Pulkit Goyal
670
+ q0w
671
+ Qiangning Hong
672
+ Qiming Xu
673
+ qraqras
674
+ Quentin Lee
675
+ Quentin Pradet
676
+ R. David Murray
677
+ Rafael Caricio
678
+ Ralf Schmitt
679
+ Ran Benita
680
+ Randy Döring
681
+ Razzi Abuissa
682
+ rdb
683
+ Reece Dunham
684
+ Remi Rampin
685
+ Rene Dudfield
686
+ Riccardo Magliocchetti
687
+ Riccardo Schirone
688
+ Richard Jones
689
+ Richard Si
690
+ Ricky Ng-Adam
691
+ Rishi
692
+ rmorotti
693
+ RobberPhex
694
+ Robert Collins
695
+ Robert McGibbon
696
+ Robert Pollak
697
+ Robert T. McGibbon
698
+ robin elisha robinson
699
+ Rodney, Tiara
700
+ Roey Berman
701
+ Rohan Jain
702
+ Roman Bogorodskiy
703
+ Roman Donchenko
704
+ Romuald Brunet
705
+ ronaudinho
706
+ Ronny Pfannschmidt
707
+ Rory McCann
708
+ Ross Brattain
709
+ Roy Wellington Ⅳ
710
+ Ruairidh MacLeod
711
+ Russell Keith-Magee
712
+ Ryan Shepherd
713
+ Ryan Wooden
714
+ ryneeverett
715
+ Ryuma Asai
716
+ S. Guliaev
717
+ Sachi King
718
+ Salvatore Rinchiera
719
+ sandeepkiran-js
720
+ Sander Van Balen
721
+ Savio Jomton
722
+ schlamar
723
+ Scott Kitterman
724
+ Sean
725
+ seanj
726
+ Sebastian Jordan
727
+ Sebastian Schaetz
728
+ Segev Finer
729
+ SeongSoo Cho
730
+ Sepehr Rasouli
731
+ sepehrrasooli
732
+ Sergey Vasilyev
733
+ Seth Michael Larson
734
+ Seth Woodworth
735
+ Shahar Epstein
736
+ Shantanu
737
+ shenxianpeng
738
+ shireenrao
739
+ Shivansh-007
740
+ Shixian Sheng
741
+ Shlomi Fish
742
+ Shovan Maity
743
+ Shubham Nagure
744
+ Simeon Visser
745
+ Simon Cross
746
+ Simon Pichugin
747
+ sinoroc
748
+ sinscary
749
+ snook92
750
+ socketubs
751
+ Sorin Sbarnea
752
+ Srinivas Nyayapati
753
+ Srishti Hegde
754
+ Stavros Korokithakis
755
+ Stefan Scherfke
756
+ Stefano Rivera
757
+ Stephan Erb
758
+ Stephane Chazelas
759
+ Stephen Payne
760
+ Stephen Rosen
761
+ stepshal
762
+ Steve (Gadget) Barnes
763
+ Steve Barnes
764
+ Steve Dower
765
+ Steve Kowalik
766
+ Steven Myint
767
+ Steven Silvester
768
+ stonebig
769
+ studioj
770
+ Stéphane Bidoul
771
+ Stéphane Bidoul (ACSONE)
772
+ Stéphane Klein
773
+ Sumana Harihareswara
774
+ Surbhi Sharma
775
+ Sviatoslav Sydorenko
776
+ Sviatoslav Sydorenko (Святослав Сидоренко)
777
+ Swat009
778
+ Sylvain
779
+ Takayuki SHIMIZUKAWA
780
+ Taneli Hukkinen
781
+ tbeswick
782
+ Terrance
783
+ Thiago
784
+ Thijs Triemstra
785
+ Thomas Fenzl
786
+ Thomas Grainger
787
+ Thomas Guettler
788
+ Thomas Johansson
789
+ Thomas Kluyver
790
+ Thomas Smith
791
+ Thomas VINCENT
792
+ Tim D. Smith
793
+ Tim Gates
794
+ Tim Harder
795
+ Tim Heap
796
+ tim smith
797
+ tinruufu
798
+ Tobias Hermann
799
+ Tom Forbes
800
+ Tom Freudenheim
801
+ Tom V
802
+ Tomas Hrnciar
803
+ Tomas Orsava
804
+ Tomer Chachamu
805
+ Tommi Enenkel | AnB
806
+ Tomáš Hrnčiar
807
+ Tony Beswick
808
+ Tony Narlock
809
+ Tony Zhaocheng Tan
810
+ TonyBeswick
811
+ toonarmycaptain
812
+ Toshio Kuratomi
813
+ toxinu
814
+ Travis Swicegood
815
+ Tushar Sadhwani
816
+ Tzu-ping Chung
817
+ Valentin Haenel
818
+ Victor Stinner
819
+ victorvpaulo
820
+ Vikram - Google
821
+ Viktor Szépe
822
+ Ville Skyttä
823
+ Vinay Sajip
824
+ Vincent Fazio
825
+ Vincent Philippon
826
+ Vinicyus Macedo
827
+ Vipul Kumar
828
+ Vitaly Babiy
829
+ Vladimir Fokow
830
+ Vladimir Rutsky
831
+ W. Trevor King
832
+ Weida Hong
833
+ Wil Tan
834
+ Wilfred Hughes
835
+ William Edwards
836
+ William ML Leslie
837
+ William T Olson
838
+ William Woodruff
839
+ Wilson Mo
840
+ wim glenn
841
+ Winson Luk
842
+ Wolfgang Maier
843
+ Wu Zhenyu
844
+ XAMES3
845
+ Xavier Fernandez
846
+ Xianpeng Shen
847
+ xoviat
848
+ xtreak
849
+ YAMAMOTO Takashi
850
+ Yash
851
+ Yashraj
852
+ Yen Chi Hsuan
853
+ Yeray Diaz Diaz
854
+ Yoval P
855
+ Yu Jian
856
+ Yuan Jing Vincent Yan
857
+ Yuki Kobayashi
858
+ Yusuke Hayashi
859
+ Zachary Ware
860
+ zackzack38
861
+ Zearin
862
+ Zhiping Deng
863
+ ziebam
864
+ Zvezdan Petkovic
865
+ Łukasz Langa
866
+ Роман Донченко
867
+ Семён Марьясин
python/Lib/site-packages/pip-26.1.1.dist-info/licenses/LICENSE.txt ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ Copyright (c) 2008-present The pip developers (see AUTHORS.txt file)
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
python/Lib/site-packages/pip-26.1.1.dist-info/licenses/src/pip/_vendor/cachecontrol/LICENSE.txt ADDED
@@ -0,0 +1,13 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ Copyright 2012-2021 Eric Larson
2
+
3
+ Licensed under the Apache License, Version 2.0 (the "License");
4
+ you may not use this file except in compliance with the License.
5
+ You may obtain a copy of the License at
6
+
7
+ http://www.apache.org/licenses/LICENSE-2.0
8
+
9
+ Unless required by applicable law or agreed to in writing, software
10
+ distributed under the License is distributed on an "AS IS" BASIS,
11
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ See the License for the specific language governing permissions and
13
+ limitations under the License.
python/Lib/site-packages/pip-26.1.1.dist-info/licenses/src/pip/_vendor/certifi/LICENSE ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ This package contains a modified version of ca-bundle.crt:
2
+
3
+ ca-bundle.crt -- Bundle of CA Root Certificates
4
+
5
+ This is a bundle of X.509 certificates of public Certificate Authorities
6
+ (CA). These were automatically extracted from Mozilla's root certificates
7
+ file (certdata.txt). This file can be found in the mozilla source tree:
8
+ https://hg.mozilla.org/mozilla-central/file/tip/security/nss/lib/ckfw/builtins/certdata.txt
9
+ It contains the certificates in PEM format and therefore
10
+ can be directly used with curl / libcurl / php_curl, or with
11
+ an Apache+mod_ssl webserver for SSL client authentication.
12
+ Just configure this file as the SSLCACertificateFile.#
13
+
14
+ ***** BEGIN LICENSE BLOCK *****
15
+ This Source Code Form is subject to the terms of the Mozilla Public License,
16
+ v. 2.0. If a copy of the MPL was not distributed with this file, You can obtain
17
+ one at http://mozilla.org/MPL/2.0/.
18
+
19
+ ***** END LICENSE BLOCK *****
20
+ @(#) $RCSfile: certdata.txt,v $ $Revision: 1.80 $ $Date: 2011/11/03 15:11:58 $
python/Lib/site-packages/pip-26.1.1.dist-info/licenses/src/pip/_vendor/distlib/LICENSE.txt ADDED
@@ -0,0 +1,284 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ A. HISTORY OF THE SOFTWARE
2
+ ==========================
3
+
4
+ Python was created in the early 1990s by Guido van Rossum at Stichting
5
+ Mathematisch Centrum (CWI, see http://www.cwi.nl) in the Netherlands
6
+ as a successor of a language called ABC. Guido remains Python's
7
+ principal author, although it includes many contributions from others.
8
+
9
+ In 1995, Guido continued his work on Python at the Corporation for
10
+ National Research Initiatives (CNRI, see http://www.cnri.reston.va.us)
11
+ in Reston, Virginia where he released several versions of the
12
+ software.
13
+
14
+ In May 2000, Guido and the Python core development team moved to
15
+ BeOpen.com to form the BeOpen PythonLabs team. In October of the same
16
+ year, the PythonLabs team moved to Digital Creations (now Zope
17
+ Corporation, see http://www.zope.com). In 2001, the Python Software
18
+ Foundation (PSF, see http://www.python.org/psf/) was formed, a
19
+ non-profit organization created specifically to own Python-related
20
+ Intellectual Property. Zope Corporation is a sponsoring member of
21
+ the PSF.
22
+
23
+ All Python releases are Open Source (see http://www.opensource.org for
24
+ the Open Source Definition). Historically, most, but not all, Python
25
+ releases have also been GPL-compatible; the table below summarizes
26
+ the various releases.
27
+
28
+ Release Derived Year Owner GPL-
29
+ from compatible? (1)
30
+
31
+ 0.9.0 thru 1.2 1991-1995 CWI yes
32
+ 1.3 thru 1.5.2 1.2 1995-1999 CNRI yes
33
+ 1.6 1.5.2 2000 CNRI no
34
+ 2.0 1.6 2000 BeOpen.com no
35
+ 1.6.1 1.6 2001 CNRI yes (2)
36
+ 2.1 2.0+1.6.1 2001 PSF no
37
+ 2.0.1 2.0+1.6.1 2001 PSF yes
38
+ 2.1.1 2.1+2.0.1 2001 PSF yes
39
+ 2.2 2.1.1 2001 PSF yes
40
+ 2.1.2 2.1.1 2002 PSF yes
41
+ 2.1.3 2.1.2 2002 PSF yes
42
+ 2.2.1 2.2 2002 PSF yes
43
+ 2.2.2 2.2.1 2002 PSF yes
44
+ 2.2.3 2.2.2 2003 PSF yes
45
+ 2.3 2.2.2 2002-2003 PSF yes
46
+ 2.3.1 2.3 2002-2003 PSF yes
47
+ 2.3.2 2.3.1 2002-2003 PSF yes
48
+ 2.3.3 2.3.2 2002-2003 PSF yes
49
+ 2.3.4 2.3.3 2004 PSF yes
50
+ 2.3.5 2.3.4 2005 PSF yes
51
+ 2.4 2.3 2004 PSF yes
52
+ 2.4.1 2.4 2005 PSF yes
53
+ 2.4.2 2.4.1 2005 PSF yes
54
+ 2.4.3 2.4.2 2006 PSF yes
55
+ 2.4.4 2.4.3 2006 PSF yes
56
+ 2.5 2.4 2006 PSF yes
57
+ 2.5.1 2.5 2007 PSF yes
58
+ 2.5.2 2.5.1 2008 PSF yes
59
+ 2.5.3 2.5.2 2008 PSF yes
60
+ 2.6 2.5 2008 PSF yes
61
+ 2.6.1 2.6 2008 PSF yes
62
+ 2.6.2 2.6.1 2009 PSF yes
63
+ 2.6.3 2.6.2 2009 PSF yes
64
+ 2.6.4 2.6.3 2009 PSF yes
65
+ 2.6.5 2.6.4 2010 PSF yes
66
+ 3.0 2.6 2008 PSF yes
67
+ 3.0.1 3.0 2009 PSF yes
68
+ 3.1 3.0.1 2009 PSF yes
69
+ 3.1.1 3.1 2009 PSF yes
70
+ 3.1.2 3.1 2010 PSF yes
71
+ 3.2 3.1 2010 PSF yes
72
+
73
+ Footnotes:
74
+
75
+ (1) GPL-compatible doesn't mean that we're distributing Python under
76
+ the GPL. All Python licenses, unlike the GPL, let you distribute
77
+ a modified version without making your changes open source. The
78
+ GPL-compatible licenses make it possible to combine Python with
79
+ other software that is released under the GPL; the others don't.
80
+
81
+ (2) According to Richard Stallman, 1.6.1 is not GPL-compatible,
82
+ because its license has a choice of law clause. According to
83
+ CNRI, however, Stallman's lawyer has told CNRI's lawyer that 1.6.1
84
+ is "not incompatible" with the GPL.
85
+
86
+ Thanks to the many outside volunteers who have worked under Guido's
87
+ direction to make these releases possible.
88
+
89
+
90
+ B. TERMS AND CONDITIONS FOR ACCESSING OR OTHERWISE USING PYTHON
91
+ ===============================================================
92
+
93
+ PYTHON SOFTWARE FOUNDATION LICENSE VERSION 2
94
+ --------------------------------------------
95
+
96
+ 1. This LICENSE AGREEMENT is between the Python Software Foundation
97
+ ("PSF"), and the Individual or Organization ("Licensee") accessing and
98
+ otherwise using this software ("Python") in source or binary form and
99
+ its associated documentation.
100
+
101
+ 2. Subject to the terms and conditions of this License Agreement, PSF hereby
102
+ grants Licensee a nonexclusive, royalty-free, world-wide license to reproduce,
103
+ analyze, test, perform and/or display publicly, prepare derivative works,
104
+ distribute, and otherwise use Python alone or in any derivative version,
105
+ provided, however, that PSF's License Agreement and PSF's notice of copyright,
106
+ i.e., "Copyright (c) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010
107
+ Python Software Foundation; All Rights Reserved" are retained in Python alone or
108
+ in any derivative version prepared by Licensee.
109
+
110
+ 3. In the event Licensee prepares a derivative work that is based on
111
+ or incorporates Python or any part thereof, and wants to make
112
+ the derivative work available to others as provided herein, then
113
+ Licensee hereby agrees to include in any such work a brief summary of
114
+ the changes made to Python.
115
+
116
+ 4. PSF is making Python available to Licensee on an "AS IS"
117
+ basis. PSF MAKES NO REPRESENTATIONS OR WARRANTIES, EXPRESS OR
118
+ IMPLIED. BY WAY OF EXAMPLE, BUT NOT LIMITATION, PSF MAKES NO AND
119
+ DISCLAIMS ANY REPRESENTATION OR WARRANTY OF MERCHANTABILITY OR FITNESS
120
+ FOR ANY PARTICULAR PURPOSE OR THAT THE USE OF PYTHON WILL NOT
121
+ INFRINGE ANY THIRD PARTY RIGHTS.
122
+
123
+ 5. PSF SHALL NOT BE LIABLE TO LICENSEE OR ANY OTHER USERS OF PYTHON
124
+ FOR ANY INCIDENTAL, SPECIAL, OR CONSEQUENTIAL DAMAGES OR LOSS AS
125
+ A RESULT OF MODIFYING, DISTRIBUTING, OR OTHERWISE USING PYTHON,
126
+ OR ANY DERIVATIVE THEREOF, EVEN IF ADVISED OF THE POSSIBILITY THEREOF.
127
+
128
+ 6. This License Agreement will automatically terminate upon a material
129
+ breach of its terms and conditions.
130
+
131
+ 7. Nothing in this License Agreement shall be deemed to create any
132
+ relationship of agency, partnership, or joint venture between PSF and
133
+ Licensee. This License Agreement does not grant permission to use PSF
134
+ trademarks or trade name in a trademark sense to endorse or promote
135
+ products or services of Licensee, or any third party.
136
+
137
+ 8. By copying, installing or otherwise using Python, Licensee
138
+ agrees to be bound by the terms and conditions of this License
139
+ Agreement.
140
+
141
+
142
+ BEOPEN.COM LICENSE AGREEMENT FOR PYTHON 2.0
143
+ -------------------------------------------
144
+
145
+ BEOPEN PYTHON OPEN SOURCE LICENSE AGREEMENT VERSION 1
146
+
147
+ 1. This LICENSE AGREEMENT is between BeOpen.com ("BeOpen"), having an
148
+ office at 160 Saratoga Avenue, Santa Clara, CA 95051, and the
149
+ Individual or Organization ("Licensee") accessing and otherwise using
150
+ this software in source or binary form and its associated
151
+ documentation ("the Software").
152
+
153
+ 2. Subject to the terms and conditions of this BeOpen Python License
154
+ Agreement, BeOpen hereby grants Licensee a non-exclusive,
155
+ royalty-free, world-wide license to reproduce, analyze, test, perform
156
+ and/or display publicly, prepare derivative works, distribute, and
157
+ otherwise use the Software alone or in any derivative version,
158
+ provided, however, that the BeOpen Python License is retained in the
159
+ Software, alone or in any derivative version prepared by Licensee.
160
+
161
+ 3. BeOpen is making the Software available to Licensee on an "AS IS"
162
+ basis. BEOPEN MAKES NO REPRESENTATIONS OR WARRANTIES, EXPRESS OR
163
+ IMPLIED. BY WAY OF EXAMPLE, BUT NOT LIMITATION, BEOPEN MAKES NO AND
164
+ DISCLAIMS ANY REPRESENTATION OR WARRANTY OF MERCHANTABILITY OR FITNESS
165
+ FOR ANY PARTICULAR PURPOSE OR THAT THE USE OF THE SOFTWARE WILL NOT
166
+ INFRINGE ANY THIRD PARTY RIGHTS.
167
+
168
+ 4. BEOPEN SHALL NOT BE LIABLE TO LICENSEE OR ANY OTHER USERS OF THE
169
+ SOFTWARE FOR ANY INCIDENTAL, SPECIAL, OR CONSEQUENTIAL DAMAGES OR LOSS
170
+ AS A RESULT OF USING, MODIFYING OR DISTRIBUTING THE SOFTWARE, OR ANY
171
+ DERIVATIVE THEREOF, EVEN IF ADVISED OF THE POSSIBILITY THEREOF.
172
+
173
+ 5. This License Agreement will automatically terminate upon a material
174
+ breach of its terms and conditions.
175
+
176
+ 6. This License Agreement shall be governed by and interpreted in all
177
+ respects by the law of the State of California, excluding conflict of
178
+ law provisions. Nothing in this License Agreement shall be deemed to
179
+ create any relationship of agency, partnership, or joint venture
180
+ between BeOpen and Licensee. This License Agreement does not grant
181
+ permission to use BeOpen trademarks or trade names in a trademark
182
+ sense to endorse or promote products or services of Licensee, or any
183
+ third party. As an exception, the "BeOpen Python" logos available at
184
+ http://www.pythonlabs.com/logos.html may be used according to the
185
+ permissions granted on that web page.
186
+
187
+ 7. By copying, installing or otherwise using the software, Licensee
188
+ agrees to be bound by the terms and conditions of this License
189
+ Agreement.
190
+
191
+
192
+ CNRI LICENSE AGREEMENT FOR PYTHON 1.6.1
193
+ ---------------------------------------
194
+
195
+ 1. This LICENSE AGREEMENT is between the Corporation for National
196
+ Research Initiatives, having an office at 1895 Preston White Drive,
197
+ Reston, VA 20191 ("CNRI"), and the Individual or Organization
198
+ ("Licensee") accessing and otherwise using Python 1.6.1 software in
199
+ source or binary form and its associated documentation.
200
+
201
+ 2. Subject to the terms and conditions of this License Agreement, CNRI
202
+ hereby grants Licensee a nonexclusive, royalty-free, world-wide
203
+ license to reproduce, analyze, test, perform and/or display publicly,
204
+ prepare derivative works, distribute, and otherwise use Python 1.6.1
205
+ alone or in any derivative version, provided, however, that CNRI's
206
+ License Agreement and CNRI's notice of copyright, i.e., "Copyright (c)
207
+ 1995-2001 Corporation for National Research Initiatives; All Rights
208
+ Reserved" are retained in Python 1.6.1 alone or in any derivative
209
+ version prepared by Licensee. Alternately, in lieu of CNRI's License
210
+ Agreement, Licensee may substitute the following text (omitting the
211
+ quotes): "Python 1.6.1 is made available subject to the terms and
212
+ conditions in CNRI's License Agreement. This Agreement together with
213
+ Python 1.6.1 may be located on the Internet using the following
214
+ unique, persistent identifier (known as a handle): 1895.22/1013. This
215
+ Agreement may also be obtained from a proxy server on the Internet
216
+ using the following URL: http://hdl.handle.net/1895.22/1013".
217
+
218
+ 3. In the event Licensee prepares a derivative work that is based on
219
+ or incorporates Python 1.6.1 or any part thereof, and wants to make
220
+ the derivative work available to others as provided herein, then
221
+ Licensee hereby agrees to include in any such work a brief summary of
222
+ the changes made to Python 1.6.1.
223
+
224
+ 4. CNRI is making Python 1.6.1 available to Licensee on an "AS IS"
225
+ basis. CNRI MAKES NO REPRESENTATIONS OR WARRANTIES, EXPRESS OR
226
+ IMPLIED. BY WAY OF EXAMPLE, BUT NOT LIMITATION, CNRI MAKES NO AND
227
+ DISCLAIMS ANY REPRESENTATION OR WARRANTY OF MERCHANTABILITY OR FITNESS
228
+ FOR ANY PARTICULAR PURPOSE OR THAT THE USE OF PYTHON 1.6.1 WILL NOT
229
+ INFRINGE ANY THIRD PARTY RIGHTS.
230
+
231
+ 5. CNRI SHALL NOT BE LIABLE TO LICENSEE OR ANY OTHER USERS OF PYTHON
232
+ 1.6.1 FOR ANY INCIDENTAL, SPECIAL, OR CONSEQUENTIAL DAMAGES OR LOSS AS
233
+ A RESULT OF MODIFYING, DISTRIBUTING, OR OTHERWISE USING PYTHON 1.6.1,
234
+ OR ANY DERIVATIVE THEREOF, EVEN IF ADVISED OF THE POSSIBILITY THEREOF.
235
+
236
+ 6. This License Agreement will automatically terminate upon a material
237
+ breach of its terms and conditions.
238
+
239
+ 7. This License Agreement shall be governed by the federal
240
+ intellectual property law of the United States, including without
241
+ limitation the federal copyright law, and, to the extent such
242
+ U.S. federal law does not apply, by the law of the Commonwealth of
243
+ Virginia, excluding Virginia's conflict of law provisions.
244
+ Notwithstanding the foregoing, with regard to derivative works based
245
+ on Python 1.6.1 that incorporate non-separable material that was
246
+ previously distributed under the GNU General Public License (GPL), the
247
+ law of the Commonwealth of Virginia shall govern this License
248
+ Agreement only as to issues arising under or with respect to
249
+ Paragraphs 4, 5, and 7 of this License Agreement. Nothing in this
250
+ License Agreement shall be deemed to create any relationship of
251
+ agency, partnership, or joint venture between CNRI and Licensee. This
252
+ License Agreement does not grant permission to use CNRI trademarks or
253
+ trade name in a trademark sense to endorse or promote products or
254
+ services of Licensee, or any third party.
255
+
256
+ 8. By clicking on the "ACCEPT" button where indicated, or by copying,
257
+ installing or otherwise using Python 1.6.1, Licensee agrees to be
258
+ bound by the terms and conditions of this License Agreement.
259
+
260
+ ACCEPT
261
+
262
+
263
+ CWI LICENSE AGREEMENT FOR PYTHON 0.9.0 THROUGH 1.2
264
+ --------------------------------------------------
265
+
266
+ Copyright (c) 1991 - 1995, Stichting Mathematisch Centrum Amsterdam,
267
+ The Netherlands. All rights reserved.
268
+
269
+ Permission to use, copy, modify, and distribute this software and its
270
+ documentation for any purpose and without fee is hereby granted,
271
+ provided that the above copyright notice appear in all copies and that
272
+ both that copyright notice and this permission notice appear in
273
+ supporting documentation, and that the name of Stichting Mathematisch
274
+ Centrum or CWI not be used in advertising or publicity pertaining to
275
+ distribution of the software without specific, written prior
276
+ permission.
277
+
278
+ STICHTING MATHEMATISCH CENTRUM DISCLAIMS ALL WARRANTIES WITH REGARD TO
279
+ THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
280
+ FITNESS, IN NO EVENT SHALL STICHTING MATHEMATISCH CENTRUM BE LIABLE
281
+ FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
282
+ WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
283
+ ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT
284
+ OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
python/Lib/site-packages/pip-26.1.1.dist-info/licenses/src/pip/_vendor/distro/LICENSE ADDED
@@ -0,0 +1,202 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "{}"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright {yyyy} {name of copyright owner}
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
202
+
python/Lib/site-packages/pip-26.1.1.dist-info/licenses/src/pip/_vendor/idna/LICENSE.md ADDED
@@ -0,0 +1,31 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ BSD 3-Clause License
2
+
3
+ Copyright (c) 2013-2025, Kim Davies and contributors.
4
+ All rights reserved.
5
+
6
+ Redistribution and use in source and binary forms, with or without
7
+ modification, are permitted provided that the following conditions are
8
+ met:
9
+
10
+ 1. Redistributions of source code must retain the above copyright
11
+ notice, this list of conditions and the following disclaimer.
12
+
13
+ 2. Redistributions in binary form must reproduce the above copyright
14
+ notice, this list of conditions and the following disclaimer in the
15
+ documentation and/or other materials provided with the distribution.
16
+
17
+ 3. Neither the name of the copyright holder nor the names of its
18
+ contributors may be used to endorse or promote products derived from
19
+ this software without specific prior written permission.
20
+
21
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22
+ "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23
+ LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
24
+ A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
25
+ HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
26
+ SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
27
+ TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
28
+ PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
29
+ LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
30
+ NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
31
+ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
python/Lib/site-packages/pip-26.1.1.dist-info/licenses/src/pip/_vendor/msgpack/COPYING ADDED
@@ -0,0 +1,14 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ Copyright (C) 2008-2011 INADA Naoki <songofacandy@gmail.com>
2
+
3
+ Licensed under the Apache License, Version 2.0 (the "License");
4
+ you may not use this file except in compliance with the License.
5
+ You may obtain a copy of the License at
6
+
7
+ http://www.apache.org/licenses/LICENSE-2.0
8
+
9
+ Unless required by applicable law or agreed to in writing, software
10
+ distributed under the License is distributed on an "AS IS" BASIS,
11
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ See the License for the specific language governing permissions and
13
+ limitations under the License.
14
+
python/Lib/site-packages/pip-26.1.1.dist-info/licenses/src/pip/_vendor/packaging/LICENSE ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ This software is made available under the terms of *either* of the licenses
2
+ found in LICENSE.APACHE or LICENSE.BSD. Contributions to this software is made
3
+ under the terms of *both* these licenses.
python/Lib/site-packages/pip-26.1.1.dist-info/licenses/src/pip/_vendor/packaging/LICENSE.APACHE ADDED
@@ -0,0 +1,177 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ Apache License
3
+ Version 2.0, January 2004
4
+ http://www.apache.org/licenses/
5
+
6
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
7
+
8
+ 1. Definitions.
9
+
10
+ "License" shall mean the terms and conditions for use, reproduction,
11
+ and distribution as defined by Sections 1 through 9 of this document.
12
+
13
+ "Licensor" shall mean the copyright owner or entity authorized by
14
+ the copyright owner that is granting the License.
15
+
16
+ "Legal Entity" shall mean the union of the acting entity and all
17
+ other entities that control, are controlled by, or are under common
18
+ control with that entity. For the purposes of this definition,
19
+ "control" means (i) the power, direct or indirect, to cause the
20
+ direction or management of such entity, whether by contract or
21
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
22
+ outstanding shares, or (iii) beneficial ownership of such entity.
23
+
24
+ "You" (or "Your") shall mean an individual or Legal Entity
25
+ exercising permissions granted by this License.
26
+
27
+ "Source" form shall mean the preferred form for making modifications,
28
+ including but not limited to software source code, documentation
29
+ source, and configuration files.
30
+
31
+ "Object" form shall mean any form resulting from mechanical
32
+ transformation or translation of a Source form, including but
33
+ not limited to compiled object code, generated documentation,
34
+ and conversions to other media types.
35
+
36
+ "Work" shall mean the work of authorship, whether in Source or
37
+ Object form, made available under the License, as indicated by a
38
+ copyright notice that is included in or attached to the work
39
+ (an example is provided in the Appendix below).
40
+
41
+ "Derivative Works" shall mean any work, whether in Source or Object
42
+ form, that is based on (or derived from) the Work and for which the
43
+ editorial revisions, annotations, elaborations, or other modifications
44
+ represent, as a whole, an original work of authorship. For the purposes
45
+ of this License, Derivative Works shall not include works that remain
46
+ separable from, or merely link (or bind by name) to the interfaces of,
47
+ the Work and Derivative Works thereof.
48
+
49
+ "Contribution" shall mean any work of authorship, including
50
+ the original version of the Work and any modifications or additions
51
+ to that Work or Derivative Works thereof, that is intentionally
52
+ submitted to Licensor for inclusion in the Work by the copyright owner
53
+ or by an individual or Legal Entity authorized to submit on behalf of
54
+ the copyright owner. For the purposes of this definition, "submitted"
55
+ means any form of electronic, verbal, or written communication sent
56
+ to the Licensor or its representatives, including but not limited to
57
+ communication on electronic mailing lists, source code control systems,
58
+ and issue tracking systems that are managed by, or on behalf of, the
59
+ Licensor for the purpose of discussing and improving the Work, but
60
+ excluding communication that is conspicuously marked or otherwise
61
+ designated in writing by the copyright owner as "Not a Contribution."
62
+
63
+ "Contributor" shall mean Licensor and any individual or Legal Entity
64
+ on behalf of whom a Contribution has been received by Licensor and
65
+ subsequently incorporated within the Work.
66
+
67
+ 2. Grant of Copyright License. Subject to the terms and conditions of
68
+ this License, each Contributor hereby grants to You a perpetual,
69
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
70
+ copyright license to reproduce, prepare Derivative Works of,
71
+ publicly display, publicly perform, sublicense, and distribute the
72
+ Work and such Derivative Works in Source or Object form.
73
+
74
+ 3. Grant of Patent License. Subject to the terms and conditions of
75
+ this License, each Contributor hereby grants to You a perpetual,
76
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
77
+ (except as stated in this section) patent license to make, have made,
78
+ use, offer to sell, sell, import, and otherwise transfer the Work,
79
+ where such license applies only to those patent claims licensable
80
+ by such Contributor that are necessarily infringed by their
81
+ Contribution(s) alone or by combination of their Contribution(s)
82
+ with the Work to which such Contribution(s) was submitted. If You
83
+ institute patent litigation against any entity (including a
84
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
85
+ or a Contribution incorporated within the Work constitutes direct
86
+ or contributory patent infringement, then any patent licenses
87
+ granted to You under this License for that Work shall terminate
88
+ as of the date such litigation is filed.
89
+
90
+ 4. Redistribution. You may reproduce and distribute copies of the
91
+ Work or Derivative Works thereof in any medium, with or without
92
+ modifications, and in Source or Object form, provided that You
93
+ meet the following conditions:
94
+
95
+ (a) You must give any other recipients of the Work or
96
+ Derivative Works a copy of this License; and
97
+
98
+ (b) You must cause any modified files to carry prominent notices
99
+ stating that You changed the files; and
100
+
101
+ (c) You must retain, in the Source form of any Derivative Works
102
+ that You distribute, all copyright, patent, trademark, and
103
+ attribution notices from the Source form of the Work,
104
+ excluding those notices that do not pertain to any part of
105
+ the Derivative Works; and
106
+
107
+ (d) If the Work includes a "NOTICE" text file as part of its
108
+ distribution, then any Derivative Works that You distribute must
109
+ include a readable copy of the attribution notices contained
110
+ within such NOTICE file, excluding those notices that do not
111
+ pertain to any part of the Derivative Works, in at least one
112
+ of the following places: within a NOTICE text file distributed
113
+ as part of the Derivative Works; within the Source form or
114
+ documentation, if provided along with the Derivative Works; or,
115
+ within a display generated by the Derivative Works, if and
116
+ wherever such third-party notices normally appear. The contents
117
+ of the NOTICE file are for informational purposes only and
118
+ do not modify the License. You may add Your own attribution
119
+ notices within Derivative Works that You distribute, alongside
120
+ or as an addendum to the NOTICE text from the Work, provided
121
+ that such additional attribution notices cannot be construed
122
+ as modifying the License.
123
+
124
+ You may add Your own copyright statement to Your modifications and
125
+ may provide additional or different license terms and conditions
126
+ for use, reproduction, or distribution of Your modifications, or
127
+ for any such Derivative Works as a whole, provided Your use,
128
+ reproduction, and distribution of the Work otherwise complies with
129
+ the conditions stated in this License.
130
+
131
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
132
+ any Contribution intentionally submitted for inclusion in the Work
133
+ by You to the Licensor shall be under the terms and conditions of
134
+ this License, without any additional terms or conditions.
135
+ Notwithstanding the above, nothing herein shall supersede or modify
136
+ the terms of any separate license agreement you may have executed
137
+ with Licensor regarding such Contributions.
138
+
139
+ 6. Trademarks. This License does not grant permission to use the trade
140
+ names, trademarks, service marks, or product names of the Licensor,
141
+ except as required for reasonable and customary use in describing the
142
+ origin of the Work and reproducing the content of the NOTICE file.
143
+
144
+ 7. Disclaimer of Warranty. Unless required by applicable law or
145
+ agreed to in writing, Licensor provides the Work (and each
146
+ Contributor provides its Contributions) on an "AS IS" BASIS,
147
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
148
+ implied, including, without limitation, any warranties or conditions
149
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
150
+ PARTICULAR PURPOSE. You are solely responsible for determining the
151
+ appropriateness of using or redistributing the Work and assume any
152
+ risks associated with Your exercise of permissions under this License.
153
+
154
+ 8. Limitation of Liability. In no event and under no legal theory,
155
+ whether in tort (including negligence), contract, or otherwise,
156
+ unless required by applicable law (such as deliberate and grossly
157
+ negligent acts) or agreed to in writing, shall any Contributor be
158
+ liable to You for damages, including any direct, indirect, special,
159
+ incidental, or consequential damages of any character arising as a
160
+ result of this License or out of the use or inability to use the
161
+ Work (including but not limited to damages for loss of goodwill,
162
+ work stoppage, computer failure or malfunction, or any and all
163
+ other commercial damages or losses), even if such Contributor
164
+ has been advised of the possibility of such damages.
165
+
166
+ 9. Accepting Warranty or Additional Liability. While redistributing
167
+ the Work or Derivative Works thereof, You may choose to offer,
168
+ and charge a fee for, acceptance of support, warranty, indemnity,
169
+ or other liability obligations and/or rights consistent with this
170
+ License. However, in accepting such obligations, You may act only
171
+ on Your own behalf and on Your sole responsibility, not on behalf
172
+ of any other Contributor, and only if You agree to indemnify,
173
+ defend, and hold each Contributor harmless for any liability
174
+ incurred by, or claims asserted against, such Contributor by reason
175
+ of your accepting any such warranty or additional liability.
176
+
177
+ END OF TERMS AND CONDITIONS
python/Lib/site-packages/pip-26.1.1.dist-info/licenses/src/pip/_vendor/packaging/LICENSE.BSD ADDED
@@ -0,0 +1,23 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ Copyright (c) Donald Stufft and individual contributors.
2
+ All rights reserved.
3
+
4
+ Redistribution and use in source and binary forms, with or without
5
+ modification, are permitted provided that the following conditions are met:
6
+
7
+ 1. Redistributions of source code must retain the above copyright notice,
8
+ this list of conditions and the following disclaimer.
9
+
10
+ 2. Redistributions in binary form must reproduce the above copyright
11
+ notice, this list of conditions and the following disclaimer in the
12
+ documentation and/or other materials provided with the distribution.
13
+
14
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
15
+ ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
16
+ WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
17
+ DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
18
+ FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19
+ DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
20
+ SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
21
+ CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
22
+ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
23
+ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
python/Lib/site-packages/pip-26.1.1.dist-info/licenses/src/pip/_vendor/pkg_resources/LICENSE ADDED
@@ -0,0 +1,17 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ Permission is hereby granted, free of charge, to any person obtaining a copy
2
+ of this software and associated documentation files (the "Software"), to
3
+ deal in the Software without restriction, including without limitation the
4
+ rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
5
+ sell copies of the Software, and to permit persons to whom the Software is
6
+ furnished to do so, subject to the following conditions:
7
+
8
+ The above copyright notice and this permission notice shall be included in
9
+ all copies or substantial portions of the Software.
10
+
11
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
12
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
13
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
14
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
15
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
16
+ FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
17
+ IN THE SOFTWARE.
python/Lib/site-packages/pip-26.1.1.dist-info/licenses/src/pip/_vendor/platformdirs/LICENSE ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ MIT License
2
+
3
+ Copyright (c) 2010-202x The platformdirs developers
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
python/Lib/site-packages/pip-26.1.1.dist-info/licenses/src/pip/_vendor/pygments/LICENSE ADDED
@@ -0,0 +1,25 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ Copyright (c) 2006-2022 by the respective authors (see AUTHORS file).
2
+ All rights reserved.
3
+
4
+ Redistribution and use in source and binary forms, with or without
5
+ modification, are permitted provided that the following conditions are
6
+ met:
7
+
8
+ * Redistributions of source code must retain the above copyright
9
+ notice, this list of conditions and the following disclaimer.
10
+
11
+ * Redistributions in binary form must reproduce the above copyright
12
+ notice, this list of conditions and the following disclaimer in the
13
+ documentation and/or other materials provided with the distribution.
14
+
15
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
16
+ "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
17
+ LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
18
+ A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
19
+ OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
20
+ SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
21
+ LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
22
+ DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
23
+ THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24
+ (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
25
+ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
python/Lib/site-packages/pip-26.1.1.dist-info/licenses/src/pip/_vendor/pyproject_hooks/LICENSE ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2017 Thomas Kluyver
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
python/Lib/site-packages/pip-26.1.1.dist-info/licenses/src/pip/_vendor/requests/LICENSE ADDED
@@ -0,0 +1,175 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ Apache License
3
+ Version 2.0, January 2004
4
+ http://www.apache.org/licenses/
5
+
6
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
7
+
8
+ 1. Definitions.
9
+
10
+ "License" shall mean the terms and conditions for use, reproduction,
11
+ and distribution as defined by Sections 1 through 9 of this document.
12
+
13
+ "Licensor" shall mean the copyright owner or entity authorized by
14
+ the copyright owner that is granting the License.
15
+
16
+ "Legal Entity" shall mean the union of the acting entity and all
17
+ other entities that control, are controlled by, or are under common
18
+ control with that entity. For the purposes of this definition,
19
+ "control" means (i) the power, direct or indirect, to cause the
20
+ direction or management of such entity, whether by contract or
21
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
22
+ outstanding shares, or (iii) beneficial ownership of such entity.
23
+
24
+ "You" (or "Your") shall mean an individual or Legal Entity
25
+ exercising permissions granted by this License.
26
+
27
+ "Source" form shall mean the preferred form for making modifications,
28
+ including but not limited to software source code, documentation
29
+ source, and configuration files.
30
+
31
+ "Object" form shall mean any form resulting from mechanical
32
+ transformation or translation of a Source form, including but
33
+ not limited to compiled object code, generated documentation,
34
+ and conversions to other media types.
35
+
36
+ "Work" shall mean the work of authorship, whether in Source or
37
+ Object form, made available under the License, as indicated by a
38
+ copyright notice that is included in or attached to the work
39
+ (an example is provided in the Appendix below).
40
+
41
+ "Derivative Works" shall mean any work, whether in Source or Object
42
+ form, that is based on (or derived from) the Work and for which the
43
+ editorial revisions, annotations, elaborations, or other modifications
44
+ represent, as a whole, an original work of authorship. For the purposes
45
+ of this License, Derivative Works shall not include works that remain
46
+ separable from, or merely link (or bind by name) to the interfaces of,
47
+ the Work and Derivative Works thereof.
48
+
49
+ "Contribution" shall mean any work of authorship, including
50
+ the original version of the Work and any modifications or additions
51
+ to that Work or Derivative Works thereof, that is intentionally
52
+ submitted to Licensor for inclusion in the Work by the copyright owner
53
+ or by an individual or Legal Entity authorized to submit on behalf of
54
+ the copyright owner. For the purposes of this definition, "submitted"
55
+ means any form of electronic, verbal, or written communication sent
56
+ to the Licensor or its representatives, including but not limited to
57
+ communication on electronic mailing lists, source code control systems,
58
+ and issue tracking systems that are managed by, or on behalf of, the
59
+ Licensor for the purpose of discussing and improving the Work, but
60
+ excluding communication that is conspicuously marked or otherwise
61
+ designated in writing by the copyright owner as "Not a Contribution."
62
+
63
+ "Contributor" shall mean Licensor and any individual or Legal Entity
64
+ on behalf of whom a Contribution has been received by Licensor and
65
+ subsequently incorporated within the Work.
66
+
67
+ 2. Grant of Copyright License. Subject to the terms and conditions of
68
+ this License, each Contributor hereby grants to You a perpetual,
69
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
70
+ copyright license to reproduce, prepare Derivative Works of,
71
+ publicly display, publicly perform, sublicense, and distribute the
72
+ Work and such Derivative Works in Source or Object form.
73
+
74
+ 3. Grant of Patent License. Subject to the terms and conditions of
75
+ this License, each Contributor hereby grants to You a perpetual,
76
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
77
+ (except as stated in this section) patent license to make, have made,
78
+ use, offer to sell, sell, import, and otherwise transfer the Work,
79
+ where such license applies only to those patent claims licensable
80
+ by such Contributor that are necessarily infringed by their
81
+ Contribution(s) alone or by combination of their Contribution(s)
82
+ with the Work to which such Contribution(s) was submitted. If You
83
+ institute patent litigation against any entity (including a
84
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
85
+ or a Contribution incorporated within the Work constitutes direct
86
+ or contributory patent infringement, then any patent licenses
87
+ granted to You under this License for that Work shall terminate
88
+ as of the date such litigation is filed.
89
+
90
+ 4. Redistribution. You may reproduce and distribute copies of the
91
+ Work or Derivative Works thereof in any medium, with or without
92
+ modifications, and in Source or Object form, provided that You
93
+ meet the following conditions:
94
+
95
+ (a) You must give any other recipients of the Work or
96
+ Derivative Works a copy of this License; and
97
+
98
+ (b) You must cause any modified files to carry prominent notices
99
+ stating that You changed the files; and
100
+
101
+ (c) You must retain, in the Source form of any Derivative Works
102
+ that You distribute, all copyright, patent, trademark, and
103
+ attribution notices from the Source form of the Work,
104
+ excluding those notices that do not pertain to any part of
105
+ the Derivative Works; and
106
+
107
+ (d) If the Work includes a "NOTICE" text file as part of its
108
+ distribution, then any Derivative Works that You distribute must
109
+ include a readable copy of the attribution notices contained
110
+ within such NOTICE file, excluding those notices that do not
111
+ pertain to any part of the Derivative Works, in at least one
112
+ of the following places: within a NOTICE text file distributed
113
+ as part of the Derivative Works; within the Source form or
114
+ documentation, if provided along with the Derivative Works; or,
115
+ within a display generated by the Derivative Works, if and
116
+ wherever such third-party notices normally appear. The contents
117
+ of the NOTICE file are for informational purposes only and
118
+ do not modify the License. You may add Your own attribution
119
+ notices within Derivative Works that You distribute, alongside
120
+ or as an addendum to the NOTICE text from the Work, provided
121
+ that such additional attribution notices cannot be construed
122
+ as modifying the License.
123
+
124
+ You may add Your own copyright statement to Your modifications and
125
+ may provide additional or different license terms and conditions
126
+ for use, reproduction, or distribution of Your modifications, or
127
+ for any such Derivative Works as a whole, provided Your use,
128
+ reproduction, and distribution of the Work otherwise complies with
129
+ the conditions stated in this License.
130
+
131
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
132
+ any Contribution intentionally submitted for inclusion in the Work
133
+ by You to the Licensor shall be under the terms and conditions of
134
+ this License, without any additional terms or conditions.
135
+ Notwithstanding the above, nothing herein shall supersede or modify
136
+ the terms of any separate license agreement you may have executed
137
+ with Licensor regarding such Contributions.
138
+
139
+ 6. Trademarks. This License does not grant permission to use the trade
140
+ names, trademarks, service marks, or product names of the Licensor,
141
+ except as required for reasonable and customary use in describing the
142
+ origin of the Work and reproducing the content of the NOTICE file.
143
+
144
+ 7. Disclaimer of Warranty. Unless required by applicable law or
145
+ agreed to in writing, Licensor provides the Work (and each
146
+ Contributor provides its Contributions) on an "AS IS" BASIS,
147
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
148
+ implied, including, without limitation, any warranties or conditions
149
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
150
+ PARTICULAR PURPOSE. You are solely responsible for determining the
151
+ appropriateness of using or redistributing the Work and assume any
152
+ risks associated with Your exercise of permissions under this License.
153
+
154
+ 8. Limitation of Liability. In no event and under no legal theory,
155
+ whether in tort (including negligence), contract, or otherwise,
156
+ unless required by applicable law (such as deliberate and grossly
157
+ negligent acts) or agreed to in writing, shall any Contributor be
158
+ liable to You for damages, including any direct, indirect, special,
159
+ incidental, or consequential damages of any character arising as a
160
+ result of this License or out of the use or inability to use the
161
+ Work (including but not limited to damages for loss of goodwill,
162
+ work stoppage, computer failure or malfunction, or any and all
163
+ other commercial damages or losses), even if such Contributor
164
+ has been advised of the possibility of such damages.
165
+
166
+ 9. Accepting Warranty or Additional Liability. While redistributing
167
+ the Work or Derivative Works thereof, You may choose to offer,
168
+ and charge a fee for, acceptance of support, warranty, indemnity,
169
+ or other liability obligations and/or rights consistent with this
170
+ License. However, in accepting such obligations, You may act only
171
+ on Your own behalf and on Your sole responsibility, not on behalf
172
+ of any other Contributor, and only if You agree to indemnify,
173
+ defend, and hold each Contributor harmless for any liability
174
+ incurred by, or claims asserted against, such Contributor by reason
175
+ of your accepting any such warranty or additional liability.
python/Lib/site-packages/pip-26.1.1.dist-info/licenses/src/pip/_vendor/resolvelib/LICENSE ADDED
@@ -0,0 +1,13 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ Copyright (c) 2018, Tzu-ping Chung <uranusjr@gmail.com>
2
+
3
+ Permission to use, copy, modify, and distribute this software for any
4
+ purpose with or without fee is hereby granted, provided that the above
5
+ copyright notice and this permission notice appear in all copies.
6
+
7
+ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
8
+ WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
9
+ MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
10
+ ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
11
+ WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
12
+ ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
13
+ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
python/Lib/site-packages/pip-26.1.1.dist-info/licenses/src/pip/_vendor/rich/LICENSE ADDED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ Copyright (c) 2020 Will McGugan
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining a copy
4
+ of this software and associated documentation files (the "Software"), to deal
5
+ in the Software without restriction, including without limitation the rights
6
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7
+ copies of the Software, and to permit persons to whom the Software is
8
+ furnished to do so, subject to the following conditions:
9
+
10
+ The above copyright notice and this permission notice shall be included in all
11
+ copies or substantial portions of the Software.
12
+
13
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
19
+ SOFTWARE.
python/Lib/site-packages/pip-26.1.1.dist-info/licenses/src/pip/_vendor/tomli/LICENSE ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ MIT License
2
+
3
+ Copyright (c) 2021 Taneli Hukkinen
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
python/Lib/site-packages/pip-26.1.1.dist-info/licenses/src/pip/_vendor/tomli_w/LICENSE ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ MIT License
2
+
3
+ Copyright (c) 2021 Taneli Hukkinen
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
python/Lib/site-packages/pip-26.1.1.dist-info/licenses/src/pip/_vendor/truststore/LICENSE ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2022 Seth Michael Larson
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
python/Lib/site-packages/pip-26.1.1.dist-info/licenses/src/pip/_vendor/urllib3/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ MIT License
2
+
3
+ Copyright (c) 2008-2020 Andrey Petrov and contributors.
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
python/Lib/site-packages/pip/__pycache__/__init__.cpython-313.pyc ADDED
Binary file (630 Bytes). View file
 
python/Lib/site-packages/pip/__pycache__/__main__.cpython-313.pyc ADDED
Binary file (873 Bytes). View file
 
python/Lib/site-packages/pip/__pycache__/__pip-runner__.cpython-313.pyc ADDED
Binary file (2.27 kB). View file
 
python/Lib/site-packages/pip/_internal/__init__.py ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from __future__ import annotations
2
+
3
+ from pip._internal.utils import _log
4
+
5
+ # init_logging() must be called before any call to logging.getLogger()
6
+ # which happens at import of most modules.
7
+ _log.init_logging()
8
+
9
+
10
+ def main(args: list[str] | None = None) -> int:
11
+ """This is preserved for old console scripts that may still be referencing
12
+ it.
13
+
14
+ For additional details, see https://github.com/pypa/pip/issues/7498.
15
+ """
16
+ from pip._internal.utils.entrypoints import _wrapper
17
+
18
+ return _wrapper(args)
python/Lib/site-packages/pip/_internal/build_env.py ADDED
@@ -0,0 +1,606 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """Build Environment used for isolation during sdist building"""
2
+
3
+ from __future__ import annotations
4
+
5
+ import logging
6
+ import os
7
+ import pathlib
8
+ import site
9
+ import sys
10
+ import textwrap
11
+ from collections import OrderedDict
12
+ from collections.abc import Iterable, Sequence
13
+ from contextlib import AbstractContextManager as ContextManager
14
+ from contextlib import nullcontext
15
+ from io import StringIO
16
+ from types import TracebackType
17
+ from typing import TYPE_CHECKING, Protocol, TypedDict
18
+
19
+ from pip._vendor.packaging.version import Version
20
+
21
+ from pip import __file__ as pip_location
22
+ from pip._internal.cli.spinners import open_rich_spinner, open_spinner
23
+ from pip._internal.exceptions import (
24
+ BuildDependencyInstallError,
25
+ DiagnosticPipError,
26
+ InstallWheelBuildError,
27
+ PipError,
28
+ )
29
+ from pip._internal.locations import get_platlib, get_purelib, get_scheme
30
+ from pip._internal.metadata import get_default_environment, get_environment
31
+ from pip._internal.utils.deprecation import deprecated
32
+ from pip._internal.utils.logging import VERBOSE, capture_logging
33
+ from pip._internal.utils.packaging import get_requirement
34
+ from pip._internal.utils.subprocess import call_subprocess
35
+ from pip._internal.utils.temp_dir import TempDirectory, tempdir_kinds
36
+
37
+ if TYPE_CHECKING:
38
+ from pip._internal.cache import WheelCache
39
+ from pip._internal.index.package_finder import PackageFinder
40
+ from pip._internal.operations.build.build_tracker import BuildTracker
41
+ from pip._internal.req.req_install import InstallRequirement
42
+ from pip._internal.resolution.base import BaseResolver
43
+
44
+ class ExtraEnviron(TypedDict, total=False):
45
+ extra_environ: dict[str, str]
46
+
47
+
48
+ logger = logging.getLogger(__name__)
49
+
50
+
51
+ def _dedup(a: str, b: str) -> tuple[str] | tuple[str, str]:
52
+ return (a, b) if a != b else (a,)
53
+
54
+
55
+ class _Prefix:
56
+ def __init__(self, path: str) -> None:
57
+ self.path = path
58
+ self.setup = False
59
+ scheme = get_scheme("", prefix=path)
60
+ self.bin_dir = scheme.scripts
61
+ self.lib_dirs = _dedup(scheme.purelib, scheme.platlib)
62
+
63
+
64
+ def get_runnable_pip() -> str:
65
+ """Get a file to pass to a Python executable, to run the currently-running pip.
66
+
67
+ This is used to run a pip subprocess, for installing requirements into the build
68
+ environment.
69
+ """
70
+ source = pathlib.Path(pip_location).resolve().parent
71
+
72
+ if not source.is_dir():
73
+ # This would happen if someone is using pip from inside a zip file. In that
74
+ # case, we can use that directly.
75
+ return str(source)
76
+
77
+ return os.fsdecode(source / "__pip-runner__.py")
78
+
79
+
80
+ def _get_system_sitepackages() -> set[str]:
81
+ """Get system site packages
82
+
83
+ Usually from site.getsitepackages,
84
+ but fallback on `get_purelib()/get_platlib()` if unavailable
85
+ (e.g. in a virtualenv created by virtualenv<20)
86
+
87
+ Returns normalized set of strings.
88
+ """
89
+ if hasattr(site, "getsitepackages"):
90
+ system_sites = site.getsitepackages()
91
+ else:
92
+ # virtualenv < 20 overwrites site.py without getsitepackages
93
+ # fallback on get_purelib/get_platlib.
94
+ # this is known to miss things, but shouldn't in the cases
95
+ # where getsitepackages() has been removed (inside a virtualenv)
96
+ system_sites = [get_purelib(), get_platlib()]
97
+ return {os.path.normcase(path) for path in system_sites}
98
+
99
+
100
+ class BuildEnvironmentInstaller(Protocol):
101
+ """
102
+ Interface for installing build dependencies into an isolated build
103
+ environment.
104
+ """
105
+
106
+ def install(
107
+ self,
108
+ requirements: Iterable[str],
109
+ prefix: _Prefix,
110
+ *,
111
+ kind: str,
112
+ for_req: InstallRequirement | None,
113
+ ) -> None: ...
114
+
115
+
116
+ class SubprocessBuildEnvironmentInstaller:
117
+ """
118
+ Install build dependencies by calling pip in a subprocess.
119
+ """
120
+
121
+ def __init__(
122
+ self,
123
+ finder: PackageFinder,
124
+ build_constraints: list[str] | None = None,
125
+ build_constraint_feature_enabled: bool = False,
126
+ ) -> None:
127
+ self.finder = finder
128
+ self._build_constraints = build_constraints or []
129
+ self._build_constraint_feature_enabled = build_constraint_feature_enabled
130
+
131
+ def _deprecation_constraint_check(self) -> None:
132
+ """
133
+ Check for deprecation warning: PIP_CONSTRAINT affecting build environments.
134
+
135
+ This warns when build-constraint feature is NOT enabled and PIP_CONSTRAINT
136
+ is not empty.
137
+ """
138
+ if self._build_constraint_feature_enabled or self._build_constraints:
139
+ return
140
+
141
+ pip_constraint = os.environ.get("PIP_CONSTRAINT")
142
+ if not pip_constraint or not pip_constraint.strip():
143
+ return
144
+
145
+ deprecated(
146
+ reason=(
147
+ "Setting PIP_CONSTRAINT will not affect "
148
+ "build constraints in the future,"
149
+ ),
150
+ replacement=(
151
+ "to specify build constraints using --build-constraint or "
152
+ "PIP_BUILD_CONSTRAINT. To disable this warning without "
153
+ "any build constraints set --use-feature=build-constraint or "
154
+ 'PIP_USE_FEATURE="build-constraint"'
155
+ ),
156
+ gone_in="26.2",
157
+ issue=None,
158
+ )
159
+
160
+ def install(
161
+ self,
162
+ requirements: Iterable[str],
163
+ prefix: _Prefix,
164
+ *,
165
+ kind: str,
166
+ for_req: InstallRequirement | None,
167
+ ) -> None:
168
+ self._deprecation_constraint_check()
169
+
170
+ finder = self.finder
171
+ args: list[str] = [
172
+ sys.executable,
173
+ get_runnable_pip(),
174
+ "install",
175
+ "--ignore-installed",
176
+ "--no-user",
177
+ "--prefix",
178
+ prefix.path,
179
+ "--no-warn-script-location",
180
+ "--disable-pip-version-check",
181
+ # As the build environment is ephemeral, it's wasteful to
182
+ # pre-compile everything, especially as not every Python
183
+ # module will be used/compiled in most cases.
184
+ "--no-compile",
185
+ # The prefix specified two lines above, thus
186
+ # target from config file or env var should be ignored
187
+ "--target",
188
+ "",
189
+ ]
190
+ if logger.getEffectiveLevel() <= logging.DEBUG:
191
+ args.append("-vv")
192
+ elif logger.getEffectiveLevel() <= VERBOSE:
193
+ args.append("-v")
194
+ for format_control in ("no_binary", "only_binary"):
195
+ formats = getattr(finder.format_control, format_control)
196
+ args.extend(
197
+ (
198
+ "--" + format_control.replace("_", "-"),
199
+ ",".join(sorted(formats or {":none:"})),
200
+ )
201
+ )
202
+
203
+ if finder.release_control is not None:
204
+ # Use ordered args to preserve the user's original command-line order
205
+ # This is important because later flags can override earlier ones
206
+ for attr_name, value in finder.release_control.get_ordered_args():
207
+ args.extend(("--" + attr_name.replace("_", "-"), value))
208
+
209
+ index_urls = finder.index_urls
210
+ if index_urls:
211
+ args.extend(["-i", index_urls[0]])
212
+ for extra_index in index_urls[1:]:
213
+ args.extend(["--extra-index-url", extra_index])
214
+ else:
215
+ args.append("--no-index")
216
+ for link in finder.find_links:
217
+ args.extend(["--find-links", link])
218
+
219
+ if finder.proxy:
220
+ args.extend(["--proxy", finder.proxy])
221
+ for host in finder.trusted_hosts:
222
+ args.extend(["--trusted-host", host])
223
+ if finder.custom_cert:
224
+ args.extend(["--cert", finder.custom_cert])
225
+ if finder.client_cert:
226
+ args.extend(["--client-cert", finder.client_cert])
227
+ if finder.prefer_binary:
228
+ args.append("--prefer-binary")
229
+
230
+ # Handle build constraints
231
+ if self._build_constraint_feature_enabled:
232
+ args.extend(["--use-feature", "build-constraint"])
233
+
234
+ if self._build_constraints:
235
+ # Build constraints must be passed as both constraints
236
+ # and build constraints, so that nested builds receive
237
+ # build constraints
238
+ for constraint_file in self._build_constraints:
239
+ args.extend(["--constraint", constraint_file])
240
+ args.extend(["--build-constraint", constraint_file])
241
+
242
+ extra_environ: ExtraEnviron = {}
243
+ if self._build_constraint_feature_enabled and not self._build_constraints:
244
+ # If there are no build constraints but the build constraints
245
+ # feature is enabled then we must ignore regular constraints
246
+ # in the isolated build environment
247
+ extra_environ = {"extra_environ": {"_PIP_IN_BUILD_IGNORE_CONSTRAINTS": "1"}}
248
+
249
+ if finder.uploaded_prior_to:
250
+ args.extend(["--uploaded-prior-to", finder.uploaded_prior_to.isoformat()])
251
+ args.append("--")
252
+ args.extend(requirements)
253
+
254
+ identify_requirement = (
255
+ f" for {for_req.name}" if for_req and for_req.name else ""
256
+ )
257
+ with open_spinner(f"Installing {kind}") as spinner:
258
+ call_subprocess(
259
+ args,
260
+ command_desc=f"installing {kind}{identify_requirement}",
261
+ spinner=spinner,
262
+ **extra_environ,
263
+ )
264
+
265
+
266
+ class InprocessBuildEnvironmentInstaller:
267
+ """
268
+ Build dependency installer that runs in the same pip process.
269
+
270
+ This contains a stripped down version of the install command with
271
+ only the logic necessary for installing build dependencies. The
272
+ finder, session, build tracker, and wheel cache are reused, but new
273
+ instances of everything else are created as needed.
274
+
275
+ Options are inherited from the parent install command unless
276
+ they don't make sense for build dependencies (in which case, they
277
+ are hard-coded, see comments below).
278
+ """
279
+
280
+ def __init__(
281
+ self,
282
+ *,
283
+ finder: PackageFinder,
284
+ build_tracker: BuildTracker,
285
+ wheel_cache: WheelCache,
286
+ build_constraints: Sequence[InstallRequirement] = (),
287
+ verbosity: int = 0,
288
+ ) -> None:
289
+ from pip._internal.operations.prepare import RequirementPreparer
290
+
291
+ self._finder = finder
292
+ self._build_constraints = build_constraints
293
+ self._wheel_cache = wheel_cache
294
+ self._level = 0
295
+
296
+ build_dir = TempDirectory(kind="build-env-install", globally_managed=True)
297
+ self._preparer = RequirementPreparer(
298
+ build_isolation_installer=self,
299
+ # Inherited options or state.
300
+ finder=finder,
301
+ session=finder._link_collector.session,
302
+ build_dir=build_dir.path,
303
+ build_tracker=build_tracker,
304
+ verbosity=verbosity,
305
+ # This is irrelevant as it only applies to editable requirements.
306
+ src_dir="",
307
+ # Hard-coded options (that should NOT be inherited).
308
+ download_dir=None,
309
+ build_isolation=True,
310
+ check_build_deps=False,
311
+ progress_bar="off",
312
+ # TODO: hash-checking should be extended to build deps, but that is
313
+ # deferred for later as it'd be a breaking change.
314
+ require_hashes=False,
315
+ use_user_site=False,
316
+ lazy_wheel=False,
317
+ legacy_resolver=False,
318
+ )
319
+
320
+ def install(
321
+ self,
322
+ requirements: Iterable[str],
323
+ prefix: _Prefix,
324
+ *,
325
+ kind: str,
326
+ for_req: InstallRequirement | None,
327
+ ) -> None:
328
+ """Install entrypoint. Manages output capturing and error handling."""
329
+ capture_logs = not logger.isEnabledFor(VERBOSE) and self._level == 0
330
+ if capture_logs:
331
+ # Hide the logs from the installation of build dependencies.
332
+ # They will be shown only if an error occurs.
333
+ capture_ctx: ContextManager[StringIO] = capture_logging()
334
+ spinner: ContextManager[None] = open_rich_spinner(f"Installing {kind}")
335
+ else:
336
+ # Otherwise, pass-through all logs (with a header).
337
+ capture_ctx, spinner = nullcontext(StringIO()), nullcontext()
338
+ logger.info("Installing %s ...", kind)
339
+
340
+ try:
341
+ self._level += 1
342
+ with spinner, capture_ctx as stream:
343
+ self._install_impl(requirements, prefix)
344
+
345
+ except DiagnosticPipError as exc:
346
+ # Format similar to a nested subprocess error, where the
347
+ # causing error is shown first, followed by the build error.
348
+ logger.info(textwrap.dedent(stream.getvalue()))
349
+ logger.error("%s", exc, extra={"rich": True})
350
+ logger.info("")
351
+ raise BuildDependencyInstallError(
352
+ for_req, requirements, cause=exc, log_lines=None
353
+ )
354
+
355
+ except Exception as exc:
356
+ logs: list[str] | None = textwrap.dedent(stream.getvalue()).splitlines()
357
+ if not capture_logs:
358
+ # If logs aren't being captured, then display the error inline
359
+ # with the rest of the logs.
360
+ logs = None
361
+ if isinstance(exc, PipError):
362
+ logger.error("%s", exc)
363
+ else:
364
+ logger.exception("pip crashed unexpectedly")
365
+ raise BuildDependencyInstallError(
366
+ for_req, requirements, cause=exc, log_lines=logs
367
+ )
368
+
369
+ finally:
370
+ self._level -= 1
371
+
372
+ def _install_impl(self, requirements: Iterable[str], prefix: _Prefix) -> None:
373
+ """Core build dependency install logic."""
374
+ from pip._internal.commands.install import installed_packages_summary
375
+ from pip._internal.req import install_given_reqs
376
+ from pip._internal.req.constructors import install_req_from_line
377
+ from pip._internal.wheel_builder import build
378
+
379
+ ireqs = [install_req_from_line(req, user_supplied=True) for req in requirements]
380
+ ireqs.extend(self._build_constraints)
381
+
382
+ resolver = self._make_resolver()
383
+ resolved_set = resolver.resolve(ireqs, check_supported_wheels=True)
384
+ self._preparer.prepare_linked_requirements_more(
385
+ resolved_set.requirements.values()
386
+ )
387
+
388
+ reqs_to_build = [
389
+ r for r in resolved_set.requirements_to_install if not r.is_wheel
390
+ ]
391
+ _, build_failures = build(reqs_to_build, self._wheel_cache, verify=True)
392
+ if build_failures:
393
+ raise InstallWheelBuildError(build_failures)
394
+
395
+ installed = install_given_reqs(
396
+ resolver.get_installation_order(resolved_set),
397
+ prefix=prefix.path,
398
+ # Hard-coded options (that should NOT be inherited).
399
+ root=None,
400
+ home=None,
401
+ warn_script_location=False,
402
+ use_user_site=False,
403
+ # As the build environment is ephemeral, it's wasteful to
404
+ # pre-compile everything since not all modules will be used.
405
+ pycompile=False,
406
+ progress_bar="off",
407
+ )
408
+
409
+ env = get_environment(list(prefix.lib_dirs))
410
+ if summary := installed_packages_summary(installed, env):
411
+ logger.info(summary)
412
+
413
+ def _make_resolver(self) -> BaseResolver:
414
+ """Create a new resolver for one time use."""
415
+ # Legacy installer never used the legacy resolver so create a
416
+ # resolvelib resolver directly. Yuck.
417
+ from pip._internal.req.constructors import install_req_from_req_string
418
+ from pip._internal.resolution.resolvelib.resolver import Resolver
419
+
420
+ return Resolver(
421
+ make_install_req=install_req_from_req_string,
422
+ # Inherited state.
423
+ preparer=self._preparer,
424
+ finder=self._finder,
425
+ wheel_cache=self._wheel_cache,
426
+ # Hard-coded options (that should NOT be inherited).
427
+ ignore_requires_python=False,
428
+ use_user_site=False,
429
+ ignore_dependencies=False,
430
+ ignore_installed=True,
431
+ force_reinstall=False,
432
+ upgrade_strategy="to-satisfy-only",
433
+ py_version_info=None,
434
+ )
435
+
436
+
437
+ class BuildEnvironment:
438
+ """Creates and manages an isolated environment to install build deps"""
439
+
440
+ def __init__(self, installer: BuildEnvironmentInstaller) -> None:
441
+ self.installer = installer
442
+ temp_dir = TempDirectory(kind=tempdir_kinds.BUILD_ENV, globally_managed=True)
443
+
444
+ self._prefixes = OrderedDict(
445
+ (name, _Prefix(os.path.join(temp_dir.path, name)))
446
+ for name in ("normal", "overlay")
447
+ )
448
+
449
+ self._bin_dirs: list[str] = []
450
+ self._lib_dirs: list[str] = []
451
+ for prefix in reversed(list(self._prefixes.values())):
452
+ self._bin_dirs.append(prefix.bin_dir)
453
+ self._lib_dirs.extend(prefix.lib_dirs)
454
+
455
+ # Customize site to:
456
+ # - ensure .pth files are honored
457
+ # - prevent access to system site packages
458
+ system_sites = _get_system_sitepackages()
459
+
460
+ self._site_dir = os.path.join(temp_dir.path, "site")
461
+ if not os.path.exists(self._site_dir):
462
+ os.mkdir(self._site_dir)
463
+ with open(
464
+ os.path.join(self._site_dir, "sitecustomize.py"), "w", encoding="utf-8"
465
+ ) as fp:
466
+ fp.write(
467
+ textwrap.dedent(
468
+ """
469
+ import os, site, sys
470
+
471
+ # First, drop system-sites related paths.
472
+ original_sys_path = sys.path[:]
473
+ known_paths = set()
474
+ for path in {system_sites!r}:
475
+ site.addsitedir(path, known_paths=known_paths)
476
+ system_paths = set(
477
+ os.path.normcase(path)
478
+ for path in sys.path[len(original_sys_path):]
479
+ )
480
+ original_sys_path = [
481
+ path for path in original_sys_path
482
+ if os.path.normcase(path) not in system_paths
483
+ ]
484
+ sys.path = original_sys_path
485
+
486
+ # Second, add lib directories.
487
+ # ensuring .pth file are processed.
488
+ for path in {lib_dirs!r}:
489
+ assert not path in sys.path
490
+ site.addsitedir(path)
491
+ """
492
+ ).format(system_sites=system_sites, lib_dirs=self._lib_dirs)
493
+ )
494
+
495
+ def __enter__(self) -> None:
496
+ self._save_env = {
497
+ name: os.environ.get(name, None)
498
+ for name in ("PATH", "PYTHONNOUSERSITE", "PYTHONPATH")
499
+ }
500
+
501
+ path = self._bin_dirs[:]
502
+ old_path = self._save_env["PATH"]
503
+ if old_path:
504
+ path.extend(old_path.split(os.pathsep))
505
+
506
+ pythonpath = [self._site_dir]
507
+
508
+ os.environ.update(
509
+ {
510
+ "PATH": os.pathsep.join(path),
511
+ "PYTHONNOUSERSITE": "1",
512
+ "PYTHONPATH": os.pathsep.join(pythonpath),
513
+ }
514
+ )
515
+
516
+ def __exit__(
517
+ self,
518
+ exc_type: type[BaseException] | None,
519
+ exc_val: BaseException | None,
520
+ exc_tb: TracebackType | None,
521
+ ) -> None:
522
+ for varname, old_value in self._save_env.items():
523
+ if old_value is None:
524
+ os.environ.pop(varname, None)
525
+ else:
526
+ os.environ[varname] = old_value
527
+
528
+ def check_requirements(
529
+ self, reqs: Iterable[str]
530
+ ) -> tuple[set[tuple[str, str]], set[str]]:
531
+ """Return 2 sets:
532
+ - conflicting requirements: set of (installed, wanted) reqs tuples
533
+ - missing requirements: set of reqs
534
+ """
535
+ missing = set()
536
+ conflicting = set()
537
+ if reqs:
538
+ env = (
539
+ get_environment(self._lib_dirs)
540
+ if hasattr(self, "_lib_dirs")
541
+ else get_default_environment()
542
+ )
543
+ for req_str in reqs:
544
+ req = get_requirement(req_str)
545
+ # We're explicitly evaluating with an empty extra value, since build
546
+ # environments are not provided any mechanism to select specific extras.
547
+ if req.marker is not None and not req.marker.evaluate({"extra": ""}):
548
+ continue
549
+ dist = env.get_distribution(req.name)
550
+ if not dist:
551
+ missing.add(req_str)
552
+ continue
553
+ if isinstance(dist.version, Version):
554
+ installed_req_str = f"{req.name}=={dist.version}"
555
+ else:
556
+ installed_req_str = f"{req.name}==={dist.version}"
557
+ if not req.specifier.contains(dist.version, prereleases=True):
558
+ conflicting.add((installed_req_str, req_str))
559
+ # FIXME: Consider direct URL?
560
+ return conflicting, missing
561
+
562
+ def install_requirements(
563
+ self,
564
+ requirements: Iterable[str],
565
+ prefix_as_string: str,
566
+ *,
567
+ kind: str,
568
+ for_req: InstallRequirement | None = None,
569
+ ) -> None:
570
+ prefix = self._prefixes[prefix_as_string]
571
+ assert not prefix.setup
572
+ prefix.setup = True
573
+ if not requirements:
574
+ return
575
+ self.installer.install(requirements, prefix, kind=kind, for_req=for_req)
576
+
577
+
578
+ class NoOpBuildEnvironment(BuildEnvironment):
579
+ """A no-op drop-in replacement for BuildEnvironment"""
580
+
581
+ def __init__(self) -> None:
582
+ pass
583
+
584
+ def __enter__(self) -> None:
585
+ pass
586
+
587
+ def __exit__(
588
+ self,
589
+ exc_type: type[BaseException] | None,
590
+ exc_val: BaseException | None,
591
+ exc_tb: TracebackType | None,
592
+ ) -> None:
593
+ pass
594
+
595
+ def cleanup(self) -> None:
596
+ pass
597
+
598
+ def install_requirements(
599
+ self,
600
+ requirements: Iterable[str],
601
+ prefix_as_string: str,
602
+ *,
603
+ kind: str,
604
+ for_req: InstallRequirement | None = None,
605
+ ) -> None:
606
+ raise NotImplementedError()
python/Lib/site-packages/pip/_internal/cache.py ADDED
@@ -0,0 +1,291 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """Cache Management"""
2
+
3
+ from __future__ import annotations
4
+
5
+ import hashlib
6
+ import json
7
+ import logging
8
+ import os
9
+ from pathlib import Path
10
+ from typing import Any
11
+
12
+ from pip._vendor.packaging.tags import Tag, interpreter_name, interpreter_version
13
+ from pip._vendor.packaging.utils import canonicalize_name
14
+
15
+ from pip._internal.exceptions import InvalidWheelFilename
16
+ from pip._internal.models.direct_url import DirectUrl
17
+ from pip._internal.models.link import Link
18
+ from pip._internal.models.wheel import Wheel
19
+ from pip._internal.utils.temp_dir import TempDirectory, tempdir_kinds
20
+ from pip._internal.utils.urls import path_to_url
21
+
22
+ logger = logging.getLogger(__name__)
23
+
24
+ ORIGIN_JSON_NAME = "origin.json"
25
+
26
+
27
+ def _hash_dict(d: dict[str, str]) -> str:
28
+ """Return a stable sha224 of a dictionary."""
29
+ s = json.dumps(d, sort_keys=True, separators=(",", ":"), ensure_ascii=True)
30
+ return hashlib.sha224(s.encode("ascii")).hexdigest()
31
+
32
+
33
+ class Cache:
34
+ """An abstract class - provides cache directories for data from links
35
+
36
+ :param cache_dir: The root of the cache.
37
+ """
38
+
39
+ def __init__(self, cache_dir: str) -> None:
40
+ super().__init__()
41
+ assert not cache_dir or os.path.isabs(cache_dir)
42
+ self.cache_dir = cache_dir or None
43
+
44
+ def _get_cache_path_parts(self, link: Link) -> list[str]:
45
+ """Get parts of part that must be os.path.joined with cache_dir"""
46
+
47
+ # We want to generate an url to use as our cache key, we don't want to
48
+ # just reuse the URL because it might have other items in the fragment
49
+ # and we don't care about those.
50
+ key_parts = {"url": link.url_without_fragment}
51
+ if link.hash_name is not None and link.hash is not None:
52
+ key_parts[link.hash_name] = link.hash
53
+ if link.subdirectory_fragment:
54
+ key_parts["subdirectory"] = link.subdirectory_fragment
55
+
56
+ # Include interpreter name, major and minor version in cache key
57
+ # to cope with ill-behaved sdists that build a different wheel
58
+ # depending on the python version their setup.py is being run on,
59
+ # and don't encode the difference in compatibility tags.
60
+ # https://github.com/pypa/pip/issues/7296
61
+ key_parts["interpreter_name"] = interpreter_name()
62
+ key_parts["interpreter_version"] = interpreter_version()
63
+
64
+ # Encode our key url with sha224, we'll use this because it has similar
65
+ # security properties to sha256, but with a shorter total output (and
66
+ # thus less secure). However the differences don't make a lot of
67
+ # difference for our use case here.
68
+ hashed = _hash_dict(key_parts)
69
+
70
+ # We want to nest the directories some to prevent having a ton of top
71
+ # level directories where we might run out of sub directories on some
72
+ # FS.
73
+ parts = [hashed[:2], hashed[2:4], hashed[4:6], hashed[6:]]
74
+
75
+ return parts
76
+
77
+ def _get_candidates(self, link: Link, canonical_package_name: str) -> list[Any]:
78
+ can_not_cache = not self.cache_dir or not canonical_package_name or not link
79
+ if can_not_cache:
80
+ return []
81
+
82
+ path = self.get_path_for_link(link)
83
+ if os.path.isdir(path):
84
+ return [(candidate, path) for candidate in os.listdir(path)]
85
+ return []
86
+
87
+ def get_path_for_link(self, link: Link) -> str:
88
+ """Return a directory to store cached items in for link."""
89
+ raise NotImplementedError()
90
+
91
+ def get(
92
+ self,
93
+ link: Link,
94
+ package_name: str | None,
95
+ supported_tags: list[Tag],
96
+ ) -> Link:
97
+ """Returns a link to a cached item if it exists, otherwise returns the
98
+ passed link.
99
+ """
100
+ raise NotImplementedError()
101
+
102
+
103
+ class SimpleWheelCache(Cache):
104
+ """A cache of wheels for future installs."""
105
+
106
+ def __init__(self, cache_dir: str) -> None:
107
+ super().__init__(cache_dir)
108
+
109
+ def get_path_for_link(self, link: Link) -> str:
110
+ """Return a directory to store cached wheels for link
111
+
112
+ Because there are M wheels for any one sdist, we provide a directory
113
+ to cache them in, and then consult that directory when looking up
114
+ cache hits.
115
+
116
+ We only insert things into the cache if they have plausible version
117
+ numbers, so that we don't contaminate the cache with things that were
118
+ not unique. E.g. ./package might have dozens of installs done for it
119
+ and build a version of 0.0...and if we built and cached a wheel, we'd
120
+ end up using the same wheel even if the source has been edited.
121
+
122
+ :param link: The link of the sdist for which this will cache wheels.
123
+ """
124
+ parts = self._get_cache_path_parts(link)
125
+ assert self.cache_dir
126
+ # Store wheels within the root cache_dir
127
+ return os.path.join(self.cache_dir, "wheels", *parts)
128
+
129
+ def get(
130
+ self,
131
+ link: Link,
132
+ package_name: str | None,
133
+ supported_tags: list[Tag],
134
+ ) -> Link:
135
+ candidates = []
136
+
137
+ if not package_name:
138
+ return link
139
+
140
+ canonical_package_name = canonicalize_name(package_name)
141
+ for wheel_name, wheel_dir in self._get_candidates(link, canonical_package_name):
142
+ try:
143
+ wheel = Wheel(wheel_name)
144
+ except InvalidWheelFilename:
145
+ continue
146
+ if wheel.name != canonical_package_name:
147
+ logger.debug(
148
+ "Ignoring cached wheel %s for %s as it "
149
+ "does not match the expected distribution name %s.",
150
+ wheel_name,
151
+ link,
152
+ package_name,
153
+ )
154
+ continue
155
+ if not wheel.supported(supported_tags):
156
+ # Built for a different python/arch/etc
157
+ continue
158
+ candidates.append(
159
+ (
160
+ wheel.support_index_min(supported_tags),
161
+ wheel_name,
162
+ wheel_dir,
163
+ )
164
+ )
165
+
166
+ if not candidates:
167
+ return link
168
+
169
+ _, wheel_name, wheel_dir = min(candidates)
170
+ return Link(path_to_url(os.path.join(wheel_dir, wheel_name)))
171
+
172
+
173
+ class EphemWheelCache(SimpleWheelCache):
174
+ """A SimpleWheelCache that creates it's own temporary cache directory"""
175
+
176
+ def __init__(self) -> None:
177
+ self._temp_dir = TempDirectory(
178
+ kind=tempdir_kinds.EPHEM_WHEEL_CACHE,
179
+ globally_managed=True,
180
+ )
181
+
182
+ super().__init__(self._temp_dir.path)
183
+
184
+
185
+ class CacheEntry:
186
+ def __init__(
187
+ self,
188
+ link: Link,
189
+ persistent: bool,
190
+ ):
191
+ self.link = link
192
+ self.persistent = persistent
193
+ self.origin: DirectUrl | None = None
194
+ origin_direct_url_path = Path(self.link.file_path).parent / ORIGIN_JSON_NAME
195
+ if origin_direct_url_path.exists():
196
+ try:
197
+ self.origin = DirectUrl.from_json(
198
+ origin_direct_url_path.read_text(encoding="utf-8")
199
+ )
200
+ except Exception as e:
201
+ logger.warning(
202
+ "Ignoring invalid cache entry origin file %s for %s (%s)",
203
+ origin_direct_url_path,
204
+ link.filename,
205
+ e,
206
+ )
207
+
208
+
209
+ class WheelCache(Cache):
210
+ """Wraps EphemWheelCache and SimpleWheelCache into a single Cache
211
+
212
+ This Cache allows for gracefully degradation, using the ephem wheel cache
213
+ when a certain link is not found in the simple wheel cache first.
214
+ """
215
+
216
+ def __init__(self, cache_dir: str) -> None:
217
+ super().__init__(cache_dir)
218
+ self._wheel_cache = SimpleWheelCache(cache_dir)
219
+ self._ephem_cache = EphemWheelCache()
220
+
221
+ def get_path_for_link(self, link: Link) -> str:
222
+ return self._wheel_cache.get_path_for_link(link)
223
+
224
+ def get_ephem_path_for_link(self, link: Link) -> str:
225
+ return self._ephem_cache.get_path_for_link(link)
226
+
227
+ def get(
228
+ self,
229
+ link: Link,
230
+ package_name: str | None,
231
+ supported_tags: list[Tag],
232
+ ) -> Link:
233
+ cache_entry = self.get_cache_entry(link, package_name, supported_tags)
234
+ if cache_entry is None:
235
+ return link
236
+ return cache_entry.link
237
+
238
+ def get_cache_entry(
239
+ self,
240
+ link: Link,
241
+ package_name: str | None,
242
+ supported_tags: list[Tag],
243
+ ) -> CacheEntry | None:
244
+ """Returns a CacheEntry with a link to a cached item if it exists or
245
+ None. The cache entry indicates if the item was found in the persistent
246
+ or ephemeral cache.
247
+ """
248
+ retval = self._wheel_cache.get(
249
+ link=link,
250
+ package_name=package_name,
251
+ supported_tags=supported_tags,
252
+ )
253
+ if retval is not link:
254
+ return CacheEntry(retval, persistent=True)
255
+
256
+ retval = self._ephem_cache.get(
257
+ link=link,
258
+ package_name=package_name,
259
+ supported_tags=supported_tags,
260
+ )
261
+ if retval is not link:
262
+ return CacheEntry(retval, persistent=False)
263
+
264
+ return None
265
+
266
+ @staticmethod
267
+ def record_download_origin(cache_dir: str, download_info: DirectUrl) -> None:
268
+ origin_path = Path(cache_dir) / ORIGIN_JSON_NAME
269
+ if origin_path.exists():
270
+ try:
271
+ origin = DirectUrl.from_json(origin_path.read_text(encoding="utf-8"))
272
+ except Exception as e:
273
+ logger.warning(
274
+ "Could not read origin file %s in cache entry (%s). "
275
+ "Will attempt to overwrite it.",
276
+ origin_path,
277
+ e,
278
+ )
279
+ else:
280
+ # TODO: use DirectUrl.equivalent when
281
+ # https://github.com/pypa/pip/pull/10564 is merged.
282
+ if origin.url != download_info.url:
283
+ logger.warning(
284
+ "Origin URL %s in cache entry %s does not match download URL "
285
+ "%s. This is likely a pip bug or a cache corruption issue. "
286
+ "Will overwrite it with the new value.",
287
+ origin.url,
288
+ cache_dir,
289
+ download_info.url,
290
+ )
291
+ origin_path.write_text(download_info.to_json(), encoding="utf-8")
python/Lib/site-packages/pip/_internal/configuration.py ADDED
@@ -0,0 +1,396 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """Configuration management setup
2
+
3
+ Some terminology:
4
+ - name
5
+ As written in config files.
6
+ - value
7
+ Value associated with a name
8
+ - key
9
+ Name combined with it's section (section.name)
10
+ - variant
11
+ A single word describing where the configuration key-value pair came from
12
+ """
13
+
14
+ from __future__ import annotations
15
+
16
+ import configparser
17
+ import locale
18
+ import os
19
+ import sys
20
+ from collections.abc import Iterable
21
+ from typing import Any, NewType
22
+
23
+ from pip._internal.exceptions import (
24
+ ConfigurationError,
25
+ ConfigurationFileCouldNotBeLoaded,
26
+ )
27
+ from pip._internal.utils import appdirs
28
+ from pip._internal.utils.compat import WINDOWS
29
+ from pip._internal.utils.logging import getLogger
30
+ from pip._internal.utils.misc import ensure_dir, enum
31
+
32
+ RawConfigParser = configparser.RawConfigParser # Shorthand
33
+ Kind = NewType("Kind", str)
34
+
35
+ CONFIG_BASENAME = "pip.ini" if WINDOWS else "pip.conf"
36
+ ENV_NAMES_IGNORED = "version", "help"
37
+
38
+ # The kinds of configurations there are.
39
+ kinds = enum(
40
+ USER="user", # User Specific
41
+ GLOBAL="global", # System Wide
42
+ SITE="site", # [Virtual] Environment Specific
43
+ ENV="env", # from PIP_CONFIG_FILE
44
+ ENV_VAR="env-var", # from Environment Variables
45
+ )
46
+ OVERRIDE_ORDER = kinds.GLOBAL, kinds.USER, kinds.SITE, kinds.ENV, kinds.ENV_VAR
47
+ VALID_LOAD_ONLY = kinds.USER, kinds.GLOBAL, kinds.SITE
48
+
49
+ logger = getLogger(__name__)
50
+
51
+
52
+ # NOTE: Maybe use the optionx attribute to normalize keynames.
53
+ def _normalize_name(name: str) -> str:
54
+ """Make a name consistent regardless of source (environment or file)"""
55
+ name = name.lower().replace("_", "-")
56
+ name = name.removeprefix("--") # only prefer long opts
57
+ return name
58
+
59
+
60
+ def _disassemble_key(name: str) -> list[str]:
61
+ if "." not in name:
62
+ error_message = (
63
+ "Key does not contain dot separated section and key. "
64
+ f"Perhaps you wanted to use 'global.{name}' instead?"
65
+ )
66
+ raise ConfigurationError(error_message)
67
+ return name.split(".", 1)
68
+
69
+
70
+ def get_configuration_files() -> dict[Kind, list[str]]:
71
+ global_config_files = [
72
+ os.path.join(path, CONFIG_BASENAME) for path in appdirs.site_config_dirs("pip")
73
+ ]
74
+
75
+ site_config_file = os.path.join(sys.prefix, CONFIG_BASENAME)
76
+ legacy_config_file = os.path.join(
77
+ os.path.expanduser("~"),
78
+ "pip" if WINDOWS else ".pip",
79
+ CONFIG_BASENAME,
80
+ )
81
+ new_config_file = os.path.join(appdirs.user_config_dir("pip"), CONFIG_BASENAME)
82
+ return {
83
+ kinds.GLOBAL: global_config_files,
84
+ kinds.SITE: [site_config_file],
85
+ kinds.USER: [legacy_config_file, new_config_file],
86
+ }
87
+
88
+
89
+ class Configuration:
90
+ """Handles management of configuration.
91
+
92
+ Provides an interface to accessing and managing configuration files.
93
+
94
+ This class converts provides an API that takes "section.key-name" style
95
+ keys and stores the value associated with it as "key-name" under the
96
+ section "section".
97
+
98
+ This allows for a clean interface wherein the both the section and the
99
+ key-name are preserved in an easy to manage form in the configuration files
100
+ and the data stored is also nice.
101
+ """
102
+
103
+ def __init__(self, isolated: bool, load_only: Kind | None = None) -> None:
104
+ super().__init__()
105
+
106
+ if load_only is not None and load_only not in VALID_LOAD_ONLY:
107
+ raise ConfigurationError(
108
+ "Got invalid value for load_only - should be one of {}".format(
109
+ ", ".join(map(repr, VALID_LOAD_ONLY))
110
+ )
111
+ )
112
+ self.isolated = isolated
113
+ self.load_only = load_only
114
+
115
+ # Because we keep track of where we got the data from
116
+ self._parsers: dict[Kind, list[tuple[str, RawConfigParser]]] = {
117
+ variant: [] for variant in OVERRIDE_ORDER
118
+ }
119
+ self._config: dict[Kind, dict[str, dict[str, Any]]] = {
120
+ variant: {} for variant in OVERRIDE_ORDER
121
+ }
122
+ self._modified_parsers: list[tuple[str, RawConfigParser]] = []
123
+
124
+ def load(self) -> None:
125
+ """Loads configuration from configuration files and environment"""
126
+ self._load_config_files()
127
+ if not self.isolated:
128
+ self._load_environment_vars()
129
+
130
+ def get_file_to_edit(self) -> str | None:
131
+ """Returns the file with highest priority in configuration"""
132
+ assert self.load_only is not None, "Need to be specified a file to be editing"
133
+
134
+ try:
135
+ return self._get_parser_to_modify()[0]
136
+ except IndexError:
137
+ return None
138
+
139
+ def items(self) -> Iterable[tuple[str, Any]]:
140
+ """Returns key-value pairs like dict.items() representing the loaded
141
+ configuration
142
+ """
143
+ return self._dictionary.items()
144
+
145
+ def get_value(self, key: str) -> Any:
146
+ """Get a value from the configuration."""
147
+ orig_key = key
148
+ key = _normalize_name(key)
149
+ try:
150
+ clean_config: dict[str, Any] = {}
151
+ for file_values in self._dictionary.values():
152
+ clean_config.update(file_values)
153
+ return clean_config[key]
154
+ except KeyError:
155
+ # disassembling triggers a more useful error message than simply
156
+ # "No such key" in the case that the key isn't in the form command.option
157
+ _disassemble_key(key)
158
+ raise ConfigurationError(f"No such key - {orig_key}")
159
+
160
+ def set_value(self, key: str, value: Any) -> None:
161
+ """Modify a value in the configuration."""
162
+ key = _normalize_name(key)
163
+ self._ensure_have_load_only()
164
+
165
+ assert self.load_only
166
+ fname, parser = self._get_parser_to_modify()
167
+
168
+ if parser is not None:
169
+ section, name = _disassemble_key(key)
170
+
171
+ # Modify the parser and the configuration
172
+ if not parser.has_section(section):
173
+ parser.add_section(section)
174
+ parser.set(section, name, value)
175
+
176
+ self._config[self.load_only].setdefault(fname, {})
177
+ self._config[self.load_only][fname][key] = value
178
+ self._mark_as_modified(fname, parser)
179
+
180
+ def unset_value(self, key: str) -> None:
181
+ """Unset a value in the configuration."""
182
+ orig_key = key
183
+ key = _normalize_name(key)
184
+ self._ensure_have_load_only()
185
+
186
+ assert self.load_only
187
+ fname, parser = self._get_parser_to_modify()
188
+
189
+ if (
190
+ key not in self._config[self.load_only][fname]
191
+ and key not in self._config[self.load_only]
192
+ ):
193
+ raise ConfigurationError(f"No such key - {orig_key}")
194
+
195
+ if parser is not None:
196
+ section, name = _disassemble_key(key)
197
+ if not (
198
+ parser.has_section(section) and parser.remove_option(section, name)
199
+ ):
200
+ # The option was not removed.
201
+ raise ConfigurationError(
202
+ "Fatal Internal error [id=1]. Please report as a bug."
203
+ )
204
+
205
+ # The section may be empty after the option was removed.
206
+ if not parser.items(section):
207
+ parser.remove_section(section)
208
+ self._mark_as_modified(fname, parser)
209
+ try:
210
+ del self._config[self.load_only][fname][key]
211
+ except KeyError:
212
+ del self._config[self.load_only][key]
213
+
214
+ def save(self) -> None:
215
+ """Save the current in-memory state."""
216
+ self._ensure_have_load_only()
217
+
218
+ for fname, parser in self._modified_parsers:
219
+ logger.info("Writing to %s", fname)
220
+
221
+ # Ensure directory exists.
222
+ ensure_dir(os.path.dirname(fname))
223
+
224
+ # Ensure directory's permission(need to be writeable)
225
+ try:
226
+ with open(fname, "w") as f:
227
+ parser.write(f)
228
+ except OSError as error:
229
+ raise ConfigurationError(
230
+ f"An error occurred while writing to the configuration file "
231
+ f"{fname}: {error}"
232
+ )
233
+
234
+ #
235
+ # Private routines
236
+ #
237
+
238
+ def _ensure_have_load_only(self) -> None:
239
+ if self.load_only is None:
240
+ raise ConfigurationError("Needed a specific file to be modifying.")
241
+ logger.debug("Will be working with %s variant only", self.load_only)
242
+
243
+ @property
244
+ def _dictionary(self) -> dict[str, dict[str, Any]]:
245
+ """A dictionary representing the loaded configuration."""
246
+ # NOTE: Dictionaries are not populated if not loaded. So, conditionals
247
+ # are not needed here.
248
+ retval = {}
249
+
250
+ for variant in OVERRIDE_ORDER:
251
+ retval.update(self._config[variant])
252
+
253
+ return retval
254
+
255
+ def _load_config_files(self) -> None:
256
+ """Loads configuration from configuration files"""
257
+ config_files = dict(self.iter_config_files())
258
+ if config_files[kinds.ENV][0:1] == [os.devnull]:
259
+ logger.debug(
260
+ "Skipping loading configuration files due to "
261
+ "environment's PIP_CONFIG_FILE being os.devnull"
262
+ )
263
+ return
264
+
265
+ for variant, files in config_files.items():
266
+ for fname in files:
267
+ # If there's specific variant set in `load_only`, load only
268
+ # that variant, not the others.
269
+ if self.load_only is not None and variant != self.load_only:
270
+ logger.debug("Skipping file '%s' (variant: %s)", fname, variant)
271
+ continue
272
+
273
+ parser = self._load_file(variant, fname)
274
+
275
+ # Keeping track of the parsers used
276
+ self._parsers[variant].append((fname, parser))
277
+
278
+ def _load_file(self, variant: Kind, fname: str) -> RawConfigParser:
279
+ logger.verbose("For variant '%s', will try loading '%s'", variant, fname)
280
+ parser = self._construct_parser(fname)
281
+
282
+ for section in parser.sections():
283
+ items = parser.items(section)
284
+ self._config[variant].setdefault(fname, {})
285
+ self._config[variant][fname].update(self._normalized_keys(section, items))
286
+
287
+ return parser
288
+
289
+ def _construct_parser(self, fname: str) -> RawConfigParser:
290
+ parser = configparser.RawConfigParser()
291
+ # If there is no such file, don't bother reading it but create the
292
+ # parser anyway, to hold the data.
293
+ # Doing this is useful when modifying and saving files, where we don't
294
+ # need to construct a parser.
295
+ if os.path.exists(fname):
296
+ locale_encoding = locale.getpreferredencoding(False)
297
+ try:
298
+ parser.read(fname, encoding=locale_encoding)
299
+ except UnicodeDecodeError:
300
+ # See https://github.com/pypa/pip/issues/4963
301
+ raise ConfigurationFileCouldNotBeLoaded(
302
+ reason=f"contains invalid {locale_encoding} characters",
303
+ fname=fname,
304
+ )
305
+ except configparser.Error as error:
306
+ # See https://github.com/pypa/pip/issues/4893
307
+ raise ConfigurationFileCouldNotBeLoaded(error=error)
308
+ return parser
309
+
310
+ def _load_environment_vars(self) -> None:
311
+ """Loads configuration from environment variables"""
312
+ self._config[kinds.ENV_VAR].setdefault(":env:", {})
313
+ self._config[kinds.ENV_VAR][":env:"].update(
314
+ self._normalized_keys(":env:", self.get_environ_vars())
315
+ )
316
+
317
+ def _normalized_keys(
318
+ self, section: str, items: Iterable[tuple[str, Any]]
319
+ ) -> dict[str, Any]:
320
+ """Normalizes items to construct a dictionary with normalized keys.
321
+
322
+ This routine is where the names become keys and are made the same
323
+ regardless of source - configuration files or environment.
324
+ """
325
+ normalized = {}
326
+ for name, val in items:
327
+ key = section + "." + _normalize_name(name)
328
+ normalized[key] = val
329
+ return normalized
330
+
331
+ def get_environ_vars(self) -> Iterable[tuple[str, str]]:
332
+ """Returns a generator with all environmental vars with prefix PIP_"""
333
+ for key, val in os.environ.items():
334
+ if key.startswith("PIP_"):
335
+ name = key[4:].lower()
336
+ if name not in ENV_NAMES_IGNORED:
337
+ yield name, val
338
+
339
+ # XXX: This is patched in the tests.
340
+ def iter_config_files(self) -> Iterable[tuple[Kind, list[str]]]:
341
+ """Yields variant and configuration files associated with it.
342
+
343
+ This should be treated like items of a dictionary. The order
344
+ here doesn't affect what gets overridden. That is controlled
345
+ by OVERRIDE_ORDER. However this does control the order they are
346
+ displayed to the user. It's probably most ergonomic to display
347
+ things in the same order as OVERRIDE_ORDER
348
+ """
349
+ # SMELL: Move the conditions out of this function
350
+
351
+ env_config_file = os.environ.get("PIP_CONFIG_FILE", None)
352
+ config_files = get_configuration_files()
353
+
354
+ yield kinds.GLOBAL, config_files[kinds.GLOBAL]
355
+
356
+ # per-user config is not loaded when env_config_file exists
357
+ should_load_user_config = not self.isolated and not (
358
+ env_config_file and os.path.exists(env_config_file)
359
+ )
360
+ if should_load_user_config:
361
+ # The legacy config file is overridden by the new config file
362
+ yield kinds.USER, config_files[kinds.USER]
363
+
364
+ # virtualenv config
365
+ yield kinds.SITE, config_files[kinds.SITE]
366
+
367
+ if env_config_file is not None:
368
+ yield kinds.ENV, [env_config_file]
369
+ else:
370
+ yield kinds.ENV, []
371
+
372
+ def get_values_in_config(self, variant: Kind) -> dict[str, Any]:
373
+ """Get values present in a config file"""
374
+ return self._config[variant]
375
+
376
+ def _get_parser_to_modify(self) -> tuple[str, RawConfigParser]:
377
+ # Determine which parser to modify
378
+ assert self.load_only
379
+ parsers = self._parsers[self.load_only]
380
+ if not parsers:
381
+ # This should not happen if everything works correctly.
382
+ raise ConfigurationError(
383
+ "Fatal Internal error [id=2]. Please report as a bug."
384
+ )
385
+
386
+ # Use the highest priority parser.
387
+ return parsers[-1]
388
+
389
+ # XXX: This is patched in the tests.
390
+ def _mark_as_modified(self, fname: str, parser: RawConfigParser) -> None:
391
+ file_parser_tuple = (fname, parser)
392
+ if file_parser_tuple not in self._modified_parsers:
393
+ self._modified_parsers.append(file_parser_tuple)
394
+
395
+ def __repr__(self) -> str:
396
+ return f"{self.__class__.__name__}({self._dictionary!r})"
python/Lib/site-packages/pip/_internal/exceptions.py ADDED
@@ -0,0 +1,971 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """Exceptions used throughout package.
2
+
3
+ This module MUST NOT try to import from anything within `pip._internal` to
4
+ operate. This is expected to be importable from any/all files within the
5
+ subpackage and, thus, should not depend on them.
6
+ """
7
+
8
+ from __future__ import annotations
9
+
10
+ import configparser
11
+ import contextlib
12
+ import locale
13
+ import logging
14
+ import pathlib
15
+ import re
16
+ import sys
17
+ import traceback
18
+ from collections.abc import Iterable, Iterator
19
+ from itertools import chain, groupby, repeat
20
+ from typing import TYPE_CHECKING, Literal
21
+
22
+ from pip._vendor.packaging.requirements import InvalidRequirement
23
+ from pip._vendor.packaging.version import InvalidVersion
24
+ from pip._vendor.rich.console import Console, ConsoleOptions, RenderResult
25
+ from pip._vendor.rich.markup import escape
26
+ from pip._vendor.rich.text import Text
27
+
28
+ if TYPE_CHECKING:
29
+ from hashlib import _Hash
30
+
31
+ from pip._vendor.requests.models import PreparedRequest, Request, Response
32
+
33
+ from pip._internal.metadata import BaseDistribution
34
+ from pip._internal.models.link import Link
35
+ from pip._internal.network.download import _FileDownload
36
+ from pip._internal.req.req_install import InstallRequirement
37
+
38
+ logger = logging.getLogger(__name__)
39
+
40
+
41
+ #
42
+ # Scaffolding
43
+ #
44
+ def _is_kebab_case(s: str) -> bool:
45
+ return re.match(r"^[a-z]+(-[a-z]+)*$", s) is not None
46
+
47
+
48
+ def _prefix_with_indent(
49
+ s: Text | str,
50
+ console: Console,
51
+ *,
52
+ prefix: str,
53
+ indent: str,
54
+ ) -> Text:
55
+ if isinstance(s, Text):
56
+ text = s
57
+ else:
58
+ text = console.render_str(s)
59
+
60
+ return console.render_str(prefix, overflow="ignore") + console.render_str(
61
+ f"\n{indent}", overflow="ignore"
62
+ ).join(text.split(allow_blank=True))
63
+
64
+
65
+ class PipError(Exception):
66
+ """The base pip error."""
67
+
68
+
69
+ class DiagnosticPipError(PipError):
70
+ """An error, that presents diagnostic information to the user.
71
+
72
+ This contains a bunch of logic, to enable pretty presentation of our error
73
+ messages. Each error gets a unique reference. Each error can also include
74
+ additional context, a hint and/or a note -- which are presented with the
75
+ main error message in a consistent style.
76
+
77
+ This is adapted from the error output styling in `sphinx-theme-builder`.
78
+ """
79
+
80
+ reference: str
81
+
82
+ def __init__(
83
+ self,
84
+ *,
85
+ kind: Literal["error", "warning"] = "error",
86
+ reference: str | None = None,
87
+ message: str | Text,
88
+ context: str | Text | None,
89
+ hint_stmt: str | Text | None,
90
+ note_stmt: str | Text | None = None,
91
+ link: str | None = None,
92
+ ) -> None:
93
+ # Ensure a proper reference is provided.
94
+ if reference is None:
95
+ assert hasattr(self, "reference"), "error reference not provided!"
96
+ reference = self.reference
97
+ assert _is_kebab_case(reference), "error reference must be kebab-case!"
98
+
99
+ self.kind = kind
100
+ self.reference = reference
101
+
102
+ self.message = message
103
+ self.context = context
104
+
105
+ self.note_stmt = note_stmt
106
+ self.hint_stmt = hint_stmt
107
+
108
+ self.link = link
109
+
110
+ super().__init__(f"<{self.__class__.__name__}: {self.reference}>")
111
+
112
+ def __repr__(self) -> str:
113
+ return (
114
+ f"<{self.__class__.__name__}("
115
+ f"reference={self.reference!r}, "
116
+ f"message={self.message!r}, "
117
+ f"context={self.context!r}, "
118
+ f"note_stmt={self.note_stmt!r}, "
119
+ f"hint_stmt={self.hint_stmt!r}"
120
+ ")>"
121
+ )
122
+
123
+ def __rich_console__(
124
+ self,
125
+ console: Console,
126
+ options: ConsoleOptions,
127
+ ) -> RenderResult:
128
+ colour = "red" if self.kind == "error" else "yellow"
129
+
130
+ yield f"[{colour} bold]{self.kind}[/]: [bold]{self.reference}[/]"
131
+ yield ""
132
+
133
+ if not options.ascii_only:
134
+ # Present the main message, with relevant context indented.
135
+ if self.context is not None:
136
+ yield _prefix_with_indent(
137
+ self.message,
138
+ console,
139
+ prefix=f"[{colour}]×[/] ",
140
+ indent=f"[{colour}]│[/] ",
141
+ )
142
+ yield _prefix_with_indent(
143
+ self.context,
144
+ console,
145
+ prefix=f"[{colour}]╰─>[/] ",
146
+ indent=f"[{colour}] [/] ",
147
+ )
148
+ else:
149
+ yield _prefix_with_indent(
150
+ self.message,
151
+ console,
152
+ prefix="[red]×[/] ",
153
+ indent=" ",
154
+ )
155
+ else:
156
+ yield self.message
157
+ if self.context is not None:
158
+ yield ""
159
+ yield self.context
160
+
161
+ if self.note_stmt is not None or self.hint_stmt is not None:
162
+ yield ""
163
+
164
+ if self.note_stmt is not None:
165
+ yield _prefix_with_indent(
166
+ self.note_stmt,
167
+ console,
168
+ prefix="[magenta bold]note[/]: ",
169
+ indent=" ",
170
+ )
171
+ if self.hint_stmt is not None:
172
+ yield _prefix_with_indent(
173
+ self.hint_stmt,
174
+ console,
175
+ prefix="[cyan bold]hint[/]: ",
176
+ indent=" ",
177
+ )
178
+
179
+ if self.link is not None:
180
+ yield ""
181
+ yield f"Link: {self.link}"
182
+
183
+
184
+ #
185
+ # Actual Errors
186
+ #
187
+ class ConfigurationError(PipError):
188
+ """General exception in configuration"""
189
+
190
+
191
+ class InstallationError(PipError):
192
+ """General exception during installation"""
193
+
194
+
195
+ class FailedToPrepareCandidate(InstallationError):
196
+ """Raised when we fail to prepare a candidate (i.e. fetch and generate metadata).
197
+
198
+ This is intentionally not a diagnostic error, since the output will be presented
199
+ above this error, when this occurs. This should instead present information to the
200
+ user.
201
+ """
202
+
203
+ def __init__(
204
+ self, *, package_name: str, requirement_chain: str, failed_step: str
205
+ ) -> None:
206
+ super().__init__(f"Failed to build '{package_name}' when {failed_step.lower()}")
207
+ self.package_name = package_name
208
+ self.requirement_chain = requirement_chain
209
+ self.failed_step = failed_step
210
+
211
+
212
+ class MissingPyProjectBuildRequires(DiagnosticPipError):
213
+ """Raised when pyproject.toml has `build-system`, but no `build-system.requires`."""
214
+
215
+ reference = "missing-pyproject-build-system-requires"
216
+
217
+ def __init__(self, *, package: str) -> None:
218
+ super().__init__(
219
+ message=f"Can not process {escape(package)}",
220
+ context=Text(
221
+ "This package has an invalid pyproject.toml file.\n"
222
+ "The [build-system] table is missing the mandatory `requires` key."
223
+ ),
224
+ note_stmt="This is an issue with the package mentioned above, not pip.",
225
+ hint_stmt=Text("See PEP 518 for the detailed specification."),
226
+ )
227
+
228
+
229
+ class InvalidPyProjectBuildRequires(DiagnosticPipError):
230
+ """Raised when pyproject.toml an invalid `build-system.requires`."""
231
+
232
+ reference = "invalid-pyproject-build-system-requires"
233
+
234
+ def __init__(self, *, package: str, reason: str) -> None:
235
+ super().__init__(
236
+ message=f"Can not process {escape(package)}",
237
+ context=Text(
238
+ "This package has an invalid `build-system.requires` key in "
239
+ f"pyproject.toml.\n{reason}"
240
+ ),
241
+ note_stmt="This is an issue with the package mentioned above, not pip.",
242
+ hint_stmt=Text("See PEP 518 for the detailed specification."),
243
+ )
244
+
245
+
246
+ class NoneMetadataError(PipError):
247
+ """Raised when accessing a Distribution's "METADATA" or "PKG-INFO".
248
+
249
+ This signifies an inconsistency, when the Distribution claims to have
250
+ the metadata file (if not, raise ``FileNotFoundError`` instead), but is
251
+ not actually able to produce its content. This may be due to permission
252
+ errors.
253
+ """
254
+
255
+ def __init__(
256
+ self,
257
+ dist: BaseDistribution,
258
+ metadata_name: str,
259
+ ) -> None:
260
+ """
261
+ :param dist: A Distribution object.
262
+ :param metadata_name: The name of the metadata being accessed
263
+ (can be "METADATA" or "PKG-INFO").
264
+ """
265
+ self.dist = dist
266
+ self.metadata_name = metadata_name
267
+
268
+ def __str__(self) -> str:
269
+ # Use `dist` in the error message because its stringification
270
+ # includes more information, like the version and location.
271
+ return f"None {self.metadata_name} metadata found for distribution: {self.dist}"
272
+
273
+
274
+ class UserInstallationInvalid(InstallationError):
275
+ """A --user install is requested on an environment without user site."""
276
+
277
+ def __str__(self) -> str:
278
+ return "User base directory is not specified"
279
+
280
+
281
+ class InvalidSchemeCombination(InstallationError):
282
+ def __str__(self) -> str:
283
+ before = ", ".join(str(a) for a in self.args[:-1])
284
+ return f"Cannot set {before} and {self.args[-1]} together"
285
+
286
+
287
+ class DistributionNotFound(InstallationError):
288
+ """Raised when a distribution cannot be found to satisfy a requirement"""
289
+
290
+
291
+ class RequirementsFileParseError(InstallationError):
292
+ """Raised when a general error occurs parsing a requirements file line."""
293
+
294
+
295
+ class BestVersionAlreadyInstalled(PipError):
296
+ """Raised when the most up-to-date version of a package is already
297
+ installed."""
298
+
299
+
300
+ class BadCommand(PipError):
301
+ """Raised when virtualenv or a command is not found"""
302
+
303
+
304
+ class CommandError(PipError):
305
+ """Raised when there is an error in command-line arguments"""
306
+
307
+
308
+ class PreviousBuildDirError(PipError):
309
+ """Raised when there's a previous conflicting build directory"""
310
+
311
+
312
+ class NetworkConnectionError(PipError):
313
+ """HTTP connection error"""
314
+
315
+ def __init__(
316
+ self,
317
+ error_msg: str,
318
+ response: Response | None = None,
319
+ request: Request | PreparedRequest | None = None,
320
+ ) -> None:
321
+ """
322
+ Initialize NetworkConnectionError with `request` and `response`
323
+ objects.
324
+ """
325
+ self.response = response
326
+ self.request = request
327
+ self.error_msg = error_msg
328
+ if (
329
+ self.response is not None
330
+ and not self.request
331
+ and hasattr(response, "request")
332
+ ):
333
+ self.request = self.response.request
334
+ super().__init__(error_msg, response, request)
335
+
336
+ def __str__(self) -> str:
337
+ return str(self.error_msg)
338
+
339
+
340
+ class InvalidWheelFilename(InstallationError):
341
+ """Invalid wheel filename."""
342
+
343
+
344
+ class UnsupportedWheel(InstallationError):
345
+ """Unsupported wheel."""
346
+
347
+
348
+ class InvalidWheel(InstallationError):
349
+ """Invalid (e.g. corrupt) wheel."""
350
+
351
+ def __init__(self, location: str, name: str):
352
+ self.location = location
353
+ self.name = name
354
+
355
+ def __str__(self) -> str:
356
+ return f"Wheel '{self.name}' located at {self.location} is invalid."
357
+
358
+
359
+ class MetadataInconsistent(InstallationError):
360
+ """Built metadata contains inconsistent information.
361
+
362
+ This is raised when the metadata contains values (e.g. name and version)
363
+ that do not match the information previously obtained from sdist filename,
364
+ user-supplied ``#egg=`` value, or an install requirement name.
365
+ """
366
+
367
+ def __init__(
368
+ self, ireq: InstallRequirement, field: str, f_val: str, m_val: str
369
+ ) -> None:
370
+ self.ireq = ireq
371
+ self.field = field
372
+ self.f_val = f_val
373
+ self.m_val = m_val
374
+
375
+ def __str__(self) -> str:
376
+ return (
377
+ f"Requested {self.ireq} has inconsistent {self.field}: "
378
+ f"expected {self.f_val!r}, but metadata has {self.m_val!r}"
379
+ )
380
+
381
+
382
+ class MetadataInvalid(InstallationError):
383
+ """Metadata is invalid."""
384
+
385
+ def __init__(self, ireq: InstallRequirement, error: str) -> None:
386
+ self.ireq = ireq
387
+ self.error = error
388
+
389
+ def __str__(self) -> str:
390
+ return f"Requested {self.ireq} has invalid metadata: {self.error}"
391
+
392
+
393
+ class InstallationSubprocessError(DiagnosticPipError, InstallationError):
394
+ """A subprocess call failed."""
395
+
396
+ reference = "subprocess-exited-with-error"
397
+
398
+ def __init__(
399
+ self,
400
+ *,
401
+ command_description: str,
402
+ exit_code: int,
403
+ output_lines: list[str] | None,
404
+ ) -> None:
405
+ if output_lines is None:
406
+ output_prompt = Text("No available output.")
407
+ else:
408
+ output_prompt = (
409
+ Text.from_markup(f"[red][{len(output_lines)} lines of output][/]\n")
410
+ + Text("".join(output_lines))
411
+ + Text.from_markup(R"[red]\[end of output][/]")
412
+ )
413
+
414
+ super().__init__(
415
+ message=(
416
+ f"[green]{escape(command_description)}[/] did not run successfully.\n"
417
+ f"exit code: {exit_code}"
418
+ ),
419
+ context=output_prompt,
420
+ hint_stmt=None,
421
+ note_stmt=(
422
+ "This error originates from a subprocess, and is likely not a "
423
+ "problem with pip."
424
+ ),
425
+ )
426
+
427
+ self.command_description = command_description
428
+ self.exit_code = exit_code
429
+
430
+ def __str__(self) -> str:
431
+ return f"{self.command_description} exited with {self.exit_code}"
432
+
433
+
434
+ class MetadataGenerationFailed(DiagnosticPipError, InstallationError):
435
+ reference = "metadata-generation-failed"
436
+
437
+ def __init__(
438
+ self,
439
+ *,
440
+ package_details: str,
441
+ ) -> None:
442
+ super().__init__(
443
+ message="Encountered error while generating package metadata.",
444
+ context=escape(package_details),
445
+ hint_stmt="See above for details.",
446
+ note_stmt="This is an issue with the package mentioned above, not pip.",
447
+ )
448
+
449
+ def __str__(self) -> str:
450
+ return "metadata generation failed"
451
+
452
+
453
+ class HashErrors(InstallationError):
454
+ """Multiple HashError instances rolled into one for reporting"""
455
+
456
+ def __init__(self) -> None:
457
+ self.errors: list[HashError] = []
458
+
459
+ def append(self, error: HashError) -> None:
460
+ self.errors.append(error)
461
+
462
+ def __str__(self) -> str:
463
+ lines = []
464
+ self.errors.sort(key=lambda e: e.order)
465
+ for cls, errors_of_cls in groupby(self.errors, lambda e: e.__class__):
466
+ lines.append(cls.head)
467
+ lines.extend(e.body() for e in errors_of_cls)
468
+ if lines:
469
+ return "\n".join(lines)
470
+ return ""
471
+
472
+ def __bool__(self) -> bool:
473
+ return bool(self.errors)
474
+
475
+
476
+ class HashError(InstallationError):
477
+ """
478
+ A failure to verify a package against known-good hashes
479
+
480
+ :cvar order: An int sorting hash exception classes by difficulty of
481
+ recovery (lower being harder), so the user doesn't bother fretting
482
+ about unpinned packages when he has deeper issues, like VCS
483
+ dependencies, to deal with. Also keeps error reports in a
484
+ deterministic order.
485
+ :cvar head: A section heading for display above potentially many
486
+ exceptions of this kind
487
+ :ivar req: The InstallRequirement that triggered this error. This is
488
+ pasted on after the exception is instantiated, because it's not
489
+ typically available earlier.
490
+
491
+ """
492
+
493
+ req: InstallRequirement | None = None
494
+ head = ""
495
+ order: int = -1
496
+
497
+ def body(self) -> str:
498
+ """Return a summary of me for display under the heading.
499
+
500
+ This default implementation simply prints a description of the
501
+ triggering requirement.
502
+
503
+ :param req: The InstallRequirement that provoked this error, with
504
+ its link already populated by the resolver's _populate_link().
505
+
506
+ """
507
+ return f" {self._requirement_name()}"
508
+
509
+ def __str__(self) -> str:
510
+ return f"{self.head}\n{self.body()}"
511
+
512
+ def _requirement_name(self) -> str:
513
+ """Return a description of the requirement that triggered me.
514
+
515
+ This default implementation returns long description of the req, with
516
+ line numbers
517
+
518
+ """
519
+ return str(self.req) if self.req else "unknown package"
520
+
521
+
522
+ class VcsHashUnsupported(HashError):
523
+ """A hash was provided for a version-control-system-based requirement, but
524
+ we don't have a method for hashing those."""
525
+
526
+ order = 0
527
+ head = (
528
+ "Can't verify hashes for these requirements because we don't "
529
+ "have a way to hash version control repositories:"
530
+ )
531
+
532
+
533
+ class DirectoryUrlHashUnsupported(HashError):
534
+ """A hash was provided for a version-control-system-based requirement, but
535
+ we don't have a method for hashing those."""
536
+
537
+ order = 1
538
+ head = (
539
+ "Can't verify hashes for these file:// requirements because they "
540
+ "point to directories:"
541
+ )
542
+
543
+
544
+ class HashMissing(HashError):
545
+ """A hash was needed for a requirement but is absent."""
546
+
547
+ order = 2
548
+ head = (
549
+ "Hashes are required in --require-hashes mode, but they are "
550
+ "missing from some requirements. Here is a list of those "
551
+ "requirements along with the hashes their downloaded archives "
552
+ "actually had. Add lines like these to your requirements files to "
553
+ "prevent tampering. (If you did not enable --require-hashes "
554
+ "manually, note that it turns on automatically when any package "
555
+ "has a hash.)"
556
+ )
557
+
558
+ def __init__(self, gotten_hash: str) -> None:
559
+ """
560
+ :param gotten_hash: The hash of the (possibly malicious) archive we
561
+ just downloaded
562
+ """
563
+ self.gotten_hash = gotten_hash
564
+
565
+ def body(self) -> str:
566
+ # Dodge circular import.
567
+ from pip._internal.utils.hashes import FAVORITE_HASH
568
+
569
+ package = None
570
+ if self.req:
571
+ # In the case of URL-based requirements, display the original URL
572
+ # seen in the requirements file rather than the package name,
573
+ # so the output can be directly copied into the requirements file.
574
+ package = (
575
+ self.req.original_link
576
+ if self.req.is_direct
577
+ # In case someone feeds something downright stupid
578
+ # to InstallRequirement's constructor.
579
+ else getattr(self.req, "req", None)
580
+ )
581
+ return " {} --hash={}:{}".format(
582
+ package or "unknown package", FAVORITE_HASH, self.gotten_hash
583
+ )
584
+
585
+
586
+ class HashUnpinned(HashError):
587
+ """A requirement had a hash specified but was not pinned to a specific
588
+ version."""
589
+
590
+ order = 3
591
+ head = (
592
+ "In --require-hashes mode, all requirements must have their "
593
+ "versions pinned with ==. These do not:"
594
+ )
595
+
596
+
597
+ class HashMismatch(HashError):
598
+ """
599
+ Distribution file hash values don't match.
600
+
601
+ :ivar package_name: The name of the package that triggered the hash
602
+ mismatch. Feel free to write to this after the exception is raise to
603
+ improve its error message.
604
+
605
+ """
606
+
607
+ order = 4
608
+ head = (
609
+ "THESE PACKAGES DO NOT MATCH THE HASHES FROM THE REQUIREMENTS "
610
+ "FILE. If you have updated the package versions, please update "
611
+ "the hashes. Otherwise, examine the package contents carefully; "
612
+ "someone may have tampered with them."
613
+ )
614
+
615
+ def __init__(self, allowed: dict[str, list[str]], gots: dict[str, _Hash]) -> None:
616
+ """
617
+ :param allowed: A dict of algorithm names pointing to lists of allowed
618
+ hex digests
619
+ :param gots: A dict of algorithm names pointing to hashes we
620
+ actually got from the files under suspicion
621
+ """
622
+ self.allowed = allowed
623
+ self.gots = gots
624
+
625
+ def body(self) -> str:
626
+ return f" {self._requirement_name()}:\n{self._hash_comparison()}"
627
+
628
+ def _hash_comparison(self) -> str:
629
+ """
630
+ Return a comparison of actual and expected hash values.
631
+
632
+ Example::
633
+
634
+ Expected sha256 abcdeabcdeabcdeabcdeabcdeabcdeabcdeabcdeabcde
635
+ or 123451234512345123451234512345123451234512345
636
+ Got bcdefbcdefbcdefbcdefbcdefbcdefbcdefbcdefbcdef
637
+
638
+ """
639
+
640
+ def hash_then_or(hash_name: str) -> chain[str]:
641
+ # For now, all the decent hashes have 6-char names, so we can get
642
+ # away with hard-coding space literals.
643
+ return chain([hash_name], repeat(" or"))
644
+
645
+ lines: list[str] = []
646
+ for hash_name, expecteds in self.allowed.items():
647
+ prefix = hash_then_or(hash_name)
648
+ lines.extend((f" Expected {next(prefix)} {e}") for e in expecteds)
649
+ lines.append(
650
+ f" Got {self.gots[hash_name].hexdigest()}\n"
651
+ )
652
+ return "\n".join(lines)
653
+
654
+
655
+ class UnsupportedPythonVersion(InstallationError):
656
+ """Unsupported python version according to Requires-Python package
657
+ metadata."""
658
+
659
+
660
+ class ConfigurationFileCouldNotBeLoaded(ConfigurationError):
661
+ """When there are errors while loading a configuration file"""
662
+
663
+ def __init__(
664
+ self,
665
+ reason: str = "could not be loaded",
666
+ fname: str | None = None,
667
+ error: configparser.Error | None = None,
668
+ ) -> None:
669
+ super().__init__(error)
670
+ self.reason = reason
671
+ self.fname = fname
672
+ self.error = error
673
+
674
+ def __str__(self) -> str:
675
+ if self.fname is not None:
676
+ message_part = f" in {self.fname}."
677
+ else:
678
+ assert self.error is not None
679
+ message_part = f".\n{self.error}\n"
680
+ return f"Configuration file {self.reason}{message_part}"
681
+
682
+
683
+ _DEFAULT_EXTERNALLY_MANAGED_ERROR = f"""\
684
+ The Python environment under {sys.prefix} is managed externally, and may not be
685
+ manipulated by the user. Please use specific tooling from the distributor of
686
+ the Python installation to interact with this environment instead.
687
+ """
688
+
689
+
690
+ class ExternallyManagedEnvironment(DiagnosticPipError):
691
+ """The current environment is externally managed.
692
+
693
+ This is raised when the current environment is externally managed, as
694
+ defined by `PEP 668`_. The ``EXTERNALLY-MANAGED`` configuration is checked
695
+ and displayed when the error is bubbled up to the user.
696
+
697
+ :param error: The error message read from ``EXTERNALLY-MANAGED``.
698
+ """
699
+
700
+ reference = "externally-managed-environment"
701
+
702
+ def __init__(self, error: str | None) -> None:
703
+ if error is None:
704
+ context = Text(_DEFAULT_EXTERNALLY_MANAGED_ERROR)
705
+ else:
706
+ context = Text(error)
707
+ super().__init__(
708
+ message="This environment is externally managed",
709
+ context=context,
710
+ note_stmt=(
711
+ "If you believe this is a mistake, please contact your "
712
+ "Python installation or OS distribution provider. "
713
+ "You can override this, at the risk of breaking your Python "
714
+ "installation or OS, by passing --break-system-packages."
715
+ ),
716
+ hint_stmt=Text("See PEP 668 for the detailed specification."),
717
+ )
718
+
719
+ @staticmethod
720
+ def _iter_externally_managed_error_keys() -> Iterator[str]:
721
+ # LC_MESSAGES is in POSIX, but not the C standard. The most common
722
+ # platform that does not implement this category is Windows, where
723
+ # using other categories for console message localization is equally
724
+ # unreliable, so we fall back to the locale-less vendor message. This
725
+ # can always be re-evaluated when a vendor proposes a new alternative.
726
+ try:
727
+ category = locale.LC_MESSAGES
728
+ except AttributeError:
729
+ lang: str | None = None
730
+ else:
731
+ lang, _ = locale.getlocale(category)
732
+ if lang is not None:
733
+ yield f"Error-{lang}"
734
+ for sep in ("-", "_"):
735
+ before, found, _ = lang.partition(sep)
736
+ if not found:
737
+ continue
738
+ yield f"Error-{before}"
739
+ yield "Error"
740
+
741
+ @classmethod
742
+ def from_config(
743
+ cls,
744
+ config: pathlib.Path | str,
745
+ ) -> ExternallyManagedEnvironment:
746
+ parser = configparser.ConfigParser(interpolation=None)
747
+ try:
748
+ parser.read(config, encoding="utf-8")
749
+ section = parser["externally-managed"]
750
+ for key in cls._iter_externally_managed_error_keys():
751
+ with contextlib.suppress(KeyError):
752
+ return cls(section[key])
753
+ except KeyError:
754
+ pass
755
+ except (OSError, UnicodeDecodeError, configparser.ParsingError):
756
+ from pip._internal.utils._log import VERBOSE
757
+
758
+ exc_info = logger.isEnabledFor(VERBOSE)
759
+ logger.warning("Failed to read %s", config, exc_info=exc_info)
760
+ return cls(None)
761
+
762
+
763
+ class UninstallMissingRecord(DiagnosticPipError):
764
+ reference = "uninstall-no-record-file"
765
+
766
+ def __init__(self, *, distribution: BaseDistribution) -> None:
767
+ installer = distribution.installer
768
+ if not installer or installer == "pip":
769
+ dep = f"{distribution.raw_name}=={distribution.version}"
770
+ hint = Text.assemble(
771
+ "You might be able to recover from this via: ",
772
+ (f"pip install --ignore-installed --no-deps {dep}", "green"),
773
+ )
774
+ else:
775
+ hint = Text(
776
+ f"The package was installed by {installer}. "
777
+ "You should check if it can uninstall the package."
778
+ )
779
+
780
+ super().__init__(
781
+ message=Text(f"Cannot uninstall {distribution}"),
782
+ context=(
783
+ "The package's contents are unknown: "
784
+ f"no RECORD file was found for {distribution.raw_name}."
785
+ ),
786
+ hint_stmt=hint,
787
+ )
788
+
789
+
790
+ class LegacyDistutilsInstall(DiagnosticPipError):
791
+ reference = "uninstall-distutils-installed-package"
792
+
793
+ def __init__(self, *, distribution: BaseDistribution) -> None:
794
+ super().__init__(
795
+ message=Text(f"Cannot uninstall {distribution}"),
796
+ context=(
797
+ "It is a distutils installed project and thus we cannot accurately "
798
+ "determine which files belong to it which would lead to only a partial "
799
+ "uninstall."
800
+ ),
801
+ hint_stmt=None,
802
+ )
803
+
804
+
805
+ class InvalidInstalledPackage(DiagnosticPipError):
806
+ reference = "invalid-installed-package"
807
+
808
+ def __init__(
809
+ self,
810
+ *,
811
+ dist: BaseDistribution,
812
+ invalid_exc: InvalidRequirement | InvalidVersion,
813
+ ) -> None:
814
+ installed_location = dist.installed_location
815
+
816
+ if isinstance(invalid_exc, InvalidRequirement):
817
+ invalid_type = "requirement"
818
+ else:
819
+ invalid_type = "version"
820
+
821
+ super().__init__(
822
+ message=Text(
823
+ f"Cannot process installed package {dist} "
824
+ + (f"in {installed_location!r} " if installed_location else "")
825
+ + f"because it has an invalid {invalid_type}:\n{invalid_exc.args[0]}"
826
+ ),
827
+ context=(
828
+ "Starting with pip 24.1, packages with invalid "
829
+ f"{invalid_type}s can not be processed."
830
+ ),
831
+ hint_stmt="To proceed this package must be uninstalled.",
832
+ )
833
+
834
+
835
+ class IncompleteDownloadError(DiagnosticPipError):
836
+ """Raised when the downloader receives fewer bytes than advertised
837
+ in the Content-Length header."""
838
+
839
+ reference = "incomplete-download"
840
+
841
+ def __init__(self, download: _FileDownload) -> None:
842
+ # Dodge circular import.
843
+ from pip._internal.utils.misc import format_size
844
+
845
+ assert download.size is not None
846
+ download_status = (
847
+ f"{format_size(download.bytes_received)}/{format_size(download.size)}"
848
+ )
849
+ if download.reattempts:
850
+ retry_status = f"after {download.reattempts + 1} attempts "
851
+ hint = "Use --resume-retries to configure resume attempt limit."
852
+ else:
853
+ # Download retrying is not enabled.
854
+ retry_status = ""
855
+ hint = "Consider using --resume-retries to enable download resumption."
856
+ message = Text(
857
+ f"Download failed {retry_status}because not enough bytes "
858
+ f"were received ({download_status})"
859
+ )
860
+
861
+ super().__init__(
862
+ message=message,
863
+ context=f"URL: {download.link.redacted_url}",
864
+ hint_stmt=hint,
865
+ note_stmt="This is an issue with network connectivity, not pip.",
866
+ )
867
+
868
+
869
+ class ResolutionTooDeepError(DiagnosticPipError):
870
+ """Raised when the dependency resolver exceeds the maximum recursion depth."""
871
+
872
+ reference = "resolution-too-deep"
873
+
874
+ def __init__(self) -> None:
875
+ super().__init__(
876
+ message="Dependency resolution exceeded maximum depth",
877
+ context=(
878
+ "Pip cannot resolve the current dependencies as the dependency graph "
879
+ "is too complex for pip to solve efficiently."
880
+ ),
881
+ hint_stmt=(
882
+ "Try adding lower bounds to constrain your dependencies, "
883
+ "for example: 'package>=2.0.0' instead of just 'package'. "
884
+ ),
885
+ link="https://pip.pypa.io/en/stable/topics/dependency-resolution/#handling-resolution-too-deep-errors",
886
+ )
887
+
888
+
889
+ class InstallWheelBuildError(DiagnosticPipError):
890
+ reference = "failed-wheel-build-for-install"
891
+
892
+ def __init__(self, failed: list[InstallRequirement]) -> None:
893
+ super().__init__(
894
+ message=(
895
+ "Failed to build installable wheels for some "
896
+ "pyproject.toml based projects"
897
+ ),
898
+ context=", ".join(r.name for r in failed), # type: ignore
899
+ hint_stmt=None,
900
+ )
901
+
902
+
903
+ class InvalidEggFragment(DiagnosticPipError):
904
+ reference = "invalid-egg-fragment"
905
+
906
+ def __init__(self, link: Link, fragment: str) -> None:
907
+ hint = ""
908
+ if ">" in fragment or "=" in fragment or "<" in fragment:
909
+ hint = (
910
+ "Version specifiers are silently ignored for URL references. "
911
+ "Remove them. "
912
+ )
913
+ if "[" in fragment and "]" in fragment:
914
+ hint += "Try using the Direct URL requirement syntax: 'name[extra] @ URL'"
915
+
916
+ if not hint:
917
+ hint = "Egg fragments can only be a valid project name."
918
+
919
+ super().__init__(
920
+ message=f"The '{escape(fragment)}' egg fragment is invalid",
921
+ context=f"from '{escape(str(link))}'",
922
+ hint_stmt=escape(hint),
923
+ )
924
+
925
+
926
+ class BuildDependencyInstallError(DiagnosticPipError):
927
+ """Raised when build dependencies cannot be installed."""
928
+
929
+ reference = "failed-build-dependency-install"
930
+
931
+ def __init__(
932
+ self,
933
+ req: InstallRequirement | None,
934
+ build_reqs: Iterable[str],
935
+ *,
936
+ cause: Exception,
937
+ log_lines: list[str] | None,
938
+ ) -> None:
939
+ if isinstance(cause, PipError):
940
+ note = "This is likely not a problem with pip."
941
+ else:
942
+ note = (
943
+ "pip crashed unexpectedly. Please file an issue on pip's issue "
944
+ "tracker: https://github.com/pypa/pip/issues/new"
945
+ )
946
+
947
+ if log_lines is None:
948
+ # No logs are available, they must have been printed earlier.
949
+ context = Text("See above for more details.")
950
+ else:
951
+ if isinstance(cause, PipError):
952
+ log_lines.append(f"ERROR: {cause}")
953
+ else:
954
+ # Split rendered error into real lines without trailing newlines.
955
+ log_lines.extend(
956
+ "".join(traceback.format_exception(cause)).splitlines()
957
+ )
958
+
959
+ context = Text.assemble(
960
+ f"Installing {' '.join(build_reqs)}\n",
961
+ (f"[{len(log_lines)} lines of output]\n", "red"),
962
+ "\n".join(log_lines),
963
+ ("\n[end of output]", "red"),
964
+ )
965
+
966
+ message = Text("Cannot install build dependencies", "green")
967
+ if req:
968
+ message += Text(f" for {req}")
969
+ super().__init__(
970
+ message=message, context=context, hint_stmt=None, note_stmt=note
971
+ )
python/Lib/site-packages/pip/_internal/main.py ADDED
@@ -0,0 +1,12 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from __future__ import annotations
2
+
3
+
4
+ def main(args: list[str] | None = None) -> int:
5
+ """This is preserved for old console scripts that may still be referencing
6
+ it.
7
+
8
+ For additional details, see https://github.com/pypa/pip/issues/7498.
9
+ """
10
+ from pip._internal.utils.entrypoints import _wrapper
11
+
12
+ return _wrapper(args)
python/Lib/site-packages/pip/_internal/pyproject.py ADDED
@@ -0,0 +1,123 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from __future__ import annotations
2
+
3
+ import os
4
+ from collections import namedtuple
5
+ from typing import Any
6
+
7
+ from pip._vendor.packaging.requirements import InvalidRequirement
8
+
9
+ from pip._internal.exceptions import (
10
+ InstallationError,
11
+ InvalidPyProjectBuildRequires,
12
+ MissingPyProjectBuildRequires,
13
+ )
14
+ from pip._internal.utils.compat import tomllib
15
+ from pip._internal.utils.packaging import get_requirement
16
+
17
+
18
+ def _is_list_of_str(obj: Any) -> bool:
19
+ return isinstance(obj, list) and all(isinstance(item, str) for item in obj)
20
+
21
+
22
+ def make_pyproject_path(unpacked_source_directory: str) -> str:
23
+ return os.path.join(unpacked_source_directory, "pyproject.toml")
24
+
25
+
26
+ BuildSystemDetails = namedtuple(
27
+ "BuildSystemDetails", ["requires", "backend", "check", "backend_path"]
28
+ )
29
+
30
+
31
+ def load_pyproject_toml(
32
+ pyproject_toml: str, setup_py: str, req_name: str
33
+ ) -> BuildSystemDetails:
34
+ """Load the pyproject.toml file.
35
+
36
+ Parameters:
37
+ pyproject_toml - Location of the project's pyproject.toml file
38
+ setup_py - Location of the project's setup.py file
39
+ req_name - The name of the requirement we're processing (for
40
+ error reporting)
41
+
42
+ Returns:
43
+ None if we should use the legacy code path, otherwise a tuple
44
+ (
45
+ requirements from pyproject.toml,
46
+ name of PEP 517 backend,
47
+ requirements we should check are installed after setting
48
+ up the build environment
49
+ directory paths to import the backend from (backend-path),
50
+ relative to the project root.
51
+ )
52
+ """
53
+ has_pyproject = os.path.isfile(pyproject_toml)
54
+ has_setup = os.path.isfile(setup_py)
55
+
56
+ if not has_pyproject and not has_setup:
57
+ raise InstallationError(
58
+ f"{req_name} does not appear to be a Python project: "
59
+ f"neither 'setup.py' nor 'pyproject.toml' found."
60
+ )
61
+
62
+ if has_pyproject:
63
+ with open(pyproject_toml, encoding="utf-8") as f:
64
+ pp_toml = tomllib.loads(f.read())
65
+ build_system = pp_toml.get("build-system")
66
+ else:
67
+ build_system = None
68
+
69
+ if build_system is None:
70
+ # In the absence of any explicit backend specification, we
71
+ # assume the setuptools backend that most closely emulates the
72
+ # traditional direct setup.py execution, and require wheel and
73
+ # a version of setuptools that supports that backend.
74
+
75
+ build_system = {
76
+ "requires": ["setuptools>=40.8.0"],
77
+ "build-backend": "setuptools.build_meta:__legacy__",
78
+ }
79
+
80
+ # Ensure that the build-system section in pyproject.toml conforms
81
+ # to PEP 518.
82
+
83
+ # Specifying the build-system table but not the requires key is invalid
84
+ if "requires" not in build_system:
85
+ raise MissingPyProjectBuildRequires(package=req_name)
86
+
87
+ # Error out if requires is not a list of strings
88
+ requires = build_system["requires"]
89
+ if not _is_list_of_str(requires):
90
+ raise InvalidPyProjectBuildRequires(
91
+ package=req_name,
92
+ reason="It is not a list of strings.",
93
+ )
94
+
95
+ # Each requirement must be valid as per PEP 508
96
+ for requirement in requires:
97
+ try:
98
+ get_requirement(requirement)
99
+ except InvalidRequirement as error:
100
+ raise InvalidPyProjectBuildRequires(
101
+ package=req_name,
102
+ reason=f"It contains an invalid requirement: {requirement!r}",
103
+ ) from error
104
+
105
+ backend = build_system.get("build-backend")
106
+ backend_path = build_system.get("backend-path", [])
107
+ check: list[str] = []
108
+ if backend is None:
109
+ # If the user didn't specify a backend, we assume they want to use
110
+ # the setuptools backend. But we can't be sure they have included
111
+ # a version of setuptools which supplies the backend. So we
112
+ # make a note to check that this requirement is present once
113
+ # we have set up the environment.
114
+ # This is quite a lot of work to check for a very specific case. But
115
+ # the problem is, that case is potentially quite common - projects that
116
+ # adopted PEP 518 early for the ability to specify requirements to
117
+ # execute setup.py, but never considered needing to mention the build
118
+ # tools themselves. The original PEP 518 code had a similar check (but
119
+ # implemented in a different way).
120
+ backend = "setuptools.build_meta:__legacy__"
121
+ check = ["setuptools>=40.8.0"]
122
+
123
+ return BuildSystemDetails(requires, backend, check, backend_path)
python/Lib/site-packages/pip/_internal/self_outdated_check.py ADDED
@@ -0,0 +1,246 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from __future__ import annotations
2
+
3
+ import datetime
4
+ import hashlib
5
+ import json
6
+ import logging
7
+ import optparse
8
+ import os.path
9
+ import sys
10
+ from dataclasses import dataclass
11
+
12
+ from pip._vendor.packaging.version import Version
13
+ from pip._vendor.packaging.version import parse as parse_version
14
+ from pip._vendor.rich.console import Group
15
+ from pip._vendor.rich.markup import escape
16
+ from pip._vendor.rich.text import Text
17
+
18
+ from pip._internal.index.collector import LinkCollector
19
+ from pip._internal.index.package_finder import PackageFinder
20
+ from pip._internal.metadata import get_default_environment
21
+ from pip._internal.models.release_control import ReleaseControl
22
+ from pip._internal.models.selection_prefs import SelectionPreferences
23
+ from pip._internal.network.session import PipSession
24
+ from pip._internal.utils.compat import WINDOWS
25
+ from pip._internal.utils.datetime import parse_iso_datetime
26
+ from pip._internal.utils.entrypoints import (
27
+ get_best_invocation_for_this_pip,
28
+ get_best_invocation_for_this_python,
29
+ )
30
+ from pip._internal.utils.filesystem import (
31
+ adjacent_tmp_file,
32
+ check_path_owner,
33
+ copy_directory_permissions,
34
+ replace,
35
+ )
36
+ from pip._internal.utils.misc import (
37
+ ExternallyManagedEnvironment,
38
+ check_externally_managed,
39
+ ensure_dir,
40
+ )
41
+
42
+ _WEEK = datetime.timedelta(days=7)
43
+
44
+ logger = logging.getLogger(__name__)
45
+
46
+
47
+ def _get_statefile_name(key: str) -> str:
48
+ key_bytes = key.encode()
49
+ name = hashlib.sha224(key_bytes).hexdigest()
50
+ return name
51
+
52
+
53
+ class SelfCheckState:
54
+ def __init__(self, cache_dir: str) -> None:
55
+ self._state: dict[str, str] = {}
56
+ self._statefile_path = None
57
+
58
+ # Try to load the existing state
59
+ if cache_dir:
60
+ self._statefile_path = os.path.join(
61
+ cache_dir, "selfcheck", _get_statefile_name(self.key)
62
+ )
63
+ try:
64
+ with open(self._statefile_path, encoding="utf-8") as statefile:
65
+ self._state = json.load(statefile)
66
+ except (OSError, ValueError, KeyError):
67
+ # Explicitly suppressing exceptions, since we don't want to
68
+ # error out if the cache file is invalid.
69
+ pass
70
+
71
+ @property
72
+ def key(self) -> str:
73
+ return sys.prefix
74
+
75
+ def get(self, current_time: datetime.datetime) -> str | None:
76
+ """Check if we have a not-outdated version loaded already."""
77
+ if not self._state:
78
+ return None
79
+
80
+ if "last_check" not in self._state:
81
+ return None
82
+
83
+ if "pypi_version" not in self._state:
84
+ return None
85
+
86
+ # Determine if we need to refresh the state
87
+ last_check = parse_iso_datetime(self._state["last_check"])
88
+ time_since_last_check = current_time - last_check
89
+ if time_since_last_check > _WEEK:
90
+ return None
91
+
92
+ return self._state["pypi_version"]
93
+
94
+ def set(self, pypi_version: str, current_time: datetime.datetime) -> None:
95
+ # If we do not have a path to cache in, don't bother saving.
96
+ if not self._statefile_path:
97
+ return
98
+
99
+ statefile_directory = os.path.dirname(self._statefile_path)
100
+
101
+ # Check to make sure that we own the directory
102
+ if not check_path_owner(statefile_directory):
103
+ return
104
+
105
+ # Now that we've ensured the directory is owned by this user, we'll go
106
+ # ahead and make sure that all our directories are created.
107
+ ensure_dir(statefile_directory)
108
+
109
+ state = {
110
+ # Include the key so it's easy to tell which pip wrote the
111
+ # file.
112
+ "key": self.key,
113
+ "last_check": current_time.isoformat(),
114
+ "pypi_version": pypi_version,
115
+ }
116
+
117
+ text = json.dumps(state, sort_keys=True, separators=(",", ":"))
118
+
119
+ with adjacent_tmp_file(self._statefile_path) as f:
120
+ f.write(text.encode())
121
+ copy_directory_permissions(statefile_directory, f)
122
+
123
+ try:
124
+ # Since we have a prefix-specific state file, we can just
125
+ # overwrite whatever is there, no need to check.
126
+ replace(f.name, self._statefile_path)
127
+ except OSError:
128
+ # Best effort.
129
+ pass
130
+
131
+
132
+ @dataclass
133
+ class UpgradePrompt:
134
+ old: str
135
+ new: str
136
+
137
+ def __rich__(self) -> Group:
138
+ if WINDOWS:
139
+ pip_cmd = f"{get_best_invocation_for_this_python()} -m pip"
140
+ else:
141
+ pip_cmd = get_best_invocation_for_this_pip()
142
+
143
+ notice = "[bold][[reset][blue]notice[reset][bold]][reset]"
144
+ return Group(
145
+ Text(),
146
+ Text.from_markup(
147
+ f"{notice} A new release of pip is available: "
148
+ f"[red]{self.old}[reset] -> [green]{self.new}[reset]"
149
+ ),
150
+ Text.from_markup(
151
+ f"{notice} To update, run: "
152
+ f"[green]{escape(pip_cmd)} install --upgrade pip"
153
+ ),
154
+ )
155
+
156
+
157
+ def _get_current_remote_pip_version(
158
+ session: PipSession, options: optparse.Values
159
+ ) -> str | None:
160
+ # Lets use PackageFinder to see what the latest pip version is
161
+ link_collector = LinkCollector.create(
162
+ session,
163
+ options=options,
164
+ suppress_no_index=True,
165
+ )
166
+
167
+ # Pass allow_yanked=False so we don't suggest upgrading to a
168
+ # yanked version.
169
+ selection_prefs = SelectionPreferences(
170
+ allow_yanked=False,
171
+ release_control=ReleaseControl(only_final={"pip"}),
172
+ )
173
+
174
+ finder = PackageFinder.create(
175
+ link_collector=link_collector,
176
+ selection_prefs=selection_prefs,
177
+ )
178
+ best_candidate = finder.find_best_candidate("pip").best_candidate
179
+ if best_candidate is None:
180
+ return None
181
+
182
+ return str(best_candidate.version)
183
+
184
+
185
+ def _compute_upgrade_prompt(
186
+ local_version: Version, remote_version_str: str, installed_by_pip: bool
187
+ ) -> UpgradePrompt | None:
188
+ remote_version = parse_version(remote_version_str)
189
+ logger.debug("Remote version of pip: %s", remote_version)
190
+ logger.debug("Local version of pip: %s", local_version)
191
+ logger.debug("Was pip installed by pip? %s", installed_by_pip)
192
+
193
+ if not installed_by_pip:
194
+ return None # Only suggest upgrade if pip is installed by pip.
195
+
196
+ local_version_is_older = (
197
+ local_version < remote_version
198
+ and local_version.base_version != remote_version.base_version
199
+ )
200
+ if local_version_is_older:
201
+ return UpgradePrompt(old=str(local_version), new=remote_version_str)
202
+
203
+ return None
204
+
205
+
206
+ def pip_self_version_check_fetch(
207
+ session: PipSession, options: optparse.Values
208
+ ) -> UpgradePrompt | None:
209
+ """Compute the pip upgrade prompt, if any, before the command runs.
210
+
211
+ Limit the frequency of checks to once per week. State is stored either in
212
+ the active virtualenv or in the user's USER_CACHE_DIR keyed off the prefix
213
+ of the pip script path.
214
+
215
+ Pair with :func:`pip_self_version_check_emit`, which displays the prompt
216
+ after the command body runs.
217
+ """
218
+ installed_dist = get_default_environment().get_distribution("pip")
219
+ if not installed_dist:
220
+ return None
221
+ try:
222
+ check_externally_managed()
223
+ except ExternallyManagedEnvironment:
224
+ return None
225
+
226
+ state = SelfCheckState(cache_dir=options.cache_dir)
227
+ current_time = datetime.datetime.now(datetime.timezone.utc)
228
+ remote_version_str = state.get(current_time)
229
+ if remote_version_str is None:
230
+ remote_version_str = _get_current_remote_pip_version(session, options)
231
+ if remote_version_str is None:
232
+ logger.debug("No remote pip version found")
233
+ return None
234
+ state.set(remote_version_str, current_time)
235
+
236
+ return _compute_upgrade_prompt(
237
+ local_version=installed_dist.version,
238
+ remote_version_str=remote_version_str,
239
+ installed_by_pip=installed_dist.installer == "pip",
240
+ )
241
+
242
+
243
+ def pip_self_version_check_emit(upgrade_prompt: UpgradePrompt | None) -> None:
244
+ """Emit the upgrade prompt captured by :func:`pip_self_version_check_fetch`."""
245
+ if upgrade_prompt is not None:
246
+ logger.warning("%s", upgrade_prompt, extra={"rich": True})
python/Lib/site-packages/pip/_internal/wheel_builder.py ADDED
@@ -0,0 +1,261 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """Orchestrator for building wheels from InstallRequirements."""
2
+
3
+ from __future__ import annotations
4
+
5
+ import logging
6
+ import os.path
7
+ import re
8
+ from collections.abc import Iterable
9
+ from tempfile import TemporaryDirectory
10
+
11
+ from pip._vendor.packaging.utils import canonicalize_name, canonicalize_version
12
+ from pip._vendor.packaging.version import InvalidVersion, Version
13
+
14
+ from pip._internal.cache import WheelCache
15
+ from pip._internal.exceptions import InvalidWheelFilename, UnsupportedWheel
16
+ from pip._internal.metadata import FilesystemWheel, get_wheel_distribution
17
+ from pip._internal.models.link import Link
18
+ from pip._internal.models.wheel import Wheel
19
+ from pip._internal.operations.build.wheel import build_wheel_pep517
20
+ from pip._internal.operations.build.wheel_editable import build_wheel_editable
21
+ from pip._internal.req.req_install import InstallRequirement
22
+ from pip._internal.utils.logging import indent_log
23
+ from pip._internal.utils.misc import ensure_dir, hash_file
24
+ from pip._internal.utils.urls import path_to_url
25
+ from pip._internal.vcs import vcs
26
+
27
+ logger = logging.getLogger(__name__)
28
+
29
+ _egg_info_re = re.compile(r"([a-z0-9_.]+)-([a-z0-9_.!+-]+)", re.IGNORECASE)
30
+
31
+ BuildResult = tuple[list[InstallRequirement], list[InstallRequirement]]
32
+
33
+
34
+ def _contains_egg_info(s: str) -> bool:
35
+ """Determine whether the string looks like an egg_info.
36
+
37
+ :param s: The string to parse. E.g. foo-2.1
38
+ """
39
+ return bool(_egg_info_re.search(s))
40
+
41
+
42
+ def _should_cache(
43
+ req: InstallRequirement,
44
+ ) -> bool | None:
45
+ """
46
+ Return whether a built InstallRequirement can be stored in the persistent
47
+ wheel cache, assuming the wheel cache is available.
48
+ """
49
+ if req.editable or not req.source_dir:
50
+ # never cache editable requirements
51
+ return False
52
+
53
+ if req.link and req.link.is_vcs:
54
+ # VCS checkout. Do not cache
55
+ # unless it points to an immutable commit hash.
56
+ assert not req.editable
57
+ assert req.source_dir
58
+ vcs_backend = vcs.get_backend_for_scheme(req.link.scheme)
59
+ assert vcs_backend
60
+ if vcs_backend.is_immutable_rev_checkout(req.link.url, req.source_dir):
61
+ return True
62
+ return False
63
+
64
+ assert req.link
65
+ base, ext = req.link.splitext()
66
+ if _contains_egg_info(base):
67
+ return True
68
+
69
+ # Otherwise, do not cache.
70
+ return False
71
+
72
+
73
+ def _get_cache_dir(
74
+ req: InstallRequirement,
75
+ wheel_cache: WheelCache,
76
+ ) -> str:
77
+ """Return the persistent or temporary cache directory where the built
78
+ wheel need to be stored.
79
+ """
80
+ cache_available = bool(wheel_cache.cache_dir)
81
+ assert req.link
82
+ if cache_available and _should_cache(req):
83
+ cache_dir = wheel_cache.get_path_for_link(req.link)
84
+ else:
85
+ cache_dir = wheel_cache.get_ephem_path_for_link(req.link)
86
+ return cache_dir
87
+
88
+
89
+ def _verify_one(req: InstallRequirement, wheel_path: str) -> None:
90
+ canonical_name = canonicalize_name(req.name or "")
91
+ w = Wheel(os.path.basename(wheel_path))
92
+ if w.name != canonical_name:
93
+ raise InvalidWheelFilename(
94
+ f"Wheel has unexpected file name: expected {canonical_name!r}, "
95
+ f"got {w.name!r}",
96
+ )
97
+ dist = get_wheel_distribution(FilesystemWheel(wheel_path), canonical_name)
98
+ dist_verstr = str(dist.version)
99
+ if canonicalize_version(dist_verstr) != canonicalize_version(w.version):
100
+ raise InvalidWheelFilename(
101
+ f"Wheel has unexpected file name: expected {dist_verstr!r}, "
102
+ f"got {w.version!r}",
103
+ )
104
+ metadata_version_value = dist.metadata_version
105
+ if metadata_version_value is None:
106
+ raise UnsupportedWheel("Missing Metadata-Version")
107
+ try:
108
+ metadata_version = Version(metadata_version_value)
109
+ except InvalidVersion:
110
+ msg = f"Invalid Metadata-Version: {metadata_version_value}"
111
+ raise UnsupportedWheel(msg)
112
+ if metadata_version >= Version("1.2") and not isinstance(dist.version, Version):
113
+ raise UnsupportedWheel(
114
+ f"Metadata 1.2 mandates PEP 440 version, but {dist_verstr!r} is not"
115
+ )
116
+
117
+
118
+ def _build_one(
119
+ req: InstallRequirement,
120
+ output_dir: str,
121
+ verify: bool,
122
+ editable: bool,
123
+ ) -> str | None:
124
+ """Build one wheel.
125
+
126
+ :return: The filename of the built wheel, or None if the build failed.
127
+ """
128
+ artifact = "editable" if editable else "wheel"
129
+ try:
130
+ ensure_dir(output_dir)
131
+ except OSError as e:
132
+ logger.warning(
133
+ "Building %s for %s failed: %s",
134
+ artifact,
135
+ req.name,
136
+ e,
137
+ )
138
+ return None
139
+
140
+ # Install build deps into temporary directory (PEP 518)
141
+ with req.build_env:
142
+ wheel_path = _build_one_inside_env(req, output_dir, editable)
143
+ if wheel_path and verify:
144
+ try:
145
+ _verify_one(req, wheel_path)
146
+ except (InvalidWheelFilename, UnsupportedWheel) as e:
147
+ logger.warning("Built %s for %s is invalid: %s", artifact, req.name, e)
148
+ return None
149
+ return wheel_path
150
+
151
+
152
+ def _build_one_inside_env(
153
+ req: InstallRequirement,
154
+ output_dir: str,
155
+ editable: bool,
156
+ ) -> str | None:
157
+ with TemporaryDirectory(dir=output_dir) as wheel_directory:
158
+ assert req.name
159
+ assert req.metadata_directory
160
+ assert req.pep517_backend
161
+ if editable:
162
+ wheel_path = build_wheel_editable(
163
+ name=req.name,
164
+ backend=req.pep517_backend,
165
+ metadata_directory=req.metadata_directory,
166
+ wheel_directory=wheel_directory,
167
+ )
168
+ else:
169
+ wheel_path = build_wheel_pep517(
170
+ name=req.name,
171
+ backend=req.pep517_backend,
172
+ metadata_directory=req.metadata_directory,
173
+ wheel_directory=wheel_directory,
174
+ )
175
+
176
+ if wheel_path is not None:
177
+ wheel_name = os.path.basename(wheel_path)
178
+ dest_path = os.path.join(output_dir, wheel_name)
179
+ try:
180
+ wheel_hash, length = hash_file(wheel_path)
181
+ # We can do a replace here because wheel_path is guaranteed to
182
+ # be in the same filesystem as output_dir. This will perform an
183
+ # atomic rename, which is necessary to avoid concurrency issues
184
+ # when populating the cache.
185
+ os.replace(wheel_path, dest_path)
186
+ logger.info(
187
+ "Created wheel for %s: filename=%s size=%d sha256=%s",
188
+ req.name,
189
+ wheel_name,
190
+ length,
191
+ wheel_hash.hexdigest(),
192
+ )
193
+ logger.info("Stored in directory: %s", output_dir)
194
+ return dest_path
195
+ except Exception as e:
196
+ logger.warning(
197
+ "Building wheel for %s failed: %s",
198
+ req.name,
199
+ e,
200
+ )
201
+ return None
202
+
203
+
204
+ def build(
205
+ requirements: Iterable[InstallRequirement],
206
+ wheel_cache: WheelCache,
207
+ verify: bool,
208
+ ) -> BuildResult:
209
+ """Build wheels.
210
+
211
+ :return: The list of InstallRequirement that succeeded to build and
212
+ the list of InstallRequirement that failed to build.
213
+ """
214
+ if not requirements:
215
+ return [], []
216
+
217
+ # Build the wheels.
218
+ logger.info(
219
+ "Building wheels for collected packages: %s",
220
+ ", ".join(req.name for req in requirements), # type: ignore
221
+ )
222
+
223
+ with indent_log():
224
+ build_successes, build_failures = [], []
225
+ for req in requirements:
226
+ assert req.name
227
+ cache_dir = _get_cache_dir(req, wheel_cache)
228
+ wheel_file = _build_one(
229
+ req,
230
+ cache_dir,
231
+ verify,
232
+ req.editable and req.permit_editable_wheels,
233
+ )
234
+ if wheel_file:
235
+ # Record the download origin in the cache
236
+ if req.download_info is not None:
237
+ # download_info is guaranteed to be set because when we build an
238
+ # InstallRequirement it has been through the preparer before, but
239
+ # let's be cautious.
240
+ wheel_cache.record_download_origin(cache_dir, req.download_info)
241
+ # Update the link for this.
242
+ req.link = Link(path_to_url(wheel_file))
243
+ req.local_file_path = req.link.file_path
244
+ assert req.link.is_wheel
245
+ build_successes.append(req)
246
+ else:
247
+ build_failures.append(req)
248
+
249
+ # notify success/failure
250
+ if build_successes:
251
+ logger.info(
252
+ "Successfully built %s",
253
+ " ".join([req.name for req in build_successes]), # type: ignore
254
+ )
255
+ if build_failures:
256
+ logger.info(
257
+ "Failed to build %s",
258
+ " ".join([req.name for req in build_failures]), # type: ignore
259
+ )
260
+ # Return a list of requirements that failed to build
261
+ return build_successes, build_failures
python/Lib/site-packages/pip/_vendor/README.rst ADDED
@@ -0,0 +1,178 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ================
2
+ Vendoring Policy
3
+ ================
4
+
5
+ * Vendored libraries **MUST** not be modified except as required to
6
+ successfully vendor them.
7
+ * Vendored libraries **MUST** be released copies of libraries available on
8
+ PyPI.
9
+ * Vendored libraries **MUST** be available under a license that allows
10
+ them to be integrated into ``pip``, which is released under the MIT license.
11
+ * Vendored libraries **MUST** be accompanied with LICENSE files.
12
+ * The versions of libraries vendored in pip **MUST** be reflected in
13
+ ``pip/_vendor/vendor.txt``.
14
+ * Vendored libraries **MUST** function without any build steps such as ``2to3``
15
+ or compilation of C code, practically this limits to single source 2.x/3.x and
16
+ pure Python.
17
+ * Any modifications made to libraries **MUST** be noted in
18
+ ``pip/_vendor/README.rst`` and their corresponding patches **MUST** be
19
+ included ``tools/vendoring/patches``.
20
+ * Vendored libraries should have corresponding ``vendored()`` entries in
21
+ ``pip/_vendor/__init__.py``.
22
+
23
+ Rationale
24
+ =========
25
+
26
+ Historically pip has not had any dependencies except for ``setuptools`` itself,
27
+ choosing instead to implement any functionality it needed to prevent needing
28
+ a dependency. However, starting with pip 1.5, we began to replace code that was
29
+ implemented inside of pip with reusable libraries from PyPI. This brought the
30
+ typical benefits of reusing libraries instead of reinventing the wheel like
31
+ higher quality and more battle tested code, centralization of bug fixes
32
+ (particularly security sensitive ones), and better/more features for less work.
33
+
34
+ However, there are several issues with having dependencies in the traditional
35
+ way (via ``install_requires``) for pip. These issues are:
36
+
37
+ **Fragility**
38
+ When pip depends on another library to function then if for whatever reason
39
+ that library either isn't installed or an incompatible version is installed
40
+ then pip ceases to function. This is of course true for all Python
41
+ applications, however for every application *except* for pip the way you fix
42
+ it is by re-running pip. Obviously, when pip can't run, you can't use pip to
43
+ fix pip, so you're left having to manually resolve dependencies and
44
+ installing them by hand.
45
+
46
+ **Making other libraries uninstallable**
47
+ One of pip's current dependencies is the ``requests`` library, for which pip
48
+ requires a fairly recent version to run. If pip depended on ``requests`` in
49
+ the traditional manner, then we'd either have to maintain compatibility with
50
+ every ``requests`` version that has ever existed (and ever will), OR allow
51
+ pip to render certain versions of ``requests`` uninstallable. (The second
52
+ issue, although technically true for any Python application, is magnified by
53
+ pip's ubiquity; pip is installed by default in Python, in ``pyvenv``, and in
54
+ ``virtualenv``.)
55
+
56
+ **Security**
57
+ This might seem puzzling at first glance, since vendoring has a tendency to
58
+ complicate updating dependencies for security updates, and that holds true
59
+ for pip. However, given the *other* reasons for avoiding dependencies, the
60
+ alternative is for pip to reinvent the wheel itself. This is what pip did
61
+ historically. It forced pip to re-implement its own HTTPS verification
62
+ routines as a workaround for the Python standard library's lack of SSL
63
+ validation, which resulted in similar bugs in the validation routine in
64
+ ``requests`` and ``urllib3``, except that they had to be discovered and
65
+ fixed independently. Even though we're vendoring, reusing libraries keeps
66
+ pip more secure by relying on the great work of our dependencies, *and*
67
+ allowing for faster, easier security fixes by simply pulling in newer
68
+ versions of dependencies.
69
+
70
+ **Bootstrapping**
71
+ Currently most popular methods of installing pip rely on pip's
72
+ self-contained nature to install pip itself. These tools work by bundling a
73
+ copy of pip, adding it to ``sys.path``, and then executing that copy of pip.
74
+ This is done instead of implementing a "mini installer" (to reduce
75
+ duplication); pip already knows how to install a Python package, and is far
76
+ more battle-tested than any "mini installer" could ever possibly be.
77
+
78
+ Many downstream redistributors have policies against this kind of bundling, and
79
+ instead opt to patch the software they distribute to debundle it and make it
80
+ rely on the global versions of the software that they already have packaged
81
+ (which may have its own patches applied to it). We (the pip team) would prefer
82
+ it if pip was *not* debundled in this manner due to the above reasons and
83
+ instead we would prefer it if pip would be left intact as it is now.
84
+
85
+ In the longer term, if someone has a *portable* solution to the above problems,
86
+ other than the bundling method we currently use, that doesn't add additional
87
+ problems that are unreasonable then we would be happy to consider, and possibly
88
+ switch to said method. This solution must function correctly across all of the
89
+ situation that we expect pip to be used and not mandate some external mechanism
90
+ such as OS packages.
91
+
92
+
93
+ Modifications
94
+ =============
95
+
96
+ * ``setuptools`` is completely stripped to only keep ``pkg_resources``.
97
+ * ``pkg_resources`` has been modified to import its dependencies from
98
+ ``pip._vendor``, and to use the vendored copy of ``platformdirs``
99
+ rather than ``appdirs``.
100
+ * ``packaging`` has been modified to import its dependencies from
101
+ ``pip._vendor``.
102
+ * ``CacheControl`` has been modified to import its dependencies from
103
+ ``pip._vendor``.
104
+ * ``requests`` has been modified to import its other dependencies from
105
+ ``pip._vendor`` and to *not* load ``simplejson`` (all platforms) and
106
+ ``pyopenssl`` (Windows).
107
+ * ``platformdirs`` has been modified to import its submodules from ``pip._vendor.platformdirs``.
108
+
109
+ Automatic Vendoring
110
+ ===================
111
+
112
+ Vendoring is automated via the `vendoring <https://pypi.org/project/vendoring/>`_ tool from the content of
113
+ ``pip/_vendor/vendor.txt`` and the different patches in
114
+ ``tools/vendoring/patches``.
115
+ Launch it via ``vendoring sync . -v`` (requires ``vendoring>=0.2.2``).
116
+ Tool configuration is done via ``pyproject.toml``.
117
+
118
+ To update the vendored library versions, we have a session defined in ``nox``.
119
+ The command to upgrade everything is::
120
+
121
+ nox -s vendoring -- --upgrade-all --skip setuptools
122
+
123
+ We do not upgrade ``setuptools``, because we only rely on ``pkg_resources``,
124
+ and tracking every ``setuptools`` change is unnecessary for our needs.
125
+
126
+
127
+ Managing Local Patches
128
+ ======================
129
+
130
+ The ``vendoring`` tool automatically applies our local patches, but updating,
131
+ the patches sometimes no longer apply cleanly. In that case, the update will
132
+ fail. To resolve this, take the following steps:
133
+
134
+ 1. Revert any incomplete changes in the revendoring branch, to ensure you have
135
+ a clean starting point.
136
+ 2. Run the revendoring of the library with a problem again: ``nox -s vendoring
137
+ -- --upgrade <library_name>``.
138
+ 3. This will fail again, but you will have the original source in your working
139
+ directory. Review the existing patch against the source, and modify the patch
140
+ to reflect the new version of the source. If you ``git add`` the changes the
141
+ vendoring made, you can modify the source to reflect the patch file and then
142
+ generate a new patch with ``git diff``.
143
+ 4. Now, revert everything *except* the patch file changes. Leave the modified
144
+ patch file unstaged but saved in the working tree.
145
+ 5. Re-run the vendoring. This time, it should pick up the changed patch file
146
+ and apply it cleanly. The patch file changes will be committed along with the
147
+ revendoring, so the new commit should be ready to test and publish as a PR.
148
+
149
+
150
+ Debundling
151
+ ==========
152
+
153
+ As mentioned in the rationale, we, the pip team, would prefer it if pip was not
154
+ debundled (other than optionally ``pip/_vendor/requests/cacert.pem``) and that
155
+ pip was left intact. However, if you insist on doing so, we have a
156
+ semi-supported method (that we don't test in our CI) and requires a bit of
157
+ extra work on your end in order to solve the problems described above.
158
+
159
+ 1. Delete everything in ``pip/_vendor/`` **except** for
160
+ ``pip/_vendor/__init__.py`` and ``pip/_vendor/vendor.txt``.
161
+ 2. Generate wheels for each of pip's dependencies (and any of their
162
+ dependencies) using your patched copies of these libraries. These must be
163
+ placed somewhere on the filesystem that pip can access (``pip/_vendor`` is
164
+ the default assumption).
165
+ 3. Modify ``pip/_vendor/__init__.py`` so that the ``DEBUNDLED`` variable is
166
+ ``True``.
167
+ 4. Upon installation, the ``INSTALLER`` file in pip's own ``dist-info``
168
+ directory should be set to something other than ``pip``, so that pip
169
+ can detect that it wasn't installed using itself.
170
+ 5. *(optional)* If you've placed the wheels in a location other than
171
+ ``pip/_vendor/``, then modify ``pip/_vendor/__init__.py`` so that the
172
+ ``WHEEL_DIR`` variable points to the location you've placed them.
173
+ 6. *(optional)* Update the ``pip_self_version_check`` logic to use the
174
+ appropriate logic for determining the latest available version of pip and
175
+ prompt the user with the correct upgrade message.
176
+
177
+ Note that partial debundling is **NOT** supported. You need to prepare wheels
178
+ for all dependencies for successful debundling.
python/Lib/site-packages/pip/_vendor/__init__.py ADDED
@@ -0,0 +1,117 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """
2
+ pip._vendor is for vendoring dependencies of pip to prevent needing pip to
3
+ depend on something external.
4
+
5
+ Files inside of pip._vendor should be considered immutable and should only be
6
+ updated to versions from upstream.
7
+ """
8
+ from __future__ import absolute_import
9
+
10
+ import glob
11
+ import os.path
12
+ import sys
13
+
14
+ # Downstream redistributors which have debundled our dependencies should also
15
+ # patch this value to be true. This will trigger the additional patching
16
+ # to cause things like "six" to be available as pip.
17
+ DEBUNDLED = False
18
+
19
+ # By default, look in this directory for a bunch of .whl files which we will
20
+ # add to the beginning of sys.path before attempting to import anything. This
21
+ # is done to support downstream re-distributors like Debian and Fedora who
22
+ # wish to create their own Wheels for our dependencies to aid in debundling.
23
+ WHEEL_DIR = os.path.abspath(os.path.dirname(__file__))
24
+
25
+
26
+ # Define a small helper function to alias our vendored modules to the real ones
27
+ # if the vendored ones do not exist. This idea of this was taken from
28
+ # https://github.com/kennethreitz/requests/pull/2567.
29
+ def vendored(modulename):
30
+ vendored_name = "{0}.{1}".format(__name__, modulename)
31
+
32
+ try:
33
+ __import__(modulename, globals(), locals(), level=0)
34
+ except ImportError:
35
+ # We can just silently allow import failures to pass here. If we
36
+ # got to this point it means that ``import pip._vendor.whatever``
37
+ # failed and so did ``import whatever``. Since we're importing this
38
+ # upfront in an attempt to alias imports, not erroring here will
39
+ # just mean we get a regular import error whenever pip *actually*
40
+ # tries to import one of these modules to use it, which actually
41
+ # gives us a better error message than we would have otherwise
42
+ # gotten.
43
+ pass
44
+ else:
45
+ sys.modules[vendored_name] = sys.modules[modulename]
46
+ base, head = vendored_name.rsplit(".", 1)
47
+ setattr(sys.modules[base], head, sys.modules[modulename])
48
+
49
+
50
+ # If we're operating in a debundled setup, then we want to go ahead and trigger
51
+ # the aliasing of our vendored libraries as well as looking for wheels to add
52
+ # to our sys.path. This will cause all of this code to be a no-op typically
53
+ # however downstream redistributors can enable it in a consistent way across
54
+ # all platforms.
55
+ if DEBUNDLED:
56
+ # Actually look inside of WHEEL_DIR to find .whl files and add them to the
57
+ # front of our sys.path.
58
+ sys.path[:] = glob.glob(os.path.join(WHEEL_DIR, "*.whl")) + sys.path
59
+
60
+ # Actually alias all of our vendored dependencies.
61
+ vendored("cachecontrol")
62
+ vendored("certifi")
63
+ vendored("dependency-groups")
64
+ vendored("distlib")
65
+ vendored("distro")
66
+ vendored("packaging")
67
+ vendored("packaging.version")
68
+ vendored("packaging.specifiers")
69
+ vendored("pkg_resources")
70
+ vendored("platformdirs")
71
+ vendored("progress")
72
+ vendored("pyproject_hooks")
73
+ vendored("requests")
74
+ vendored("requests.exceptions")
75
+ vendored("requests.packages")
76
+ vendored("requests.packages.urllib3")
77
+ vendored("requests.packages.urllib3._collections")
78
+ vendored("requests.packages.urllib3.connection")
79
+ vendored("requests.packages.urllib3.connectionpool")
80
+ vendored("requests.packages.urllib3.contrib")
81
+ vendored("requests.packages.urllib3.contrib.ntlmpool")
82
+ vendored("requests.packages.urllib3.contrib.pyopenssl")
83
+ vendored("requests.packages.urllib3.exceptions")
84
+ vendored("requests.packages.urllib3.fields")
85
+ vendored("requests.packages.urllib3.filepost")
86
+ vendored("requests.packages.urllib3.packages")
87
+ vendored("requests.packages.urllib3.packages.ordered_dict")
88
+ vendored("requests.packages.urllib3.packages.six")
89
+ vendored("requests.packages.urllib3.packages.ssl_match_hostname")
90
+ vendored("requests.packages.urllib3.packages.ssl_match_hostname."
91
+ "_implementation")
92
+ vendored("requests.packages.urllib3.poolmanager")
93
+ vendored("requests.packages.urllib3.request")
94
+ vendored("requests.packages.urllib3.response")
95
+ vendored("requests.packages.urllib3.util")
96
+ vendored("requests.packages.urllib3.util.connection")
97
+ vendored("requests.packages.urllib3.util.request")
98
+ vendored("requests.packages.urllib3.util.response")
99
+ vendored("requests.packages.urllib3.util.retry")
100
+ vendored("requests.packages.urllib3.util.ssl_")
101
+ vendored("requests.packages.urllib3.util.timeout")
102
+ vendored("requests.packages.urllib3.util.url")
103
+ vendored("resolvelib")
104
+ vendored("rich")
105
+ vendored("rich.console")
106
+ vendored("rich.highlighter")
107
+ vendored("rich.logging")
108
+ vendored("rich.markup")
109
+ vendored("rich.progress")
110
+ vendored("rich.segment")
111
+ vendored("rich.style")
112
+ vendored("rich.text")
113
+ vendored("rich.traceback")
114
+ if sys.version_info < (3, 11):
115
+ vendored("tomli")
116
+ vendored("truststore")
117
+ vendored("urllib3")
python/Lib/site-packages/pip/_vendor/cachecontrol/LICENSE.txt ADDED
@@ -0,0 +1,13 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ Copyright 2012-2021 Eric Larson
2
+
3
+ Licensed under the Apache License, Version 2.0 (the "License");
4
+ you may not use this file except in compliance with the License.
5
+ You may obtain a copy of the License at
6
+
7
+ http://www.apache.org/licenses/LICENSE-2.0
8
+
9
+ Unless required by applicable law or agreed to in writing, software
10
+ distributed under the License is distributed on an "AS IS" BASIS,
11
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ See the License for the specific language governing permissions and
13
+ limitations under the License.
python/Lib/site-packages/pip/_vendor/cachecontrol/__init__.py ADDED
@@ -0,0 +1,32 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # SPDX-FileCopyrightText: 2015 Eric Larson
2
+ #
3
+ # SPDX-License-Identifier: Apache-2.0
4
+
5
+ """CacheControl import Interface.
6
+
7
+ Make it easy to import from cachecontrol without long namespaces.
8
+ """
9
+
10
+ import importlib.metadata
11
+
12
+ from pip._vendor.cachecontrol.adapter import CacheControlAdapter
13
+ from pip._vendor.cachecontrol.controller import CacheController
14
+ from pip._vendor.cachecontrol.wrapper import CacheControl
15
+
16
+ __author__ = "Eric Larson"
17
+ __email__ = "eric@ionrock.org"
18
+ # pip patch: this won't work when vendored, so just patch it out as it's unused
19
+ # __version__ = importlib.metadata.version("cachecontrol")
20
+
21
+ __all__ = [
22
+ "__author__",
23
+ "__email__",
24
+ "__version__",
25
+ "CacheControlAdapter",
26
+ "CacheController",
27
+ "CacheControl",
28
+ ]
29
+
30
+ import logging
31
+
32
+ logging.getLogger(__name__).addHandler(logging.NullHandler())
python/Lib/site-packages/pip/_vendor/cachecontrol/_cmd.py ADDED
@@ -0,0 +1,70 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # SPDX-FileCopyrightText: 2015 Eric Larson
2
+ #
3
+ # SPDX-License-Identifier: Apache-2.0
4
+ from __future__ import annotations
5
+
6
+ import logging
7
+ from argparse import ArgumentParser
8
+ from typing import TYPE_CHECKING
9
+
10
+ from pip._vendor import requests
11
+
12
+ from pip._vendor.cachecontrol.adapter import CacheControlAdapter
13
+ from pip._vendor.cachecontrol.cache import DictCache
14
+ from pip._vendor.cachecontrol.controller import logger
15
+
16
+ if TYPE_CHECKING:
17
+ from argparse import Namespace
18
+
19
+ from pip._vendor.cachecontrol.controller import CacheController
20
+
21
+
22
+ def setup_logging() -> None:
23
+ logger.setLevel(logging.DEBUG)
24
+ handler = logging.StreamHandler()
25
+ logger.addHandler(handler)
26
+
27
+
28
+ def get_session() -> requests.Session:
29
+ adapter = CacheControlAdapter(
30
+ DictCache(), cache_etags=True, serializer=None, heuristic=None
31
+ )
32
+ sess = requests.Session()
33
+ sess.mount("http://", adapter)
34
+ sess.mount("https://", adapter)
35
+
36
+ sess.cache_controller = adapter.controller # type: ignore[attr-defined]
37
+ return sess
38
+
39
+
40
+ def get_args() -> Namespace:
41
+ parser = ArgumentParser()
42
+ parser.add_argument("url", help="The URL to try and cache")
43
+ return parser.parse_args()
44
+
45
+
46
+ def main() -> None:
47
+ args = get_args()
48
+ sess = get_session()
49
+
50
+ # Make a request to get a response
51
+ resp = sess.get(args.url)
52
+
53
+ # Turn on logging
54
+ setup_logging()
55
+
56
+ # try setting the cache
57
+ cache_controller: CacheController = (
58
+ sess.cache_controller # type: ignore[attr-defined]
59
+ )
60
+ cache_controller.cache_response(resp.request, resp.raw)
61
+
62
+ # Now try to get it
63
+ if cache_controller.cached_request(resp.request):
64
+ print("Cached!")
65
+ else:
66
+ print("Not cached :(")
67
+
68
+
69
+ if __name__ == "__main__":
70
+ main()
python/Lib/site-packages/pip/_vendor/cachecontrol/adapter.py ADDED
@@ -0,0 +1,167 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # SPDX-FileCopyrightText: 2015 Eric Larson
2
+ #
3
+ # SPDX-License-Identifier: Apache-2.0
4
+ from __future__ import annotations
5
+
6
+ import functools
7
+ import weakref
8
+ import zlib
9
+ from typing import TYPE_CHECKING, Any, Collection, Mapping
10
+
11
+ from pip._vendor.requests.adapters import HTTPAdapter
12
+
13
+ from pip._vendor.cachecontrol.cache import DictCache
14
+ from pip._vendor.cachecontrol.controller import PERMANENT_REDIRECT_STATUSES, CacheController
15
+ from pip._vendor.cachecontrol.filewrapper import CallbackFileWrapper
16
+
17
+ if TYPE_CHECKING:
18
+ from pip._vendor.requests import PreparedRequest, Response
19
+ from pip._vendor.urllib3 import HTTPResponse
20
+
21
+ from pip._vendor.cachecontrol.cache import BaseCache
22
+ from pip._vendor.cachecontrol.heuristics import BaseHeuristic
23
+ from pip._vendor.cachecontrol.serialize import Serializer
24
+
25
+
26
+ class CacheControlAdapter(HTTPAdapter):
27
+ invalidating_methods = {"PUT", "PATCH", "DELETE"}
28
+
29
+ def __init__(
30
+ self,
31
+ cache: BaseCache | None = None,
32
+ cache_etags: bool = True,
33
+ controller_class: type[CacheController] | None = None,
34
+ serializer: Serializer | None = None,
35
+ heuristic: BaseHeuristic | None = None,
36
+ cacheable_methods: Collection[str] | None = None,
37
+ *args: Any,
38
+ **kw: Any,
39
+ ) -> None:
40
+ super().__init__(*args, **kw)
41
+ self.cache = DictCache() if cache is None else cache
42
+ self.heuristic = heuristic
43
+ self.cacheable_methods = cacheable_methods or ("GET",)
44
+
45
+ controller_factory = controller_class or CacheController
46
+ self.controller = controller_factory(
47
+ self.cache, cache_etags=cache_etags, serializer=serializer
48
+ )
49
+
50
+ def send(
51
+ self,
52
+ request: PreparedRequest,
53
+ stream: bool = False,
54
+ timeout: None | float | tuple[float, float] | tuple[float, None] = None,
55
+ verify: bool | str = True,
56
+ cert: (None | bytes | str | tuple[bytes | str, bytes | str]) = None,
57
+ proxies: Mapping[str, str] | None = None,
58
+ cacheable_methods: Collection[str] | None = None,
59
+ ) -> Response:
60
+ """
61
+ Send a request. Use the request information to see if it
62
+ exists in the cache and cache the response if we need to and can.
63
+ """
64
+ cacheable = cacheable_methods or self.cacheable_methods
65
+ if request.method in cacheable:
66
+ try:
67
+ cached_response = self.controller.cached_request(request)
68
+ except zlib.error:
69
+ cached_response = None
70
+ if cached_response:
71
+ return self.build_response(request, cached_response, from_cache=True)
72
+
73
+ # check for etags and add headers if appropriate
74
+ request.headers.update(self.controller.conditional_headers(request))
75
+
76
+ resp = super().send(request, stream, timeout, verify, cert, proxies)
77
+
78
+ return resp
79
+
80
+ def build_response( # type: ignore[override]
81
+ self,
82
+ request: PreparedRequest,
83
+ response: HTTPResponse,
84
+ from_cache: bool = False,
85
+ cacheable_methods: Collection[str] | None = None,
86
+ ) -> Response:
87
+ """
88
+ Build a response by making a request or using the cache.
89
+
90
+ This will end up calling send and returning a potentially
91
+ cached response
92
+ """
93
+ cacheable = cacheable_methods or self.cacheable_methods
94
+ if not from_cache and request.method in cacheable:
95
+ # Check for any heuristics that might update headers
96
+ # before trying to cache.
97
+ if self.heuristic:
98
+ response = self.heuristic.apply(response)
99
+
100
+ # apply any expiration heuristics
101
+ if response.status == 304:
102
+ # We must have sent an ETag request. This could mean
103
+ # that we've been expired already or that we simply
104
+ # have an etag. In either case, we want to try and
105
+ # update the cache if that is the case.
106
+ cached_response = self.controller.update_cached_response(
107
+ request, response
108
+ )
109
+
110
+ if cached_response is not response:
111
+ from_cache = True
112
+
113
+ # We are done with the server response, read a
114
+ # possible response body (compliant servers will
115
+ # not return one, but we cannot be 100% sure) and
116
+ # release the connection back to the pool.
117
+ response.read(decode_content=False)
118
+ response.release_conn()
119
+
120
+ response = cached_response
121
+
122
+ # We always cache the 301 responses
123
+ elif int(response.status) in PERMANENT_REDIRECT_STATUSES:
124
+ self.controller.cache_response(request, response)
125
+ else:
126
+ # Wrap the response file with a wrapper that will cache the
127
+ # response when the stream has been consumed.
128
+ response._fp = CallbackFileWrapper( # type: ignore[assignment]
129
+ response._fp, # type: ignore[arg-type]
130
+ functools.partial(
131
+ self.controller.cache_response, request, weakref.ref(response)
132
+ ),
133
+ )
134
+ if response.chunked:
135
+ super_update_chunk_length = response.__class__._update_chunk_length
136
+
137
+ def _update_chunk_length(
138
+ weak_self: weakref.ReferenceType[HTTPResponse],
139
+ ) -> None:
140
+ self = weak_self()
141
+ if self is None:
142
+ return
143
+
144
+ super_update_chunk_length(self)
145
+ if self.chunk_left == 0:
146
+ self._fp._close() # type: ignore[union-attr]
147
+
148
+ response._update_chunk_length = functools.partial( # type: ignore[method-assign]
149
+ _update_chunk_length, weakref.ref(response)
150
+ )
151
+
152
+ resp: Response = super().build_response(request, response)
153
+
154
+ # See if we should invalidate the cache.
155
+ if request.method in self.invalidating_methods and resp.ok:
156
+ assert request.url is not None
157
+ cache_url = self.controller.cache_url(request.url)
158
+ self.cache.delete(cache_url)
159
+
160
+ # Give the request a from_cache attr to let people use it
161
+ resp.from_cache = from_cache # type: ignore[attr-defined]
162
+
163
+ return resp
164
+
165
+ def close(self) -> None:
166
+ self.cache.close()
167
+ super().close() # type: ignore[no-untyped-call]
python/Lib/site-packages/pip/_vendor/cachecontrol/cache.py ADDED
@@ -0,0 +1,75 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # SPDX-FileCopyrightText: 2015 Eric Larson
2
+ #
3
+ # SPDX-License-Identifier: Apache-2.0
4
+
5
+ """
6
+ The cache object API for implementing caches. The default is a thread
7
+ safe in-memory dictionary.
8
+ """
9
+
10
+ from __future__ import annotations
11
+
12
+ from threading import Lock
13
+ from typing import IO, TYPE_CHECKING, MutableMapping
14
+
15
+ if TYPE_CHECKING:
16
+ from datetime import datetime
17
+
18
+
19
+ class BaseCache:
20
+ def get(self, key: str) -> bytes | None:
21
+ raise NotImplementedError()
22
+
23
+ def set(
24
+ self, key: str, value: bytes, expires: int | datetime | None = None
25
+ ) -> None:
26
+ raise NotImplementedError()
27
+
28
+ def delete(self, key: str) -> None:
29
+ raise NotImplementedError()
30
+
31
+ def close(self) -> None:
32
+ pass
33
+
34
+
35
+ class DictCache(BaseCache):
36
+ def __init__(self, init_dict: MutableMapping[str, bytes] | None = None) -> None:
37
+ self.lock = Lock()
38
+ self.data = init_dict or {}
39
+
40
+ def get(self, key: str) -> bytes | None:
41
+ return self.data.get(key, None)
42
+
43
+ def set(
44
+ self, key: str, value: bytes, expires: int | datetime | None = None
45
+ ) -> None:
46
+ with self.lock:
47
+ self.data.update({key: value})
48
+
49
+ def delete(self, key: str) -> None:
50
+ with self.lock:
51
+ if key in self.data:
52
+ self.data.pop(key)
53
+
54
+
55
+ class SeparateBodyBaseCache(BaseCache):
56
+ """
57
+ In this variant, the body is not stored mixed in with the metadata, but is
58
+ passed in (as a bytes-like object) in a separate call to ``set_body()``.
59
+
60
+ That is, the expected interaction pattern is::
61
+
62
+ cache.set(key, serialized_metadata)
63
+ cache.set_body(key)
64
+
65
+ Similarly, the body should be loaded separately via ``get_body()``.
66
+ """
67
+
68
+ def set_body(self, key: str, body: bytes) -> None:
69
+ raise NotImplementedError()
70
+
71
+ def get_body(self, key: str) -> IO[bytes] | None:
72
+ """
73
+ Return the body as file-like object.
74
+ """
75
+ raise NotImplementedError()
python/Lib/site-packages/pip/_vendor/cachecontrol/controller.py ADDED
@@ -0,0 +1,511 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # SPDX-FileCopyrightText: 2015 Eric Larson
2
+ #
3
+ # SPDX-License-Identifier: Apache-2.0
4
+
5
+ """
6
+ The httplib2 algorithms ported for use with requests.
7
+ """
8
+
9
+ from __future__ import annotations
10
+
11
+ import calendar
12
+ import logging
13
+ import re
14
+ import time
15
+ import weakref
16
+ from email.utils import parsedate_tz
17
+ from typing import TYPE_CHECKING, Collection, Mapping
18
+
19
+ from pip._vendor.requests.structures import CaseInsensitiveDict
20
+
21
+ from pip._vendor.cachecontrol.cache import DictCache, SeparateBodyBaseCache
22
+ from pip._vendor.cachecontrol.serialize import Serializer
23
+
24
+ if TYPE_CHECKING:
25
+ from typing import Literal
26
+
27
+ from pip._vendor.requests import PreparedRequest
28
+ from pip._vendor.urllib3 import HTTPResponse
29
+
30
+ from pip._vendor.cachecontrol.cache import BaseCache
31
+
32
+ logger = logging.getLogger(__name__)
33
+
34
+ URI = re.compile(r"^(([^:/?#]+):)?(//([^/?#]*))?([^?#]*)(\?([^#]*))?(#(.*))?")
35
+
36
+ PERMANENT_REDIRECT_STATUSES = (301, 308)
37
+
38
+
39
+ def parse_uri(uri: str) -> tuple[str, str, str, str, str]:
40
+ """Parses a URI using the regex given in Appendix B of RFC 3986.
41
+
42
+ (scheme, authority, path, query, fragment) = parse_uri(uri)
43
+ """
44
+ match = URI.match(uri)
45
+ assert match is not None
46
+ groups = match.groups()
47
+ return (groups[1], groups[3], groups[4], groups[6], groups[8])
48
+
49
+
50
+ class CacheController:
51
+ """An interface to see if request should cached or not."""
52
+
53
+ def __init__(
54
+ self,
55
+ cache: BaseCache | None = None,
56
+ cache_etags: bool = True,
57
+ serializer: Serializer | None = None,
58
+ status_codes: Collection[int] | None = None,
59
+ ):
60
+ self.cache = DictCache() if cache is None else cache
61
+ self.cache_etags = cache_etags
62
+ self.serializer = serializer or Serializer()
63
+ self.cacheable_status_codes = status_codes or (200, 203, 300, 301, 308)
64
+
65
+ @classmethod
66
+ def _urlnorm(cls, uri: str) -> str:
67
+ """Normalize the URL to create a safe key for the cache"""
68
+ (scheme, authority, path, query, fragment) = parse_uri(uri)
69
+ if not scheme or not authority:
70
+ raise Exception("Only absolute URIs are allowed. uri = %s" % uri)
71
+
72
+ scheme = scheme.lower()
73
+ authority = authority.lower()
74
+
75
+ if not path:
76
+ path = "/"
77
+
78
+ # Could do syntax based normalization of the URI before
79
+ # computing the digest. See Section 6.2.2 of Std 66.
80
+ request_uri = query and "?".join([path, query]) or path
81
+ defrag_uri = scheme + "://" + authority + request_uri
82
+
83
+ return defrag_uri
84
+
85
+ @classmethod
86
+ def cache_url(cls, uri: str) -> str:
87
+ return cls._urlnorm(uri)
88
+
89
+ def parse_cache_control(self, headers: Mapping[str, str]) -> dict[str, int | None]:
90
+ known_directives = {
91
+ # https://tools.ietf.org/html/rfc7234#section-5.2
92
+ "max-age": (int, True),
93
+ "max-stale": (int, False),
94
+ "min-fresh": (int, True),
95
+ "no-cache": (None, False),
96
+ "no-store": (None, False),
97
+ "no-transform": (None, False),
98
+ "only-if-cached": (None, False),
99
+ "must-revalidate": (None, False),
100
+ "public": (None, False),
101
+ "private": (None, False),
102
+ "proxy-revalidate": (None, False),
103
+ "s-maxage": (int, True),
104
+ }
105
+
106
+ cc_headers = headers.get("cache-control", headers.get("Cache-Control", ""))
107
+
108
+ retval: dict[str, int | None] = {}
109
+
110
+ for cc_directive in cc_headers.split(","):
111
+ if not cc_directive.strip():
112
+ continue
113
+
114
+ parts = cc_directive.split("=", 1)
115
+ directive = parts[0].strip()
116
+
117
+ try:
118
+ typ, required = known_directives[directive]
119
+ except KeyError:
120
+ logger.debug("Ignoring unknown cache-control directive: %s", directive)
121
+ continue
122
+
123
+ if not typ or not required:
124
+ retval[directive] = None
125
+ if typ:
126
+ try:
127
+ retval[directive] = typ(parts[1].strip())
128
+ except IndexError:
129
+ if required:
130
+ logger.debug(
131
+ "Missing value for cache-control " "directive: %s",
132
+ directive,
133
+ )
134
+ except ValueError:
135
+ logger.debug(
136
+ "Invalid value for cache-control directive " "%s, must be %s",
137
+ directive,
138
+ typ.__name__,
139
+ )
140
+
141
+ return retval
142
+
143
+ def _load_from_cache(self, request: PreparedRequest) -> HTTPResponse | None:
144
+ """
145
+ Load a cached response, or return None if it's not available.
146
+ """
147
+ # We do not support caching of partial content: so if the request contains a
148
+ # Range header then we don't want to load anything from the cache.
149
+ if "Range" in request.headers:
150
+ return None
151
+
152
+ cache_url = request.url
153
+ assert cache_url is not None
154
+ cache_data = self.cache.get(cache_url)
155
+ if cache_data is None:
156
+ logger.debug("No cache entry available")
157
+ return None
158
+
159
+ if isinstance(self.cache, SeparateBodyBaseCache):
160
+ body_file = self.cache.get_body(cache_url)
161
+ else:
162
+ body_file = None
163
+
164
+ result = self.serializer.loads(request, cache_data, body_file)
165
+ if result is None:
166
+ logger.warning("Cache entry deserialization failed, entry ignored")
167
+ return result
168
+
169
+ def cached_request(self, request: PreparedRequest) -> HTTPResponse | Literal[False]:
170
+ """
171
+ Return a cached response if it exists in the cache, otherwise
172
+ return False.
173
+ """
174
+ assert request.url is not None
175
+ cache_url = self.cache_url(request.url)
176
+ logger.debug('Looking up "%s" in the cache', cache_url)
177
+ cc = self.parse_cache_control(request.headers)
178
+
179
+ # Bail out if the request insists on fresh data
180
+ if "no-cache" in cc:
181
+ logger.debug('Request header has "no-cache", cache bypassed')
182
+ return False
183
+
184
+ if "max-age" in cc and cc["max-age"] == 0:
185
+ logger.debug('Request header has "max_age" as 0, cache bypassed')
186
+ return False
187
+
188
+ # Check whether we can load the response from the cache:
189
+ resp = self._load_from_cache(request)
190
+ if not resp:
191
+ return False
192
+
193
+ # If we have a cached permanent redirect, return it immediately. We
194
+ # don't need to test our response for other headers b/c it is
195
+ # intrinsically "cacheable" as it is Permanent.
196
+ #
197
+ # See:
198
+ # https://tools.ietf.org/html/rfc7231#section-6.4.2
199
+ #
200
+ # Client can try to refresh the value by repeating the request
201
+ # with cache busting headers as usual (ie no-cache).
202
+ if int(resp.status) in PERMANENT_REDIRECT_STATUSES:
203
+ msg = (
204
+ "Returning cached permanent redirect response "
205
+ "(ignoring date and etag information)"
206
+ )
207
+ logger.debug(msg)
208
+ return resp
209
+
210
+ headers: CaseInsensitiveDict[str] = CaseInsensitiveDict(resp.headers)
211
+ if not headers or "date" not in headers:
212
+ if "etag" not in headers:
213
+ # Without date or etag, the cached response can never be used
214
+ # and should be deleted.
215
+ logger.debug("Purging cached response: no date or etag")
216
+ self.cache.delete(cache_url)
217
+ logger.debug("Ignoring cached response: no date")
218
+ return False
219
+
220
+ now = time.time()
221
+ time_tuple = parsedate_tz(headers["date"])
222
+ assert time_tuple is not None
223
+ date = calendar.timegm(time_tuple[:6])
224
+ current_age = max(0, now - date)
225
+ logger.debug("Current age based on date: %i", current_age)
226
+
227
+ # TODO: There is an assumption that the result will be a
228
+ # urllib3 response object. This may not be best since we
229
+ # could probably avoid instantiating or constructing the
230
+ # response until we know we need it.
231
+ resp_cc = self.parse_cache_control(headers)
232
+
233
+ # determine freshness
234
+ freshness_lifetime = 0
235
+
236
+ # Check the max-age pragma in the cache control header
237
+ max_age = resp_cc.get("max-age")
238
+ if max_age is not None:
239
+ freshness_lifetime = max_age
240
+ logger.debug("Freshness lifetime from max-age: %i", freshness_lifetime)
241
+
242
+ # If there isn't a max-age, check for an expires header
243
+ elif "expires" in headers:
244
+ expires = parsedate_tz(headers["expires"])
245
+ if expires is not None:
246
+ expire_time = calendar.timegm(expires[:6]) - date
247
+ freshness_lifetime = max(0, expire_time)
248
+ logger.debug("Freshness lifetime from expires: %i", freshness_lifetime)
249
+
250
+ # Determine if we are setting freshness limit in the
251
+ # request. Note, this overrides what was in the response.
252
+ max_age = cc.get("max-age")
253
+ if max_age is not None:
254
+ freshness_lifetime = max_age
255
+ logger.debug(
256
+ "Freshness lifetime from request max-age: %i", freshness_lifetime
257
+ )
258
+
259
+ min_fresh = cc.get("min-fresh")
260
+ if min_fresh is not None:
261
+ # adjust our current age by our min fresh
262
+ current_age += min_fresh
263
+ logger.debug("Adjusted current age from min-fresh: %i", current_age)
264
+
265
+ # Return entry if it is fresh enough
266
+ if freshness_lifetime > current_age:
267
+ logger.debug('The response is "fresh", returning cached response')
268
+ logger.debug("%i > %i", freshness_lifetime, current_age)
269
+ return resp
270
+
271
+ # we're not fresh. If we don't have an Etag, clear it out
272
+ if "etag" not in headers:
273
+ logger.debug('The cached response is "stale" with no etag, purging')
274
+ self.cache.delete(cache_url)
275
+
276
+ # return the original handler
277
+ return False
278
+
279
+ def conditional_headers(self, request: PreparedRequest) -> dict[str, str]:
280
+ resp = self._load_from_cache(request)
281
+ new_headers = {}
282
+
283
+ if resp:
284
+ headers: CaseInsensitiveDict[str] = CaseInsensitiveDict(resp.headers)
285
+
286
+ if "etag" in headers:
287
+ new_headers["If-None-Match"] = headers["ETag"]
288
+
289
+ if "last-modified" in headers:
290
+ new_headers["If-Modified-Since"] = headers["Last-Modified"]
291
+
292
+ return new_headers
293
+
294
+ def _cache_set(
295
+ self,
296
+ cache_url: str,
297
+ request: PreparedRequest,
298
+ response: HTTPResponse,
299
+ body: bytes | None = None,
300
+ expires_time: int | None = None,
301
+ ) -> None:
302
+ """
303
+ Store the data in the cache.
304
+ """
305
+ if isinstance(self.cache, SeparateBodyBaseCache):
306
+ # We pass in the body separately; just put a placeholder empty
307
+ # string in the metadata.
308
+ self.cache.set(
309
+ cache_url,
310
+ self.serializer.dumps(request, response, b""),
311
+ expires=expires_time,
312
+ )
313
+ # body is None can happen when, for example, we're only updating
314
+ # headers, as is the case in update_cached_response().
315
+ if body is not None:
316
+ self.cache.set_body(cache_url, body)
317
+ else:
318
+ self.cache.set(
319
+ cache_url,
320
+ self.serializer.dumps(request, response, body),
321
+ expires=expires_time,
322
+ )
323
+
324
+ def cache_response(
325
+ self,
326
+ request: PreparedRequest,
327
+ response_or_ref: HTTPResponse | weakref.ReferenceType[HTTPResponse],
328
+ body: bytes | None = None,
329
+ status_codes: Collection[int] | None = None,
330
+ ) -> None:
331
+ """
332
+ Algorithm for caching requests.
333
+
334
+ This assumes a requests Response object.
335
+ """
336
+ if isinstance(response_or_ref, weakref.ReferenceType):
337
+ response = response_or_ref()
338
+ if response is None:
339
+ # The weakref can be None only in case the user used streamed request
340
+ # and did not consume or close it, and holds no reference to requests.Response.
341
+ # In such case, we don't want to cache the response.
342
+ return
343
+ else:
344
+ response = response_or_ref
345
+
346
+ # From httplib2: Don't cache 206's since we aren't going to
347
+ # handle byte range requests
348
+ cacheable_status_codes = status_codes or self.cacheable_status_codes
349
+ if response.status not in cacheable_status_codes:
350
+ logger.debug(
351
+ "Status code %s not in %s", response.status, cacheable_status_codes
352
+ )
353
+ return
354
+
355
+ response_headers: CaseInsensitiveDict[str] = CaseInsensitiveDict(
356
+ response.headers
357
+ )
358
+
359
+ if "date" in response_headers:
360
+ time_tuple = parsedate_tz(response_headers["date"])
361
+ assert time_tuple is not None
362
+ date = calendar.timegm(time_tuple[:6])
363
+ else:
364
+ date = 0
365
+
366
+ # If we've been given a body, our response has a Content-Length, that
367
+ # Content-Length is valid then we can check to see if the body we've
368
+ # been given matches the expected size, and if it doesn't we'll just
369
+ # skip trying to cache it.
370
+ if (
371
+ body is not None
372
+ and "content-length" in response_headers
373
+ and response_headers["content-length"].isdigit()
374
+ and int(response_headers["content-length"]) != len(body)
375
+ ):
376
+ return
377
+
378
+ cc_req = self.parse_cache_control(request.headers)
379
+ cc = self.parse_cache_control(response_headers)
380
+
381
+ assert request.url is not None
382
+ cache_url = self.cache_url(request.url)
383
+ logger.debug('Updating cache with response from "%s"', cache_url)
384
+
385
+ # Delete it from the cache if we happen to have it stored there
386
+ no_store = False
387
+ if "no-store" in cc:
388
+ no_store = True
389
+ logger.debug('Response header has "no-store"')
390
+ if "no-store" in cc_req:
391
+ no_store = True
392
+ logger.debug('Request header has "no-store"')
393
+ if no_store and self.cache.get(cache_url):
394
+ logger.debug('Purging existing cache entry to honor "no-store"')
395
+ self.cache.delete(cache_url)
396
+ if no_store:
397
+ return
398
+
399
+ # https://tools.ietf.org/html/rfc7234#section-4.1:
400
+ # A Vary header field-value of "*" always fails to match.
401
+ # Storing such a response leads to a deserialization warning
402
+ # during cache lookup and is not allowed to ever be served,
403
+ # so storing it can be avoided.
404
+ if "*" in response_headers.get("vary", ""):
405
+ logger.debug('Response header has "Vary: *"')
406
+ return
407
+
408
+ # If we've been given an etag, then keep the response
409
+ if self.cache_etags and "etag" in response_headers:
410
+ expires_time = 0
411
+ if response_headers.get("expires"):
412
+ expires = parsedate_tz(response_headers["expires"])
413
+ if expires is not None:
414
+ expires_time = calendar.timegm(expires[:6]) - date
415
+
416
+ expires_time = max(expires_time, 14 * 86400)
417
+
418
+ logger.debug(f"etag object cached for {expires_time} seconds")
419
+ logger.debug("Caching due to etag")
420
+ self._cache_set(cache_url, request, response, body, expires_time)
421
+
422
+ # Add to the cache any permanent redirects. We do this before looking
423
+ # that the Date headers.
424
+ elif int(response.status) in PERMANENT_REDIRECT_STATUSES:
425
+ logger.debug("Caching permanent redirect")
426
+ self._cache_set(cache_url, request, response, b"")
427
+
428
+ # Add to the cache if the response headers demand it. If there
429
+ # is no date header then we can't do anything about expiring
430
+ # the cache.
431
+ elif "date" in response_headers:
432
+ time_tuple = parsedate_tz(response_headers["date"])
433
+ assert time_tuple is not None
434
+ date = calendar.timegm(time_tuple[:6])
435
+ # cache when there is a max-age > 0
436
+ max_age = cc.get("max-age")
437
+ if max_age is not None and max_age > 0:
438
+ logger.debug("Caching b/c date exists and max-age > 0")
439
+ expires_time = max_age
440
+ self._cache_set(
441
+ cache_url,
442
+ request,
443
+ response,
444
+ body,
445
+ expires_time,
446
+ )
447
+
448
+ # If the request can expire, it means we should cache it
449
+ # in the meantime.
450
+ elif "expires" in response_headers:
451
+ if response_headers["expires"]:
452
+ expires = parsedate_tz(response_headers["expires"])
453
+ if expires is not None:
454
+ expires_time = calendar.timegm(expires[:6]) - date
455
+ else:
456
+ expires_time = None
457
+
458
+ logger.debug(
459
+ "Caching b/c of expires header. expires in {} seconds".format(
460
+ expires_time
461
+ )
462
+ )
463
+ self._cache_set(
464
+ cache_url,
465
+ request,
466
+ response,
467
+ body,
468
+ expires_time,
469
+ )
470
+
471
+ def update_cached_response(
472
+ self, request: PreparedRequest, response: HTTPResponse
473
+ ) -> HTTPResponse:
474
+ """On a 304 we will get a new set of headers that we want to
475
+ update our cached value with, assuming we have one.
476
+
477
+ This should only ever be called when we've sent an ETag and
478
+ gotten a 304 as the response.
479
+ """
480
+ assert request.url is not None
481
+ cache_url = self.cache_url(request.url)
482
+ cached_response = self._load_from_cache(request)
483
+
484
+ if not cached_response:
485
+ # we didn't have a cached response
486
+ return response
487
+
488
+ # Lets update our headers with the headers from the new request:
489
+ # http://tools.ietf.org/html/draft-ietf-httpbis-p4-conditional-26#section-4.1
490
+ #
491
+ # The server isn't supposed to send headers that would make
492
+ # the cached body invalid. But... just in case, we'll be sure
493
+ # to strip out ones we know that might be problematic due to
494
+ # typical assumptions.
495
+ excluded_headers = ["content-length"]
496
+
497
+ cached_response.headers.update(
498
+ {
499
+ k: v
500
+ for k, v in response.headers.items()
501
+ if k.lower() not in excluded_headers
502
+ }
503
+ )
504
+
505
+ # we want a 200 b/c we have content via the cache
506
+ cached_response.status = 200
507
+
508
+ # update our cache
509
+ self._cache_set(cache_url, request, cached_response)
510
+
511
+ return cached_response
python/Lib/site-packages/pip/_vendor/cachecontrol/filewrapper.py ADDED
@@ -0,0 +1,121 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # SPDX-FileCopyrightText: 2015 Eric Larson
2
+ #
3
+ # SPDX-License-Identifier: Apache-2.0
4
+ from __future__ import annotations
5
+
6
+ import mmap
7
+ from tempfile import NamedTemporaryFile
8
+ from typing import TYPE_CHECKING, Any, Callable
9
+
10
+ if TYPE_CHECKING:
11
+ from collections.abc import Buffer
12
+ from http.client import HTTPResponse
13
+
14
+
15
+ class CallbackFileWrapper:
16
+ """
17
+ Small wrapper around a fp object which will tee everything read into a
18
+ buffer, and when that file is closed it will execute a callback with the
19
+ contents of that buffer.
20
+
21
+ All attributes are proxied to the underlying file object.
22
+
23
+ This class uses members with a double underscore (__) leading prefix so as
24
+ not to accidentally shadow an attribute.
25
+
26
+ The data is stored in a temporary file until it is all available. As long
27
+ as the temporary files directory is disk-based (sometimes it's a
28
+ memory-backed-``tmpfs`` on Linux), data will be unloaded to disk if memory
29
+ pressure is high. For small files the disk usually won't be used at all,
30
+ it'll all be in the filesystem memory cache, so there should be no
31
+ performance impact.
32
+ """
33
+
34
+ def __init__(
35
+ self, fp: HTTPResponse, callback: Callable[[Buffer], None] | None
36
+ ) -> None:
37
+ self.__buf = NamedTemporaryFile("rb+", delete=True)
38
+ self.__fp = fp
39
+ self.__callback = callback
40
+
41
+ def __getattr__(self, name: str) -> Any:
42
+ # The vagaries of garbage collection means that self.__fp is
43
+ # not always set. By using __getattribute__ and the private
44
+ # name[0] allows looking up the attribute value and raising an
45
+ # AttributeError when it doesn't exist. This stop things from
46
+ # infinitely recursing calls to getattr in the case where
47
+ # self.__fp hasn't been set.
48
+ #
49
+ # [0] https://docs.python.org/2/reference/expressions.html#atom-identifiers
50
+ fp = self.__getattribute__("_CallbackFileWrapper__fp")
51
+ return getattr(fp, name)
52
+
53
+ def __is_fp_closed(self) -> bool:
54
+ try:
55
+ return self.__fp.fp is None
56
+
57
+ except AttributeError:
58
+ pass
59
+
60
+ try:
61
+ closed: bool = self.__fp.closed
62
+ return closed
63
+
64
+ except AttributeError:
65
+ pass
66
+
67
+ # We just don't cache it then.
68
+ # TODO: Add some logging here...
69
+ return False
70
+
71
+ def _close(self) -> None:
72
+ result: Buffer
73
+ if self.__callback:
74
+ if self.__buf.tell() == 0:
75
+ # Empty file:
76
+ result = b""
77
+ else:
78
+ # Return the data without actually loading it into memory,
79
+ # relying on Python's buffer API and mmap(). mmap() just gives
80
+ # a view directly into the filesystem's memory cache, so it
81
+ # doesn't result in duplicate memory use.
82
+ self.__buf.seek(0, 0)
83
+ result = memoryview(
84
+ mmap.mmap(self.__buf.fileno(), 0, access=mmap.ACCESS_READ)
85
+ )
86
+ self.__callback(result)
87
+
88
+ # We assign this to None here, because otherwise we can get into
89
+ # really tricky problems where the CPython interpreter dead locks
90
+ # because the callback is holding a reference to something which
91
+ # has a __del__ method. Setting this to None breaks the cycle
92
+ # and allows the garbage collector to do it's thing normally.
93
+ self.__callback = None
94
+
95
+ # Closing the temporary file releases memory and frees disk space.
96
+ # Important when caching big files.
97
+ self.__buf.close()
98
+
99
+ def read(self, amt: int | None = None) -> bytes:
100
+ data: bytes = self.__fp.read(amt)
101
+ if data:
102
+ # We may be dealing with b'', a sign that things are over:
103
+ # it's passed e.g. after we've already closed self.__buf.
104
+ self.__buf.write(data)
105
+ if self.__is_fp_closed():
106
+ self._close()
107
+
108
+ return data
109
+
110
+ def _safe_read(self, amt: int) -> bytes:
111
+ data: bytes = self.__fp._safe_read(amt) # type: ignore[attr-defined]
112
+ if amt == 2 and data == b"\r\n":
113
+ # urllib executes this read to toss the CRLF at the end
114
+ # of the chunk.
115
+ return data
116
+
117
+ self.__buf.write(data)
118
+ if self.__is_fp_closed():
119
+ self._close()
120
+
121
+ return data
python/Lib/site-packages/pip/_vendor/cachecontrol/heuristics.py ADDED
@@ -0,0 +1,157 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # SPDX-FileCopyrightText: 2015 Eric Larson
2
+ #
3
+ # SPDX-License-Identifier: Apache-2.0
4
+ from __future__ import annotations
5
+
6
+ import calendar
7
+ import time
8
+ from datetime import datetime, timedelta, timezone
9
+ from email.utils import formatdate, parsedate, parsedate_tz
10
+ from typing import TYPE_CHECKING, Any, Mapping
11
+
12
+ if TYPE_CHECKING:
13
+ from pip._vendor.urllib3 import HTTPResponse
14
+
15
+ TIME_FMT = "%a, %d %b %Y %H:%M:%S GMT"
16
+
17
+
18
+ def expire_after(delta: timedelta, date: datetime | None = None) -> datetime:
19
+ date = date or datetime.now(timezone.utc)
20
+ return date + delta
21
+
22
+
23
+ def datetime_to_header(dt: datetime) -> str:
24
+ return formatdate(calendar.timegm(dt.timetuple()))
25
+
26
+
27
+ class BaseHeuristic:
28
+ def warning(self, response: HTTPResponse) -> str | None:
29
+ """
30
+ Return a valid 1xx warning header value describing the cache
31
+ adjustments.
32
+
33
+ The response is provided too allow warnings like 113
34
+ http://tools.ietf.org/html/rfc7234#section-5.5.4 where we need
35
+ to explicitly say response is over 24 hours old.
36
+ """
37
+ return '110 - "Response is Stale"'
38
+
39
+ def update_headers(self, response: HTTPResponse) -> dict[str, str]:
40
+ """Update the response headers with any new headers.
41
+
42
+ NOTE: This SHOULD always include some Warning header to
43
+ signify that the response was cached by the client, not
44
+ by way of the provided headers.
45
+ """
46
+ return {}
47
+
48
+ def apply(self, response: HTTPResponse) -> HTTPResponse:
49
+ updated_headers = self.update_headers(response)
50
+
51
+ if updated_headers:
52
+ response.headers.update(updated_headers)
53
+ warning_header_value = self.warning(response)
54
+ if warning_header_value is not None:
55
+ response.headers.update({"Warning": warning_header_value})
56
+
57
+ return response
58
+
59
+
60
+ class OneDayCache(BaseHeuristic):
61
+ """
62
+ Cache the response by providing an expires 1 day in the
63
+ future.
64
+ """
65
+
66
+ def update_headers(self, response: HTTPResponse) -> dict[str, str]:
67
+ headers = {}
68
+
69
+ if "expires" not in response.headers:
70
+ date = parsedate(response.headers["date"])
71
+ expires = expire_after(
72
+ timedelta(days=1),
73
+ date=datetime(*date[:6], tzinfo=timezone.utc), # type: ignore[index,misc]
74
+ )
75
+ headers["expires"] = datetime_to_header(expires)
76
+ headers["cache-control"] = "public"
77
+ return headers
78
+
79
+
80
+ class ExpiresAfter(BaseHeuristic):
81
+ """
82
+ Cache **all** requests for a defined time period.
83
+ """
84
+
85
+ def __init__(self, **kw: Any) -> None:
86
+ self.delta = timedelta(**kw)
87
+
88
+ def update_headers(self, response: HTTPResponse) -> dict[str, str]:
89
+ expires = expire_after(self.delta)
90
+ return {"expires": datetime_to_header(expires), "cache-control": "public"}
91
+
92
+ def warning(self, response: HTTPResponse) -> str | None:
93
+ tmpl = "110 - Automatically cached for %s. Response might be stale"
94
+ return tmpl % self.delta
95
+
96
+
97
+ class LastModified(BaseHeuristic):
98
+ """
99
+ If there is no Expires header already, fall back on Last-Modified
100
+ using the heuristic from
101
+ http://tools.ietf.org/html/rfc7234#section-4.2.2
102
+ to calculate a reasonable value.
103
+
104
+ Firefox also does something like this per
105
+ https://developer.mozilla.org/en-US/docs/Web/HTTP/Caching_FAQ
106
+ http://lxr.mozilla.org/mozilla-release/source/netwerk/protocol/http/nsHttpResponseHead.cpp#397
107
+ Unlike mozilla we limit this to 24-hr.
108
+ """
109
+
110
+ cacheable_by_default_statuses = {
111
+ 200,
112
+ 203,
113
+ 204,
114
+ 206,
115
+ 300,
116
+ 301,
117
+ 404,
118
+ 405,
119
+ 410,
120
+ 414,
121
+ 501,
122
+ }
123
+
124
+ def update_headers(self, resp: HTTPResponse) -> dict[str, str]:
125
+ headers: Mapping[str, str] = resp.headers
126
+
127
+ if "expires" in headers:
128
+ return {}
129
+
130
+ if "cache-control" in headers and headers["cache-control"] != "public":
131
+ return {}
132
+
133
+ if resp.status not in self.cacheable_by_default_statuses:
134
+ return {}
135
+
136
+ if "date" not in headers or "last-modified" not in headers:
137
+ return {}
138
+
139
+ time_tuple = parsedate_tz(headers["date"])
140
+ assert time_tuple is not None
141
+ date = calendar.timegm(time_tuple[:6])
142
+ last_modified = parsedate(headers["last-modified"])
143
+ if last_modified is None:
144
+ return {}
145
+
146
+ now = time.time()
147
+ current_age = max(0, now - date)
148
+ delta = date - calendar.timegm(last_modified)
149
+ freshness_lifetime = max(0, min(delta / 10, 24 * 3600))
150
+ if freshness_lifetime <= current_age:
151
+ return {}
152
+
153
+ expires = date + freshness_lifetime
154
+ return {"expires": time.strftime(TIME_FMT, time.gmtime(expires))}
155
+
156
+ def warning(self, resp: HTTPResponse) -> str | None:
157
+ return None
python/Lib/site-packages/pip/_vendor/cachecontrol/py.typed ADDED
File without changes
python/Lib/site-packages/pip/_vendor/cachecontrol/serialize.py ADDED
@@ -0,0 +1,146 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # SPDX-FileCopyrightText: 2015 Eric Larson
2
+ #
3
+ # SPDX-License-Identifier: Apache-2.0
4
+ from __future__ import annotations
5
+
6
+ import io
7
+ from typing import IO, TYPE_CHECKING, Any, Mapping, cast
8
+
9
+ from pip._vendor import msgpack
10
+ from pip._vendor.requests.structures import CaseInsensitiveDict
11
+ from pip._vendor.urllib3 import HTTPResponse
12
+
13
+ if TYPE_CHECKING:
14
+ from pip._vendor.requests import PreparedRequest
15
+
16
+
17
+ class Serializer:
18
+ serde_version = "4"
19
+
20
+ def dumps(
21
+ self,
22
+ request: PreparedRequest,
23
+ response: HTTPResponse,
24
+ body: bytes | None = None,
25
+ ) -> bytes:
26
+ response_headers: CaseInsensitiveDict[str] = CaseInsensitiveDict(
27
+ response.headers
28
+ )
29
+
30
+ if body is None:
31
+ # When a body isn't passed in, we'll read the response. We
32
+ # also update the response with a new file handler to be
33
+ # sure it acts as though it was never read.
34
+ body = response.read(decode_content=False)
35
+ response._fp = io.BytesIO(body) # type: ignore[assignment]
36
+ response.length_remaining = len(body)
37
+
38
+ data = {
39
+ "response": {
40
+ "body": body, # Empty bytestring if body is stored separately
41
+ "headers": {str(k): str(v) for k, v in response.headers.items()},
42
+ "status": response.status,
43
+ "version": response.version,
44
+ "reason": str(response.reason),
45
+ "decode_content": response.decode_content,
46
+ }
47
+ }
48
+
49
+ # Construct our vary headers
50
+ data["vary"] = {}
51
+ if "vary" in response_headers:
52
+ varied_headers = response_headers["vary"].split(",")
53
+ for header in varied_headers:
54
+ header = str(header).strip()
55
+ header_value = request.headers.get(header, None)
56
+ if header_value is not None:
57
+ header_value = str(header_value)
58
+ data["vary"][header] = header_value
59
+
60
+ return b",".join([f"cc={self.serde_version}".encode(), self.serialize(data)])
61
+
62
+ def serialize(self, data: dict[str, Any]) -> bytes:
63
+ return cast(bytes, msgpack.dumps(data, use_bin_type=True))
64
+
65
+ def loads(
66
+ self,
67
+ request: PreparedRequest,
68
+ data: bytes,
69
+ body_file: IO[bytes] | None = None,
70
+ ) -> HTTPResponse | None:
71
+ # Short circuit if we've been given an empty set of data
72
+ if not data:
73
+ return None
74
+
75
+ # Previous versions of this library supported other serialization
76
+ # formats, but these have all been removed.
77
+ if not data.startswith(f"cc={self.serde_version},".encode()):
78
+ return None
79
+
80
+ data = data[5:]
81
+ return self._loads_v4(request, data, body_file)
82
+
83
+ def prepare_response(
84
+ self,
85
+ request: PreparedRequest,
86
+ cached: Mapping[str, Any],
87
+ body_file: IO[bytes] | None = None,
88
+ ) -> HTTPResponse | None:
89
+ """Verify our vary headers match and construct a real urllib3
90
+ HTTPResponse object.
91
+ """
92
+ # Special case the '*' Vary value as it means we cannot actually
93
+ # determine if the cached response is suitable for this request.
94
+ # This case is also handled in the controller code when creating
95
+ # a cache entry, but is left here for backwards compatibility.
96
+ if "*" in cached.get("vary", {}):
97
+ return None
98
+
99
+ # Ensure that the Vary headers for the cached response match our
100
+ # request
101
+ for header, value in cached.get("vary", {}).items():
102
+ if request.headers.get(header, None) != value:
103
+ return None
104
+
105
+ body_raw = cached["response"].pop("body")
106
+
107
+ headers: CaseInsensitiveDict[str] = CaseInsensitiveDict(
108
+ data=cached["response"]["headers"]
109
+ )
110
+ if headers.get("transfer-encoding", "") == "chunked":
111
+ headers.pop("transfer-encoding")
112
+
113
+ cached["response"]["headers"] = headers
114
+
115
+ try:
116
+ body: IO[bytes]
117
+ if body_file is None:
118
+ body = io.BytesIO(body_raw)
119
+ else:
120
+ body = body_file
121
+ except TypeError:
122
+ # This can happen if cachecontrol serialized to v1 format (pickle)
123
+ # using Python 2. A Python 2 str(byte string) will be unpickled as
124
+ # a Python 3 str (unicode string), which will cause the above to
125
+ # fail with:
126
+ #
127
+ # TypeError: 'str' does not support the buffer interface
128
+ body = io.BytesIO(body_raw.encode("utf8"))
129
+
130
+ # Discard any `strict` parameter serialized by older version of cachecontrol.
131
+ cached["response"].pop("strict", None)
132
+
133
+ return HTTPResponse(body=body, preload_content=False, **cached["response"])
134
+
135
+ def _loads_v4(
136
+ self,
137
+ request: PreparedRequest,
138
+ data: bytes,
139
+ body_file: IO[bytes] | None = None,
140
+ ) -> HTTPResponse | None:
141
+ try:
142
+ cached = msgpack.loads(data, raw=False)
143
+ except ValueError:
144
+ return None
145
+
146
+ return self.prepare_response(request, cached, body_file)
python/Lib/site-packages/pip/_vendor/cachecontrol/wrapper.py ADDED
@@ -0,0 +1,43 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # SPDX-FileCopyrightText: 2015 Eric Larson
2
+ #
3
+ # SPDX-License-Identifier: Apache-2.0
4
+ from __future__ import annotations
5
+
6
+ from typing import TYPE_CHECKING, Collection
7
+
8
+ from pip._vendor.cachecontrol.adapter import CacheControlAdapter
9
+ from pip._vendor.cachecontrol.cache import DictCache
10
+
11
+ if TYPE_CHECKING:
12
+ from pip._vendor import requests
13
+
14
+ from pip._vendor.cachecontrol.cache import BaseCache
15
+ from pip._vendor.cachecontrol.controller import CacheController
16
+ from pip._vendor.cachecontrol.heuristics import BaseHeuristic
17
+ from pip._vendor.cachecontrol.serialize import Serializer
18
+
19
+
20
+ def CacheControl(
21
+ sess: requests.Session,
22
+ cache: BaseCache | None = None,
23
+ cache_etags: bool = True,
24
+ serializer: Serializer | None = None,
25
+ heuristic: BaseHeuristic | None = None,
26
+ controller_class: type[CacheController] | None = None,
27
+ adapter_class: type[CacheControlAdapter] | None = None,
28
+ cacheable_methods: Collection[str] | None = None,
29
+ ) -> requests.Session:
30
+ cache = DictCache() if cache is None else cache
31
+ adapter_class = adapter_class or CacheControlAdapter
32
+ adapter = adapter_class(
33
+ cache,
34
+ cache_etags=cache_etags,
35
+ serializer=serializer,
36
+ heuristic=heuristic,
37
+ controller_class=controller_class,
38
+ cacheable_methods=cacheable_methods,
39
+ )
40
+ sess.mount("http://", adapter)
41
+ sess.mount("https://", adapter)
42
+
43
+ return sess
python/Lib/site-packages/pip/_vendor/certifi/LICENSE ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ This package contains a modified version of ca-bundle.crt:
2
+
3
+ ca-bundle.crt -- Bundle of CA Root Certificates
4
+
5
+ This is a bundle of X.509 certificates of public Certificate Authorities
6
+ (CA). These were automatically extracted from Mozilla's root certificates
7
+ file (certdata.txt). This file can be found in the mozilla source tree:
8
+ https://hg.mozilla.org/mozilla-central/file/tip/security/nss/lib/ckfw/builtins/certdata.txt
9
+ It contains the certificates in PEM format and therefore
10
+ can be directly used with curl / libcurl / php_curl, or with
11
+ an Apache+mod_ssl webserver for SSL client authentication.
12
+ Just configure this file as the SSLCACertificateFile.#
13
+
14
+ ***** BEGIN LICENSE BLOCK *****
15
+ This Source Code Form is subject to the terms of the Mozilla Public License,
16
+ v. 2.0. If a copy of the MPL was not distributed with this file, You can obtain
17
+ one at http://mozilla.org/MPL/2.0/.
18
+
19
+ ***** END LICENSE BLOCK *****
20
+ @(#) $RCSfile: certdata.txt,v $ $Revision: 1.80 $ $Date: 2011/11/03 15:11:58 $