class Distribution(_Distribution): (source)
Known subclasses: setuptools.build_meta.Distribution
Distribution with support for tests and package data This is an enhanced version of 'distutils.dist.Distribution' that effectively adds the following new optional keyword arguments to 'setup()': 'install_requires' -- a string or sequence of strings specifying project versions that the distribution requires when installed, in the format used by 'pkg_resources.require()'. They will be installed automatically when the package is installed. If you wish to use packages that are not available in PyPI, or want to give your users an alternate download location, you can add a 'find_links' option to the '[easy_install]' section of your project's 'setup.cfg' file, and then setuptools will scan the listed web pages for links that satisfy the requirements. 'extras_require' -- a dictionary mapping names of optional "extras" to the additional requirement(s) that using those extras incurs. For example, this:: extras_require = dict(reST = ["docutils>=0.3", "reSTedit"]) indicates that the distribution can optionally provide an extra capability called "reST", but it can only be used if docutils and reSTedit are installed. If the user installs your package using EasyInstall and requests one of your extras, the corresponding additional requirements will be installed if needed. 'test_suite' -- the name of a test suite to run for the 'test' command. If the user runs 'python setup.py test', the package will be installed, and the named test suite will be run. The format is the same as would be used on a 'unittest.py' command line. That is, it is the dotted name of an object to import and call to generate a test suite. 'package_data' -- a dictionary mapping package names to lists of filenames or globs to use to find data files contained in the named packages. If the dictionary has filenames or globs listed under '""' (the empty string), those names will be searched for in every package, in addition to any names for the specific package. Data files found using these names/globs will be installed along with the package, in the same location as the package. Note that globs are allowed to reference the contents of non-package subdirectories, as long as you use '/' as a path separator. (Globs are automatically converted to platform-specific paths at runtime.) In addition to these new keywords, this class also has several new methods for manipulating the distribution's contents. For example, the 'include()' and 'exclude()' methods can be thought of as in-place add and subtract commands that add or remove packages, modules, extensions, and so on from the distribution.
Method | __init__ |
Undocumented |
Method | exclude |
Remove items from distribution that are named in keyword arguments |
Method | exclude |
Remove packages, modules, and extensions in named package |
Method | fetch |
Fetch an egg needed for building |
Method | fetch |
Resolve pre-setup requirements |
Method | finalize |
Allow plugins to apply arbitrary operations to the distribution. Each hook may optionally define a 'order' to influence the order of execution. Smaller numbers go first and the default is 0. |
Method | get |
Return a '{cmd: {opt:val}}' map of all command-line options |
Method | get |
Pluggable version of get_command_class() |
Method | get |
Undocumented |
Method | get |
Undocumented |
Method | handle |
If there were any non-global "display-only" options (--help-commands or the metadata display options) on the command line, display the requested info and return true; else return false. |
Method | has |
Return true if 'exclude_package(package)' would do something |
Method | include |
Add items to distribution that are named in keyword arguments |
Method | iter |
Yield all packages, modules, and extension names in distribution |
Method | make |
Undocumented |
Method | parse |
Parses configuration files from various levels and loads configuration. |
Method | patch |
Undocumented |
Method | print |
Undocumented |
Method | run |
Undocumented |
Method | warn |
Undocumented |
Instance Variable | dependency |
Undocumented |
Instance Variable | dist |
Undocumented |
Instance Variable | ext |
Undocumented |
Instance Variable | extras |
Undocumented |
Instance Variable | global |
Undocumented |
Instance Variable | install |
Undocumented |
Instance Variable | negative |
Undocumented |
Instance Variable | package |
Undocumented |
Instance Variable | packages |
Undocumented |
Instance Variable | py |
Undocumented |
Instance Variable | set |
Undocumented |
Instance Variable | setup |
Undocumented |
Instance Variable | src |
Undocumented |
Static Method | _expand |
>>> list(Distribution._expand_patterns(['LICENSE'])) ['LICENSE'] >>> list(Distribution._expand_patterns(['setup.cfg', 'LIC*'])) ['setup.cfg', 'LICENSE'] |
Static Method | _normalize |
Undocumented |
Static Method | _removed |
When removing an entry point, if metadata is loaded from an older version of Setuptools, that removed entry point will attempt to be loaded and will fail. See #2765 for more details. |
Static Method | _suffix |
For a requirement, return the 'extras_require' suffix for that requirement. |
Static Method | _validate |
Undocumented |
Method | _clean |
Given a Requirement, remove environment markers and return it. |
Method | _convert |
Convert requirements in `extras_require` of the form `"extra": ["barbazquux; {marker}"]` to `"extra:{marker}": ["barbazquux"]`. |
Method | _exclude |
Handle 'exclude()' for list/tuple attrs without a special handler |
Method | _exclude |
Undocumented |
Method | _finalize |
Compute names of all license files which should be included. |
Method | _finalize |
Set `metadata.python_requires` and fix environment markers in `install_requires` and `extras_require`. |
Method | _finalize |
Undocumented |
Method | _get |
Add default file and split between INI and TOML |
Method | _include |
Handle 'include()' for list/tuple attrs without a special handler |
Method | _move |
Move requirements in `install_requires` that are using environment markers `extras_require`. |
Method | _parse |
Undocumented |
Method | _parse |
Adapted from distutils.dist.Distribution.parse_config_files, this method provides the same functionality in subtly-improved ways. |
Method | _set |
Set the options for 'command_obj' from 'option_dict'. Basically this means copying elements of a dictionary ('option_dict') to attributes of an instance ('command'). |
Method | _set |
Fill-in missing metadata fields not supported by distutils. Some fields may have been set by other tools (e.g. pbr). Those fields (vars(self.metadata)) take precedence to supplied attrs. |
Method | _setuptools |
Undocumented |
Method | _validate |
Undocumented |
Constant | _DISTUTILS |
Undocumented |
Instance Variable | _orig |
Undocumented |
Instance Variable | _orig |
Undocumented |
Instance Variable | _patched |
Undocumented |
Instance Variable | _referenced |
Undocumented |
Instance Variable | _tmp |
Undocumented |
Remove items from distribution that are named in keyword arguments For example, 'dist.exclude(py_modules=["x"])' would remove 'x' from the distribution's 'py_modules' attribute. Excluding packages uses the 'exclude_package()' method, so all of the package's contained packages, modules, and extensions are also excluded. Currently, this method only supports exclusion from attributes that are lists or tuples. If you need to add support for excluding from other attributes in this or a subclass, you can add an '_exclude_X' method, where 'X' is the name of the attribute. The method will be called with the value passed to 'exclude()'. So, 'dist.exclude(foo={"bar":"baz"})' will try to call 'dist._exclude_foo({"bar":"baz"})', which can then handle whatever special exclusion logic is needed.
Allow plugins to apply arbitrary operations to the distribution. Each hook may optionally define a 'order' to influence the order of execution. Smaller numbers go first and the default is 0.
Return a '{cmd: {opt:val}}' map of all command-line options Option names are all long, but do not include the leading '--', and contain dashes rather than underscores. If the option doesn't take an argument (e.g. '--quiet'), the 'val' is 'None'. Note that options provided by config files are intentionally excluded.
If there were any non-global "display-only" options (--help-commands or the metadata display options) on the command line, display the requested info and return true; else return false.
Add items to distribution that are named in keyword arguments For example, 'dist.include(py_modules=["x"])' would add 'x' to the distribution's 'py_modules' attribute, if it was not already there. Currently, this method only supports inclusion for attributes that are lists or tuples. If you need to add support for adding to other attributes in this or a subclass, you can add an '_include_X' method, where 'X' is the name of the attribute. The method will be called with the value passed to 'include()'. So, 'dist.include(foo={"bar":"baz"})' will try to call 'dist._include_foo({"bar":"baz"})', which can then handle whatever special inclusion logic is needed.
>>> list(Distribution._expand_patterns(['LICENSE'])) ['LICENSE'] >>> list(Distribution._expand_patterns(['setup.cfg', 'LIC*'])) ['setup.cfg', 'LICENSE']
When removing an entry point, if metadata is loaded from an older version of Setuptools, that removed entry point will attempt to be loaded and will fail. See #2765 for more details.
Convert requirements in `extras_require` of the form `"extra": ["barbazquux; {marker}"]` to `"extra:{marker}": ["barbazquux"]`.
Set `metadata.python_requires` and fix environment markers in `install_requires` and `extras_require`.
Adapted from distutils.dist.Distribution.parse_config_files, this method provides the same functionality in subtly-improved ways.
Set the options for 'command_obj' from 'option_dict'. Basically this means copying elements of a dictionary ('option_dict') to attributes of an instance ('command'). 'command_obj' must be a Command instance. If 'option_dict' is not supplied, uses the standard option dictionary for this command (from 'self.command_options'). (Adopted from distutils.dist.Distribution._set_command_options)
Fill-in missing metadata fields not supported by distutils. Some fields may have been set by other tools (e.g. pbr). Those fields (vars(self.metadata)) take precedence to supplied attrs.
Undocumented
Value |
|