我们从Python开源项目中,提取了以下50个代码示例,用于说明如何使用versioneer.get_cmdclass()。
def get_cmdclass(): versioneer_cmds = versioneer.get_cmdclass() sdist_class = versioneer_cmds['sdist'] class sdist(sdist_class): """ensure cython files are compiled to c, when distributing""" def run(self): # only run if .git is present if not os.path.exists('.git'): print("Not on git, can not create source distribution") return try: from Cython.Build import cythonize print("cythonizing sources") cythonize(extensions()) except ImportError: warnings.warn('sdist cythonize failed') return sdist_class.run(self) versioneer_cmds['sdist'] = sdist return versioneer_cmds
def get_cmdclass(): cmdclass = versioneer.get_cmdclass() # add clean command cmdclass.update(dict(clean=octoprint_setuptools.CleanCommand.for_options(source_folder="src", eggs=["OctoPrint*.egg-info"]))) # add translation commands translation_dir = "translations" pot_file = os.path.join(translation_dir, "messages.pot") bundled_dir = os.path.join("src", "octoprint", "translations") cmdclass.update(octoprint_setuptools.get_babel_commandclasses(pot_file=pot_file, output_dir=translation_dir, pack_name_prefix="OctoPrint-i18n-", pack_path_prefix="", bundled_dir=bundled_dir)) cmdclass["build_py"] = data_copy_build_py_factory({ "octoprint/templates/_data": [ "AUTHORS.md", "CHANGELOG.md", "SUPPORTERS.md", "THIRDPARTYLICENSES.md", ] }, cmdclass["build_py"] if "build_py" in cmdclass else _build_py) return cmdclass
def scan_setup_py(): """Validate the contents of setup.py against Versioneer's expectations.""" found = set() setters = False errors = 0 with open("setup.py", "r") as f: for line in f.readlines(): if "import versioneer" in line: found.add("import") if "versioneer.get_cmdclass()" in line: found.add("cmdclass") if "versioneer.get_version()" in line: found.add("get_version") if "versioneer.VCS" in line: setters = True if "versioneer.versionfile_source" in line: setters = True if len(found) != 3: print("") print("Your setup.py appears to be missing some important items") print("(but I might be wrong). Please make sure it has something") print("roughly like the following:") print("") print(" import versioneer") print(" setup( version=versioneer.get_version(),") print(" cmdclass=versioneer.get_cmdclass(), ...)") print("") errors += 1 if setters: print("You should remove lines like 'versioneer.VCS = ' and") print("'versioneer.versionfile_source = ' . This configuration") print("now lives in setup.cfg, and should be removed from setup.py") print("") errors += 1 return errors
def scan_setup_py(): found = set() setters = False errors = 0 with open("setup.py", "r") as f: for line in f.readlines(): if "import versioneer" in line: found.add("import") if "versioneer.get_cmdclass()" in line: found.add("cmdclass") if "versioneer.get_version()" in line: found.add("get_version") if "versioneer.VCS" in line: setters = True if "versioneer.versionfile_source" in line: setters = True if len(found) != 3: print("") print("Your setup.py appears to be missing some important items") print("(but I might be wrong). Please make sure it has something") print("roughly like the following:") print("") print(" import versioneer") print(" setup( version=versioneer.get_version(),") print(" cmdclass=versioneer.get_cmdclass(), ...)") print("") errors += 1 if setters: print("You should remove lines like 'versioneer.VCS = ' and") print("'versioneer.versionfile_source = ' . This configuration") print("now lives in setup.cfg, and should be removed from setup.py") print("") errors += 1 return errors
def get_cmdclass(): """Get our cmdclass dictionary for use in setuptool.setup(). This must be done outside the call to setuptools.setup() because we need to add our own classes to the cmdclass dictionary, and then update that dictionary with the one returned from versioneer.get_cmdclass(). """ cmdclass = {'test': Trial,} cmdclass.update(versioneer.get_cmdclass()) return cmdclass
def get_cmdclass(): """ Get setuptools command class :return: """ setup_versioneer() clean_cache() import versioneer return versioneer.get_cmdclass()