MCPcopy
hub / github.com/quantopian/zipline / do_setup

Function do_setup

versioneer.py:1577–1655  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

1575
1576
1577def do_setup():
1578 root = get_root()
1579 try:
1580 cfg = get_config_from_root(root)
1581 except (EnvironmentError, configparser.NoSectionError,
1582 configparser.NoOptionError) as e:
1583 if isinstance(e, (EnvironmentError, configparser.NoSectionError)):
1584 print("Adding sample versioneer config to setup.cfg",
1585 file=sys.stderr)
1586 with open(os.path.join(root, "setup.cfg"), "a") as f:
1587 f.write(SAMPLE_CONFIG)
1588 print(CONFIG_ERROR, file=sys.stderr)
1589 return 1
1590
1591 print(" creating %s" % cfg.versionfile_source)
1592 with open(cfg.versionfile_source, "w") as f:
1593 LONG = LONG_VERSION_PY[cfg.VCS]
1594 f.write(LONG % {"DOLLAR": "$",
1595 "STYLE": cfg.style,
1596 "TAG_PREFIX": cfg.tag_prefix,
1597 "PARENTDIR_PREFIX": cfg.parentdir_prefix,
1598 "VERSIONFILE_SOURCE": cfg.versionfile_source,
1599 })
1600
1601 ipy = os.path.join(os.path.dirname(cfg.versionfile_source),
1602 "__init__.py")
1603 if os.path.exists(ipy):
1604 try:
1605 with open(ipy, "r") as f:
1606 old = f.read()
1607 except EnvironmentError:
1608 old = ""
1609 if INIT_PY_SNIPPET not in old:
1610 print(" appending to %s" % ipy)
1611 with open(ipy, "a") as f:
1612 f.write(INIT_PY_SNIPPET)
1613 else:
1614 print(" %s unmodified" % ipy)
1615 else:
1616 print(" %s doesn't exist, ok" % ipy)
1617 ipy = None
1618
1619 # Make sure both the top-level "versioneer.py" and versionfile_source
1620 # (PKG/_version.py, used by runtime code) are in MANIFEST.in, so
1621 # they'll be copied into source distributions. Pip won't be able to
1622 # install the package without this.
1623 manifest_in = os.path.join(root, "MANIFEST.in")
1624 simple_includes = set()
1625 try:
1626 with open(manifest_in, "r") as f:
1627 for line in f:
1628 if line.startswith("include "):
1629 for include in line.split()[1:]:
1630 simple_includes.add(include)
1631 except EnvironmentError:
1632 pass
1633 # That doesn't cover everything MANIFEST.in can do
1634 # (http://docs.python.org/2/distutils/sourcedist.html#commands), so

Callers 1

versioneer.pyFile · 0.85

Calls 9

get_rootFunction · 0.85
get_config_from_rootFunction · 0.85
do_vcs_installFunction · 0.85
joinMethod · 0.80
existsMethod · 0.80
addMethod · 0.80
writeMethod · 0.45
readMethod · 0.45
startswithMethod · 0.45

Tested by

no test coverage detected