def METHOD_NAME(
    package: Package, graph: Graph, doc_namespace: str, external_doc_ref_to_namespace: Dict[str, str]
):
    package_resource = URIRef(add_namespace_to_spdx_id(package.spdx_id, doc_namespace, external_doc_ref_to_namespace))
    graph.add((package_resource, RDF.type, SPDX_NAMESPACE.Package))
    graph.add((package_resource, SPDX_NAMESPACE.name, Literal(package.name)))
    add_optional_literal(package.version, graph, package_resource, SPDX_NAMESPACE.versionInfo)
    add_optional_literal(package.file_name, graph, package_resource, SPDX_NAMESPACE.packageFileName)
    add_optional_literal(package.supplier, graph, package_resource, SPDX_NAMESPACE.supplier)
    add_optional_literal(package.originator, graph, package_resource, SPDX_NAMESPACE.originator)
    add_literal_or_no_assertion_or_none(
        package.download_location, graph, package_resource, SPDX_NAMESPACE.downloadLocation
    )
    graph.add((package_resource, SPDX_NAMESPACE.filesAnalyzed, Literal(package.files_analyzed, datatype=XSD.boolean)))
    add_package_verification_code_to_graph(package.verification_code, graph, package_resource)
    for checksum in package.checksums:
        add_checksum_to_graph(checksum, graph, package_resource)
    add_optional_literal(package.homepage, graph, package_resource, DOAP.homepage)
    add_optional_literal(package.source_info, graph, package_resource, SPDX_NAMESPACE.sourceInfo)
    add_license_expression_or_none_or_no_assertion(
        package.license_concluded, graph, package_resource, SPDX_NAMESPACE.licenseConcluded, doc_namespace
    )
    add_license_expression_or_none_or_no_assertion(
        package.license_info_from_files, graph, package_resource, SPDX_NAMESPACE.licenseInfoFromFiles, doc_namespace
    )
    add_license_expression_or_none_or_no_assertion(
        package.license_declared, graph, package_resource, SPDX_NAMESPACE.licenseDeclared, doc_namespace
    )
    add_optional_literal(package.license_comment, graph, package_resource, SPDX_NAMESPACE.licenseComments)
    add_optional_literal(package.copyright_text, graph, package_resource, SPDX_NAMESPACE.copyrightText)
    add_optional_literal(package.summary, graph, package_resource, SPDX_NAMESPACE.summary)
    add_optional_literal(package.description, graph, package_resource, SPDX_NAMESPACE.description)
    add_optional_literal(package.comment, graph, package_resource, RDFS.comment)
    for external_reference in package.external_references:
        add_external_package_ref_to_graph(external_reference, graph, package_resource, doc_namespace)
    for attribution_text in package.attribution_texts:
        add_optional_literal(attribution_text, graph, package_resource, SPDX_NAMESPACE.attributionText)
    if package.primary_package_purpose:
        graph.add(
            (
                package_resource,
                SPDX_NAMESPACE.primaryPackagePurpose,
                SPDX_NAMESPACE[f"purpose_{snake_case_to_camel_case(package.primary_package_purpose.name)}"],
            )
        )
    add_datetime_to_graph(package.release_date, graph, package_resource, SPDX_NAMESPACE.releaseDate)
    add_datetime_to_graph(package.built_date, graph, package_resource, SPDX_NAMESPACE.builtDate)
    add_datetime_to_graph(package.valid_until_date, graph, package_resource, SPDX_NAMESPACE.validUntilDate)