Search is not available for this dataset
identifier
stringlengths
1
155
parameters
stringlengths
2
6.09k
docstring
stringlengths
11
63.4k
docstring_summary
stringlengths
0
63.4k
function
stringlengths
29
99.8k
function_tokens
sequence
start_point
sequence
end_point
sequence
language
stringclasses
1 value
docstring_language
stringlengths
2
7
docstring_language_predictions
stringlengths
18
23
is_langid_reliable
stringclasses
2 values
check_extras
(dist, attr, value)
Verify that extras_require mapping is valid
Verify that extras_require mapping is valid
def check_extras(dist, attr, value): """Verify that extras_require mapping is valid""" try: list(itertools.starmap(_check_extra, value.items())) except (TypeError, ValueError, AttributeError): raise DistutilsSetupError( "'extras_require' must be a dictionary whose values are " "strings or lists of strings containing valid project/version " "requirement specifiers." )
[ "def", "check_extras", "(", "dist", ",", "attr", ",", "value", ")", ":", "try", ":", "list", "(", "itertools", ".", "starmap", "(", "_check_extra", ",", "value", ".", "items", "(", ")", ")", ")", "except", "(", "TypeError", ",", "ValueError", ",", "AttributeError", ")", ":", "raise", "DistutilsSetupError", "(", "\"'extras_require' must be a dictionary whose values are \"", "\"strings or lists of strings containing valid project/version \"", "\"requirement specifiers.\"", ")" ]
[ 176, 0 ]
[ 185, 9 ]
python
en
['en', 'en', 'en']
True
assert_bool
(dist, attr, value)
Verify that value is True, False, 0, or 1
Verify that value is True, False, 0, or 1
def assert_bool(dist, attr, value): """Verify that value is True, False, 0, or 1""" if bool(value) != value: tmpl = "{attr!r} must be a boolean value (got {value!r})" raise DistutilsSetupError(tmpl.format(attr=attr, value=value))
[ "def", "assert_bool", "(", "dist", ",", "attr", ",", "value", ")", ":", "if", "bool", "(", "value", ")", "!=", "value", ":", "tmpl", "=", "\"{attr!r} must be a boolean value (got {value!r})\"", "raise", "DistutilsSetupError", "(", "tmpl", ".", "format", "(", "attr", "=", "attr", ",", "value", "=", "value", ")", ")" ]
[ 195, 0 ]
[ 199, 70 ]
python
en
['en', 'en', 'en']
True
check_requirements
(dist, attr, value)
Verify that install_requires is a valid requirements list
Verify that install_requires is a valid requirements list
def check_requirements(dist, attr, value): """Verify that install_requires is a valid requirements list""" try: list(pkg_resources.parse_requirements(value)) if isinstance(value, (dict, set)): raise TypeError("Unordered types are not allowed") except (TypeError, ValueError) as error: tmpl = ( "{attr!r} must be a string or list of strings " "containing valid project/version requirement specifiers; {error}" ) raise DistutilsSetupError(tmpl.format(attr=attr, error=error))
[ "def", "check_requirements", "(", "dist", ",", "attr", ",", "value", ")", ":", "try", ":", "list", "(", "pkg_resources", ".", "parse_requirements", "(", "value", ")", ")", "if", "isinstance", "(", "value", ",", "(", "dict", ",", "set", ")", ")", ":", "raise", "TypeError", "(", "\"Unordered types are not allowed\"", ")", "except", "(", "TypeError", ",", "ValueError", ")", "as", "error", ":", "tmpl", "=", "(", "\"{attr!r} must be a string or list of strings \"", "\"containing valid project/version requirement specifiers; {error}\"", ")", "raise", "DistutilsSetupError", "(", "tmpl", ".", "format", "(", "attr", "=", "attr", ",", "error", "=", "error", ")", ")" ]
[ 202, 0 ]
[ 213, 70 ]
python
en
['en', 'en', 'en']
True
check_specifier
(dist, attr, value)
Verify that value is a valid version specifier
Verify that value is a valid version specifier
def check_specifier(dist, attr, value): """Verify that value is a valid version specifier""" try: packaging.specifiers.SpecifierSet(value) except packaging.specifiers.InvalidSpecifier as error: tmpl = ( "{attr!r} must be a string " "containing valid version specifiers; {error}" ) raise DistutilsSetupError(tmpl.format(attr=attr, error=error))
[ "def", "check_specifier", "(", "dist", ",", "attr", ",", "value", ")", ":", "try", ":", "packaging", ".", "specifiers", ".", "SpecifierSet", "(", "value", ")", "except", "packaging", ".", "specifiers", ".", "InvalidSpecifier", "as", "error", ":", "tmpl", "=", "(", "\"{attr!r} must be a string \"", "\"containing valid version specifiers; {error}\"", ")", "raise", "DistutilsSetupError", "(", "tmpl", ".", "format", "(", "attr", "=", "attr", ",", "error", "=", "error", ")", ")" ]
[ 216, 0 ]
[ 225, 70 ]
python
en
['en', 'en', 'en']
True
check_entry_points
(dist, attr, value)
Verify that entry_points map is parseable
Verify that entry_points map is parseable
def check_entry_points(dist, attr, value): """Verify that entry_points map is parseable""" try: pkg_resources.EntryPoint.parse_map(value) except ValueError as e: raise DistutilsSetupError(e)
[ "def", "check_entry_points", "(", "dist", ",", "attr", ",", "value", ")", ":", "try", ":", "pkg_resources", ".", "EntryPoint", ".", "parse_map", "(", "value", ")", "except", "ValueError", "as", "e", ":", "raise", "DistutilsSetupError", "(", "e", ")" ]
[ 228, 0 ]
[ 233, 36 ]
python
en
['en', 'en', 'en']
True
check_package_data
(dist, attr, value)
Verify that value is a dictionary of package names to glob lists
Verify that value is a dictionary of package names to glob lists
def check_package_data(dist, attr, value): """Verify that value is a dictionary of package names to glob lists""" if isinstance(value, dict): for k, v in value.items(): if not isinstance(k, str): break try: iter(v) except TypeError: break else: return raise DistutilsSetupError( attr + " must be a dictionary mapping package names to lists of " "wildcard patterns" )
[ "def", "check_package_data", "(", "dist", ",", "attr", ",", "value", ")", ":", "if", "isinstance", "(", "value", ",", "dict", ")", ":", "for", "k", ",", "v", "in", "value", ".", "items", "(", ")", ":", "if", "not", "isinstance", "(", "k", ",", "str", ")", ":", "break", "try", ":", "iter", "(", "v", ")", "except", "TypeError", ":", "break", "else", ":", "return", "raise", "DistutilsSetupError", "(", "attr", "+", "\" must be a dictionary mapping package names to lists of \"", "\"wildcard patterns\"", ")" ]
[ 241, 0 ]
[ 256, 5 ]
python
en
['en', 'en', 'en']
True
Distribution._finalize_requires
(self)
Set `metadata.python_requires` and fix environment markers in `install_requires` and `extras_require`.
Set `metadata.python_requires` and fix environment markers in `install_requires` and `extras_require`.
def _finalize_requires(self): """ Set `metadata.python_requires` and fix environment markers in `install_requires` and `extras_require`. """ if getattr(self, 'python_requires', None): self.metadata.python_requires = self.python_requires if getattr(self, 'extras_require', None): for extra in self.extras_require.keys(): # Since this gets called multiple times at points where the # keys have become 'converted' extras, ensure that we are only # truly adding extras we haven't seen before here. extra = extra.split(':')[0] if extra: self.metadata.provides_extras.add(extra) self._convert_extras_requirements() self._move_install_requirements_markers()
[ "def", "_finalize_requires", "(", "self", ")", ":", "if", "getattr", "(", "self", ",", "'python_requires'", ",", "None", ")", ":", "self", ".", "metadata", ".", "python_requires", "=", "self", ".", "python_requires", "if", "getattr", "(", "self", ",", "'extras_require'", ",", "None", ")", ":", "for", "extra", "in", "self", ".", "extras_require", ".", "keys", "(", ")", ":", "# Since this gets called multiple times at points where the", "# keys have become 'converted' extras, ensure that we are only", "# truly adding extras we haven't seen before here.", "extra", "=", "extra", ".", "split", "(", "':'", ")", "[", "0", "]", "if", "extra", ":", "self", ".", "metadata", ".", "provides_extras", ".", "add", "(", "extra", ")", "self", ".", "_convert_extras_requirements", "(", ")", "self", ".", "_move_install_requirements_markers", "(", ")" ]
[ 409, 4 ]
[ 427, 49 ]
python
en
['en', 'error', 'th']
False
Distribution._convert_extras_requirements
(self)
Convert requirements in `extras_require` of the form `"extra": ["barbazquux; {marker}"]` to `"extra:{marker}": ["barbazquux"]`.
Convert requirements in `extras_require` of the form `"extra": ["barbazquux; {marker}"]` to `"extra:{marker}": ["barbazquux"]`.
def _convert_extras_requirements(self): """ Convert requirements in `extras_require` of the form `"extra": ["barbazquux; {marker}"]` to `"extra:{marker}": ["barbazquux"]`. """ spec_ext_reqs = getattr(self, 'extras_require', None) or {} self._tmp_extras_require = defaultdict(list) for section, v in spec_ext_reqs.items(): # Do not strip empty sections. self._tmp_extras_require[section] for r in pkg_resources.parse_requirements(v): suffix = self._suffix_for(r) self._tmp_extras_require[section + suffix].append(r)
[ "def", "_convert_extras_requirements", "(", "self", ")", ":", "spec_ext_reqs", "=", "getattr", "(", "self", ",", "'extras_require'", ",", "None", ")", "or", "{", "}", "self", ".", "_tmp_extras_require", "=", "defaultdict", "(", "list", ")", "for", "section", ",", "v", "in", "spec_ext_reqs", ".", "items", "(", ")", ":", "# Do not strip empty sections.", "self", ".", "_tmp_extras_require", "[", "section", "]", "for", "r", "in", "pkg_resources", ".", "parse_requirements", "(", "v", ")", ":", "suffix", "=", "self", ".", "_suffix_for", "(", "r", ")", "self", ".", "_tmp_extras_require", "[", "section", "+", "suffix", "]", ".", "append", "(", "r", ")" ]
[ 429, 4 ]
[ 442, 68 ]
python
en
['en', 'error', 'th']
False
Distribution._suffix_for
(req)
For a requirement, return the 'extras_require' suffix for that requirement.
For a requirement, return the 'extras_require' suffix for that requirement.
def _suffix_for(req): """ For a requirement, return the 'extras_require' suffix for that requirement. """ return ':' + str(req.marker) if req.marker else ''
[ "def", "_suffix_for", "(", "req", ")", ":", "return", "':'", "+", "str", "(", "req", ".", "marker", ")", "if", "req", ".", "marker", "else", "''" ]
[ 445, 4 ]
[ 450, 58 ]
python
en
['en', 'error', 'th']
False
Distribution._move_install_requirements_markers
(self)
Move requirements in `install_requires` that are using environment markers `extras_require`.
Move requirements in `install_requires` that are using environment markers `extras_require`.
def _move_install_requirements_markers(self): """ Move requirements in `install_requires` that are using environment markers `extras_require`. """ # divide the install_requires into two sets, simple ones still # handled by install_requires and more complex ones handled # by extras_require. def is_simple_req(req): return not req.marker spec_inst_reqs = getattr(self, 'install_requires', None) or () inst_reqs = list(pkg_resources.parse_requirements(spec_inst_reqs)) simple_reqs = filter(is_simple_req, inst_reqs) complex_reqs = filterfalse(is_simple_req, inst_reqs) self.install_requires = list(map(str, simple_reqs)) for r in complex_reqs: self._tmp_extras_require[':' + str(r.marker)].append(r) self.extras_require = dict( (k, [str(r) for r in map(self._clean_req, v)]) for k, v in self._tmp_extras_require.items() )
[ "def", "_move_install_requirements_markers", "(", "self", ")", ":", "# divide the install_requires into two sets, simple ones still", "# handled by install_requires and more complex ones handled", "# by extras_require.", "def", "is_simple_req", "(", "req", ")", ":", "return", "not", "req", ".", "marker", "spec_inst_reqs", "=", "getattr", "(", "self", ",", "'install_requires'", ",", "None", ")", "or", "(", ")", "inst_reqs", "=", "list", "(", "pkg_resources", ".", "parse_requirements", "(", "spec_inst_reqs", ")", ")", "simple_reqs", "=", "filter", "(", "is_simple_req", ",", "inst_reqs", ")", "complex_reqs", "=", "filterfalse", "(", "is_simple_req", ",", "inst_reqs", ")", "self", ".", "install_requires", "=", "list", "(", "map", "(", "str", ",", "simple_reqs", ")", ")", "for", "r", "in", "complex_reqs", ":", "self", ".", "_tmp_extras_require", "[", "':'", "+", "str", "(", "r", ".", "marker", ")", "]", ".", "append", "(", "r", ")", "self", ".", "extras_require", "=", "dict", "(", "(", "k", ",", "[", "str", "(", "r", ")", "for", "r", "in", "map", "(", "self", ".", "_clean_req", ",", "v", ")", "]", ")", "for", "k", ",", "v", "in", "self", ".", "_tmp_extras_require", ".", "items", "(", ")", ")" ]
[ 452, 4 ]
[ 476, 9 ]
python
en
['en', 'error', 'th']
False
Distribution._clean_req
(self, req)
Given a Requirement, remove environment markers and return it.
Given a Requirement, remove environment markers and return it.
def _clean_req(self, req): """ Given a Requirement, remove environment markers and return it. """ req.marker = None return req
[ "def", "_clean_req", "(", "self", ",", "req", ")", ":", "req", ".", "marker", "=", "None", "return", "req" ]
[ 478, 4 ]
[ 483, 18 ]
python
en
['en', 'error', 'th']
False
Distribution.parse_config_files
(self, filenames=None, ignore_option_errors=False)
Parses configuration files from various levels and loads configuration.
Parses configuration files from various levels and loads configuration.
def parse_config_files(self, filenames=None, ignore_option_errors=False): """Parses configuration files from various levels and loads configuration. """ _Distribution.parse_config_files(self, filenames=filenames) parse_configuration(self, self.command_options, ignore_option_errors=ignore_option_errors) self._finalize_requires()
[ "def", "parse_config_files", "(", "self", ",", "filenames", "=", "None", ",", "ignore_option_errors", "=", "False", ")", ":", "_Distribution", ".", "parse_config_files", "(", "self", ",", "filenames", "=", "filenames", ")", "parse_configuration", "(", "self", ",", "self", ".", "command_options", ",", "ignore_option_errors", "=", "ignore_option_errors", ")", "self", ".", "_finalize_requires", "(", ")" ]
[ 485, 4 ]
[ 494, 33 ]
python
en
['en', 'en', 'en']
True
Distribution.parse_command_line
(self)
Process features after parsing command line options
Process features after parsing command line options
def parse_command_line(self): """Process features after parsing command line options""" result = _Distribution.parse_command_line(self) if self.features: self._finalize_features() return result
[ "def", "parse_command_line", "(", "self", ")", ":", "result", "=", "_Distribution", ".", "parse_command_line", "(", "self", ")", "if", "self", ".", "features", ":", "self", ".", "_finalize_features", "(", ")", "return", "result" ]
[ 496, 4 ]
[ 501, 21 ]
python
en
['en', 'en', 'en']
True
Distribution._feature_attrname
(self, name)
Convert feature name to corresponding option attribute name
Convert feature name to corresponding option attribute name
def _feature_attrname(self, name): """Convert feature name to corresponding option attribute name""" return 'with_' + name.replace('-', '_')
[ "def", "_feature_attrname", "(", "self", ",", "name", ")", ":", "return", "'with_'", "+", "name", ".", "replace", "(", "'-'", ",", "'_'", ")" ]
[ 503, 4 ]
[ 505, 47 ]
python
en
['en', 'en', 'en']
True
Distribution.fetch_build_eggs
(self, requires)
Resolve pre-setup requirements
Resolve pre-setup requirements
def fetch_build_eggs(self, requires): """Resolve pre-setup requirements""" resolved_dists = pkg_resources.working_set.resolve( pkg_resources.parse_requirements(requires), installer=self.fetch_build_egg, replace_conflicting=True, ) for dist in resolved_dists: pkg_resources.working_set.add(dist, replace=True) return resolved_dists
[ "def", "fetch_build_eggs", "(", "self", ",", "requires", ")", ":", "resolved_dists", "=", "pkg_resources", ".", "working_set", ".", "resolve", "(", "pkg_resources", ".", "parse_requirements", "(", "requires", ")", ",", "installer", "=", "self", ".", "fetch_build_egg", ",", "replace_conflicting", "=", "True", ",", ")", "for", "dist", "in", "resolved_dists", ":", "pkg_resources", ".", "working_set", ".", "add", "(", "dist", ",", "replace", "=", "True", ")", "return", "resolved_dists" ]
[ 507, 4 ]
[ 516, 29 ]
python
en
['en', 'en', 'en']
True
Distribution.fetch_build_egg
(self, req)
Fetch an egg needed for building
Fetch an egg needed for building
def fetch_build_egg(self, req): """Fetch an egg needed for building""" from setuptools.command.easy_install import easy_install dist = self.__class__({'script_args': ['easy_install']}) opts = dist.get_option_dict('easy_install') opts.clear() opts.update( (k, v) for k, v in self.get_option_dict('easy_install').items() if k in ( # don't use any other settings 'find_links', 'site_dirs', 'index_url', 'optimize', 'site_dirs', 'allow_hosts', )) if self.dependency_links: links = self.dependency_links[:] if 'find_links' in opts: links = opts['find_links'][1] + links opts['find_links'] = ('setup', links) install_dir = self.get_egg_cache_dir() cmd = easy_install( dist, args=["x"], install_dir=install_dir, exclude_scripts=True, always_copy=False, build_directory=None, editable=False, upgrade=False, multi_version=True, no_report=True, user=False ) cmd.ensure_finalized() return cmd.easy_install(req)
[ "def", "fetch_build_egg", "(", "self", ",", "req", ")", ":", "from", "setuptools", ".", "command", ".", "easy_install", "import", "easy_install", "dist", "=", "self", ".", "__class__", "(", "{", "'script_args'", ":", "[", "'easy_install'", "]", "}", ")", "opts", "=", "dist", ".", "get_option_dict", "(", "'easy_install'", ")", "opts", ".", "clear", "(", ")", "opts", ".", "update", "(", "(", "k", ",", "v", ")", "for", "k", ",", "v", "in", "self", ".", "get_option_dict", "(", "'easy_install'", ")", ".", "items", "(", ")", "if", "k", "in", "(", "# don't use any other settings", "'find_links'", ",", "'site_dirs'", ",", "'index_url'", ",", "'optimize'", ",", "'site_dirs'", ",", "'allow_hosts'", ",", ")", ")", "if", "self", ".", "dependency_links", ":", "links", "=", "self", ".", "dependency_links", "[", ":", "]", "if", "'find_links'", "in", "opts", ":", "links", "=", "opts", "[", "'find_links'", "]", "[", "1", "]", "+", "links", "opts", "[", "'find_links'", "]", "=", "(", "'setup'", ",", "links", ")", "install_dir", "=", "self", ".", "get_egg_cache_dir", "(", ")", "cmd", "=", "easy_install", "(", "dist", ",", "args", "=", "[", "\"x\"", "]", ",", "install_dir", "=", "install_dir", ",", "exclude_scripts", "=", "True", ",", "always_copy", "=", "False", ",", "build_directory", "=", "None", ",", "editable", "=", "False", ",", "upgrade", "=", "False", ",", "multi_version", "=", "True", ",", "no_report", "=", "True", ",", "user", "=", "False", ")", "cmd", ".", "ensure_finalized", "(", ")", "return", "cmd", ".", "easy_install", "(", "req", ")" ]
[ 552, 4 ]
[ 579, 36 ]
python
en
['en', 'en', 'en']
True
Distribution._set_global_opts_from_features
(self)
Add --with-X/--without-X options based on optional features
Add --with-X/--without-X options based on optional features
def _set_global_opts_from_features(self): """Add --with-X/--without-X options based on optional features""" go = [] no = self.negative_opt.copy() for name, feature in self.features.items(): self._set_feature(name, None) feature.validate(self) if feature.optional: descr = feature.description incdef = ' (default)' excdef = '' if not feature.include_by_default(): excdef, incdef = incdef, excdef new = ( ('with-' + name, None, 'include ' + descr + incdef), ('without-' + name, None, 'exclude ' + descr + excdef), ) go.extend(new) no['without-' + name] = 'with-' + name self.global_options = self.feature_options = go + self.global_options self.negative_opt = self.feature_negopt = no
[ "def", "_set_global_opts_from_features", "(", "self", ")", ":", "go", "=", "[", "]", "no", "=", "self", ".", "negative_opt", ".", "copy", "(", ")", "for", "name", ",", "feature", "in", "self", ".", "features", ".", "items", "(", ")", ":", "self", ".", "_set_feature", "(", "name", ",", "None", ")", "feature", ".", "validate", "(", "self", ")", "if", "feature", ".", "optional", ":", "descr", "=", "feature", ".", "description", "incdef", "=", "' (default)'", "excdef", "=", "''", "if", "not", "feature", ".", "include_by_default", "(", ")", ":", "excdef", ",", "incdef", "=", "incdef", ",", "excdef", "new", "=", "(", "(", "'with-'", "+", "name", ",", "None", ",", "'include '", "+", "descr", "+", "incdef", ")", ",", "(", "'without-'", "+", "name", ",", "None", ",", "'exclude '", "+", "descr", "+", "excdef", ")", ",", ")", "go", ".", "extend", "(", "new", ")", "no", "[", "'without-'", "+", "name", "]", "=", "'with-'", "+", "name", "self", ".", "global_options", "=", "self", ".", "feature_options", "=", "go", "+", "self", ".", "global_options", "self", ".", "negative_opt", "=", "self", ".", "feature_negopt", "=", "no" ]
[ 581, 4 ]
[ 606, 52 ]
python
en
['en', 'en', 'en']
True
Distribution._finalize_features
(self)
Add/remove features and resolve dependencies between them
Add/remove features and resolve dependencies between them
def _finalize_features(self): """Add/remove features and resolve dependencies between them""" # First, flag all the enabled items (and thus their dependencies) for name, feature in self.features.items(): enabled = self.feature_is_included(name) if enabled or (enabled is None and feature.include_by_default()): feature.include_in(self) self._set_feature(name, 1) # Then disable the rest, so that off-by-default features don't # get flagged as errors when they're required by an enabled feature for name, feature in self.features.items(): if not self.feature_is_included(name): feature.exclude_from(self) self._set_feature(name, 0)
[ "def", "_finalize_features", "(", "self", ")", ":", "# First, flag all the enabled items (and thus their dependencies)", "for", "name", ",", "feature", "in", "self", ".", "features", ".", "items", "(", ")", ":", "enabled", "=", "self", ".", "feature_is_included", "(", "name", ")", "if", "enabled", "or", "(", "enabled", "is", "None", "and", "feature", ".", "include_by_default", "(", ")", ")", ":", "feature", ".", "include_in", "(", "self", ")", "self", ".", "_set_feature", "(", "name", ",", "1", ")", "# Then disable the rest, so that off-by-default features don't", "# get flagged as errors when they're required by an enabled feature", "for", "name", ",", "feature", "in", "self", ".", "features", ".", "items", "(", ")", ":", "if", "not", "self", ".", "feature_is_included", "(", "name", ")", ":", "feature", ".", "exclude_from", "(", "self", ")", "self", ".", "_set_feature", "(", "name", ",", "0", ")" ]
[ 608, 4 ]
[ 623, 42 ]
python
en
['en', 'en', 'en']
True
Distribution.get_command_class
(self, command)
Pluggable version of get_command_class()
Pluggable version of get_command_class()
def get_command_class(self, command): """Pluggable version of get_command_class()""" if command in self.cmdclass: return self.cmdclass[command] eps = pkg_resources.iter_entry_points('distutils.commands', command) for ep in eps: ep.require(installer=self.fetch_build_egg) self.cmdclass[command] = cmdclass = ep.load() return cmdclass else: return _Distribution.get_command_class(self, command)
[ "def", "get_command_class", "(", "self", ",", "command", ")", ":", "if", "command", "in", "self", ".", "cmdclass", ":", "return", "self", ".", "cmdclass", "[", "command", "]", "eps", "=", "pkg_resources", ".", "iter_entry_points", "(", "'distutils.commands'", ",", "command", ")", "for", "ep", "in", "eps", ":", "ep", ".", "require", "(", "installer", "=", "self", ".", "fetch_build_egg", ")", "self", ".", "cmdclass", "[", "command", "]", "=", "cmdclass", "=", "ep", ".", "load", "(", ")", "return", "cmdclass", "else", ":", "return", "_Distribution", ".", "get_command_class", "(", "self", ",", "command", ")" ]
[ 625, 4 ]
[ 636, 65 ]
python
en
['en', 'en', 'en']
True
Distribution._set_feature
(self, name, status)
Set feature's inclusion status
Set feature's inclusion status
def _set_feature(self, name, status): """Set feature's inclusion status""" setattr(self, self._feature_attrname(name), status)
[ "def", "_set_feature", "(", "self", ",", "name", ",", "status", ")", ":", "setattr", "(", "self", ",", "self", ".", "_feature_attrname", "(", "name", ")", ",", "status", ")" ]
[ 654, 4 ]
[ 656, 59 ]
python
en
['en', 'fr', 'en']
True
Distribution.feature_is_included
(self, name)
Return 1 if feature is included, 0 if excluded, 'None' if unknown
Return 1 if feature is included, 0 if excluded, 'None' if unknown
def feature_is_included(self, name): """Return 1 if feature is included, 0 if excluded, 'None' if unknown""" return getattr(self, self._feature_attrname(name))
[ "def", "feature_is_included", "(", "self", ",", "name", ")", ":", "return", "getattr", "(", "self", ",", "self", ".", "_feature_attrname", "(", "name", ")", ")" ]
[ 658, 4 ]
[ 660, 58 ]
python
en
['en', 'en', 'en']
True
Distribution.include_feature
(self, name)
Request inclusion of feature named 'name
Request inclusion of feature named 'name
def include_feature(self, name): """Request inclusion of feature named 'name'""" if self.feature_is_included(name) == 0: descr = self.features[name].description raise DistutilsOptionError( descr + " is required, but was excluded or is not available" ) self.features[name].include_in(self) self._set_feature(name, 1)
[ "def", "include_feature", "(", "self", ",", "name", ")", ":", "if", "self", ".", "feature_is_included", "(", "name", ")", "==", "0", ":", "descr", "=", "self", ".", "features", "[", "name", "]", ".", "description", "raise", "DistutilsOptionError", "(", "descr", "+", "\" is required, but was excluded or is not available\"", ")", "self", ".", "features", "[", "name", "]", ".", "include_in", "(", "self", ")", "self", ".", "_set_feature", "(", "name", ",", "1", ")" ]
[ 662, 4 ]
[ 671, 34 ]
python
en
['en', 'en', 'en']
True
Distribution.include
(self, **attrs)
Add items to distribution that are named in keyword arguments For example, 'dist.exclude(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.
Add items to distribution that are named in keyword arguments
def include(self, **attrs): """Add items to distribution that are named in keyword arguments For example, 'dist.exclude(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. """ for k, v in attrs.items(): include = getattr(self, '_include_' + k, None) if include: include(v) else: self._include_misc(k, v)
[ "def", "include", "(", "self", ",", "*", "*", "attrs", ")", ":", "for", "k", ",", "v", "in", "attrs", ".", "items", "(", ")", ":", "include", "=", "getattr", "(", "self", ",", "'_include_'", "+", "k", ",", "None", ")", "if", "include", ":", "include", "(", "v", ")", "else", ":", "self", ".", "_include_misc", "(", "k", ",", "v", ")" ]
[ 673, 4 ]
[ 693, 40 ]
python
en
['en', 'en', 'en']
True
Distribution.exclude_package
(self, package)
Remove packages, modules, and extensions in named package
Remove packages, modules, and extensions in named package
def exclude_package(self, package): """Remove packages, modules, and extensions in named package""" pfx = package + '.' if self.packages: self.packages = [ p for p in self.packages if p != package and not p.startswith(pfx) ] if self.py_modules: self.py_modules = [ p for p in self.py_modules if p != package and not p.startswith(pfx) ] if self.ext_modules: self.ext_modules = [ p for p in self.ext_modules if p.name != package and not p.name.startswith(pfx) ]
[ "def", "exclude_package", "(", "self", ",", "package", ")", ":", "pfx", "=", "package", "+", "'.'", "if", "self", ".", "packages", ":", "self", ".", "packages", "=", "[", "p", "for", "p", "in", "self", ".", "packages", "if", "p", "!=", "package", "and", "not", "p", ".", "startswith", "(", "pfx", ")", "]", "if", "self", ".", "py_modules", ":", "self", ".", "py_modules", "=", "[", "p", "for", "p", "in", "self", ".", "py_modules", "if", "p", "!=", "package", "and", "not", "p", ".", "startswith", "(", "pfx", ")", "]", "if", "self", ".", "ext_modules", ":", "self", ".", "ext_modules", "=", "[", "p", "for", "p", "in", "self", ".", "ext_modules", "if", "p", ".", "name", "!=", "package", "and", "not", "p", ".", "name", ".", "startswith", "(", "pfx", ")", "]" ]
[ 695, 4 ]
[ 715, 13 ]
python
en
['en', 'en', 'en']
True
Distribution.has_contents_for
(self, package)
Return true if 'exclude_package(package)' would do something
Return true if 'exclude_package(package)' would do something
def has_contents_for(self, package): """Return true if 'exclude_package(package)' would do something""" pfx = package + '.' for p in self.iter_distribution_names(): if p == package or p.startswith(pfx): return True
[ "def", "has_contents_for", "(", "self", ",", "package", ")", ":", "pfx", "=", "package", "+", "'.'", "for", "p", "in", "self", ".", "iter_distribution_names", "(", ")", ":", "if", "p", "==", "package", "or", "p", ".", "startswith", "(", "pfx", ")", ":", "return", "True" ]
[ 717, 4 ]
[ 724, 27 ]
python
en
['en', 'en', 'en']
True
Distribution._exclude_misc
(self, name, value)
Handle 'exclude()' for list/tuple attrs without a special handler
Handle 'exclude()' for list/tuple attrs without a special handler
def _exclude_misc(self, name, value): """Handle 'exclude()' for list/tuple attrs without a special handler""" if not isinstance(value, sequence): raise DistutilsSetupError( "%s: setting must be a list or tuple (%r)" % (name, value) ) try: old = getattr(self, name) except AttributeError: raise DistutilsSetupError( "%s: No such distribution setting" % name ) if old is not None and not isinstance(old, sequence): raise DistutilsSetupError( name + ": this setting cannot be changed via include/exclude" ) elif old: setattr(self, name, [item for item in old if item not in value])
[ "def", "_exclude_misc", "(", "self", ",", "name", ",", "value", ")", ":", "if", "not", "isinstance", "(", "value", ",", "sequence", ")", ":", "raise", "DistutilsSetupError", "(", "\"%s: setting must be a list or tuple (%r)\"", "%", "(", "name", ",", "value", ")", ")", "try", ":", "old", "=", "getattr", "(", "self", ",", "name", ")", "except", "AttributeError", ":", "raise", "DistutilsSetupError", "(", "\"%s: No such distribution setting\"", "%", "name", ")", "if", "old", "is", "not", "None", "and", "not", "isinstance", "(", "old", ",", "sequence", ")", ":", "raise", "DistutilsSetupError", "(", "name", "+", "\": this setting cannot be changed via include/exclude\"", ")", "elif", "old", ":", "setattr", "(", "self", ",", "name", ",", "[", "item", "for", "item", "in", "old", "if", "item", "not", "in", "value", "]", ")" ]
[ 726, 4 ]
[ 743, 76 ]
python
en
['en', 'en', 'en']
True
Distribution._include_misc
(self, name, value)
Handle 'include()' for list/tuple attrs without a special handler
Handle 'include()' for list/tuple attrs without a special handler
def _include_misc(self, name, value): """Handle 'include()' for list/tuple attrs without a special handler""" if not isinstance(value, sequence): raise DistutilsSetupError( "%s: setting must be a list (%r)" % (name, value) ) try: old = getattr(self, name) except AttributeError: raise DistutilsSetupError( "%s: No such distribution setting" % name ) if old is None: setattr(self, name, value) elif not isinstance(old, sequence): raise DistutilsSetupError( name + ": this setting cannot be changed via include/exclude" ) else: new = [item for item in value if item not in old] setattr(self, name, old + new)
[ "def", "_include_misc", "(", "self", ",", "name", ",", "value", ")", ":", "if", "not", "isinstance", "(", "value", ",", "sequence", ")", ":", "raise", "DistutilsSetupError", "(", "\"%s: setting must be a list (%r)\"", "%", "(", "name", ",", "value", ")", ")", "try", ":", "old", "=", "getattr", "(", "self", ",", "name", ")", "except", "AttributeError", ":", "raise", "DistutilsSetupError", "(", "\"%s: No such distribution setting\"", "%", "name", ")", "if", "old", "is", "None", ":", "setattr", "(", "self", ",", "name", ",", "value", ")", "elif", "not", "isinstance", "(", "old", ",", "sequence", ")", ":", "raise", "DistutilsSetupError", "(", "name", "+", "\": this setting cannot be changed via include/exclude\"", ")", "else", ":", "new", "=", "[", "item", "for", "item", "in", "value", "if", "item", "not", "in", "old", "]", "setattr", "(", "self", ",", "name", ",", "old", "+", "new", ")" ]
[ 745, 4 ]
[ 766, 42 ]
python
en
['en', 'en', 'en']
True
Distribution.exclude
(self, **attrs)
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.
Remove items from distribution that are named in keyword arguments
def exclude(self, **attrs): """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. """ for k, v in attrs.items(): exclude = getattr(self, '_exclude_' + k, None) if exclude: exclude(v) else: self._exclude_misc(k, v)
[ "def", "exclude", "(", "self", ",", "*", "*", "attrs", ")", ":", "for", "k", ",", "v", "in", "attrs", ".", "items", "(", ")", ":", "exclude", "=", "getattr", "(", "self", ",", "'_exclude_'", "+", "k", ",", "None", ")", "if", "exclude", ":", "exclude", "(", "v", ")", "else", ":", "self", ".", "_exclude_misc", "(", "k", ",", "v", ")" ]
[ 768, 4 ]
[ 789, 40 ]
python
en
['en', 'en', 'en']
True
Distribution.get_cmdline_options
(self)
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.
Return a '{cmd: {opt:val}}' map of all command-line options
def get_cmdline_options(self): """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. """ d = {} for cmd, opts in self.command_options.items(): for opt, (src, val) in opts.items(): if src != "command line": continue opt = opt.replace('_', '-') if val == 0: cmdobj = self.get_command_obj(cmd) neg_opt = self.negative_opt.copy() neg_opt.update(getattr(cmdobj, 'negative_opt', {})) for neg, pos in neg_opt.items(): if pos == opt: opt = neg val = None break else: raise AssertionError("Shouldn't be able to get here") elif val == 1: val = None d.setdefault(cmd, {})[opt] = val return d
[ "def", "get_cmdline_options", "(", "self", ")", ":", "d", "=", "{", "}", "for", "cmd", ",", "opts", "in", "self", ".", "command_options", ".", "items", "(", ")", ":", "for", "opt", ",", "(", "src", ",", "val", ")", "in", "opts", ".", "items", "(", ")", ":", "if", "src", "!=", "\"command line\"", ":", "continue", "opt", "=", "opt", ".", "replace", "(", "'_'", ",", "'-'", ")", "if", "val", "==", "0", ":", "cmdobj", "=", "self", ".", "get_command_obj", "(", "cmd", ")", "neg_opt", "=", "self", ".", "negative_opt", ".", "copy", "(", ")", "neg_opt", ".", "update", "(", "getattr", "(", "cmdobj", ",", "'negative_opt'", ",", "{", "}", ")", ")", "for", "neg", ",", "pos", "in", "neg_opt", ".", "items", "(", ")", ":", "if", "pos", "==", "opt", ":", "opt", "=", "neg", "val", "=", "None", "break", "else", ":", "raise", "AssertionError", "(", "\"Shouldn't be able to get here\"", ")", "elif", "val", "==", "1", ":", "val", "=", "None", "d", ".", "setdefault", "(", "cmd", ",", "{", "}", ")", "[", "opt", "]", "=", "val", "return", "d" ]
[ 824, 4 ]
[ 862, 16 ]
python
en
['en', 'en', 'en']
True
Distribution.iter_distribution_names
(self)
Yield all packages, modules, and extension names in distribution
Yield all packages, modules, and extension names in distribution
def iter_distribution_names(self): """Yield all packages, modules, and extension names in distribution""" for pkg in self.packages or (): yield pkg for module in self.py_modules or (): yield module for ext in self.ext_modules or (): if isinstance(ext, tuple): name, buildinfo = ext else: name = ext.name if name.endswith('module'): name = name[:-6] yield name
[ "def", "iter_distribution_names", "(", "self", ")", ":", "for", "pkg", "in", "self", ".", "packages", "or", "(", ")", ":", "yield", "pkg", "for", "module", "in", "self", ".", "py_modules", "or", "(", ")", ":", "yield", "module", "for", "ext", "in", "self", ".", "ext_modules", "or", "(", ")", ":", "if", "isinstance", "(", "ext", ",", "tuple", ")", ":", "name", ",", "buildinfo", "=", "ext", "else", ":", "name", "=", "ext", ".", "name", "if", "name", ".", "endswith", "(", "'module'", ")", ":", "name", "=", "name", "[", ":", "-", "6", "]", "yield", "name" ]
[ 864, 4 ]
[ 880, 22 ]
python
en
['en', 'en', 'en']
True
Distribution.handle_display_options
(self, option_order)
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.
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.
def handle_display_options(self, option_order): """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. """ import sys if six.PY2 or self.help_commands: return _Distribution.handle_display_options(self, option_order) # Stdout may be StringIO (e.g. in tests) import io if not isinstance(sys.stdout, io.TextIOWrapper): return _Distribution.handle_display_options(self, option_order) # Don't wrap stdout if utf-8 is already the encoding. Provides # workaround for #334. if sys.stdout.encoding.lower() in ('utf-8', 'utf8'): return _Distribution.handle_display_options(self, option_order) # Print metadata in UTF-8 no matter the platform encoding = sys.stdout.encoding errors = sys.stdout.errors newline = sys.platform != 'win32' and '\n' or None line_buffering = sys.stdout.line_buffering sys.stdout = io.TextIOWrapper( sys.stdout.detach(), 'utf-8', errors, newline, line_buffering) try: return _Distribution.handle_display_options(self, option_order) finally: sys.stdout = io.TextIOWrapper( sys.stdout.detach(), encoding, errors, newline, line_buffering)
[ "def", "handle_display_options", "(", "self", ",", "option_order", ")", ":", "import", "sys", "if", "six", ".", "PY2", "or", "self", ".", "help_commands", ":", "return", "_Distribution", ".", "handle_display_options", "(", "self", ",", "option_order", ")", "# Stdout may be StringIO (e.g. in tests)", "import", "io", "if", "not", "isinstance", "(", "sys", ".", "stdout", ",", "io", ".", "TextIOWrapper", ")", ":", "return", "_Distribution", ".", "handle_display_options", "(", "self", ",", "option_order", ")", "# Don't wrap stdout if utf-8 is already the encoding. Provides", "# workaround for #334.", "if", "sys", ".", "stdout", ".", "encoding", ".", "lower", "(", ")", "in", "(", "'utf-8'", ",", "'utf8'", ")", ":", "return", "_Distribution", ".", "handle_display_options", "(", "self", ",", "option_order", ")", "# Print metadata in UTF-8 no matter the platform", "encoding", "=", "sys", ".", "stdout", ".", "encoding", "errors", "=", "sys", ".", "stdout", ".", "errors", "newline", "=", "sys", ".", "platform", "!=", "'win32'", "and", "'\\n'", "or", "None", "line_buffering", "=", "sys", ".", "stdout", ".", "line_buffering", "sys", ".", "stdout", "=", "io", ".", "TextIOWrapper", "(", "sys", ".", "stdout", ".", "detach", "(", ")", ",", "'utf-8'", ",", "errors", ",", "newline", ",", "line_buffering", ")", "try", ":", "return", "_Distribution", ".", "handle_display_options", "(", "self", ",", "option_order", ")", "finally", ":", "sys", ".", "stdout", "=", "io", ".", "TextIOWrapper", "(", "sys", ".", "stdout", ".", "detach", "(", ")", ",", "encoding", ",", "errors", ",", "newline", ",", "line_buffering", ")" ]
[ 882, 4 ]
[ 915, 79 ]
python
en
['en', 'en', 'en']
True
Feature.include_by_default
(self)
Should this feature be included by default?
Should this feature be included by default?
def include_by_default(self): """Should this feature be included by default?""" return self.available and self.standard
[ "def", "include_by_default", "(", "self", ")", ":", "return", "self", ".", "available", "and", "self", ".", "standard" ]
[ 1013, 4 ]
[ 1015, 47 ]
python
en
['en', 'en', 'en']
True
Feature.include_in
(self, dist)
Ensure feature and its requirements are included in distribution You may override this in a subclass to perform additional operations on the distribution. Note that this method may be called more than once per feature, and so should be idempotent.
Ensure feature and its requirements are included in distribution
def include_in(self, dist): """Ensure feature and its requirements are included in distribution You may override this in a subclass to perform additional operations on the distribution. Note that this method may be called more than once per feature, and so should be idempotent. """ if not self.available: raise DistutilsPlatformError( self.description + " is required, " "but is not available on this platform" ) dist.include(**self.extras) for f in self.require_features: dist.include_feature(f)
[ "def", "include_in", "(", "self", ",", "dist", ")", ":", "if", "not", "self", ".", "available", ":", "raise", "DistutilsPlatformError", "(", "self", ".", "description", "+", "\" is required, \"", "\"but is not available on this platform\"", ")", "dist", ".", "include", "(", "*", "*", "self", ".", "extras", ")", "for", "f", "in", "self", ".", "require_features", ":", "dist", ".", "include_feature", "(", "f", ")" ]
[ 1017, 4 ]
[ 1035, 35 ]
python
en
['en', 'en', 'en']
True
Feature.exclude_from
(self, dist)
Ensure feature is excluded from distribution You may override this in a subclass to perform additional operations on the distribution. This method will be called at most once per feature, and only after all included features have been asked to include themselves.
Ensure feature is excluded from distribution
def exclude_from(self, dist): """Ensure feature is excluded from distribution You may override this in a subclass to perform additional operations on the distribution. This method will be called at most once per feature, and only after all included features have been asked to include themselves. """ dist.exclude(**self.extras) if self.remove: for item in self.remove: dist.exclude_package(item)
[ "def", "exclude_from", "(", "self", ",", "dist", ")", ":", "dist", ".", "exclude", "(", "*", "*", "self", ".", "extras", ")", "if", "self", ".", "remove", ":", "for", "item", "in", "self", ".", "remove", ":", "dist", ".", "exclude_package", "(", "item", ")" ]
[ 1037, 4 ]
[ 1050, 42 ]
python
en
['en', 'en', 'en']
True
Feature.validate
(self, dist)
Verify that feature makes sense in context of distribution This method is called by the distribution just before it parses its command line. It checks to ensure that the 'remove' attribute, if any, contains only valid package/module names that are present in the base distribution when 'setup()' is called. You may override it in a subclass to perform any other required validation of the feature against a target distribution.
Verify that feature makes sense in context of distribution
def validate(self, dist): """Verify that feature makes sense in context of distribution This method is called by the distribution just before it parses its command line. It checks to ensure that the 'remove' attribute, if any, contains only valid package/module names that are present in the base distribution when 'setup()' is called. You may override it in a subclass to perform any other required validation of the feature against a target distribution. """ for item in self.remove: if not dist.has_contents_for(item): raise DistutilsSetupError( "%s wants to be able to remove %s, but the distribution" " doesn't contain any packages or modules under %s" % (self.description, item, item) )
[ "def", "validate", "(", "self", ",", "dist", ")", ":", "for", "item", "in", "self", ".", "remove", ":", "if", "not", "dist", ".", "has_contents_for", "(", "item", ")", ":", "raise", "DistutilsSetupError", "(", "\"%s wants to be able to remove %s, but the distribution\"", "\" doesn't contain any packages or modules under %s\"", "%", "(", "self", ".", "description", ",", "item", ",", "item", ")", ")" ]
[ 1052, 4 ]
[ 1069, 17 ]
python
en
['en', 'en', 'en']
True
FBCodeBuilder.render
(self, steps)
Converts nested actions to your builder's expected output format. Typically takes the output of build().
def render(self, steps): ''' Converts nested actions to your builder's expected output format. Typically takes the output of build(). ''' res = self._render_impl(steps) # Implementation-dependent # Now that the output is rendered, we expect all options to have # been used. unused_options = set(self._options_do_not_access) unused_options -= self.options_used if unused_options: raise RuntimeError( 'Unused options: {0} -- please check if you made a typo ' 'in any of them. Those that are truly not useful should ' 'be not be set so that this typo detection can be useful.' .format(unused_options) ) return res
[ "def", "render", "(", "self", ",", "steps", ")", ":", "res", "=", "self", ".", "_render_impl", "(", "steps", ")", "# Implementation-dependent", "# Now that the output is rendered, we expect all options to have", "# been used.", "unused_options", "=", "set", "(", "self", ".", "_options_do_not_access", ")", "unused_options", "-=", "self", ".", "options_used", "if", "unused_options", ":", "raise", "RuntimeError", "(", "'Unused options: {0} -- please check if you made a typo '", "'in any of them. Those that are truly not useful should '", "'be not be set so that this typo detection can be useful.'", ".", "format", "(", "unused_options", ")", ")", "return", "res" ]
[ 118, 4 ]
[ 137, 18 ]
python
en
['en', 'error', 'th']
False
FBCodeBuilder.setup
(self)
Your builder may want to install packages here.
Your builder may want to install packages here.
def setup(self): 'Your builder may want to install packages here.' raise NotImplementedError
[ "def", "setup", "(", "self", ")", ":", "raise", "NotImplementedError" ]
[ 145, 4 ]
[ 147, 33 ]
python
en
['en', 'en', 'en']
True
FBCodeBuilder.diagnostics
(self)
Log some system diagnostics before/after setup for ease of debugging
Log some system diagnostics before/after setup for ease of debugging
def diagnostics(self): 'Log some system diagnostics before/after setup for ease of debugging' # The builder's repr is not used in a command to avoid pointlessly # invalidating Docker's build cache. return self.step('Diagnostics', [ self.comment('Builder {0}'.format(repr(self))), self.run(ShellQuoted('hostname')), self.run(ShellQuoted('cat /etc/issue || echo no /etc/issue')), self.run(ShellQuoted('g++ --version || echo g++ not installed')), self.run(ShellQuoted('cmake --version || echo cmake not installed')), ])
[ "def", "diagnostics", "(", "self", ")", ":", "# The builder's repr is not used in a command to avoid pointlessly", "# invalidating Docker's build cache.", "return", "self", ".", "step", "(", "'Diagnostics'", ",", "[", "self", ".", "comment", "(", "'Builder {0}'", ".", "format", "(", "repr", "(", "self", ")", ")", ")", ",", "self", ".", "run", "(", "ShellQuoted", "(", "'hostname'", ")", ")", ",", "self", ".", "run", "(", "ShellQuoted", "(", "'cat /etc/issue || echo no /etc/issue'", ")", ")", ",", "self", ".", "run", "(", "ShellQuoted", "(", "'g++ --version || echo g++ not installed'", ")", ")", ",", "self", ".", "run", "(", "ShellQuoted", "(", "'cmake --version || echo cmake not installed'", ")", ")", ",", "]", ")" ]
[ 149, 4 ]
[ 159, 10 ]
python
en
['en', 'da', 'en']
True
FBCodeBuilder.step
(self, name, actions)
A labeled collection of actions or other steps
A labeled collection of actions or other steps
def step(self, name, actions): 'A labeled collection of actions or other steps' raise NotImplementedError
[ "def", "step", "(", "self", ",", "name", ",", "actions", ")", ":", "raise", "NotImplementedError" ]
[ 161, 4 ]
[ 163, 33 ]
python
en
['en', 'en', 'en']
True
FBCodeBuilder.run
(self, shell_cmd)
Run this bash command
Run this bash command
def run(self, shell_cmd): 'Run this bash command' raise NotImplementedError
[ "def", "run", "(", "self", ",", "shell_cmd", ")", ":", "raise", "NotImplementedError" ]
[ 165, 4 ]
[ 167, 33 ]
python
en
['en', 'en', 'en']
True
FBCodeBuilder.workdir
(self, dir)
Create this directory if it does not exist, and change into it
Create this directory if it does not exist, and change into it
def workdir(self, dir): 'Create this directory if it does not exist, and change into it' raise NotImplementedError
[ "def", "workdir", "(", "self", ",", "dir", ")", ":", "raise", "NotImplementedError" ]
[ 169, 4 ]
[ 171, 33 ]
python
en
['en', 'en', 'en']
True
FBCodeBuilder.copy_local_repo
(self, dir, dest_name)
Copy the local repo at `dir` into this step's `workdir()`, analog of: cp -r /path/to/folly folly
Copy the local repo at `dir` into this step's `workdir()`, analog of: cp -r /path/to/folly folly
def copy_local_repo(self, dir, dest_name): ''' Copy the local repo at `dir` into this step's `workdir()`, analog of: cp -r /path/to/folly folly ''' raise NotImplementedError
[ "def", "copy_local_repo", "(", "self", ",", "dir", ",", "dest_name", ")", ":", "raise", "NotImplementedError" ]
[ 173, 4 ]
[ 178, 33 ]
python
en
['en', 'error', 'th']
False
FBCodeBuilder.fb_github_project_workdir
(self, project_and_path, github_org='facebook')
This helper lets Facebook-internal CI special-cases FB projects
This helper lets Facebook-internal CI special-cases FB projects
def fb_github_project_workdir(self, project_and_path, github_org='facebook'): 'This helper lets Facebook-internal CI special-cases FB projects' project, path = project_and_path.split('/', 1) return self.github_project_workdir(github_org + '/' + project, path)
[ "def", "fb_github_project_workdir", "(", "self", ",", "project_and_path", ",", "github_org", "=", "'facebook'", ")", ":", "project", ",", "path", "=", "project_and_path", ".", "split", "(", "'/'", ",", "1", ")", "return", "self", ".", "github_project_workdir", "(", "github_org", "+", "'/'", "+", "project", ",", "path", ")" ]
[ 276, 4 ]
[ 279, 76 ]
python
en
['en', 'en', 'en']
True
_should_use_osx_framework_prefix
()
Check for Apple's ``osx_framework_library`` scheme. Python distributed by Apple's Command Line Tools has this special scheme that's used when: * This is a framework build. * We are installing into the system prefix. This does not account for ``pip install --prefix`` (also means we're not installing to the system prefix), which should use ``posix_prefix``, but logic here means ``_infer_prefix()`` outputs ``osx_framework_library``. But since ``prefix`` is not available for ``sysconfig.get_default_scheme()``, which is the stdlib replacement for ``_infer_prefix()``, presumably Apple wouldn't be able to magically switch between ``osx_framework_library`` and ``posix_prefix``. ``_infer_prefix()`` returning ``osx_framework_library`` means its behavior is consistent whether we use the stdlib implementation or our own, and we deal with this special case in ``get_scheme()`` instead.
Check for Apple's ``osx_framework_library`` scheme.
def _should_use_osx_framework_prefix() -> bool: """Check for Apple's ``osx_framework_library`` scheme. Python distributed by Apple's Command Line Tools has this special scheme that's used when: * This is a framework build. * We are installing into the system prefix. This does not account for ``pip install --prefix`` (also means we're not installing to the system prefix), which should use ``posix_prefix``, but logic here means ``_infer_prefix()`` outputs ``osx_framework_library``. But since ``prefix`` is not available for ``sysconfig.get_default_scheme()``, which is the stdlib replacement for ``_infer_prefix()``, presumably Apple wouldn't be able to magically switch between ``osx_framework_library`` and ``posix_prefix``. ``_infer_prefix()`` returning ``osx_framework_library`` means its behavior is consistent whether we use the stdlib implementation or our own, and we deal with this special case in ``get_scheme()`` instead. """ return ( "osx_framework_library" in _AVAILABLE_SCHEMES and not running_under_virtualenv() and is_osx_framework() )
[ "def", "_should_use_osx_framework_prefix", "(", ")", "->", "bool", ":", "return", "(", "\"osx_framework_library\"", "in", "_AVAILABLE_SCHEMES", "and", "not", "running_under_virtualenv", "(", ")", "and", "is_osx_framework", "(", ")", ")" ]
[ 29, 0 ]
[ 52, 5 ]
python
en
['en', 'en', 'en']
True
_infer_prefix
()
Try to find a prefix scheme for the current platform. This tries: * A special ``osx_framework_library`` for Python distributed by Apple's Command Line Tools, when not running in a virtual environment. * Implementation + OS, used by PyPy on Windows (``pypy_nt``). * Implementation without OS, used by PyPy on POSIX (``pypy``). * OS + "prefix", used by CPython on POSIX (``posix_prefix``). * Just the OS name, used by CPython on Windows (``nt``). If none of the above works, fall back to ``posix_prefix``.
Try to find a prefix scheme for the current platform.
def _infer_prefix() -> str: """Try to find a prefix scheme for the current platform. This tries: * A special ``osx_framework_library`` for Python distributed by Apple's Command Line Tools, when not running in a virtual environment. * Implementation + OS, used by PyPy on Windows (``pypy_nt``). * Implementation without OS, used by PyPy on POSIX (``pypy``). * OS + "prefix", used by CPython on POSIX (``posix_prefix``). * Just the OS name, used by CPython on Windows (``nt``). If none of the above works, fall back to ``posix_prefix``. """ if _PREFERRED_SCHEME_API: return _PREFERRED_SCHEME_API("prefix") if _should_use_osx_framework_prefix(): return "osx_framework_library" implementation_suffixed = f"{sys.implementation.name}_{os.name}" if implementation_suffixed in _AVAILABLE_SCHEMES: return implementation_suffixed if sys.implementation.name in _AVAILABLE_SCHEMES: return sys.implementation.name suffixed = f"{os.name}_prefix" if suffixed in _AVAILABLE_SCHEMES: return suffixed if os.name in _AVAILABLE_SCHEMES: # On Windows, prefx is just called "nt". return os.name return "posix_prefix"
[ "def", "_infer_prefix", "(", ")", "->", "str", ":", "if", "_PREFERRED_SCHEME_API", ":", "return", "_PREFERRED_SCHEME_API", "(", "\"prefix\"", ")", "if", "_should_use_osx_framework_prefix", "(", ")", ":", "return", "\"osx_framework_library\"", "implementation_suffixed", "=", "f\"{sys.implementation.name}_{os.name}\"", "if", "implementation_suffixed", "in", "_AVAILABLE_SCHEMES", ":", "return", "implementation_suffixed", "if", "sys", ".", "implementation", ".", "name", "in", "_AVAILABLE_SCHEMES", ":", "return", "sys", ".", "implementation", ".", "name", "suffixed", "=", "f\"{os.name}_prefix\"", "if", "suffixed", "in", "_AVAILABLE_SCHEMES", ":", "return", "suffixed", "if", "os", ".", "name", "in", "_AVAILABLE_SCHEMES", ":", "# On Windows, prefx is just called \"nt\".", "return", "os", ".", "name", "return", "\"posix_prefix\"" ]
[ 55, 0 ]
[ 83, 25 ]
python
en
['en', 'en', 'en']
True
_infer_user
()
Try to find a user scheme for the current platform.
Try to find a user scheme for the current platform.
def _infer_user() -> str: """Try to find a user scheme for the current platform.""" if _PREFERRED_SCHEME_API: return _PREFERRED_SCHEME_API("user") if is_osx_framework() and not running_under_virtualenv(): suffixed = "osx_framework_user" else: suffixed = f"{os.name}_user" if suffixed in _AVAILABLE_SCHEMES: return suffixed if "posix_user" not in _AVAILABLE_SCHEMES: # User scheme unavailable. raise UserInstallationInvalid() return "posix_user"
[ "def", "_infer_user", "(", ")", "->", "str", ":", "if", "_PREFERRED_SCHEME_API", ":", "return", "_PREFERRED_SCHEME_API", "(", "\"user\"", ")", "if", "is_osx_framework", "(", ")", "and", "not", "running_under_virtualenv", "(", ")", ":", "suffixed", "=", "\"osx_framework_user\"", "else", ":", "suffixed", "=", "f\"{os.name}_user\"", "if", "suffixed", "in", "_AVAILABLE_SCHEMES", ":", "return", "suffixed", "if", "\"posix_user\"", "not", "in", "_AVAILABLE_SCHEMES", ":", "# User scheme unavailable.", "raise", "UserInstallationInvalid", "(", ")", "return", "\"posix_user\"" ]
[ 86, 0 ]
[ 98, 23 ]
python
en
['en', 'en', 'en']
True
_infer_home
()
Try to find a home for the current platform.
Try to find a home for the current platform.
def _infer_home() -> str: """Try to find a home for the current platform.""" if _PREFERRED_SCHEME_API: return _PREFERRED_SCHEME_API("home") suffixed = f"{os.name}_home" if suffixed in _AVAILABLE_SCHEMES: return suffixed return "posix_home"
[ "def", "_infer_home", "(", ")", "->", "str", ":", "if", "_PREFERRED_SCHEME_API", ":", "return", "_PREFERRED_SCHEME_API", "(", "\"home\"", ")", "suffixed", "=", "f\"{os.name}_home\"", "if", "suffixed", "in", "_AVAILABLE_SCHEMES", ":", "return", "suffixed", "return", "\"posix_home\"" ]
[ 101, 0 ]
[ 108, 23 ]
python
en
['en', 'en', 'en']
True
get_scheme
( dist_name: str, user: bool = False, home: typing.Optional[str] = None, root: typing.Optional[str] = None, isolated: bool = False, prefix: typing.Optional[str] = None, )
Get the "scheme" corresponding to the input parameters. :param dist_name: the name of the package to retrieve the scheme for, used in the headers scheme path :param user: indicates to use the "user" scheme :param home: indicates to use the "home" scheme :param root: root under which other directories are re-based :param isolated: ignored, but kept for distutils compatibility (where this controls whether the user-site pydistutils.cfg is honored) :param prefix: indicates to use the "prefix" scheme and provides the base directory for the same
Get the "scheme" corresponding to the input parameters.
def get_scheme( dist_name: str, user: bool = False, home: typing.Optional[str] = None, root: typing.Optional[str] = None, isolated: bool = False, prefix: typing.Optional[str] = None, ) -> Scheme: """ Get the "scheme" corresponding to the input parameters. :param dist_name: the name of the package to retrieve the scheme for, used in the headers scheme path :param user: indicates to use the "user" scheme :param home: indicates to use the "home" scheme :param root: root under which other directories are re-based :param isolated: ignored, but kept for distutils compatibility (where this controls whether the user-site pydistutils.cfg is honored) :param prefix: indicates to use the "prefix" scheme and provides the base directory for the same """ if user and prefix: raise InvalidSchemeCombination("--user", "--prefix") if home and prefix: raise InvalidSchemeCombination("--home", "--prefix") if home is not None: scheme_name = _infer_home() elif user: scheme_name = _infer_user() else: scheme_name = _infer_prefix() # Special case: When installing into a custom prefix, use posix_prefix # instead of osx_framework_library. See _should_use_osx_framework_prefix() # docstring for details. if prefix is not None and scheme_name == "osx_framework_library": scheme_name = "posix_prefix" if home is not None: variables = {k: home for k in _HOME_KEYS} elif prefix is not None: variables = {k: prefix for k in _HOME_KEYS} else: variables = {} paths = sysconfig.get_paths(scheme=scheme_name, vars=variables) # Logic here is very arbitrary, we're doing it for compatibility, don't ask. # 1. Pip historically uses a special header path in virtual environments. # 2. If the distribution name is not known, distutils uses 'UNKNOWN'. We # only do the same when not running in a virtual environment because # pip's historical header path logic (see point 1) did not do this. if running_under_virtualenv(): if user: base = variables.get("userbase", sys.prefix) else: base = variables.get("base", sys.prefix) python_xy = f"python{get_major_minor_version()}" paths["include"] = os.path.join(base, "include", "site", python_xy) elif not dist_name: dist_name = "UNKNOWN" scheme = Scheme( platlib=paths["platlib"], purelib=paths["purelib"], headers=os.path.join(paths["include"], dist_name), scripts=paths["scripts"], data=paths["data"], ) if root is not None: for key in SCHEME_KEYS: value = distutils.util.change_root(root, getattr(scheme, key)) setattr(scheme, key, value) return scheme
[ "def", "get_scheme", "(", "dist_name", ":", "str", ",", "user", ":", "bool", "=", "False", ",", "home", ":", "typing", ".", "Optional", "[", "str", "]", "=", "None", ",", "root", ":", "typing", ".", "Optional", "[", "str", "]", "=", "None", ",", "isolated", ":", "bool", "=", "False", ",", "prefix", ":", "typing", ".", "Optional", "[", "str", "]", "=", "None", ",", ")", "->", "Scheme", ":", "if", "user", "and", "prefix", ":", "raise", "InvalidSchemeCombination", "(", "\"--user\"", ",", "\"--prefix\"", ")", "if", "home", "and", "prefix", ":", "raise", "InvalidSchemeCombination", "(", "\"--home\"", ",", "\"--prefix\"", ")", "if", "home", "is", "not", "None", ":", "scheme_name", "=", "_infer_home", "(", ")", "elif", "user", ":", "scheme_name", "=", "_infer_user", "(", ")", "else", ":", "scheme_name", "=", "_infer_prefix", "(", ")", "# Special case: When installing into a custom prefix, use posix_prefix", "# instead of osx_framework_library. See _should_use_osx_framework_prefix()", "# docstring for details.", "if", "prefix", "is", "not", "None", "and", "scheme_name", "==", "\"osx_framework_library\"", ":", "scheme_name", "=", "\"posix_prefix\"", "if", "home", "is", "not", "None", ":", "variables", "=", "{", "k", ":", "home", "for", "k", "in", "_HOME_KEYS", "}", "elif", "prefix", "is", "not", "None", ":", "variables", "=", "{", "k", ":", "prefix", "for", "k", "in", "_HOME_KEYS", "}", "else", ":", "variables", "=", "{", "}", "paths", "=", "sysconfig", ".", "get_paths", "(", "scheme", "=", "scheme_name", ",", "vars", "=", "variables", ")", "# Logic here is very arbitrary, we're doing it for compatibility, don't ask.", "# 1. Pip historically uses a special header path in virtual environments.", "# 2. If the distribution name is not known, distutils uses 'UNKNOWN'. We", "# only do the same when not running in a virtual environment because", "# pip's historical header path logic (see point 1) did not do this.", "if", "running_under_virtualenv", "(", ")", ":", "if", "user", ":", "base", "=", "variables", ".", "get", "(", "\"userbase\"", ",", "sys", ".", "prefix", ")", "else", ":", "base", "=", "variables", ".", "get", "(", "\"base\"", ",", "sys", ".", "prefix", ")", "python_xy", "=", "f\"python{get_major_minor_version()}\"", "paths", "[", "\"include\"", "]", "=", "os", ".", "path", ".", "join", "(", "base", ",", "\"include\"", ",", "\"site\"", ",", "python_xy", ")", "elif", "not", "dist_name", ":", "dist_name", "=", "\"UNKNOWN\"", "scheme", "=", "Scheme", "(", "platlib", "=", "paths", "[", "\"platlib\"", "]", ",", "purelib", "=", "paths", "[", "\"purelib\"", "]", ",", "headers", "=", "os", ".", "path", ".", "join", "(", "paths", "[", "\"include\"", "]", ",", "dist_name", ")", ",", "scripts", "=", "paths", "[", "\"scripts\"", "]", ",", "data", "=", "paths", "[", "\"data\"", "]", ",", ")", "if", "root", "is", "not", "None", ":", "for", "key", "in", "SCHEME_KEYS", ":", "value", "=", "distutils", ".", "util", ".", "change_root", "(", "root", ",", "getattr", "(", "scheme", ",", "key", ")", ")", "setattr", "(", "scheme", ",", "key", ",", "value", ")", "return", "scheme" ]
[ 124, 0 ]
[ 198, 17 ]
python
en
['en', 'error', 'th']
False
msvc9_find_vcvarsall
(version)
Patched "distutils.msvc9compiler.find_vcvarsall" to use the standalone compiler build for Python (VCForPython). Fall back to original behavior when the standalone compiler is not available. Redirect the path of "vcvarsall.bat". Known supported compilers ------------------------- Microsoft Visual C++ 9.0: Microsoft Visual C++ Compiler for Python 2.7 (x86, amd64) Parameters ---------- version: float Required Microsoft Visual C++ version. Return ------ vcvarsall.bat path: str
Patched "distutils.msvc9compiler.find_vcvarsall" to use the standalone compiler build for Python (VCForPython). Fall back to original behavior when the standalone compiler is not available.
def msvc9_find_vcvarsall(version): """ Patched "distutils.msvc9compiler.find_vcvarsall" to use the standalone compiler build for Python (VCForPython). Fall back to original behavior when the standalone compiler is not available. Redirect the path of "vcvarsall.bat". Known supported compilers ------------------------- Microsoft Visual C++ 9.0: Microsoft Visual C++ Compiler for Python 2.7 (x86, amd64) Parameters ---------- version: float Required Microsoft Visual C++ version. Return ------ vcvarsall.bat path: str """ VC_BASE = r'Software\%sMicrosoft\DevDiv\VCForPython\%0.1f' key = VC_BASE % ('', version) try: # Per-user installs register the compiler path here productdir = Reg.get_value(key, "installdir") except KeyError: try: # All-user installs on a 64-bit system register here key = VC_BASE % ('Wow6432Node\\', version) productdir = Reg.get_value(key, "installdir") except KeyError: productdir = None if productdir: vcvarsall = os.path.os.path.join(productdir, "vcvarsall.bat") if os.path.isfile(vcvarsall): return vcvarsall return get_unpatched(msvc9_find_vcvarsall)(version)
[ "def", "msvc9_find_vcvarsall", "(", "version", ")", ":", "VC_BASE", "=", "r'Software\\%sMicrosoft\\DevDiv\\VCForPython\\%0.1f'", "key", "=", "VC_BASE", "%", "(", "''", ",", "version", ")", "try", ":", "# Per-user installs register the compiler path here", "productdir", "=", "Reg", ".", "get_value", "(", "key", ",", "\"installdir\"", ")", "except", "KeyError", ":", "try", ":", "# All-user installs on a 64-bit system register here", "key", "=", "VC_BASE", "%", "(", "'Wow6432Node\\\\'", ",", "version", ")", "productdir", "=", "Reg", ".", "get_value", "(", "key", ",", "\"installdir\"", ")", "except", "KeyError", ":", "productdir", "=", "None", "if", "productdir", ":", "vcvarsall", "=", "os", ".", "path", ".", "os", ".", "path", ".", "join", "(", "productdir", ",", "\"vcvarsall.bat\"", ")", "if", "os", ".", "path", ".", "isfile", "(", "vcvarsall", ")", ":", "return", "vcvarsall", "return", "get_unpatched", "(", "msvc9_find_vcvarsall", ")", "(", "version", ")" ]
[ 62, 0 ]
[ 102, 55 ]
python
en
['en', 'error', 'th']
False
msvc9_query_vcvarsall
(ver, arch='x86', *args, **kwargs)
Patched "distutils.msvc9compiler.query_vcvarsall" for support extra compilers. Set environment without use of "vcvarsall.bat". Known supported compilers ------------------------- Microsoft Visual C++ 9.0: Microsoft Visual C++ Compiler for Python 2.7 (x86, amd64) Microsoft Windows SDK 6.1 (x86, x64, ia64) Microsoft Windows SDK 7.0 (x86, x64, ia64) Microsoft Visual C++ 10.0: Microsoft Windows SDK 7.1 (x86, x64, ia64) Parameters ---------- ver: float Required Microsoft Visual C++ version. arch: str Target architecture. Return ------ environment: dict
Patched "distutils.msvc9compiler.query_vcvarsall" for support extra compilers.
def msvc9_query_vcvarsall(ver, arch='x86', *args, **kwargs): """ Patched "distutils.msvc9compiler.query_vcvarsall" for support extra compilers. Set environment without use of "vcvarsall.bat". Known supported compilers ------------------------- Microsoft Visual C++ 9.0: Microsoft Visual C++ Compiler for Python 2.7 (x86, amd64) Microsoft Windows SDK 6.1 (x86, x64, ia64) Microsoft Windows SDK 7.0 (x86, x64, ia64) Microsoft Visual C++ 10.0: Microsoft Windows SDK 7.1 (x86, x64, ia64) Parameters ---------- ver: float Required Microsoft Visual C++ version. arch: str Target architecture. Return ------ environment: dict """ # Try to get environement from vcvarsall.bat (Classical way) try: orig = get_unpatched(msvc9_query_vcvarsall) return orig(ver, arch, *args, **kwargs) except distutils.errors.DistutilsPlatformError: # Pass error if Vcvarsall.bat is missing pass except ValueError: # Pass error if environment not set after executing vcvarsall.bat pass # If error, try to set environment directly try: return EnvironmentInfo(arch, ver).return_env() except distutils.errors.DistutilsPlatformError as exc: _augment_exception(exc, ver, arch) raise
[ "def", "msvc9_query_vcvarsall", "(", "ver", ",", "arch", "=", "'x86'", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "# Try to get environement from vcvarsall.bat (Classical way)", "try", ":", "orig", "=", "get_unpatched", "(", "msvc9_query_vcvarsall", ")", "return", "orig", "(", "ver", ",", "arch", ",", "*", "args", ",", "*", "*", "kwargs", ")", "except", "distutils", ".", "errors", ".", "DistutilsPlatformError", ":", "# Pass error if Vcvarsall.bat is missing", "pass", "except", "ValueError", ":", "# Pass error if environment not set after executing vcvarsall.bat", "pass", "# If error, try to set environment directly", "try", ":", "return", "EnvironmentInfo", "(", "arch", ",", "ver", ")", ".", "return_env", "(", ")", "except", "distutils", ".", "errors", ".", "DistutilsPlatformError", "as", "exc", ":", "_augment_exception", "(", "exc", ",", "ver", ",", "arch", ")", "raise" ]
[ 105, 0 ]
[ 149, 13 ]
python
en
['en', 'error', 'th']
False
msvc14_get_vc_env
(plat_spec)
Patched "distutils._msvccompiler._get_vc_env" for support extra compilers. Set environment without use of "vcvarsall.bat". Known supported compilers ------------------------- Microsoft Visual C++ 14.0: Microsoft Visual C++ Build Tools 2015 (x86, x64, arm) Microsoft Visual Studio 2017 (x86, x64, arm, arm64) Microsoft Visual Studio Build Tools 2017 (x86, x64, arm, arm64) Parameters ---------- plat_spec: str Target architecture. Return ------ environment: dict
Patched "distutils._msvccompiler._get_vc_env" for support extra compilers.
def msvc14_get_vc_env(plat_spec): """ Patched "distutils._msvccompiler._get_vc_env" for support extra compilers. Set environment without use of "vcvarsall.bat". Known supported compilers ------------------------- Microsoft Visual C++ 14.0: Microsoft Visual C++ Build Tools 2015 (x86, x64, arm) Microsoft Visual Studio 2017 (x86, x64, arm, arm64) Microsoft Visual Studio Build Tools 2017 (x86, x64, arm, arm64) Parameters ---------- plat_spec: str Target architecture. Return ------ environment: dict """ # Try to get environment from vcvarsall.bat (Classical way) try: return get_unpatched(msvc14_get_vc_env)(plat_spec) except distutils.errors.DistutilsPlatformError: # Pass error Vcvarsall.bat is missing pass # If error, try to set environment directly try: return EnvironmentInfo(plat_spec, vc_min_ver=14.0).return_env() except distutils.errors.DistutilsPlatformError as exc: _augment_exception(exc, 14.0) raise
[ "def", "msvc14_get_vc_env", "(", "plat_spec", ")", ":", "# Try to get environment from vcvarsall.bat (Classical way)", "try", ":", "return", "get_unpatched", "(", "msvc14_get_vc_env", ")", "(", "plat_spec", ")", "except", "distutils", ".", "errors", ".", "DistutilsPlatformError", ":", "# Pass error Vcvarsall.bat is missing", "pass", "# If error, try to set environment directly", "try", ":", "return", "EnvironmentInfo", "(", "plat_spec", ",", "vc_min_ver", "=", "14.0", ")", ".", "return_env", "(", ")", "except", "distutils", ".", "errors", ".", "DistutilsPlatformError", "as", "exc", ":", "_augment_exception", "(", "exc", ",", "14.0", ")", "raise" ]
[ 152, 0 ]
[ 187, 13 ]
python
en
['en', 'error', 'th']
False
msvc14_gen_lib_options
(*args, **kwargs)
Patched "distutils._msvccompiler.gen_lib_options" for fix compatibility between "numpy.distutils" and "distutils._msvccompiler" (for Numpy < 1.11.2)
Patched "distutils._msvccompiler.gen_lib_options" for fix compatibility between "numpy.distutils" and "distutils._msvccompiler" (for Numpy < 1.11.2)
def msvc14_gen_lib_options(*args, **kwargs): """ Patched "distutils._msvccompiler.gen_lib_options" for fix compatibility between "numpy.distutils" and "distutils._msvccompiler" (for Numpy < 1.11.2) """ if "numpy.distutils" in sys.modules: import numpy as np if LegacyVersion(np.__version__) < LegacyVersion('1.11.2'): return np.distutils.ccompiler.gen_lib_options(*args, **kwargs) return get_unpatched(msvc14_gen_lib_options)(*args, **kwargs)
[ "def", "msvc14_gen_lib_options", "(", "*", "args", ",", "*", "*", "kwargs", ")", ":", "if", "\"numpy.distutils\"", "in", "sys", ".", "modules", ":", "import", "numpy", "as", "np", "if", "LegacyVersion", "(", "np", ".", "__version__", ")", "<", "LegacyVersion", "(", "'1.11.2'", ")", ":", "return", "np", ".", "distutils", ".", "ccompiler", ".", "gen_lib_options", "(", "*", "args", ",", "*", "*", "kwargs", ")", "return", "get_unpatched", "(", "msvc14_gen_lib_options", ")", "(", "*", "args", ",", "*", "*", "kwargs", ")" ]
[ 190, 0 ]
[ 200, 65 ]
python
en
['en', 'error', 'th']
False
_augment_exception
(exc, version, arch='')
Add details to the exception message to help guide the user as to what action will resolve it.
Add details to the exception message to help guide the user as to what action will resolve it.
def _augment_exception(exc, version, arch=''): """ Add details to the exception message to help guide the user as to what action will resolve it. """ # Error if MSVC++ directory not found or environment not set message = exc.args[0] if "vcvarsall" in message.lower() or "visual c" in message.lower(): # Special error message if MSVC++ not installed tmpl = 'Microsoft Visual C++ {version:0.1f} is required.' message = tmpl.format(**locals()) msdownload = 'www.microsoft.com/download/details.aspx?id=%d' if version == 9.0: if arch.lower().find('ia64') > -1: # For VC++ 9.0, if IA64 support is needed, redirect user # to Windows SDK 7.0 message += ' Get it with "Microsoft Windows SDK 7.0": ' message += msdownload % 3138 else: # For VC++ 9.0 redirect user to Vc++ for Python 2.7 : # This redirection link is maintained by Microsoft. # Contact [email protected] if it needs updating. message += ' Get it from http://aka.ms/vcpython27' elif version == 10.0: # For VC++ 10.0 Redirect user to Windows SDK 7.1 message += ' Get it with "Microsoft Windows SDK 7.1": ' message += msdownload % 8279 elif version >= 14.0: # For VC++ 14.0 Redirect user to Visual C++ Build Tools message += (' Get it with "Microsoft Visual C++ Build Tools": ' r'http://landinghub.visualstudio.com/' 'visual-cpp-build-tools') exc.args = (message, )
[ "def", "_augment_exception", "(", "exc", ",", "version", ",", "arch", "=", "''", ")", ":", "# Error if MSVC++ directory not found or environment not set", "message", "=", "exc", ".", "args", "[", "0", "]", "if", "\"vcvarsall\"", "in", "message", ".", "lower", "(", ")", "or", "\"visual c\"", "in", "message", ".", "lower", "(", ")", ":", "# Special error message if MSVC++ not installed", "tmpl", "=", "'Microsoft Visual C++ {version:0.1f} is required.'", "message", "=", "tmpl", ".", "format", "(", "*", "*", "locals", "(", ")", ")", "msdownload", "=", "'www.microsoft.com/download/details.aspx?id=%d'", "if", "version", "==", "9.0", ":", "if", "arch", ".", "lower", "(", ")", ".", "find", "(", "'ia64'", ")", ">", "-", "1", ":", "# For VC++ 9.0, if IA64 support is needed, redirect user", "# to Windows SDK 7.0", "message", "+=", "' Get it with \"Microsoft Windows SDK 7.0\": '", "message", "+=", "msdownload", "%", "3138", "else", ":", "# For VC++ 9.0 redirect user to Vc++ for Python 2.7 :", "# This redirection link is maintained by Microsoft.", "# Contact [email protected] if it needs updating.", "message", "+=", "' Get it from http://aka.ms/vcpython27'", "elif", "version", "==", "10.0", ":", "# For VC++ 10.0 Redirect user to Windows SDK 7.1", "message", "+=", "' Get it with \"Microsoft Windows SDK 7.1\": '", "message", "+=", "msdownload", "%", "8279", "elif", "version", ">=", "14.0", ":", "# For VC++ 14.0 Redirect user to Visual C++ Build Tools", "message", "+=", "(", "' Get it with \"Microsoft Visual C++ Build Tools\": '", "r'http://landinghub.visualstudio.com/'", "'visual-cpp-build-tools'", ")", "exc", ".", "args", "=", "(", "message", ",", ")" ]
[ 203, 0 ]
[ 237, 26 ]
python
en
['en', 'error', 'th']
False
PlatformInfo.current_dir
(self, hidex86=False, x64=False)
Current platform specific subfolder. Parameters ---------- hidex86: bool return '' and not '\x86' if architecture is x86. x64: bool return '\x64' and not '\amd64' if architecture is amd64. Return ------ subfolder: str '\target', or '' (see hidex86 parameter)
Current platform specific subfolder.
def current_dir(self, hidex86=False, x64=False): """ Current platform specific subfolder. Parameters ---------- hidex86: bool return '' and not '\x86' if architecture is x86. x64: bool return '\x64' and not '\amd64' if architecture is amd64. Return ------ subfolder: str '\target', or '' (see hidex86 parameter) """ return ( '' if (self.current_cpu == 'x86' and hidex86) else r'\x64' if (self.current_cpu == 'amd64' and x64) else r'\%s' % self.current_cpu )
[ "def", "current_dir", "(", "self", ",", "hidex86", "=", "False", ",", "x64", "=", "False", ")", ":", "return", "(", "''", "if", "(", "self", ".", "current_cpu", "==", "'x86'", "and", "hidex86", ")", "else", "r'\\x64'", "if", "(", "self", ".", "current_cpu", "==", "'amd64'", "and", "x64", ")", "else", "r'\\%s'", "%", "self", ".", "current_cpu", ")" ]
[ 264, 4 ]
[ 284, 9 ]
python
en
['en', 'error', 'th']
False
PlatformInfo.target_dir
(self, hidex86=False, x64=False)
r""" Target platform specific subfolder. Parameters ---------- hidex86: bool return '' and not '\x86' if architecture is x86. x64: bool return '\x64' and not '\amd64' if architecture is amd64. Return ------ subfolder: str '\current', or '' (see hidex86 parameter)
r""" Target platform specific subfolder.
def target_dir(self, hidex86=False, x64=False): r""" Target platform specific subfolder. Parameters ---------- hidex86: bool return '' and not '\x86' if architecture is x86. x64: bool return '\x64' and not '\amd64' if architecture is amd64. Return ------ subfolder: str '\current', or '' (see hidex86 parameter) """ return ( '' if (self.target_cpu == 'x86' and hidex86) else r'\x64' if (self.target_cpu == 'amd64' and x64) else r'\%s' % self.target_cpu )
[ "def", "target_dir", "(", "self", ",", "hidex86", "=", "False", ",", "x64", "=", "False", ")", ":", "return", "(", "''", "if", "(", "self", ".", "target_cpu", "==", "'x86'", "and", "hidex86", ")", "else", "r'\\x64'", "if", "(", "self", ".", "target_cpu", "==", "'amd64'", "and", "x64", ")", "else", "r'\\%s'", "%", "self", ".", "target_cpu", ")" ]
[ 286, 4 ]
[ 306, 9 ]
python
cy
['en', 'cy', 'hi']
False
PlatformInfo.cross_dir
(self, forcex86=False)
r""" Cross platform specific subfolder. Parameters ---------- forcex86: bool Use 'x86' as current architecture even if current acritecture is not x86. Return ------ subfolder: str '' if target architecture is current architecture, '\current_target' if not.
r""" Cross platform specific subfolder.
def cross_dir(self, forcex86=False): r""" Cross platform specific subfolder. Parameters ---------- forcex86: bool Use 'x86' as current architecture even if current acritecture is not x86. Return ------ subfolder: str '' if target architecture is current architecture, '\current_target' if not. """ current = 'x86' if forcex86 else self.current_cpu return ( '' if self.target_cpu == current else self.target_dir().replace('\\', '\\%s_' % current) )
[ "def", "cross_dir", "(", "self", ",", "forcex86", "=", "False", ")", ":", "current", "=", "'x86'", "if", "forcex86", "else", "self", ".", "current_cpu", "return", "(", "''", "if", "self", ".", "target_cpu", "==", "current", "else", "self", ".", "target_dir", "(", ")", ".", "replace", "(", "'\\\\'", ",", "'\\\\%s_'", "%", "current", ")", ")" ]
[ 308, 4 ]
[ 328, 9 ]
python
cy
['en', 'cy', 'hi']
False
RegistryInfo.visualstudio
(self)
Microsoft Visual Studio root registry key.
Microsoft Visual Studio root registry key.
def visualstudio(self): """ Microsoft Visual Studio root registry key. """ return 'VisualStudio'
[ "def", "visualstudio", "(", "self", ")", ":", "return", "'VisualStudio'" ]
[ 349, 4 ]
[ 353, 29 ]
python
en
['en', 'error', 'th']
False
RegistryInfo.sxs
(self)
Microsoft Visual Studio SxS registry key.
Microsoft Visual Studio SxS registry key.
def sxs(self): """ Microsoft Visual Studio SxS registry key. """ return os.path.join(self.visualstudio, 'SxS')
[ "def", "sxs", "(", "self", ")", ":", "return", "os", ".", "path", ".", "join", "(", "self", ".", "visualstudio", ",", "'SxS'", ")" ]
[ 356, 4 ]
[ 360, 53 ]
python
en
['en', 'error', 'th']
False
RegistryInfo.vc
(self)
Microsoft Visual C++ VC7 registry key.
Microsoft Visual C++ VC7 registry key.
def vc(self): """ Microsoft Visual C++ VC7 registry key. """ return os.path.join(self.sxs, 'VC7')
[ "def", "vc", "(", "self", ")", ":", "return", "os", ".", "path", ".", "join", "(", "self", ".", "sxs", ",", "'VC7'", ")" ]
[ 363, 4 ]
[ 367, 44 ]
python
en
['en', 'error', 'th']
False
RegistryInfo.vs
(self)
Microsoft Visual Studio VS7 registry key.
Microsoft Visual Studio VS7 registry key.
def vs(self): """ Microsoft Visual Studio VS7 registry key. """ return os.path.join(self.sxs, 'VS7')
[ "def", "vs", "(", "self", ")", ":", "return", "os", ".", "path", ".", "join", "(", "self", ".", "sxs", ",", "'VS7'", ")" ]
[ 370, 4 ]
[ 374, 44 ]
python
en
['en', 'error', 'th']
False
RegistryInfo.vc_for_python
(self)
Microsoft Visual C++ for Python registry key.
Microsoft Visual C++ for Python registry key.
def vc_for_python(self): """ Microsoft Visual C++ for Python registry key. """ return r'DevDiv\VCForPython'
[ "def", "vc_for_python", "(", "self", ")", ":", "return", "r'DevDiv\\VCForPython'" ]
[ 377, 4 ]
[ 381, 36 ]
python
en
['en', 'error', 'th']
False
RegistryInfo.microsoft_sdk
(self)
Microsoft SDK registry key.
Microsoft SDK registry key.
def microsoft_sdk(self): """ Microsoft SDK registry key. """ return 'Microsoft SDKs'
[ "def", "microsoft_sdk", "(", "self", ")", ":", "return", "'Microsoft SDKs'" ]
[ 384, 4 ]
[ 388, 31 ]
python
en
['en', 'error', 'th']
False
RegistryInfo.windows_sdk
(self)
Microsoft Windows/Platform SDK registry key.
Microsoft Windows/Platform SDK registry key.
def windows_sdk(self): """ Microsoft Windows/Platform SDK registry key. """ return os.path.join(self.microsoft_sdk, 'Windows')
[ "def", "windows_sdk", "(", "self", ")", ":", "return", "os", ".", "path", ".", "join", "(", "self", ".", "microsoft_sdk", ",", "'Windows'", ")" ]
[ 391, 4 ]
[ 395, 58 ]
python
en
['en', 'error', 'th']
False
RegistryInfo.netfx_sdk
(self)
Microsoft .NET Framework SDK registry key.
Microsoft .NET Framework SDK registry key.
def netfx_sdk(self): """ Microsoft .NET Framework SDK registry key. """ return os.path.join(self.microsoft_sdk, 'NETFXSDK')
[ "def", "netfx_sdk", "(", "self", ")", ":", "return", "os", ".", "path", ".", "join", "(", "self", ".", "microsoft_sdk", ",", "'NETFXSDK'", ")" ]
[ 398, 4 ]
[ 402, 59 ]
python
en
['en', 'error', 'th']
False
RegistryInfo.windows_kits_roots
(self)
Microsoft Windows Kits Roots registry key.
Microsoft Windows Kits Roots registry key.
def windows_kits_roots(self): """ Microsoft Windows Kits Roots registry key. """ return r'Windows Kits\Installed Roots'
[ "def", "windows_kits_roots", "(", "self", ")", ":", "return", "r'Windows Kits\\Installed Roots'" ]
[ 405, 4 ]
[ 409, 46 ]
python
en
['en', 'error', 'th']
False
RegistryInfo.microsoft
(self, key, x86=False)
Return key in Microsoft software registry. Parameters ---------- key: str Registry key path where look. x86: str Force x86 software registry. Return ------ str: value
Return key in Microsoft software registry.
def microsoft(self, key, x86=False): """ Return key in Microsoft software registry. Parameters ---------- key: str Registry key path where look. x86: str Force x86 software registry. Return ------ str: value """ node64 = '' if self.pi.current_is_x86() or x86 else 'Wow6432Node' return os.path.join('Software', node64, 'Microsoft', key)
[ "def", "microsoft", "(", "self", ",", "key", ",", "x86", "=", "False", ")", ":", "node64", "=", "''", "if", "self", ".", "pi", ".", "current_is_x86", "(", ")", "or", "x86", "else", "'Wow6432Node'", "return", "os", ".", "path", ".", "join", "(", "'Software'", ",", "node64", ",", "'Microsoft'", ",", "key", ")" ]
[ 411, 4 ]
[ 427, 65 ]
python
en
['en', 'error', 'th']
False
RegistryInfo.lookup
(self, key, name)
Look for values in registry in Microsoft software registry. Parameters ---------- key: str Registry key path where look. name: str Value name to find. Return ------ str: value
Look for values in registry in Microsoft software registry.
def lookup(self, key, name): """ Look for values in registry in Microsoft software registry. Parameters ---------- key: str Registry key path where look. name: str Value name to find. Return ------ str: value """ KEY_READ = winreg.KEY_READ openkey = winreg.OpenKey ms = self.microsoft for hkey in self.HKEYS: try: bkey = openkey(hkey, ms(key), 0, KEY_READ) except (OSError, IOError): if not self.pi.current_is_x86(): try: bkey = openkey(hkey, ms(key, True), 0, KEY_READ) except (OSError, IOError): continue else: continue try: return winreg.QueryValueEx(bkey, name)[0] except (OSError, IOError): pass
[ "def", "lookup", "(", "self", ",", "key", ",", "name", ")", ":", "KEY_READ", "=", "winreg", ".", "KEY_READ", "openkey", "=", "winreg", ".", "OpenKey", "ms", "=", "self", ".", "microsoft", "for", "hkey", "in", "self", ".", "HKEYS", ":", "try", ":", "bkey", "=", "openkey", "(", "hkey", ",", "ms", "(", "key", ")", ",", "0", ",", "KEY_READ", ")", "except", "(", "OSError", ",", "IOError", ")", ":", "if", "not", "self", ".", "pi", ".", "current_is_x86", "(", ")", ":", "try", ":", "bkey", "=", "openkey", "(", "hkey", ",", "ms", "(", "key", ",", "True", ")", ",", "0", ",", "KEY_READ", ")", "except", "(", "OSError", ",", "IOError", ")", ":", "continue", "else", ":", "continue", "try", ":", "return", "winreg", ".", "QueryValueEx", "(", "bkey", ",", "name", ")", "[", "0", "]", "except", "(", "OSError", ",", "IOError", ")", ":", "pass" ]
[ 429, 4 ]
[ 461, 20 ]
python
en
['en', 'error', 'th']
False
SystemInfo.find_available_vc_vers
(self)
Find all available Microsoft Visual C++ versions.
Find all available Microsoft Visual C++ versions.
def find_available_vc_vers(self): """ Find all available Microsoft Visual C++ versions. """ ms = self.ri.microsoft vckeys = (self.ri.vc, self.ri.vc_for_python, self.ri.vs) vc_vers = [] for hkey in self.ri.HKEYS: for key in vckeys: try: bkey = winreg.OpenKey(hkey, ms(key), 0, winreg.KEY_READ) except (OSError, IOError): continue subkeys, values, _ = winreg.QueryInfoKey(bkey) for i in range(values): try: ver = float(winreg.EnumValue(bkey, i)[0]) if ver not in vc_vers: vc_vers.append(ver) except ValueError: pass for i in range(subkeys): try: ver = float(winreg.EnumKey(bkey, i)) if ver not in vc_vers: vc_vers.append(ver) except ValueError: pass return sorted(vc_vers)
[ "def", "find_available_vc_vers", "(", "self", ")", ":", "ms", "=", "self", ".", "ri", ".", "microsoft", "vckeys", "=", "(", "self", ".", "ri", ".", "vc", ",", "self", ".", "ri", ".", "vc_for_python", ",", "self", ".", "ri", ".", "vs", ")", "vc_vers", "=", "[", "]", "for", "hkey", "in", "self", ".", "ri", ".", "HKEYS", ":", "for", "key", "in", "vckeys", ":", "try", ":", "bkey", "=", "winreg", ".", "OpenKey", "(", "hkey", ",", "ms", "(", "key", ")", ",", "0", ",", "winreg", ".", "KEY_READ", ")", "except", "(", "OSError", ",", "IOError", ")", ":", "continue", "subkeys", ",", "values", ",", "_", "=", "winreg", ".", "QueryInfoKey", "(", "bkey", ")", "for", "i", "in", "range", "(", "values", ")", ":", "try", ":", "ver", "=", "float", "(", "winreg", ".", "EnumValue", "(", "bkey", ",", "i", ")", "[", "0", "]", ")", "if", "ver", "not", "in", "vc_vers", ":", "vc_vers", ".", "append", "(", "ver", ")", "except", "ValueError", ":", "pass", "for", "i", "in", "range", "(", "subkeys", ")", ":", "try", ":", "ver", "=", "float", "(", "winreg", ".", "EnumKey", "(", "bkey", ",", "i", ")", ")", "if", "ver", "not", "in", "vc_vers", ":", "vc_vers", ".", "append", "(", "ver", ")", "except", "ValueError", ":", "pass", "return", "sorted", "(", "vc_vers", ")" ]
[ 494, 4 ]
[ 522, 30 ]
python
en
['en', 'error', 'th']
False
SystemInfo.VSInstallDir
(self)
Microsoft Visual Studio directory.
Microsoft Visual Studio directory.
def VSInstallDir(self): """ Microsoft Visual Studio directory. """ # Default path name = 'Microsoft Visual Studio %0.1f' % self.vc_ver default = os.path.join(self.ProgramFilesx86, name) # Try to get path from registry, if fail use default path return self.ri.lookup(self.ri.vs, '%0.1f' % self.vc_ver) or default
[ "def", "VSInstallDir", "(", "self", ")", ":", "# Default path", "name", "=", "'Microsoft Visual Studio %0.1f'", "%", "self", ".", "vc_ver", "default", "=", "os", ".", "path", ".", "join", "(", "self", ".", "ProgramFilesx86", ",", "name", ")", "# Try to get path from registry, if fail use default path", "return", "self", ".", "ri", ".", "lookup", "(", "self", ".", "ri", ".", "vs", ",", "'%0.1f'", "%", "self", ".", "vc_ver", ")", "or", "default" ]
[ 525, 4 ]
[ 534, 75 ]
python
en
['en', 'error', 'th']
False
SystemInfo.VCInstallDir
(self)
Microsoft Visual C++ directory.
Microsoft Visual C++ directory.
def VCInstallDir(self): """ Microsoft Visual C++ directory. """ self.VSInstallDir guess_vc = self._guess_vc() or self._guess_vc_legacy() # Try to get "VC++ for Python" path from registry as default path reg_path = os.path.join(self.ri.vc_for_python, '%0.1f' % self.vc_ver) python_vc = self.ri.lookup(reg_path, 'installdir') default_vc = os.path.join(python_vc, 'VC') if python_vc else guess_vc # Try to get path from registry, if fail use default path path = self.ri.lookup(self.ri.vc, '%0.1f' % self.vc_ver) or default_vc if not os.path.isdir(path): msg = 'Microsoft Visual C++ directory not found' raise distutils.errors.DistutilsPlatformError(msg) return path
[ "def", "VCInstallDir", "(", "self", ")", ":", "self", ".", "VSInstallDir", "guess_vc", "=", "self", ".", "_guess_vc", "(", ")", "or", "self", ".", "_guess_vc_legacy", "(", ")", "# Try to get \"VC++ for Python\" path from registry as default path", "reg_path", "=", "os", ".", "path", ".", "join", "(", "self", ".", "ri", ".", "vc_for_python", ",", "'%0.1f'", "%", "self", ".", "vc_ver", ")", "python_vc", "=", "self", ".", "ri", ".", "lookup", "(", "reg_path", ",", "'installdir'", ")", "default_vc", "=", "os", ".", "path", ".", "join", "(", "python_vc", ",", "'VC'", ")", "if", "python_vc", "else", "guess_vc", "# Try to get path from registry, if fail use default path", "path", "=", "self", ".", "ri", ".", "lookup", "(", "self", ".", "ri", ".", "vc", ",", "'%0.1f'", "%", "self", ".", "vc_ver", ")", "or", "default_vc", "if", "not", "os", ".", "path", ".", "isdir", "(", "path", ")", ":", "msg", "=", "'Microsoft Visual C++ directory not found'", "raise", "distutils", ".", "errors", ".", "DistutilsPlatformError", "(", "msg", ")", "return", "path" ]
[ 537, 4 ]
[ 557, 19 ]
python
en
['en', 'error', 'th']
False
SystemInfo._guess_vc
(self)
Locate Visual C for 2017
Locate Visual C for 2017
def _guess_vc(self): """ Locate Visual C for 2017 """ if self.vc_ver <= 14.0: return default = r'VC\Tools\MSVC' guess_vc = os.path.join(self.VSInstallDir, default) # Subdir with VC exact version as name try: vc_exact_ver = os.listdir(guess_vc)[-1] return os.path.join(guess_vc, vc_exact_ver) except (OSError, IOError, IndexError): pass
[ "def", "_guess_vc", "(", "self", ")", ":", "if", "self", ".", "vc_ver", "<=", "14.0", ":", "return", "default", "=", "r'VC\\Tools\\MSVC'", "guess_vc", "=", "os", ".", "path", ".", "join", "(", "self", ".", "VSInstallDir", ",", "default", ")", "# Subdir with VC exact version as name", "try", ":", "vc_exact_ver", "=", "os", ".", "listdir", "(", "guess_vc", ")", "[", "-", "1", "]", "return", "os", ".", "path", ".", "join", "(", "guess_vc", ",", "vc_exact_ver", ")", "except", "(", "OSError", ",", "IOError", ",", "IndexError", ")", ":", "pass" ]
[ 559, 4 ]
[ 573, 16 ]
python
en
['en', 'error', 'th']
False
SystemInfo._guess_vc_legacy
(self)
Locate Visual C for versions prior to 2017
Locate Visual C for versions prior to 2017
def _guess_vc_legacy(self): """ Locate Visual C for versions prior to 2017 """ default = r'Microsoft Visual Studio %0.1f\VC' % self.vc_ver return os.path.join(self.ProgramFilesx86, default)
[ "def", "_guess_vc_legacy", "(", "self", ")", ":", "default", "=", "r'Microsoft Visual Studio %0.1f\\VC'", "%", "self", ".", "vc_ver", "return", "os", ".", "path", ".", "join", "(", "self", ".", "ProgramFilesx86", ",", "default", ")" ]
[ 575, 4 ]
[ 580, 58 ]
python
en
['en', 'error', 'th']
False
SystemInfo.WindowsSdkVersion
(self)
Microsoft Windows SDK versions for specified MSVC++ version.
Microsoft Windows SDK versions for specified MSVC++ version.
def WindowsSdkVersion(self): """ Microsoft Windows SDK versions for specified MSVC++ version. """ if self.vc_ver <= 9.0: return ('7.0', '6.1', '6.0a') elif self.vc_ver == 10.0: return ('7.1', '7.0a') elif self.vc_ver == 11.0: return ('8.0', '8.0a') elif self.vc_ver == 12.0: return ('8.1', '8.1a') elif self.vc_ver >= 14.0: return ('10.0', '8.1')
[ "def", "WindowsSdkVersion", "(", "self", ")", ":", "if", "self", ".", "vc_ver", "<=", "9.0", ":", "return", "(", "'7.0'", ",", "'6.1'", ",", "'6.0a'", ")", "elif", "self", ".", "vc_ver", "==", "10.0", ":", "return", "(", "'7.1'", ",", "'7.0a'", ")", "elif", "self", ".", "vc_ver", "==", "11.0", ":", "return", "(", "'8.0'", ",", "'8.0a'", ")", "elif", "self", ".", "vc_ver", "==", "12.0", ":", "return", "(", "'8.1'", ",", "'8.1a'", ")", "elif", "self", ".", "vc_ver", ">=", "14.0", ":", "return", "(", "'10.0'", ",", "'8.1'", ")" ]
[ 583, 4 ]
[ 596, 34 ]
python
en
['en', 'error', 'th']
False
SystemInfo.WindowsSdkLastVersion
(self)
Microsoft Windows SDK last version
Microsoft Windows SDK last version
def WindowsSdkLastVersion(self): """ Microsoft Windows SDK last version """ return self._use_last_dir_name(os.path.join( self.WindowsSdkDir, 'lib'))
[ "def", "WindowsSdkLastVersion", "(", "self", ")", ":", "return", "self", ".", "_use_last_dir_name", "(", "os", ".", "path", ".", "join", "(", "self", ".", "WindowsSdkDir", ",", "'lib'", ")", ")" ]
[ 599, 4 ]
[ 604, 39 ]
python
en
['en', 'error', 'th']
False
SystemInfo.WindowsSdkDir
(self)
Microsoft Windows SDK directory.
Microsoft Windows SDK directory.
def WindowsSdkDir(self): """ Microsoft Windows SDK directory. """ sdkdir = '' for ver in self.WindowsSdkVersion: # Try to get it from registry loc = os.path.join(self.ri.windows_sdk, 'v%s' % ver) sdkdir = self.ri.lookup(loc, 'installationfolder') if sdkdir: break if not sdkdir or not os.path.isdir(sdkdir): # Try to get "VC++ for Python" version from registry path = os.path.join(self.ri.vc_for_python, '%0.1f' % self.vc_ver) install_base = self.ri.lookup(path, 'installdir') if install_base: sdkdir = os.path.join(install_base, 'WinSDK') if not sdkdir or not os.path.isdir(sdkdir): # If fail, use default new path for ver in self.WindowsSdkVersion: intver = ver[:ver.rfind('.')] path = r'Microsoft SDKs\Windows Kits\%s' % (intver) d = os.path.join(self.ProgramFiles, path) if os.path.isdir(d): sdkdir = d if not sdkdir or not os.path.isdir(sdkdir): # If fail, use default old path for ver in self.WindowsSdkVersion: path = r'Microsoft SDKs\Windows\v%s' % ver d = os.path.join(self.ProgramFiles, path) if os.path.isdir(d): sdkdir = d if not sdkdir: # If fail, use Platform SDK sdkdir = os.path.join(self.VCInstallDir, 'PlatformSDK') return sdkdir
[ "def", "WindowsSdkDir", "(", "self", ")", ":", "sdkdir", "=", "''", "for", "ver", "in", "self", ".", "WindowsSdkVersion", ":", "# Try to get it from registry", "loc", "=", "os", ".", "path", ".", "join", "(", "self", ".", "ri", ".", "windows_sdk", ",", "'v%s'", "%", "ver", ")", "sdkdir", "=", "self", ".", "ri", ".", "lookup", "(", "loc", ",", "'installationfolder'", ")", "if", "sdkdir", ":", "break", "if", "not", "sdkdir", "or", "not", "os", ".", "path", ".", "isdir", "(", "sdkdir", ")", ":", "# Try to get \"VC++ for Python\" version from registry", "path", "=", "os", ".", "path", ".", "join", "(", "self", ".", "ri", ".", "vc_for_python", ",", "'%0.1f'", "%", "self", ".", "vc_ver", ")", "install_base", "=", "self", ".", "ri", ".", "lookup", "(", "path", ",", "'installdir'", ")", "if", "install_base", ":", "sdkdir", "=", "os", ".", "path", ".", "join", "(", "install_base", ",", "'WinSDK'", ")", "if", "not", "sdkdir", "or", "not", "os", ".", "path", ".", "isdir", "(", "sdkdir", ")", ":", "# If fail, use default new path", "for", "ver", "in", "self", ".", "WindowsSdkVersion", ":", "intver", "=", "ver", "[", ":", "ver", ".", "rfind", "(", "'.'", ")", "]", "path", "=", "r'Microsoft SDKs\\Windows Kits\\%s'", "%", "(", "intver", ")", "d", "=", "os", ".", "path", ".", "join", "(", "self", ".", "ProgramFiles", ",", "path", ")", "if", "os", ".", "path", ".", "isdir", "(", "d", ")", ":", "sdkdir", "=", "d", "if", "not", "sdkdir", "or", "not", "os", ".", "path", ".", "isdir", "(", "sdkdir", ")", ":", "# If fail, use default old path", "for", "ver", "in", "self", ".", "WindowsSdkVersion", ":", "path", "=", "r'Microsoft SDKs\\Windows\\v%s'", "%", "ver", "d", "=", "os", ".", "path", ".", "join", "(", "self", ".", "ProgramFiles", ",", "path", ")", "if", "os", ".", "path", ".", "isdir", "(", "d", ")", ":", "sdkdir", "=", "d", "if", "not", "sdkdir", ":", "# If fail, use Platform SDK", "sdkdir", "=", "os", ".", "path", ".", "join", "(", "self", ".", "VCInstallDir", ",", "'PlatformSDK'", ")", "return", "sdkdir" ]
[ 607, 4 ]
[ 642, 21 ]
python
en
['en', 'error', 'th']
False
SystemInfo.WindowsSDKExecutablePath
(self)
Microsoft Windows SDK executable directory.
Microsoft Windows SDK executable directory.
def WindowsSDKExecutablePath(self): """ Microsoft Windows SDK executable directory. """ # Find WinSDK NetFx Tools registry dir name if self.vc_ver <= 11.0: netfxver = 35 arch = '' else: netfxver = 40 hidex86 = True if self.vc_ver <= 12.0 else False arch = self.pi.current_dir(x64=True, hidex86=hidex86) fx = 'WinSDK-NetFx%dTools%s' % (netfxver, arch.replace('\\', '-')) # liste all possibles registry paths regpaths = [] if self.vc_ver >= 14.0: for ver in self.NetFxSdkVersion: regpaths += [os.path.join(self.ri.netfx_sdk, ver, fx)] for ver in self.WindowsSdkVersion: regpaths += [os.path.join(self.ri.windows_sdk, 'v%sA' % ver, fx)] # Return installation folder from the more recent path for path in regpaths: execpath = self.ri.lookup(path, 'installationfolder') if execpath: break return execpath
[ "def", "WindowsSDKExecutablePath", "(", "self", ")", ":", "# Find WinSDK NetFx Tools registry dir name", "if", "self", ".", "vc_ver", "<=", "11.0", ":", "netfxver", "=", "35", "arch", "=", "''", "else", ":", "netfxver", "=", "40", "hidex86", "=", "True", "if", "self", ".", "vc_ver", "<=", "12.0", "else", "False", "arch", "=", "self", ".", "pi", ".", "current_dir", "(", "x64", "=", "True", ",", "hidex86", "=", "hidex86", ")", "fx", "=", "'WinSDK-NetFx%dTools%s'", "%", "(", "netfxver", ",", "arch", ".", "replace", "(", "'\\\\'", ",", "'-'", ")", ")", "# liste all possibles registry paths", "regpaths", "=", "[", "]", "if", "self", ".", "vc_ver", ">=", "14.0", ":", "for", "ver", "in", "self", ".", "NetFxSdkVersion", ":", "regpaths", "+=", "[", "os", ".", "path", ".", "join", "(", "self", ".", "ri", ".", "netfx_sdk", ",", "ver", ",", "fx", ")", "]", "for", "ver", "in", "self", ".", "WindowsSdkVersion", ":", "regpaths", "+=", "[", "os", ".", "path", ".", "join", "(", "self", ".", "ri", ".", "windows_sdk", ",", "'v%sA'", "%", "ver", ",", "fx", ")", "]", "# Return installation folder from the more recent path", "for", "path", "in", "regpaths", ":", "execpath", "=", "self", ".", "ri", ".", "lookup", "(", "path", ",", "'installationfolder'", ")", "if", "execpath", ":", "break", "return", "execpath" ]
[ 645, 4 ]
[ 673, 23 ]
python
en
['en', 'error', 'th']
False
SystemInfo.FSharpInstallDir
(self)
Microsoft Visual F# directory.
Microsoft Visual F# directory.
def FSharpInstallDir(self): """ Microsoft Visual F# directory. """ path = r'%0.1f\Setup\F#' % self.vc_ver path = os.path.join(self.ri.visualstudio, path) return self.ri.lookup(path, 'productdir') or ''
[ "def", "FSharpInstallDir", "(", "self", ")", ":", "path", "=", "r'%0.1f\\Setup\\F#'", "%", "self", ".", "vc_ver", "path", "=", "os", ".", "path", ".", "join", "(", "self", ".", "ri", ".", "visualstudio", ",", "path", ")", "return", "self", ".", "ri", ".", "lookup", "(", "path", ",", "'productdir'", ")", "or", "''" ]
[ 676, 4 ]
[ 682, 55 ]
python
en
['en', 'error', 'th']
False
SystemInfo.UniversalCRTSdkDir
(self)
Microsoft Universal CRT SDK directory.
Microsoft Universal CRT SDK directory.
def UniversalCRTSdkDir(self): """ Microsoft Universal CRT SDK directory. """ # Set Kit Roots versions for specified MSVC++ version if self.vc_ver >= 14.0: vers = ('10', '81') else: vers = () # Find path of the more recent Kit for ver in vers: sdkdir = self.ri.lookup(self.ri.windows_kits_roots, 'kitsroot%s' % ver) if sdkdir: break return sdkdir or ''
[ "def", "UniversalCRTSdkDir", "(", "self", ")", ":", "# Set Kit Roots versions for specified MSVC++ version", "if", "self", ".", "vc_ver", ">=", "14.0", ":", "vers", "=", "(", "'10'", ",", "'81'", ")", "else", ":", "vers", "=", "(", ")", "# Find path of the more recent Kit", "for", "ver", "in", "vers", ":", "sdkdir", "=", "self", ".", "ri", ".", "lookup", "(", "self", ".", "ri", ".", "windows_kits_roots", ",", "'kitsroot%s'", "%", "ver", ")", "if", "sdkdir", ":", "break", "return", "sdkdir", "or", "''" ]
[ 685, 4 ]
[ 701, 27 ]
python
en
['en', 'error', 'th']
False
SystemInfo.UniversalCRTSdkLastVersion
(self)
Microsoft Universal C Runtime SDK last version
Microsoft Universal C Runtime SDK last version
def UniversalCRTSdkLastVersion(self): """ Microsoft Universal C Runtime SDK last version """ return self._use_last_dir_name(os.path.join( self.UniversalCRTSdkDir, 'lib'))
[ "def", "UniversalCRTSdkLastVersion", "(", "self", ")", ":", "return", "self", ".", "_use_last_dir_name", "(", "os", ".", "path", ".", "join", "(", "self", ".", "UniversalCRTSdkDir", ",", "'lib'", ")", ")" ]
[ 704, 4 ]
[ 709, 44 ]
python
en
['en', 'error', 'th']
False
SystemInfo.NetFxSdkVersion
(self)
Microsoft .NET Framework SDK versions.
Microsoft .NET Framework SDK versions.
def NetFxSdkVersion(self): """ Microsoft .NET Framework SDK versions. """ # Set FxSdk versions for specified MSVC++ version if self.vc_ver >= 14.0: return ('4.6.1', '4.6') else: return ()
[ "def", "NetFxSdkVersion", "(", "self", ")", ":", "# Set FxSdk versions for specified MSVC++ version", "if", "self", ".", "vc_ver", ">=", "14.0", ":", "return", "(", "'4.6.1'", ",", "'4.6'", ")", "else", ":", "return", "(", ")" ]
[ 712, 4 ]
[ 720, 21 ]
python
en
['en', 'error', 'th']
False
SystemInfo.NetFxSdkDir
(self)
Microsoft .NET Framework SDK directory.
Microsoft .NET Framework SDK directory.
def NetFxSdkDir(self): """ Microsoft .NET Framework SDK directory. """ for ver in self.NetFxSdkVersion: loc = os.path.join(self.ri.netfx_sdk, ver) sdkdir = self.ri.lookup(loc, 'kitsinstallationfolder') if sdkdir: break return sdkdir or ''
[ "def", "NetFxSdkDir", "(", "self", ")", ":", "for", "ver", "in", "self", ".", "NetFxSdkVersion", ":", "loc", "=", "os", ".", "path", ".", "join", "(", "self", ".", "ri", ".", "netfx_sdk", ",", "ver", ")", "sdkdir", "=", "self", ".", "ri", ".", "lookup", "(", "loc", ",", "'kitsinstallationfolder'", ")", "if", "sdkdir", ":", "break", "return", "sdkdir", "or", "''" ]
[ 723, 4 ]
[ 732, 27 ]
python
en
['en', 'error', 'th']
False
SystemInfo.FrameworkDir32
(self)
Microsoft .NET Framework 32bit directory.
Microsoft .NET Framework 32bit directory.
def FrameworkDir32(self): """ Microsoft .NET Framework 32bit directory. """ # Default path guess_fw = os.path.join(self.WinDir, r'Microsoft.NET\Framework') # Try to get path from registry, if fail use default path return self.ri.lookup(self.ri.vc, 'frameworkdir32') or guess_fw
[ "def", "FrameworkDir32", "(", "self", ")", ":", "# Default path", "guess_fw", "=", "os", ".", "path", ".", "join", "(", "self", ".", "WinDir", ",", "r'Microsoft.NET\\Framework'", ")", "# Try to get path from registry, if fail use default path", "return", "self", ".", "ri", ".", "lookup", "(", "self", ".", "ri", ".", "vc", ",", "'frameworkdir32'", ")", "or", "guess_fw" ]
[ 735, 4 ]
[ 743, 71 ]
python
en
['en', 'error', 'th']
False
SystemInfo.FrameworkDir64
(self)
Microsoft .NET Framework 64bit directory.
Microsoft .NET Framework 64bit directory.
def FrameworkDir64(self): """ Microsoft .NET Framework 64bit directory. """ # Default path guess_fw = os.path.join(self.WinDir, r'Microsoft.NET\Framework64') # Try to get path from registry, if fail use default path return self.ri.lookup(self.ri.vc, 'frameworkdir64') or guess_fw
[ "def", "FrameworkDir64", "(", "self", ")", ":", "# Default path", "guess_fw", "=", "os", ".", "path", ".", "join", "(", "self", ".", "WinDir", ",", "r'Microsoft.NET\\Framework64'", ")", "# Try to get path from registry, if fail use default path", "return", "self", ".", "ri", ".", "lookup", "(", "self", ".", "ri", ".", "vc", ",", "'frameworkdir64'", ")", "or", "guess_fw" ]
[ 746, 4 ]
[ 754, 71 ]
python
en
['en', 'error', 'th']
False
SystemInfo.FrameworkVersion32
(self)
Microsoft .NET Framework 32bit versions.
Microsoft .NET Framework 32bit versions.
def FrameworkVersion32(self): """ Microsoft .NET Framework 32bit versions. """ return self._find_dot_net_versions(32)
[ "def", "FrameworkVersion32", "(", "self", ")", ":", "return", "self", ".", "_find_dot_net_versions", "(", "32", ")" ]
[ 757, 4 ]
[ 761, 46 ]
python
en
['en', 'error', 'th']
False
SystemInfo.FrameworkVersion64
(self)
Microsoft .NET Framework 64bit versions.
Microsoft .NET Framework 64bit versions.
def FrameworkVersion64(self): """ Microsoft .NET Framework 64bit versions. """ return self._find_dot_net_versions(64)
[ "def", "FrameworkVersion64", "(", "self", ")", ":", "return", "self", ".", "_find_dot_net_versions", "(", "64", ")" ]
[ 764, 4 ]
[ 768, 46 ]
python
en
['en', 'error', 'th']
False
SystemInfo._find_dot_net_versions
(self, bits)
Find Microsoft .NET Framework versions. Parameters ---------- bits: int Platform number of bits: 32 or 64.
Find Microsoft .NET Framework versions.
def _find_dot_net_versions(self, bits): """ Find Microsoft .NET Framework versions. Parameters ---------- bits: int Platform number of bits: 32 or 64. """ # Find actual .NET version in registry reg_ver = self.ri.lookup(self.ri.vc, 'frameworkver%d' % bits) dot_net_dir = getattr(self, 'FrameworkDir%d' % bits) ver = reg_ver or self._use_last_dir_name(dot_net_dir, 'v') or '' # Set .NET versions for specified MSVC++ version if self.vc_ver >= 12.0: frameworkver = (ver, 'v4.0') elif self.vc_ver >= 10.0: frameworkver = ('v4.0.30319' if ver.lower()[:2] != 'v4' else ver, 'v3.5') elif self.vc_ver == 9.0: frameworkver = ('v3.5', 'v2.0.50727') if self.vc_ver == 8.0: frameworkver = ('v3.0', 'v2.0.50727') return frameworkver
[ "def", "_find_dot_net_versions", "(", "self", ",", "bits", ")", ":", "# Find actual .NET version in registry", "reg_ver", "=", "self", ".", "ri", ".", "lookup", "(", "self", ".", "ri", ".", "vc", ",", "'frameworkver%d'", "%", "bits", ")", "dot_net_dir", "=", "getattr", "(", "self", ",", "'FrameworkDir%d'", "%", "bits", ")", "ver", "=", "reg_ver", "or", "self", ".", "_use_last_dir_name", "(", "dot_net_dir", ",", "'v'", ")", "or", "''", "# Set .NET versions for specified MSVC++ version", "if", "self", ".", "vc_ver", ">=", "12.0", ":", "frameworkver", "=", "(", "ver", ",", "'v4.0'", ")", "elif", "self", ".", "vc_ver", ">=", "10.0", ":", "frameworkver", "=", "(", "'v4.0.30319'", "if", "ver", ".", "lower", "(", ")", "[", ":", "2", "]", "!=", "'v4'", "else", "ver", ",", "'v3.5'", ")", "elif", "self", ".", "vc_ver", "==", "9.0", ":", "frameworkver", "=", "(", "'v3.5'", ",", "'v2.0.50727'", ")", "if", "self", ".", "vc_ver", "==", "8.0", ":", "frameworkver", "=", "(", "'v3.0'", ",", "'v2.0.50727'", ")", "return", "frameworkver" ]
[ 770, 4 ]
[ 794, 27 ]
python
en
['en', 'error', 'th']
False
SystemInfo._use_last_dir_name
(self, path, prefix='')
Return name of the last dir in path or '' if no dir found. Parameters ---------- path: str Use dirs in this path prefix: str Use only dirs startings by this prefix
Return name of the last dir in path or '' if no dir found.
def _use_last_dir_name(self, path, prefix=''): """ Return name of the last dir in path or '' if no dir found. Parameters ---------- path: str Use dirs in this path prefix: str Use only dirs startings by this prefix """ matching_dirs = ( dir_name for dir_name in reversed(os.listdir(path)) if os.path.isdir(os.path.join(path, dir_name)) and dir_name.startswith(prefix) ) return next(matching_dirs, None) or ''
[ "def", "_use_last_dir_name", "(", "self", ",", "path", ",", "prefix", "=", "''", ")", ":", "matching_dirs", "=", "(", "dir_name", "for", "dir_name", "in", "reversed", "(", "os", ".", "listdir", "(", "path", ")", ")", "if", "os", ".", "path", ".", "isdir", "(", "os", ".", "path", ".", "join", "(", "path", ",", "dir_name", ")", ")", "and", "dir_name", ".", "startswith", "(", "prefix", ")", ")", "return", "next", "(", "matching_dirs", ",", "None", ")", "or", "''" ]
[ 796, 4 ]
[ 813, 46 ]
python
en
['en', 'error', 'th']
False
EnvironmentInfo.vc_ver
(self)
Microsoft Visual C++ version.
Microsoft Visual C++ version.
def vc_ver(self): """ Microsoft Visual C++ version. """ return self.si.vc_ver
[ "def", "vc_ver", "(", "self", ")", ":", "return", "self", ".", "si", ".", "vc_ver" ]
[ 850, 4 ]
[ 854, 29 ]
python
en
['en', 'error', 'th']
False
EnvironmentInfo.VSTools
(self)
Microsoft Visual Studio Tools
Microsoft Visual Studio Tools
def VSTools(self): """ Microsoft Visual Studio Tools """ paths = [r'Common7\IDE', r'Common7\Tools'] if self.vc_ver >= 14.0: arch_subdir = self.pi.current_dir(hidex86=True, x64=True) paths += [r'Common7\IDE\CommonExtensions\Microsoft\TestWindow'] paths += [r'Team Tools\Performance Tools'] paths += [r'Team Tools\Performance Tools%s' % arch_subdir] return [os.path.join(self.si.VSInstallDir, path) for path in paths]
[ "def", "VSTools", "(", "self", ")", ":", "paths", "=", "[", "r'Common7\\IDE'", ",", "r'Common7\\Tools'", "]", "if", "self", ".", "vc_ver", ">=", "14.0", ":", "arch_subdir", "=", "self", ".", "pi", ".", "current_dir", "(", "hidex86", "=", "True", ",", "x64", "=", "True", ")", "paths", "+=", "[", "r'Common7\\IDE\\CommonExtensions\\Microsoft\\TestWindow'", "]", "paths", "+=", "[", "r'Team Tools\\Performance Tools'", "]", "paths", "+=", "[", "r'Team Tools\\Performance Tools%s'", "%", "arch_subdir", "]", "return", "[", "os", ".", "path", ".", "join", "(", "self", ".", "si", ".", "VSInstallDir", ",", "path", ")", "for", "path", "in", "paths", "]" ]
[ 857, 4 ]
[ 869, 75 ]
python
en
['en', 'error', 'th']
False
EnvironmentInfo.VCIncludes
(self)
Microsoft Visual C++ & Microsoft Foundation Class Includes
Microsoft Visual C++ & Microsoft Foundation Class Includes
def VCIncludes(self): """ Microsoft Visual C++ & Microsoft Foundation Class Includes """ return [os.path.join(self.si.VCInstallDir, 'Include'), os.path.join(self.si.VCInstallDir, r'ATLMFC\Include')]
[ "def", "VCIncludes", "(", "self", ")", ":", "return", "[", "os", ".", "path", ".", "join", "(", "self", ".", "si", ".", "VCInstallDir", ",", "'Include'", ")", ",", "os", ".", "path", ".", "join", "(", "self", ".", "si", ".", "VCInstallDir", ",", "r'ATLMFC\\Include'", ")", "]" ]
[ 872, 4 ]
[ 877, 70 ]
python
en
['en', 'error', 'th']
False
EnvironmentInfo.VCLibraries
(self)
Microsoft Visual C++ & Microsoft Foundation Class Libraries
Microsoft Visual C++ & Microsoft Foundation Class Libraries
def VCLibraries(self): """ Microsoft Visual C++ & Microsoft Foundation Class Libraries """ if self.vc_ver >= 15.0: arch_subdir = self.pi.target_dir(x64=True) else: arch_subdir = self.pi.target_dir(hidex86=True) paths = ['Lib%s' % arch_subdir, r'ATLMFC\Lib%s' % arch_subdir] if self.vc_ver >= 14.0: paths += [r'Lib\store%s' % arch_subdir] return [os.path.join(self.si.VCInstallDir, path) for path in paths]
[ "def", "VCLibraries", "(", "self", ")", ":", "if", "self", ".", "vc_ver", ">=", "15.0", ":", "arch_subdir", "=", "self", ".", "pi", ".", "target_dir", "(", "x64", "=", "True", ")", "else", ":", "arch_subdir", "=", "self", ".", "pi", ".", "target_dir", "(", "hidex86", "=", "True", ")", "paths", "=", "[", "'Lib%s'", "%", "arch_subdir", ",", "r'ATLMFC\\Lib%s'", "%", "arch_subdir", "]", "if", "self", ".", "vc_ver", ">=", "14.0", ":", "paths", "+=", "[", "r'Lib\\store%s'", "%", "arch_subdir", "]", "return", "[", "os", ".", "path", ".", "join", "(", "self", ".", "si", ".", "VCInstallDir", ",", "path", ")", "for", "path", "in", "paths", "]" ]
[ 880, 4 ]
[ 893, 75 ]
python
en
['en', 'error', 'th']
False
EnvironmentInfo.VCStoreRefs
(self)
Microsoft Visual C++ store references Libraries
Microsoft Visual C++ store references Libraries
def VCStoreRefs(self): """ Microsoft Visual C++ store references Libraries """ if self.vc_ver < 14.0: return [] return [os.path.join(self.si.VCInstallDir, r'Lib\store\references')]
[ "def", "VCStoreRefs", "(", "self", ")", ":", "if", "self", ".", "vc_ver", "<", "14.0", ":", "return", "[", "]", "return", "[", "os", ".", "path", ".", "join", "(", "self", ".", "si", ".", "VCInstallDir", ",", "r'Lib\\store\\references'", ")", "]" ]
[ 896, 4 ]
[ 902, 76 ]
python
en
['en', 'error', 'th']
False
EnvironmentInfo.VCTools
(self)
Microsoft Visual C++ Tools
Microsoft Visual C++ Tools
def VCTools(self): """ Microsoft Visual C++ Tools """ si = self.si tools = [os.path.join(si.VCInstallDir, 'VCPackages')] forcex86 = True if self.vc_ver <= 10.0 else False arch_subdir = self.pi.cross_dir(forcex86) if arch_subdir: tools += [os.path.join(si.VCInstallDir, 'Bin%s' % arch_subdir)] if self.vc_ver == 14.0: path = 'Bin%s' % self.pi.current_dir(hidex86=True) tools += [os.path.join(si.VCInstallDir, path)] elif self.vc_ver >= 15.0: host_dir = (r'bin\HostX86%s' if self.pi.current_is_x86() else r'bin\HostX64%s') tools += [os.path.join( si.VCInstallDir, host_dir % self.pi.target_dir(x64=True))] if self.pi.current_cpu != self.pi.target_cpu: tools += [os.path.join( si.VCInstallDir, host_dir % self.pi.current_dir(x64=True))] else: tools += [os.path.join(si.VCInstallDir, 'Bin')] return tools
[ "def", "VCTools", "(", "self", ")", ":", "si", "=", "self", ".", "si", "tools", "=", "[", "os", ".", "path", ".", "join", "(", "si", ".", "VCInstallDir", ",", "'VCPackages'", ")", "]", "forcex86", "=", "True", "if", "self", ".", "vc_ver", "<=", "10.0", "else", "False", "arch_subdir", "=", "self", ".", "pi", ".", "cross_dir", "(", "forcex86", ")", "if", "arch_subdir", ":", "tools", "+=", "[", "os", ".", "path", ".", "join", "(", "si", ".", "VCInstallDir", ",", "'Bin%s'", "%", "arch_subdir", ")", "]", "if", "self", ".", "vc_ver", "==", "14.0", ":", "path", "=", "'Bin%s'", "%", "self", ".", "pi", ".", "current_dir", "(", "hidex86", "=", "True", ")", "tools", "+=", "[", "os", ".", "path", ".", "join", "(", "si", ".", "VCInstallDir", ",", "path", ")", "]", "elif", "self", ".", "vc_ver", ">=", "15.0", ":", "host_dir", "=", "(", "r'bin\\HostX86%s'", "if", "self", ".", "pi", ".", "current_is_x86", "(", ")", "else", "r'bin\\HostX64%s'", ")", "tools", "+=", "[", "os", ".", "path", ".", "join", "(", "si", ".", "VCInstallDir", ",", "host_dir", "%", "self", ".", "pi", ".", "target_dir", "(", "x64", "=", "True", ")", ")", "]", "if", "self", ".", "pi", ".", "current_cpu", "!=", "self", ".", "pi", ".", "target_cpu", ":", "tools", "+=", "[", "os", ".", "path", ".", "join", "(", "si", ".", "VCInstallDir", ",", "host_dir", "%", "self", ".", "pi", ".", "current_dir", "(", "x64", "=", "True", ")", ")", "]", "else", ":", "tools", "+=", "[", "os", ".", "path", ".", "join", "(", "si", ".", "VCInstallDir", ",", "'Bin'", ")", "]", "return", "tools" ]
[ 905, 4 ]
[ 934, 20 ]
python
en
['en', 'error', 'th']
False
EnvironmentInfo.OSLibraries
(self)
Microsoft Windows SDK Libraries
Microsoft Windows SDK Libraries
def OSLibraries(self): """ Microsoft Windows SDK Libraries """ if self.vc_ver <= 10.0: arch_subdir = self.pi.target_dir(hidex86=True, x64=True) return [os.path.join(self.si.WindowsSdkDir, 'Lib%s' % arch_subdir)] else: arch_subdir = self.pi.target_dir(x64=True) lib = os.path.join(self.si.WindowsSdkDir, 'lib') libver = self._sdk_subdir return [os.path.join(lib, '%sum%s' % (libver , arch_subdir))]
[ "def", "OSLibraries", "(", "self", ")", ":", "if", "self", ".", "vc_ver", "<=", "10.0", ":", "arch_subdir", "=", "self", ".", "pi", ".", "target_dir", "(", "hidex86", "=", "True", ",", "x64", "=", "True", ")", "return", "[", "os", ".", "path", ".", "join", "(", "self", ".", "si", ".", "WindowsSdkDir", ",", "'Lib%s'", "%", "arch_subdir", ")", "]", "else", ":", "arch_subdir", "=", "self", ".", "pi", ".", "target_dir", "(", "x64", "=", "True", ")", "lib", "=", "os", ".", "path", ".", "join", "(", "self", ".", "si", ".", "WindowsSdkDir", ",", "'lib'", ")", "libver", "=", "self", ".", "_sdk_subdir", "return", "[", "os", ".", "path", ".", "join", "(", "lib", ",", "'%sum%s'", "%", "(", "libver", ",", "arch_subdir", ")", ")", "]" ]
[ 937, 4 ]
[ 949, 73 ]
python
en
['en', 'error', 'th']
False
EnvironmentInfo.OSIncludes
(self)
Microsoft Windows SDK Include
Microsoft Windows SDK Include
def OSIncludes(self): """ Microsoft Windows SDK Include """ include = os.path.join(self.si.WindowsSdkDir, 'include') if self.vc_ver <= 10.0: return [include, os.path.join(include, 'gl')] else: if self.vc_ver >= 14.0: sdkver = self._sdk_subdir else: sdkver = '' return [os.path.join(include, '%sshared' % sdkver), os.path.join(include, '%sum' % sdkver), os.path.join(include, '%swinrt' % sdkver)]
[ "def", "OSIncludes", "(", "self", ")", ":", "include", "=", "os", ".", "path", ".", "join", "(", "self", ".", "si", ".", "WindowsSdkDir", ",", "'include'", ")", "if", "self", ".", "vc_ver", "<=", "10.0", ":", "return", "[", "include", ",", "os", ".", "path", ".", "join", "(", "include", ",", "'gl'", ")", "]", "else", ":", "if", "self", ".", "vc_ver", ">=", "14.0", ":", "sdkver", "=", "self", ".", "_sdk_subdir", "else", ":", "sdkver", "=", "''", "return", "[", "os", ".", "path", ".", "join", "(", "include", ",", "'%sshared'", "%", "sdkver", ")", ",", "os", ".", "path", ".", "join", "(", "include", ",", "'%sum'", "%", "sdkver", ")", ",", "os", ".", "path", ".", "join", "(", "include", ",", "'%swinrt'", "%", "sdkver", ")", "]" ]
[ 952, 4 ]
[ 968, 62 ]
python
en
['en', 'error', 'th']
False
EnvironmentInfo.OSLibpath
(self)
Microsoft Windows SDK Libraries Paths
Microsoft Windows SDK Libraries Paths
def OSLibpath(self): """ Microsoft Windows SDK Libraries Paths """ ref = os.path.join(self.si.WindowsSdkDir, 'References') libpath = [] if self.vc_ver <= 9.0: libpath += self.OSLibraries if self.vc_ver >= 11.0: libpath += [os.path.join(ref, r'CommonConfiguration\Neutral')] if self.vc_ver >= 14.0: libpath += [ ref, os.path.join(self.si.WindowsSdkDir, 'UnionMetadata'), os.path.join( ref, 'Windows.Foundation.UniversalApiContract', '1.0.0.0', ), os.path.join( ref, 'Windows.Foundation.FoundationContract', '1.0.0.0', ), os.path.join( ref, 'Windows.Networking.Connectivity.WwanContract', '1.0.0.0', ), os.path.join( self.si.WindowsSdkDir, 'ExtensionSDKs', 'Microsoft.VCLibs', '%0.1f' % self.vc_ver, 'References', 'CommonConfiguration', 'neutral', ), ] return libpath
[ "def", "OSLibpath", "(", "self", ")", ":", "ref", "=", "os", ".", "path", ".", "join", "(", "self", ".", "si", ".", "WindowsSdkDir", ",", "'References'", ")", "libpath", "=", "[", "]", "if", "self", ".", "vc_ver", "<=", "9.0", ":", "libpath", "+=", "self", ".", "OSLibraries", "if", "self", ".", "vc_ver", ">=", "11.0", ":", "libpath", "+=", "[", "os", ".", "path", ".", "join", "(", "ref", ",", "r'CommonConfiguration\\Neutral'", ")", "]", "if", "self", ".", "vc_ver", ">=", "14.0", ":", "libpath", "+=", "[", "ref", ",", "os", ".", "path", ".", "join", "(", "self", ".", "si", ".", "WindowsSdkDir", ",", "'UnionMetadata'", ")", ",", "os", ".", "path", ".", "join", "(", "ref", ",", "'Windows.Foundation.UniversalApiContract'", ",", "'1.0.0.0'", ",", ")", ",", "os", ".", "path", ".", "join", "(", "ref", ",", "'Windows.Foundation.FoundationContract'", ",", "'1.0.0.0'", ",", ")", ",", "os", ".", "path", ".", "join", "(", "ref", ",", "'Windows.Networking.Connectivity.WwanContract'", ",", "'1.0.0.0'", ",", ")", ",", "os", ".", "path", ".", "join", "(", "self", ".", "si", ".", "WindowsSdkDir", ",", "'ExtensionSDKs'", ",", "'Microsoft.VCLibs'", ",", "'%0.1f'", "%", "self", ".", "vc_ver", ",", "'References'", ",", "'CommonConfiguration'", ",", "'neutral'", ",", ")", ",", "]", "return", "libpath" ]
[ 971, 4 ]
[ 1013, 22 ]
python
en
['en', 'error', 'th']
False
EnvironmentInfo.SdkTools
(self)
Microsoft Windows SDK Tools
Microsoft Windows SDK Tools
def SdkTools(self): """ Microsoft Windows SDK Tools """ return list(self._sdk_tools())
[ "def", "SdkTools", "(", "self", ")", ":", "return", "list", "(", "self", ".", "_sdk_tools", "(", ")", ")" ]
[ 1016, 4 ]
[ 1020, 38 ]
python
en
['en', 'error', 'th']
False
EnvironmentInfo._sdk_tools
(self)
Microsoft Windows SDK Tools paths generator
Microsoft Windows SDK Tools paths generator
def _sdk_tools(self): """ Microsoft Windows SDK Tools paths generator """ if self.vc_ver < 15.0: bin_dir = 'Bin' if self.vc_ver <= 11.0 else r'Bin\x86' yield os.path.join(self.si.WindowsSdkDir, bin_dir) if not self.pi.current_is_x86(): arch_subdir = self.pi.current_dir(x64=True) path = 'Bin%s' % arch_subdir yield os.path.join(self.si.WindowsSdkDir, path) if self.vc_ver == 10.0 or self.vc_ver == 11.0: if self.pi.target_is_x86(): arch_subdir = '' else: arch_subdir = self.pi.current_dir(hidex86=True, x64=True) path = r'Bin\NETFX 4.0 Tools%s' % arch_subdir yield os.path.join(self.si.WindowsSdkDir, path) elif self.vc_ver >= 15.0: path = os.path.join(self.si.WindowsSdkDir, 'Bin') arch_subdir = self.pi.current_dir(x64=True) sdkver = self.si.WindowsSdkLastVersion yield os.path.join(path, '%s%s' % (sdkver, arch_subdir)) if self.si.WindowsSDKExecutablePath: yield self.si.WindowsSDKExecutablePath
[ "def", "_sdk_tools", "(", "self", ")", ":", "if", "self", ".", "vc_ver", "<", "15.0", ":", "bin_dir", "=", "'Bin'", "if", "self", ".", "vc_ver", "<=", "11.0", "else", "r'Bin\\x86'", "yield", "os", ".", "path", ".", "join", "(", "self", ".", "si", ".", "WindowsSdkDir", ",", "bin_dir", ")", "if", "not", "self", ".", "pi", ".", "current_is_x86", "(", ")", ":", "arch_subdir", "=", "self", ".", "pi", ".", "current_dir", "(", "x64", "=", "True", ")", "path", "=", "'Bin%s'", "%", "arch_subdir", "yield", "os", ".", "path", ".", "join", "(", "self", ".", "si", ".", "WindowsSdkDir", ",", "path", ")", "if", "self", ".", "vc_ver", "==", "10.0", "or", "self", ".", "vc_ver", "==", "11.0", ":", "if", "self", ".", "pi", ".", "target_is_x86", "(", ")", ":", "arch_subdir", "=", "''", "else", ":", "arch_subdir", "=", "self", ".", "pi", ".", "current_dir", "(", "hidex86", "=", "True", ",", "x64", "=", "True", ")", "path", "=", "r'Bin\\NETFX 4.0 Tools%s'", "%", "arch_subdir", "yield", "os", ".", "path", ".", "join", "(", "self", ".", "si", ".", "WindowsSdkDir", ",", "path", ")", "elif", "self", ".", "vc_ver", ">=", "15.0", ":", "path", "=", "os", ".", "path", ".", "join", "(", "self", ".", "si", ".", "WindowsSdkDir", ",", "'Bin'", ")", "arch_subdir", "=", "self", ".", "pi", ".", "current_dir", "(", "x64", "=", "True", ")", "sdkver", "=", "self", ".", "si", ".", "WindowsSdkLastVersion", "yield", "os", ".", "path", ".", "join", "(", "path", ",", "'%s%s'", "%", "(", "sdkver", ",", "arch_subdir", ")", ")", "if", "self", ".", "si", ".", "WindowsSDKExecutablePath", ":", "yield", "self", ".", "si", ".", "WindowsSDKExecutablePath" ]
[ 1022, 4 ]
[ 1050, 50 ]
python
en
['en', 'error', 'th']
False
EnvironmentInfo._sdk_subdir
(self)
Microsoft Windows SDK version subdir
Microsoft Windows SDK version subdir
def _sdk_subdir(self): """ Microsoft Windows SDK version subdir """ ucrtver = self.si.WindowsSdkLastVersion return ('%s\\' % ucrtver) if ucrtver else ''
[ "def", "_sdk_subdir", "(", "self", ")", ":", "ucrtver", "=", "self", ".", "si", ".", "WindowsSdkLastVersion", "return", "(", "'%s\\\\'", "%", "ucrtver", ")", "if", "ucrtver", "else", "''" ]
[ 1053, 4 ]
[ 1058, 52 ]
python
en
['en', 'error', 'th']
False
EnvironmentInfo.SdkSetup
(self)
Microsoft Windows SDK Setup
Microsoft Windows SDK Setup
def SdkSetup(self): """ Microsoft Windows SDK Setup """ if self.vc_ver > 9.0: return [] return [os.path.join(self.si.WindowsSdkDir, 'Setup')]
[ "def", "SdkSetup", "(", "self", ")", ":", "if", "self", ".", "vc_ver", ">", "9.0", ":", "return", "[", "]", "return", "[", "os", ".", "path", ".", "join", "(", "self", ".", "si", ".", "WindowsSdkDir", ",", "'Setup'", ")", "]" ]
[ 1061, 4 ]
[ 1068, 61 ]
python
en
['en', 'error', 'th']
False