MCPcopy Index your code
hub / github.com/python/cpython / package

Function package

Android/android.py:762–810  ·  view source on GitHub ↗
(context)

Source from the content-addressed store, hash-verified

760
761
762def package(context):
763 prefix_dir = subdir(context.host, "prefix")
764 version = package_version(prefix_dir)
765
766 with TemporaryDirectory(prefix=SCRIPT_NAME) as temp_dir:
767 temp_dir = Path(temp_dir)
768
769 # Include all tracked files from the Android directory.
770 for line in run(
771 ["git", "ls-files"],
772 cwd=ANDROID_DIR, capture_output=True, text=True, log=False,
773 ).stdout.splitlines():
774 src = ANDROID_DIR / line
775 dst = temp_dir / line
776 dst.parent.mkdir(parents=True, exist_ok=True)
777 shutil.copy2(src, dst, follow_symlinks=False)
778
779 # Include anything from the prefix directory which could be useful
780 # either for embedding Python in an app, or building third-party
781 # packages against it.
782 for rel_dir, patterns in [
783 ("include", ["openssl*", "python*", "sqlite*"]),
784 ("lib", ["engines-3", "libcrypto*.so", "libpython*", "libsqlite*",
785 "libssl*.so", "ossl-modules", "python*"]),
786 ("lib/pkgconfig", ["*crypto*", "*ssl*", "*python*", "*sqlite*"]),
787 ]:
788 for pattern in patterns:
789 for src in glob(f"{prefix_dir}/{rel_dir}/{pattern}"):
790 dst = temp_dir / relpath(src, prefix_dir.parent)
791 dst.parent.mkdir(parents=True, exist_ok=True)
792 if Path(src).is_dir():
793 shutil.copytree(
794 src, dst, symlinks=True,
795 ignore=lambda *args: ["__pycache__"]
796 )
797 else:
798 shutil.copy2(src, dst, follow_symlinks=False)
799
800 # Strip debug information.
801 if not context.debug:
802 so_files = glob(f"{temp_dir}/**/*.so", recursive=True)
803 run([android_env(context.host)["STRIP"], *so_files], log=False)
804
805 dist_dir = subdir(context.host, "dist", create=True)
806 package_path = shutil.make_archive(
807 f"{dist_dir}/python-{version}-{context.host}", "gztar", temp_dir
808 )
809 print(f"Wrote {package_path}")
810 return package_path
811
812
813def ci(context):

Callers

nothing calls this directly

Calls 12

TemporaryDirectoryClass · 0.90
PathClass · 0.90
globFunction · 0.90
relpathFunction · 0.90
android_envFunction · 0.85
make_archiveMethod · 0.80
subdirFunction · 0.70
package_versionFunction · 0.70
runFunction · 0.70
splitlinesMethod · 0.45
mkdirMethod · 0.45
is_dirMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…