Class: PypiPackages

Inherits:
Object show all
Defined in:
pypi_packages.rb

Overview

This class is part of an internal API. This class may only be used internally in repositories owned by Homebrew, except in casks or formulae. Third parties should avoid using this class if possible, as it may be removed or changed without warning.

Helper class for pypi_packages DSL.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(package_name: nil, extra_packages: [], exclude_packages: [], dependencies: [], needs_manual_update: false, defined_pypi_mapping: true) ⇒ void

This method is part of a private API. This method may only be used in the Homebrew/brew repository. Third parties should avoid using this method if possible, as it may be removed or changed without warning.

Parameters:

  • package_name (String, nil) (defaults to: nil)
  • extra_packages (Array<String>) (defaults to: [])
  • exclude_packages (Array<String>) (defaults to: [])
  • dependencies (Array<String>) (defaults to: [])
  • needs_manual_update (Boolean) (defaults to: false)
  • defined_pypi_mapping (Boolean) (defaults to: true)


50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
# File 'pypi_packages.rb', line 50

def initialize(
  package_name: nil,
  extra_packages: [],
  exclude_packages: [],
  dependencies: [],
  needs_manual_update: false,
  defined_pypi_mapping: true
)
  @package_name = T.let(package_name, T.nilable(String))
  @extra_packages = T.let(extra_packages, T::Array[String])
  @exclude_packages = T.let(exclude_packages, T::Array[String])
  @dependencies = T.let(dependencies, T::Array[String])
  @needs_manual_update = T.let(needs_manual_update, T::Boolean)
  @defined_pypi_mapping = T.let(defined_pypi_mapping, T::Boolean)
end

Instance Attribute Details

#dependenciesArray<String> (readonly)

This method is part of a private API. This method may only be used in the Homebrew/brew repository. Third parties should avoid using this method if possible, as it may be removed or changed without warning.

Returns:



17
18
19
# File 'pypi_packages.rb', line 17

def dependencies
  @dependencies
end

#exclude_packagesArray<String> (readonly)

This method is part of a private API. This method may only be used in the Homebrew/brew repository. Third parties should avoid using this method if possible, as it may be removed or changed without warning.

Returns:



14
15
16
# File 'pypi_packages.rb', line 14

def exclude_packages
  @exclude_packages
end

#extra_packagesArray<String> (readonly)

This method is part of a private API. This method may only be used in the Homebrew/brew repository. Third parties should avoid using this method if possible, as it may be removed or changed without warning.

Returns:



11
12
13
# File 'pypi_packages.rb', line 11

def extra_packages
  @extra_packages
end

#package_nameString? (readonly)

This method is part of a private API. This method may only be used in the Homebrew/brew repository. Third parties should avoid using this method if possible, as it may be removed or changed without warning.

Returns:



8
9
10
# File 'pypi_packages.rb', line 8

def package_name
  @package_name
end

Class Method Details

.from_json_file(tap, formula_name) ⇒ T.attached_class

This method is part of a private API. This method may only be used in the Homebrew/brew repository. Third parties should avoid using this method if possible, as it may be removed or changed without warning.

Parameters:

Returns:

  • (T.attached_class)


20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'pypi_packages.rb', line 20

def self.from_json_file(tap, formula_name)
  list_entry = tap&.pypi_formula_mappings&.fetch(formula_name, nil)

  return new(defined_pypi_mapping: false) if list_entry.nil?

  case T.cast(list_entry, T.any(FalseClass, String, T::Hash[String, T.any(String, T::Array[String])]))
  when false
    new needs_manual_update: true
  when String
    new package_name: list_entry
  when Hash
    package_name = list_entry["package_name"]
    extra_packages = list_entry.fetch("extra_packages", [])
    exclude_packages = list_entry.fetch("exclude_packages", [])
    dependencies = list_entry.fetch("dependencies", [])

    new package_name:, extra_packages:, exclude_packages:, dependencies:
  end
end

Instance Method Details

#defined_pypi_mapping?Boolean

This method is part of a private API. This method may only be used in the Homebrew/brew repository. Third parties should avoid using this method if possible, as it may be removed or changed without warning.

Returns:

  • (Boolean)


67
# File 'pypi_packages.rb', line 67

def defined_pypi_mapping? = @defined_pypi_mapping

#needs_manual_update?Boolean

This method is part of a private API. This method may only be used in the Homebrew/brew repository. Third parties should avoid using this method if possible, as it may be removed or changed without warning.

Returns:

  • (Boolean)


70
# File 'pypi_packages.rb', line 70

def needs_manual_update? = @needs_manual_update