Example #1
0
def verify_description_rst_is_up_to_date():
  """If the DESCRIPTION.rst file is not up to date, abort."""
  temp_dir = tempfile.mkdtemp()
  readme_md = os.path.join(build_utils.PYTYPE_SRC_ROOT, "README.md")
  temp_readme_md = os.path.join(temp_dir, "README.md")
  with open(readme_md) as readme_md_file:
    readme_lines = readme_md_file.readlines()
  with open(temp_readme_md, "w") as temp_readme_md_file:
    readme_text = "".join(readme_lines[2:])  # We strip the build status line.
    temp_readme_md_file.write(readme_text)

  description_rst = os.path.join(build_utils.PYTYPE_SRC_ROOT, "DESCRIPTION.rst")
  new_description_rst = os.path.join(temp_dir, "DESCRIPTION.rst")
  pandoc_cmd = [
      "pandoc", "--from=markdown", "--to=rst",
      "--output=%s" % new_description_rst,
      temp_readme_md,
  ]
  returncode, stdout = build_utils.run_cmd(pandoc_cmd)
  if returncode != 0:
    sys.exit("Running 'pandoc' failed:\n%s" % stdout)

  with open(description_rst) as description_rst_file:
    contents = set(description_rst_file.readlines())
    with open(new_description_rst) as new_description_rst_file:
      new_contents = set(new_description_rst_file.readlines())
  if contents.symmetric_difference(new_contents):
    sys.exit("ERROR: DESCRIPTION.rst is not up to date.")
Example #2
0
def _run_steps(steps):
    for s in steps:
        _begin_step(s)
        returncode, _ = build_utils.run_cmd(s.command, pipe=False)
        if returncode != 0:
            _report_failure(s)
            sys.exit(1)
        _end_step(s)
Example #3
0
def upload_package(package_path, test=False):
  twine_cmd = ["twine", "upload"]
  if test:
    twine_cmd.extend(["--repository", "testpypi"])
  twine_cmd.append(os.path.join(package_path, "*"))
  print("Uploading: %s" % twine_cmd)
  returncode, stdout = build_utils.run_cmd(twine_cmd)
  if returncode != 0:
    raise ReleaseError("Package upload failed:\n%s" % stdout)
Example #4
0
 def __enter__(self):
   sdist_cmd = ["python", "setup.py", "sdist"]
   print("Creating distribution package: %s\n" % sdist_cmd)
   returncode, stdout = build_utils.run_cmd(sdist_cmd)
   if returncode != 0:
     raise ReleaseError("Running %s failed:\n%s" % (sdist_cmd, stdout))
   # The sdist command creates the distribution package in a directory
   # named "dist"
   self.dist_path = os.path.join(build_utils.PYTYPE_SRC_ROOT, "dist")
   return self.dist_path
Example #5
0
def main():
    options = parse_args()
    returncode, stdout = build_utils.run_cmd([options.binary])
    if options.logfile:
        with open(options.logfile, "w") as logfile:
            logfile.write(stdout)
    if returncode == 0:
        print(build_utils.pass_msg(options.target))
    else:
        print(build_utils.failure_msg(options.target, options.logfile))
        sys.exit(1)
Example #6
0
def _install():
  return build_utils.run_cmd(["make", "install"], cwd=_BUILD_DIR)
Example #7
0
def _build():
  return build_utils.run_cmd(["make", "-j16"], cwd=_BUILD_DIR)
Example #8
0
def _configure_build():
  config_script = os.path.join(_CPYTHON_SRC_DIR, "configure")
  return build_utils.run_cmd([config_script, "--prefix=%s" % _INSTALL_DIR],
                             cwd=_BUILD_DIR)
Example #9
0
def _revert_patch():
  return build_utils.run_cmd(["git", "checkout", "--", "."],
                             cwd=_CPYTHON_SRC_DIR)
Example #10
0
def _apply_patch():
  patch_file = os.path.join(build_utils.PYTYPE_SRC_ROOT, "2.7_patches",
                            "python_2_7_type_annotations.diff")
  return build_utils.run_cmd(["git", "apply", patch_file], cwd=_CPYTHON_SRC_DIR)