MCPcopy Create free account
hub / github.com/microsoft/debugpy / do_setup

Function do_setup

versioneer.py:2047–2100  ·  view source on GitHub ↗

Do main VCS-independent setup function for installing Versioneer.

()

Source from the content-addressed store, hash-verified

2045
2046
2047def do_setup():
2048 """Do main VCS-independent setup function for installing Versioneer."""
2049 root = get_root()
2050 try:
2051 cfg = get_config_from_root(root)
2052 except (OSError, configparser.NoSectionError,
2053 configparser.NoOptionError) as e:
2054 if isinstance(e, (OSError, configparser.NoSectionError)):
2055 print("Adding sample versioneer config to setup.cfg",
2056 file=sys.stderr)
2057 with open(os.path.join(root, "setup.cfg"), "a") as f:
2058 f.write(SAMPLE_CONFIG)
2059 print(CONFIG_ERROR, file=sys.stderr)
2060 return 1
2061
2062 print(" creating %s" % cfg.versionfile_source)
2063 with open(cfg.versionfile_source, "w") as f:
2064 LONG = LONG_VERSION_PY[cfg.VCS]
2065 f.write(LONG % {"DOLLAR": "$",
2066 "STYLE": cfg.style,
2067 "TAG_PREFIX": cfg.tag_prefix,
2068 "PARENTDIR_PREFIX": cfg.parentdir_prefix,
2069 "VERSIONFILE_SOURCE": cfg.versionfile_source,
2070 })
2071
2072 ipy = os.path.join(os.path.dirname(cfg.versionfile_source),
2073 "__init__.py")
2074 if os.path.exists(ipy):
2075 try:
2076 with open(ipy, "r") as f:
2077 old = f.read()
2078 except OSError:
2079 old = ""
2080 module = os.path.splitext(os.path.basename(cfg.versionfile_source))[0]
2081 snippet = INIT_PY_SNIPPET.format(module)
2082 if OLD_SNIPPET in old:
2083 print(" replacing boilerplate in %s" % ipy)
2084 with open(ipy, "w") as f:
2085 f.write(old.replace(OLD_SNIPPET, snippet))
2086 elif snippet not in old:
2087 print(" appending to %s" % ipy)
2088 with open(ipy, "a") as f:
2089 f.write(snippet)
2090 else:
2091 print(" %s unmodified" % ipy)
2092 else:
2093 print(" %s doesn't exist, ok" % ipy)
2094 ipy = None
2095
2096 # Make VCS-specific changes. For git, this means creating/changing
2097 # .gitattributes to mark _version.py for export-subst keyword
2098 # substitution.
2099 do_vcs_install(cfg.versionfile_source, ipy)
2100 return 0
2101
2102
2103def scan_setup_py():

Callers 1

versioneer.pyFile · 0.85

Calls 6

get_rootFunction · 0.85
get_config_from_rootFunction · 0.85
do_vcs_installFunction · 0.85
joinMethod · 0.45
writeMethod · 0.45
readMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…