def version() -> None: """Shows the version of the project.""" try: v = Version.from_git().serialize(style=Style.SemVer) except RuntimeError: v = __version__ print("pynfogen", v)
# If extensions (or modules to document with autodoc) are in another directory, # add these directories to sys.path here. If the directory is relative to the # documentation root, use os.path.abspath to make it absolute, like shown here. # # import os # import sys # sys.path.insert(0, os.path.abspath('.')) # -- Project information ----------------------------------------------------- project = 'pydvdcss' copyright = '2021, PHOENiX' author = 'PHOENiX' # The full version, including alpha/beta/rc tags version = Version.from_git().base release = version # -- General configuration --------------------------------------------------- # Add any Sphinx extension module names here, as strings. They can be # extensions coming with Sphinx (named 'sphinx.ext.*') or your custom # ones. extensions = ['sphinx.ext.autosectionlabel', 'sphinx.ext.autodoc'] # Add any paths that contain templates here, relative to this directory. templates_path = ['_templates'] # List of patterns, relative to source directory, that match files and # directories to ignore when looking for source files. # This pattern also affects html_static_path and html_extra_path.
import os from typing import Optional from dunamai import Version, bump_version, serialize_pep440 if "CI_MERGE_REQUEST_IID" in os.environ: mr_version: Optional[str] = os.environ["CI_MERGE_REQUEST_IID"] else: mr_version = None build_official = "BUILD_OFFICIAL" in os.environ v = Version.from_git(pattern=r"^(?P<base>\d+\.\d+\.\d+)$") if v.distance == 0: out = serialize_pep440(v.base, v.stage, v.revision) else: if build_official: out = serialize_pep440(bump_version(v.base), None, None, dev=v.distance) elif mr_version is not None: out = serialize_pep440(bump_version(v.base), None, None, dev=v.distance, metadata=[f"mr{mr_version}"]) else: out = serialize_pep440(bump_version(v.base), None, None,
extensions = ['sphinx.ext.autodoc', 'sphinx.ext.viewcode', 'sphinx.ext.napoleon', 'sphinx.ext.intersphinx', 'sphinx.ext.mathjax', 'sphinx.ext.todo', 'sphinx.ext.ifconfig', ] templates_path = ['_templates'] source_suffix = '.rst' master_doc = 'index' project = u'chronon' copyright = u"2020, McLaren Applied" version = str(Version.from_git()) release = version exclude_patterns = ['_build'] pygments_style = 'sphinx' import sphinx_rtd_theme html_theme = 'sphinx_rtd_theme' html_theme_path = [sphinx_rtd_theme.get_html_theme_path()] htmlhelp_basename = 'chronondoc' autoclass_content = "both" man_pages = [
def _generate(source, config, ta_version, outputdir=None): logger.info(f"ucc-gen version {__version__} is used") if outputdir is None: outputdir = os.path.join(os.getcwd(), "output") if not ta_version: version = Version.from_git() if not version.stage: stage = "R" else: stage = version.stage[:1] version_str = version.serialize(metadata=True, style=Style.SemVer) version_splunk = f"{version.base}{stage}{version.commit}" ta_version = version_splunk else: ta_version = ta_version.strip() version_str = ta_version if not os.path.exists(source): raise NotADirectoryError(f"{os.path.abspath(source)} not Found.") # Setting default value to Config argument if not config: config = os.path.abspath( os.path.join(source, PARENT_DIR, "globalConfig.json")) clean_before_build(outputdir) app_manifest_path = os.path.abspath( os.path.join(source, APP_MANIFEST_FILE_NAME), ) with open(app_manifest_path) as manifest_file: app_manifest_content = manifest_file.read() manifest = AppManifest() try: manifest.read(app_manifest_content) except AppManifestFormatException: logger.error( f"Manifest file @ {app_manifest_path} has invalid format.\n" f"Please refer to {APP_MANIFEST_WEBSITE}.\n" f'Lines with comments are supported if they start with "#".\n') sys.exit(1) ta_name = manifest.get_addon_name() if os.path.exists(config): try: with open(config) as f_config: config_raw = f_config.read() validator = GlobalConfigValidator(sourcedir, json.loads(config_raw)) validator.validate() logger.info("Config is valid") except GlobalConfigValidatorException as e: logger.error(f"Config is not valid. Error: {e}") sys.exit(1) update_ta_version(config, ta_version) # handle_update check schemaVersion and update globalConfig.json if required and return schema schema_content = handle_update(config) scheme = GlobalConfigBuilderSchema(schema_content, j2_env) ta_version = schema_content.get("meta").get("version") logger.info("Addon Version : " + ta_version) ta_tabs = schema_content.get("pages").get("configuration").get("tabs") ta_namespace = schema_content.get("meta").get("restRoot") import_declare_name = "import_declare_test" is_inputs = "inputs" in schema_content.get("pages") logger.info("Package ID is " + ta_name) logger.info("Copy UCC template directory") recursive_overwrite(os.path.join(sourcedir, "package"), os.path.join(outputdir, ta_name)) logger.info("Copy globalConfig to output") shutil.copyfile( config, os.path.join( outputdir, ta_name, "appserver", "static", "js", "build", "globalConfig.json", ), ) ucc_lib_target = os.path.join(outputdir, ta_name, "lib") logger.info( f"Install add-on requirements into {ucc_lib_target} from {source}") install_libs(source, ucc_lib_target) replace_token(ta_name, outputdir) generate_rest(ta_name, scheme, import_declare_name, outputdir) modify_and_replace_token_for_oauth_templates( ta_name, ta_tabs, schema_content.get("meta").get("version"), outputdir) if is_inputs: add_modular_input(ta_name, schema_content, import_declare_name, outputdir) else: handle_no_inputs(ta_name, outputdir) make_modular_alerts(ta_name, ta_namespace, schema_content, outputdir) else: logger.info("Addon Version : " + ta_version) logger.warning( "Skipped generating UI components as globalConfig.json does not exist." ) ucc_lib_target = os.path.join(outputdir, ta_name, "lib") logger.info( f"Install add-on requirements into {ucc_lib_target} from {source}") install_libs(source, ucc_lib_target=ucc_lib_target) ignore_list = get_ignore_list( ta_name, os.path.abspath(os.path.join(source, PARENT_DIR, ".uccignore"))) remove_listed_files(ignore_list) logger.info("Copy package directory") recursive_overwrite(source, os.path.join(outputdir, ta_name)) default_meta_conf_path = os.path.join(outputdir, ta_name, "metadata", "default.meta") if not os.path.exists(default_meta_conf_path): os.makedirs(os.path.join(outputdir, ta_name, "metadata")) with open(default_meta_conf_path, "w") as default_meta_conf_fd: MetaConf().create_default(default_meta_conf_fd) # Update app.manifest with open(os.path.join(outputdir, ta_name, "VERSION"), "w") as version_file: version_file.write(version_str) version_file.write("\n") version_file.write(ta_version) manifest.update_addon_version(ta_version) output_manifest_path = os.path.abspath( os.path.join(outputdir, ta_name, APP_MANIFEST_FILE_NAME)) with open(output_manifest_path, "w") as manifest_file: manifest_file.write(str(manifest)) app_config = AppConf() path = os.path.join(outputdir, ta_name, "default", "app.conf") app_config.read(path) app_config.update(ta_version, ta_name, manifest.get_description(), manifest.get_title()) with open(path, "w") as app_conf_fd: app_config.write(app_conf_fd) # Copy Licenses license_dir = os.path.abspath(os.path.join(source, PARENT_DIR, "LICENSES")) if os.path.exists(license_dir): logger.info("Copy LICENSES directory ") recursive_overwrite(license_dir, os.path.join(outputdir, ta_name, "LICENSES")) if os.path.exists( os.path.abspath( os.path.join(source, PARENT_DIR, "additional_packaging.py"))): sys.path.insert(0, os.path.abspath(os.path.join(source, PARENT_DIR))) from additional_packaging import additional_packaging additional_packaging(ta_name)
# -- Project information ----------------------------------------------------- # General project metadata is stored in pyproject.toml with open(os.path.join(root, "pyproject.toml"), "rb") as f: config = tomli.load(f) project_meta = config["tool"]["poetry"] print(project_meta) project = project_meta["name"] author = project_meta["authors"][0] description = project_meta["description"] url = project_meta["homepage"] title = project + " Documentation" _version = Version.from_git() # The full version, including alpha/beta/rc tags release = _version.serialize(metadata=False) # The short X.Y.Z version version = _version.base # -- General configuration --------------------------------------------------- # If your documentation needs a minimal Sphinx version, state it here. # needs_sphinx = "2.0" # Add any Sphinx extension module names here, as strings. They can be # extensions coming with Sphinx (named 'sphinx.ext.*') or your custom # ones. extensions = [
# If extensions (or modules to document with autodoc) are in another directory, # add these directories to sys.path here. If the directory is relative to the # documentation root, use os.path.abspath to make it absolute, like shown here. # # import os # import sys # sys.path.insert(0, os.path.abspath('.')) # -- Project information ----------------------------------------------------- project = 'pydvdcss' copyright = '2021, PHOENiX' author = 'PHOENiX' # The full version, including alpha/beta/rc tags version = Version.from_git().serialize(style=Style.SemVer) release = Version.from_git().base # -- General configuration --------------------------------------------------- # Add any Sphinx extension module names here, as strings. They can be # extensions coming with Sphinx (named 'sphinx.ext.*') or your custom # ones. extensions = [ 'sphinx.ext.autosectionlabel', 'sphinx.ext.autodoc', 'myst_parser' ] # Add any paths that contain templates here, relative to this directory. templates_path = ['_templates'] # List of patterns, relative to source directory, that match files and
from setuptools import setup, find_namespace_packages import os from dunamai import Version REQUIRED = ["protobuf>=3.11.3", "grpclib>=0.3.1"] EXTRAS = {} # This is pretty hacky but dunamai expects things that don't # apply to our versioning scheme. VERSION_PATTERN = r"^(?P<base>\d+\.\d+\.\d+)((?P<stage>\.?)(?P<revision>\d+))?$" version = Version.from_git(pattern=VERSION_PATTERN, latest_tag=True) setup( name="zetasql", version=version.serialize(), description="gRPC client library for ZetaSQL", url="http://github.com/VideoAmp/zetasql", author="Gregory Bean", author_email="*****@*****.**", packages=find_namespace_packages("python"), package_dir={"": "python"}, package_data={"zetasql": ["py.typed", "**/*.pyi"]}, zip_safe=False, python_requires=">=3.7", install_requires=REQUIRED, extras_require=EXTRAS, include_package_data=True, setup_requires=["dunamai>=1.1.0"], )
# pylint: skip-file import os from pathlib import Path from dunamai import Style, Version DOCS_DIR = Path(__file__).parent.parent.resolve() ROOT_DIR = DOCS_DIR.parent SRC_DIR = DOCS_DIR / "source" # -- Project information ----------------------------------------------------- # https://www.sphinx-doc.org/en/master/usage/configuration.html#project-information project = "Runway" copyright = "2021, Onica Group" author = "Onica Group" release = Version.from_git().serialize(metadata=False, style=Style.SemVer) version = ".".join(release.split(".")[:2]) # short X.Y version # -- General configuration --------------------------------------------------- # https://www.sphinx-doc.org/en/master/usage/configuration.html#general-configuration add_function_parentheses = True add_module_names = True default_role = None exclude_patterns = [] extensions = [ "sphinx.ext.autodoc", "sphinx.ext.intersphinx", "sphinx.ext.napoleon", "sphinx.ext.viewcode", "sphinx_github_changelog", "sphinx_tabs.tabs",
def main(): parser = argparse.ArgumentParser(description="Build the add-on") parser.add_argument( "--source", type=str, nargs='?', help="Folder containing the app.manifest and app source", default="package", ) parser.add_argument( "--config", type=str, nargs='?', help="Path to configuration file, Defaults to GlobalConfig.json in parent directory of source provided", default=None ) version = Version.from_git() if not version.stage: stage = 'R' else: stage = version.stage[:1] version_str = version.serialize(metadata=True,style=Style.SemVer) version_splunk = f"{version.base}{stage}{version.commit}" parser.add_argument( "--ta-version", type=str, help="Version of TA, Deafult version is version specified in the package such as app.manifest, app.conf, and globalConfig.json", default = version_splunk ) args = parser.parse_args() ta_version = args.ta_version.strip() if not ta_version: ta_version = version_splunk if not os.path.exists(args.source): raise NotADirectoryError("{} not Found.".format(os.path.abspath(args.source))) # Setting default value to Config argument if not args.config: args.config = os.path.abspath(os.path.join(args.source, PARENT_DIR, "globalConfig.json")) clean_before_build() manifest= None with open(os.path.abspath(os.path.join(args.source, "app.manifest")), "r") as manifest_file: manifest = json.load(manifest_file) ta_name = manifest['info']['id']['name'] if os.path.exists(args.config): update_ta_version(args.config, ta_version) # handle_update check schemaVersion and update globalConfig.json if required and return schema schema_content = handle_update(args.config) scheme = GlobalConfigBuilderSchema(schema_content, j2_env) ta_version = schema_content.get("meta").get("version") logger.info("Addon Version : " + ta_version) ta_tabs = schema_content.get("pages").get("configuration").get("tabs") ta_namespace = schema_content.get("meta").get("restRoot") import_declare_name = "import_declare_test" is_inputs = ("inputs" in schema_content.get("pages")) logger.info("Package ID is " + ta_name) logger.info("Copy UCC template directory") recursive_overwrite( os.path.join(sourcedir,"package"), os.path.join(outputdir, ta_name) ) logger.info("Copy globalConfig to output") shutil.copyfile( args.config, os.path.join(outputdir, ta_name, "appserver", "static", "js", "build", "globalConfig.json"), ) ucc_lib_target = os.path.join(outputdir, ta_name, "lib") logger.info(f"Install Addon Requirements into {ucc_lib_target} from {args.source}") install_libs( args.source , ucc_lib_target ) replace_token(args, ta_name) generate_rest(args, ta_name, scheme, import_declare_name) modify_and_replace_token_for_oauth_templates( args, ta_name, ta_tabs, schema_content.get('meta').get('version') ) if is_inputs: add_modular_input( args, ta_name, schema_content, import_declare_name ) else: handle_no_inputs(ta_name) make_modular_alerts(args, ta_name, ta_namespace, schema_content) else: logger.info("Addon Version : " + ta_version) logger.warning("Skipped installing UCC required python modules as GlobalConfig.json does not exist.") logger.warning("Skipped Generating UI components as GlobalConfig.json does not exist.") logger.info("Setting TA name as generic") ucc_lib_target = os.path.join(outputdir, ta_name, "lib") install_libs( args.source, ucc_lib_target=ucc_lib_target ) ignore_list = get_ignore_list(ta_name, os.path.abspath(os.path.join(args.source, PARENT_DIR, ".uccignore"))) remove_listed_files(ignore_list) copy_package_source(args, ta_name) #Update app.manifest with open(os.path.join(outputdir, ta_name,'VERSION'), 'w') as version_file: version_file.write(version_str) version_file.write("\n") version_file.write(ta_version) manifest= None with open(os.path.abspath(os.path.join(outputdir, ta_name, "app.manifest")), "r") as manifest_file: manifest = json.load(manifest_file) manifest['info']['id']['version'] = ta_version with open(os.path.abspath(os.path.join(outputdir, ta_name, "app.manifest")), "w") as manifest_file: manifest_file.write(json.dumps(manifest, indent=4, sort_keys=True)) comment_map = save_comments(outputdir, ta_name) app_config = configparser.ConfigParser() app_config.read_file(open(os.path.join(outputdir, ta_name,'default', "app.conf"))) if not 'launcher' in app_config: app_config.add_section('launcher') if not 'id' in app_config: app_config.add_section('id') if not 'install' in app_config: app_config.add_section('install') if not 'package' in app_config: app_config.add_section('package') if not 'ui' in app_config: app_config.add_section('ui') app_config['launcher']['version'] = ta_version app_config['launcher']['description']=manifest['info']['description'] app_config['id']['version'] = ta_version app_config['install']['build']=str(int(time.time())) app_config['package']['id']=manifest['info']['id']['name'] app_config['ui']['label']=manifest['info']['title'] with open(os.path.join(outputdir, ta_name,'default', "app.conf"), 'w') as configfile: app_config.write(configfile) #restore License header restore_comments(outputdir, ta_name, comment_map) #Copy Licenses license_dir = os.path.abspath(os.path.join(args.source, PARENT_DIR, "LICENSES")) if os.path.exists(license_dir): logger.info("Copy LICENSES directory ") recursive_overwrite(license_dir, os.path.join(outputdir, ta_name,"LICENSES")) if os.path.exists(os.path.abspath(os.path.join(args.source,PARENT_DIR,"additional_packaging.py"))): sys.path.insert(0,os.path.abspath(os.path.join(args.source,PARENT_DIR))) from additional_packaging import additional_packaging additional_packaging(ta_name)
def test__get_version__defaults(config): v, s = plugin._get_version(config) assert v == Version.from_git() assert s == Version.from_git().serialize()