10800:c6ce5522be30 | 10801:5859861e7a1f |
---|---|
31 pyModDir = None | 31 pyModDir = None |
32 distDir = None | 32 distDir = None |
33 installPackage = "eric7" | 33 installPackage = "eric7" |
34 doCleanup = True | 34 doCleanup = True |
35 doCompile = True | 35 doCompile = True |
36 proxy = None | |
36 sourceDir = "eric" | 37 sourceDir = "eric" |
37 eric7SourceDir = "" | 38 eric7SourceDir = "" |
38 | 39 |
39 | 40 |
40 def exit(rcode=0): | 41 def exit(rcode=0): |
228 without asking the user | 229 without asking the user |
229 @type bool | 230 @type bool |
230 @return flag indicating a successful installation | 231 @return flag indicating a successful installation |
231 @rtype bool | 232 @rtype bool |
232 """ | 233 """ |
234 global proxy | |
235 | |
233 ok = False | 236 ok = False |
234 if force: | 237 if force: |
235 answer = "y" | 238 answer = "y" |
236 else: | 239 else: |
237 print( | 240 print( |
240 ), | 243 ), |
241 end=" ", | 244 end=" ", |
242 ) | 245 ) |
243 answer = input() # secok | 246 answer = input() # secok |
244 if answer in ("", "Y", "y"): | 247 if answer in ("", "Y", "y"): |
245 exitCode = subprocess.run( # secok | 248 args = [ |
246 [ | 249 sys.executable, |
247 sys.executable, | 250 "-m", |
248 "-m", | 251 "pip", |
249 "pip", | 252 "install", |
250 "install", | 253 "--prefer-binary", |
251 "--prefer-binary", | 254 "--upgrade", |
252 "--upgrade", | 255 ] |
253 packageName, | 256 if proxy: |
254 ] | 257 args.append(f"--proxy={proxy}") |
255 ).returncode | 258 args.append(packageName) |
259 exitCode = subprocess.run(args).returncode # secok | |
256 ok = exitCode == 0 | 260 ok = exitCode == 0 |
257 | 261 |
258 return ok | 262 return ok |
259 | 263 |
260 | 264 |
263 Check, if pip is outdated. | 267 Check, if pip is outdated. |
264 | 268 |
265 @return flag indicating an outdated pip | 269 @return flag indicating an outdated pip |
266 @rtype bool | 270 @rtype bool |
267 """ | 271 """ |
268 try: | 272 global proxy |
273 | |
274 try: | |
275 args = [ | |
276 sys.executable, | |
277 "-m", | |
278 "pip", | |
279 "list", | |
280 "--outdated", | |
281 "--format=json", | |
282 ] | |
283 if proxy: | |
284 args.append(f"--proxy={proxy}") | |
269 pipOut = ( | 285 pipOut = ( |
270 subprocess.run( # secok | 286 subprocess.run( # secok |
271 [sys.executable, "-m", "pip", "list", "--outdated", "--format=json"], | 287 args, |
272 check=True, | 288 check=True, |
273 capture_output=True, | 289 capture_output=True, |
274 text=True, | 290 text=True, |
275 ) | 291 ) |
276 .stdout.strip() | 292 .stdout.strip() |
297 | 313 |
298 def updatePip(): | 314 def updatePip(): |
299 """ | 315 """ |
300 Update the installed pip package. | 316 Update the installed pip package. |
301 """ | 317 """ |
302 global yes2All | 318 global proxy |
303 | 319 |
304 if yes2All: | 320 print("Shall 'pip' be updated (recommended)? (Y/n)", end=" ") |
305 answer = "y" | 321 answer = input() # secok |
306 else: | |
307 print("Shall 'pip' be updated (recommended)? (Y/n)", end=" ") | |
308 answer = input() # secok | |
309 if answer in ("", "Y", "y"): | 322 if answer in ("", "Y", "y"): |
310 subprocess.run( # secok | 323 args = [ |
311 [sys.executable, "-m", "pip", "install", "--upgrade", "pip"] | 324 sys.executable, |
312 ) | 325 "-m", |
326 "pip", | |
327 "install", | |
328 "--upgrade", | |
329 ] | |
330 if proxy: | |
331 args.append(f"--proxy={proxy}") | |
332 args.append("pip") | |
333 subprocess.run(args) # secok | |
313 | 334 |
314 | 335 |
315 def doDependancyChecks(): | 336 def doDependancyChecks(): |
316 """ | 337 """ |
317 Perform some dependency checks. | 338 Perform some dependency checks. |
403 parser.add_argument( | 424 parser.add_argument( |
404 "-z", | 425 "-z", |
405 action="store_false", | 426 action="store_false", |
406 help="don't compile the installed python files", | 427 help="don't compile the installed python files", |
407 ) | 428 ) |
429 parser.add_argument( | |
430 "--proxy", | |
431 default=None, | |
432 metavar="url", | |
433 help="HTTP proxy url will be used with pip (default: no proxy used)", | |
434 ) | |
408 | 435 |
409 return parser | 436 return parser |
410 | 437 |
411 | 438 |
412 def main(argv): | 439 def main(argv): |
414 The main function of the script. | 441 The main function of the script. |
415 | 442 |
416 @param argv the list of command line arguments | 443 @param argv the list of command line arguments |
417 @type list of str | 444 @type list of str |
418 """ | 445 """ |
419 global modDir, doCleanup, doCompile, distDir | 446 global modDir, doCleanup, doCompile, distDir, proxy |
420 global sourceDir, eric7SourceDir | 447 global sourceDir, eric7SourceDir |
421 | 448 |
422 if sys.version_info < (3, 8, 0) or sys.version_info >= (4, 0, 0): | 449 if sys.version_info < (3, 8, 0) or sys.version_info >= (4, 0, 0): |
423 print("Sorry, the eric debugger requires Python 3.8 or better for running.") | 450 print("Sorry, the eric debugger requires Python 3.8 or better for running.") |
424 exit(5) | 451 exit(5) |
432 args = parser.parse_args() | 459 args = parser.parse_args() |
433 | 460 |
434 modDir = args.d | 461 modDir = args.d |
435 doCleanup = args.c | 462 doCleanup = args.c |
436 doCompile = args.z | 463 doCompile = args.z |
464 proxy = args.proxy | |
437 if not sys.platform.startswith(("win", "cygwin")) and args.i: | 465 if not sys.platform.startswith(("win", "cygwin")) and args.i: |
438 distDir = os.path.normpath(args.i) | 466 distDir = os.path.normpath(args.i) |
439 | 467 |
440 # check dependencies | 468 # check dependencies |
441 doDependancyChecks() | 469 doDependancyChecks() |