dependabot-python 0.106.29 → 0.106.30

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e9a9b878f32b9f61d96f268e5bc09ad2b96dae5437e93fc51f64af14d937c412
4
- data.tar.gz: ad007a266ed387a88549a613516edffa3f38fef736324ba0048b1c2a2fa18b30
3
+ metadata.gz: 9815a164c54336ff2535c3dad743bc5485fe4b77331567e6538091fd3435ef67
4
+ data.tar.gz: 60930b83e4d7159669e9e81f794030ccdaa934fedcce290ca01d82824cff2523
5
5
  SHA512:
6
- metadata.gz: 7d2d327a80a060cc7b59848a35881772840e167716d56b2c162a3fce644e0d6670739e5aeda72578c97a58773aa5ed0d1f645c84851902edd3f9736ccc69289f
7
- data.tar.gz: 2fe1c1638688eb095753bb220005d686d626238a8bebaeffa4769e97a399767f0b4b6e9483b496c1d76133d12bf39fa3bce5f6c39c6798a84160345f71a3a653
6
+ metadata.gz: ec6047e8104e46f95cd4a401311baed1c5e09e08f45d151b8346209e1c67c8fe845540b861c785a53d61fa2773579c5eea5c6da205388f1f729820ccb8e402a8
7
+ data.tar.gz: 4e51c3e3a82974ba0b20af09b0349e1ffd65980ca326e80ebfad2f11642da1e8127ba144cf06352d03e620e7580baeaf5c042e585365fe39e27e782f697cbf70
@@ -550,6 +550,7 @@ module Dependabot
550
550
  # (e.g., Django 2.x implies Python 3)
551
551
  @python_version ||=
552
552
  user_specified_python_version ||
553
+ python_version_from_compiled_requirements ||
553
554
  PythonVersions::PRE_INSTALLED_PYTHON_VERSIONS.first
554
555
  end
555
556
 
@@ -569,6 +570,34 @@ module Dependabot
569
570
  runtime_file.content.match(/(?<=python-).*/)&.to_s&.strip
570
571
  end
571
572
 
573
+ def python_version_from_compiled_requirements
574
+ PythonVersions::SUPPORTED_VERSIONS_TO_ITERATE.find do |version_string|
575
+ version = Python::Version.new(version_string)
576
+ compiled_file_python_requirement_markers.all? do |req|
577
+ req.satisfied_by?(version)
578
+ end
579
+ end
580
+ end
581
+
582
+ def compiled_file_python_requirement_markers
583
+ @python_requirement_strings ||=
584
+ compiled_files.flat_map do |file|
585
+ file.content.lines.
586
+ select { |l| l.include?(";") && l.include?("python") }.
587
+ map { |l| l.match(/python_version(?<req>.*?["'].*?['"])/) }.
588
+ compact.
589
+ map { |re| re.named_captures.fetch("req").gsub(/['"]/, "") }.
590
+ select do |r|
591
+ requirement_class.new(r)
592
+ true
593
+ rescue Gem::Requirement::BadRequirementError
594
+ false
595
+ end
596
+ end
597
+
598
+ @python_requirement_strings.map { |r| requirement_class.new(r) }
599
+ end
600
+
572
601
  def pyenv_versions
573
602
  @pyenv_versions ||= run_command("pyenv install --list")
574
603
  end
@@ -585,6 +614,10 @@ module Dependabot
585
614
  dependency_files.select { |f| f.name.end_with?(".in") }
586
615
  end
587
616
 
617
+ def compiled_files
618
+ dependency_files.select { |f| f.name.end_with?(".txt") }
619
+ end
620
+
588
621
  def setup_cfg_files
589
622
  dependency_files.select { |f| f.name.end_with?("setup.cfg") }
590
623
  end
@@ -596,6 +629,10 @@ module Dependabot
596
629
  def runtime_file
597
630
  dependency_files.find { |f| f.name.end_with?("runtime.txt") }
598
631
  end
632
+
633
+ def requirement_class
634
+ Python::Requirement
635
+ end
599
636
  end
600
637
  # rubocop:enable Metrics/ClassLength
601
638
  end
@@ -438,6 +438,7 @@ module Dependabot
438
438
  # (e.g., Django 2.x implies Python 3)
439
439
  @python_version ||=
440
440
  user_specified_python_version ||
441
+ python_version_matching_requirements ||
441
442
  PythonVersions::PRE_INSTALLED_PYTHON_VERSIONS.first
442
443
  end
443
444
 
@@ -457,6 +458,34 @@ module Dependabot
457
458
  runtime_file.content.match(/(?<=python-).*/)&.to_s&.strip
458
459
  end
459
460
 
461
+ def python_version_matching_requirements
462
+ PythonVersions::SUPPORTED_VERSIONS_TO_ITERATE.find do |version_string|
463
+ version = Python::Version.new(version_string)
464
+ compiled_file_python_requirement_markers.all? do |req|
465
+ req.satisfied_by?(version)
466
+ end
467
+ end
468
+ end
469
+
470
+ def compiled_file_python_requirement_markers
471
+ @python_requirement_strings ||=
472
+ compiled_files.flat_map do |file|
473
+ file.content.lines.
474
+ select { |l| l.include?(";") && l.include?("python") }.
475
+ map { |l| l.match(/python_version(?<req>.*?["'].*?['"])/) }.
476
+ compact.
477
+ map { |re| re.named_captures.fetch("req").gsub(/['"]/, "") }.
478
+ select do |r|
479
+ requirement_class.new(r)
480
+ true
481
+ rescue Gem::Requirement::BadRequirementError
482
+ false
483
+ end
484
+ end
485
+
486
+ @python_requirement_strings.map { |r| requirement_class.new(r) }
487
+ end
488
+
460
489
  def pyenv_versions
461
490
  @pyenv_versions ||= run_command("pyenv install --list")
462
491
  end
@@ -473,6 +502,10 @@ module Dependabot
473
502
  dependency_files.select { |f| f.name.end_with?(".in") }
474
503
  end
475
504
 
505
+ def compiled_files
506
+ dependency_files.select { |f| f.name.end_with?(".txt") }
507
+ end
508
+
476
509
  def setup_cfg_files
477
510
  dependency_files.select { |f| f.name.end_with?("setup.cfg") }
478
511
  end
@@ -484,6 +517,10 @@ module Dependabot
484
517
  def runtime_file
485
518
  dependency_files.find { |f| f.name.end_with?("runtime.txt") }
486
519
  end
520
+
521
+ def requirement_class
522
+ Python::Requirement
523
+ end
487
524
  end
488
525
  # rubocop:enable Metrics/ClassLength
489
526
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dependabot-python
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.106.29
4
+ version: 0.106.30
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dependabot
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-05-02 00:00:00.000000000 Z
11
+ date: 2019-05-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: dependabot-common
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - '='
18
18
  - !ruby/object:Gem::Version
19
- version: 0.106.29
19
+ version: 0.106.30
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - '='
25
25
  - !ruby/object:Gem::Version
26
- version: 0.106.29
26
+ version: 0.106.30
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: byebug
29
29
  requirement: !ruby/object:Gem::Requirement