41ec94b758aac39c13f59e694fba5ed096a51ba9,src/python/pants/backend/python/rules/run_setup_py.py,,get_sources,#Any#,466

Before Change


async def get_sources(request: SetupPySourcesRequest) -> SetupPySources:
    targets = request.targets
    stripped_srcs_list = await MultiGet(
        Get(
            SourceRootStrippedSources,
            StripSourcesFieldRequest(
                target.get(Sources),
                for_sources_types=(PythonSources, ResourcesSources),
                enable_codegen=True,
            ),
        )
        for target in targets
    )

    // Create a chroot with all the sources, and any ancestor __init__.py files that might be needed
    // for imports to work.  Note that if a repo has multiple exported targets under a single ancestor
    // package, then that package must be a namespace package, which in Python 3 means it must not
    // have an __init__.py. We don"t validate this here, because it would require inspecting *all*
    // targets, whether or not they are in the target set for this run - basically the entire repo.
    // So it"s the repo owners" responsibility to ensure __init__.py hygiene.
    stripped_srcs_digests = [
        stripped_sources.snapshot.digest for stripped_sources in stripped_srcs_list
    ]
    ancestor_init_pys = await Get(AncestorInitPyFiles, Targets, targets)
    sources_digest = await Get(
        Digest, MergeDigests((*stripped_srcs_digests, *ancestor_init_pys.digests))
    )
    init_py_digest_contents = await Get(
        DigestContents, DigestSubset(sources_digest, PathGlobs(["**/__init__.py"]))
    )

After Change



@rule
async def get_sources(request: SetupPySourcesRequest) -> SetupPySources:
    python_sources = await Get(
        StrippedPythonSources,
        StrippedPythonSourcesRequest(
            targets=request.targets, include_resources=False, include_files=False
        ),
    )
    all_sources = await Get(
        StrippedPythonSources,
        StrippedPythonSourcesRequest(
            targets=request.targets, include_resources=True, include_files=True
        ),
    )

    python_files = set(python_sources.snapshot.files)
    all_files = set(all_sources.snapshot.files)
    resource_files = all_files - python_files

    init_py_digest_contents = await Get(
        DigestContents, DigestSubset(python_sources.snapshot.digest, PathGlobs(["**/__init__.py"]))
    )
Italian Trulli
In pattern: SUPERPATTERN

Frequency: 3

Non-data size: 8

Instances


Project Name: pantsbuild/pants
Commit Name: 41ec94b758aac39c13f59e694fba5ed096a51ba9
Time: 2020-08-01
Author: benjyw@gmail.com
File Name: src/python/pants/backend/python/rules/run_setup_py.py
Class Name:
Method Name: get_sources


Project Name: pantsbuild/pants
Commit Name: 500e1268ceddfe67674ae2a3b741f1ea199046c0
Time: 2020-09-21
Author: benjyw@gmail.com
File Name: src/python/pants/backend/python/goals/create_python_binary.py
Class Name:
Method Name: create_python_binary


Project Name: pantsbuild/pants
Commit Name: 500e1268ceddfe67674ae2a3b741f1ea199046c0
Time: 2020-09-21
Author: benjyw@gmail.com
File Name: src/python/pants/backend/python/goals/run_python_binary.py
Class Name:
Method Name: create_python_binary_run_request