def get_version(path): """Retrieves the version for a package """ v_path = find_file(path, "version.txt") f = open(v_path, 'r') version = f.read().strip() return get_normalized_version(version)
def print_unreleased_packages(): """Given a directory with packages (such as the src/ created by mr.developer, traverses it and print packages that have changes in their history files that haven't been released as eggs """ unreleased = [] changes = '' args = sys.argv if len(args) == 1: print "You need to provide a path where to look for packages" sys.exit(1) folder = args[1] for name in os.listdir(folder): dirname = os.path.join(folder, name) if not os.path.isdir(dirname): continue print "Looking in package %s" % dirname try: history = find_file(dirname, "HISTORY.txt") except ValueError: print "Did not find a history file, skipping" continue lines = open(history).read() parser = HistoryParser(lines) try: if len(parser.entries[0]) > 2: if parser.entries[0][2].strip() != "*": #might be just a placeholder star unreleased.append(name) changes += "\n\n%s\n============================\n" % dirname for change in parser.entries[0][2:]: changes += "\n" + change except: print "Got an error while processing history file, skipping" continue if not unreleased: print "No unreleased packages have been found" sys.exit(0) else: print "\n\n\n" print changes print "\n\n" print "The following packages have unreleased modifications:", print ", ".join(unreleased) sys.exit(1)
def bump_version(path): """Writes new versions into version file It will always go from dev to final and from released to increased dev number. Example: Called first time: 1.6.28-dev => 1.6.28 Called second time: 1.6.28 => 1.6.29-dev """ v_path = find_file(path, "version.txt") f = open(v_path, 'rw+') version = f.read().strip() version = get_normalized_version(version) newver = _increment_version(version) f.truncate(0); f.seek(0) f.write(newver) f.close()
def bump_version(path): """Writes new versions into version file It will always go from dev to final and from released to increased dev number. Example: Called first time: 1.6.28-dev => 1.6.28 Called second time: 1.6.28 => 1.6.29-dev """ v_path = find_file(path, "version.txt") f = open(v_path, 'rw+') version = f.read().strip() version = get_normalized_version(version) newver = _increment_version(version) f.truncate(0) f.seek(0) f.write(newver) f.close()
def check_package_sanity(self): # if self.pkg_scm.is_dirty(): # raise Error("Package is dirty. Quiting") if not os.path.exists(self.package_path): raise Error("Path %s is invalid, quiting." % self.package_path) # check if we have hardcoded version in setup.py # this is a dumb but hopefully effective method: we look for a line # starting with version= and fail if there's a number on it setup_py = find_file(self.package_path, 'setup.py') f = open(setup_py) version = [l for l in f.readlines() if l.strip().startswith('version')] for l in version: for c in l: if c.isdigit(): raise Error("There's a hardcoded version in the " "setup.py file. Quiting.") vv = get_version(self.package_path) vh = FileHistoryParser(self.package_path).get_current_version() if self.resume_from > 1: return # Bypass sanity checks when resuming vv_version = Version(vv) if not vv_version.is_prerelease: raise Error("Version.txt file does not contain a dev version. " "Quiting.") vh_version = Version(vh) if not vh_version.is_prerelease: raise Error("HISTORY.txt file does not contain a dev version. " "Quiting.") if vh != vv: raise Error("Latest version in HISTORY.txt is not the " "same as in version.txt. Quiting.") # We depend on collective.dist installed in the python. # Installing eggmonkey under buildout with a different python doesn't # install properly the collective.dist print_msg("Installing collective.dist in ", self.python) cmd = self.python + " setup.py easy_install -q -U collective.dist" try: subprocess.check_call(cmd, cwd=self.package_path, shell=True) except subprocess.CalledProcessError: # raise Error("Failed to install collective.dist in", self.python) pass # easier not to fail here # check if package metadata is properly filled try: cmd = self.python + " setup.py check --strict" subprocess.check_call(cmd, cwd=self.package_path, shell=True) except subprocess.CalledProcessError: print "Make sure that the package following metadata filled in:" print " - name" print " - version" print " - url" print " - author and author_email" print " - maintainer and maintainer_email" raise Error("Package has improperly filled metadata. Quiting")
print "Also, make sure you run the eggmonkey from the buildout folder" sys.exit(1) cmd = argparse.ArgumentParser( u"Devivy: make a package to be -dev version\n") cmd.add_argument("packages", nargs="*", metavar="PACKAGE", help=u"The packages to devify. Can be any of: [ %s ]" % u" ".join(sorted(sources.keys()))) args = cmd.parse_args() packages = args.packages if not packages: cmd.print_help() sys.exit(1) for package in packages: package_path = sources[package]['path'] parser = FileHistoryParser(package_path) has_changed = parser._make_dev() version = parser.get_current_version() version_file = find_file(package_path, 'version.txt') with open(version_file, 'w') as f: f.write(version) if has_changed: print "Changed version to -dev for package", package else: print "Package", package, " already at -dev"
def __init__(self, path): h_path = find_file(path, "HISTORY.txt") self.h_path = h_path self.file = open(h_path, 'rw+') content = self.file.read() HistoryParser.__init__(self, content)
cmd = argparse.ArgumentParser( u"Devivy: make a package to be -dev version\n") cmd.add_argument("packages", nargs="*", metavar="PACKAGE", help=u"The packages to devify. Can be any of: [ %s ]" % u" ".join(sorted(sources.keys()))) args = cmd.parse_args() packages = args.packages if not packages: cmd.print_help() sys.exit(1) for package in packages: package_path = sources[package]['path'] parser = FileHistoryParser(package_path) has_changed = parser._make_dev() version = parser.get_current_version() version_file = find_file(package_path, 'version.txt') with open(version_file, 'w') as f: f.write(version) if has_changed: print "Changed version to -dev for package", package else: print "Package", package, " already at -dev"