Uploaded image for project: 'Puppet'
  1. Puppet
  2. PUP-10296

Add SemVerRange support to pip package provider

    XMLWordPrintable

    Details

    • Template:
    • Team:
      Night's Watch
    • Story Points:
      5
    • Sprint:
      NW - 2020-03-04, NW - 2020-03-17, NW - 2020-04-01
    • Release Notes:
      Enhancement
    • Release Notes Summary:
      Hide
      Add support of >, >=, <, <=, >=A <=B ranges for package version specified in the :ensure manifest field.

      This will install a version that satisfies the provided range. The package version must respect pip's package versioning format (https://www.python.org/dev/peps/pep-0440/).
      Show
      Add support of >, >=, <, <=, >=A <=B ranges for package version specified in the :ensure manifest field. This will install a version that satisfies the provided range. The package version must respect pip's package versioning format ( https://www.python.org/dev/peps/pep-0440/ ).
    • QA Risk Assessment:
      Needs Assessment

      Description

      Implement SemVerRange type support for the pip provider.

      Sample manifest with a range passed for a package:

      package { 'Flask':
        # this will be parsed as: >= 1.0.0 < 1.1.0
        ensure => SemVerRange('~> 1.0')
      }
       
      package { 'Flask':
        ensure => SemVerRange('>= 1')
      }
       
      package { 'Flask':
        ensure => SemVerRange('< 1')
      }
       
      package { 'Flask':
        # this is a valid range, but we should not support it in this provider
        ensure => SemVerRange('~> 0.5 || ~> 1.0')
      }
      

      This value should be handled inside the pip provider code, and should be munged into a valid string for the pip install command. We should also make sure we don't take additional actions if the range is already satisfied (i.e. puppet apply with a SemVerRange should be idempotent)

      Sample code on how the ensure property can be treated inside the provider:

      if @resource.should(:ensure).is_a?(SemanticPuppet::VersionRange)
        version = @resource.should(:ensure).ranges.first
       
        case version
        when SemanticPuppet::VersionRange::MinMaxRange
          # pip requires min/max ranges to be separated by a comma
          version.to_s.tr(' ', ',')
        else
          version.to_s
        end
      end
      

      Example pip install with a version range (note the double quotes):

      pip install "Flask>=1.0.0,<1.1.0"

        Attachments

          Activity

            People

            Assignee:
            luchian.nemes Luchian Nemes
            Reporter:
            gabriel.nagy Gabriel Nagy
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved:

                Zendesk Support