def METHOD_NAME(tmp_path, with_lockfile):
    archive_path = tmp_path / "test1.zip"
    with zipfile.ZipFile(archive_path, mode="w") as fh_zip:
        fh_zip.writestr("packageA/c/a.py", "1+1")
        fh_zip.writestr("packageA/d.c", "x = 1")
    wheel_data = {
        "a.so": "abc",
        "b.txt": "123",
        "METADATA": "a",
        "packageB/a.py": "1+1",
    }
    input_wheel_path = _create_tmp_wheel(
        "packageB", base_dir=tmp_path, data=wheel_data, tag="py3-none-any"
    )
    lockfile_path = tmp_path / "pyodide-lock.json"
    lockfile = {
        "info": {"arch": "wasm32"},
        "packages": {
            "packageA": {"version": "1.0", "file_name": archive_path.name},
            "packageB": {"version": "1.0", "file_name": input_wheel_path.name},
            "packageC": {
                "version": "1.0",
                "file_name": "some-path.tar",
                "checksum": "123",
            },
        },
    }
    expected_in = {"test1.zip", "packageB-0.1.0-py3-none-any.whl"}
    expected_out = {"test1.zip", "packageb-0.1.0-cp311-none-any.whl"}
    if with_lockfile:
        with open(lockfile_path, "w") as fh:
            json.dump(lockfile, fh)
        expected_in.add("pyodide-lock.json")
        expected_out.add("pyodide-lock.json")
    assert set(el.name for el in tmp_path.glob("*")) == expected_in
    mapping = _py_compile_archive_dir(tmp_path, keep=False)
    assert mapping == {
        "packageB-0.1.0-py3-none-any.whl": "packageb-0.1.0-cp311-none-any.whl",
        "test1.zip": "test1.zip",
    }
    assert set(el.name for el in tmp_path.glob("*")) == expected_out
    if not with_lockfile:
        return
    with open(lockfile_path) as fh:
        lockfile_new = json.load(fh)
    assert lockfile_new["info"] == lockfile["info"]
    assert lockfile_new["packages"]["packageA"]["file_name"] == "test1.zip"
    # sha256 is not reproducible, since it depends on the timestamp
    assert len(lockfile_new["packages"]["packageA"]["sha256"]) == 64
    assert (
        lockfile_new["packages"]["packageB"]["file_name"]
        == "packageb-0.1.0-cp311-none-any.whl"
    )
    assert len(lockfile_new["packages"]["packageA"]["sha256"]) == 64
    assert lockfile_new["packages"]["packageC"] == {
        "version": "1.0",
        "file_name": "some-path.tar",
        "checksum": "123",
    }