def createNamespacePackage(module_name, is_top, module_relpath):
    source_ref = SourceCodeReference.fromFilenameAndLine(
        filename=module_relpath, line=1)
    source_ref = source_ref.atInternal()

    package = CompiledPythonPackage(
        module_name=module_name,
        is_top=is_top,
        mode="compiled",
        future_spec=FutureSpec(),
        source_ref=source_ref,
    )

    if python_version >= 300:
        statement = createPython3NamespacePath(package=package,
                                               module_relpath=module_relpath,
                                               source_ref=source_ref)
    else:
        statement = createPathAssignment(package, source_ref)

    package.setBody(makeStatementsSequenceFromStatement(statement=statement))

    completeVariableClosures(package)

    return source_ref, package
def createNamespacePackage(package_name, module_relpath):
    parts = package_name.split('.')

    source_ref = SourceCodeReference.fromFilenameAndLine(
        filename    = module_relpath,
        line        = 1,
        future_spec = FutureSpec(),
    )
    source_ref = source_ref.atInternal()

    package_package_name = '.'.join(parts[:-1]) or None
    package = CompiledPythonPackage(
        name         = parts[-1],
        package_name = package_package_name,
        source_ref   = source_ref,
    )

    if python_version >= 300:
        statement = createPython3NamespacePath(
            package_name   = package_name,
            module_relpath = module_relpath,
            source_ref     = source_ref
        )
    else:
        statement = createPathAssignment(source_ref)

    package.setBody(
        makeStatementsSequenceFromStatement(
            statement = statement
        )
    )

    completeVariableClosures(package)

    return source_ref, package
def createNamespacePackage(package_name, module_relpath):
    parts = package_name.split('.')

    source_ref = SourceCodeReference.fromFilenameAndLine(
        filename=module_relpath,
        line=1,
        future_spec=FutureSpec(),
    )
    source_ref = source_ref.atInternal()

    package_package_name = '.'.join(parts[:-1]) or None
    package = CompiledPythonPackage(
        name=parts[-1],
        mode="compiled",
        package_name=package_package_name,
        source_ref=source_ref,
    )

    if python_version >= 300:
        statement = createPython3NamespacePath(package_name=package_name,
                                               module_relpath=module_relpath,
                                               source_ref=source_ref)
    else:
        statement = createPathAssignment(source_ref)

    package.setBody(makeStatementsSequenceFromStatement(statement=statement))

    completeVariableClosures(package)

    return source_ref, package
def createNamespacePackage(module_name, package_name, is_top, module_relpath):
    source_ref = SourceCodeReference.fromFilenameAndLine(
        filename=module_relpath, line=1
    )
    source_ref = source_ref.atInternal()

    package_name = package_name or None

    package = CompiledPythonPackage(
        name=module_name,
        package_name=package_name,
        is_top=is_top,
        mode="compiled",
        future_spec=FutureSpec(),
        source_ref=source_ref,
    )

    if python_version >= 300:
        statement = createPython3NamespacePath(
            package=package, module_relpath=module_relpath, source_ref=source_ref
        )
    else:
        statement = createPathAssignment(package, source_ref)

    package.setBody(makeStatementsSequenceFromStatement(statement=statement))

    completeVariableClosures(package)

    return source_ref, package