INNER CODE UNIT · Python

get_version

brentp/peddy · setup.py:12

def get_version():
    """Get the version info from the mpld3 package without importing it"""
    import ast

    with open(os.path.join("peddy", "__init__.py"), "r") as init_file:
        module = ast.parse(init_file.read())

    version = (ast.literal_eval(node.value) for node in ast.walk(module)
             if isinstance(node, ast.Assign)
             and node.targets[0].id == "__version__")
    try:
        return next(version)
    except StopIteration:
        raise ValueError("version could not be located")

setup(
    version=get_version(),
    name='peddy',

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…