diff options
author | Zachary Ware <zachary.ware@gmail.com> | 2017-06-16 03:08:51 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-06-16 03:08:51 (GMT) |
commit | 51599e2bdd10ab77212a7cbb41a13ea70ee13da8 (patch) | |
tree | fcab1fc60d7fc81f55836dde4faa7b9067327443 /PCbuild/get_external.py | |
parent | 7a801839e9a88bdcac5aaab494b532230fcf7caa (diff) | |
download | cpython-51599e2bdd10ab77212a7cbb41a13ea70ee13da8.zip cpython-51599e2bdd10ab77212a7cbb41a13ea70ee13da8.tar.gz cpython-51599e2bdd10ab77212a7cbb41a13ea70ee13da8.tar.bz2 |
bpo-30450: Pull Windows dependencies from GitHub rather than svn (GH-1783)
The Windows build now depends on Python 3.6 to fetch externals, but it will be downloaded via NuGet (which is downloaded via PowerShell) if it is not available via `py -3.6`. This means the only thing that must be installed on a modern Windows box to do a full build of CPython with all extensions is Visual Studio.
Also fixes an outdated note about _lzma in PCbuild/readme.txt
Diffstat (limited to 'PCbuild/get_external.py')
-rw-r--r-- | PCbuild/get_external.py | 60 |
1 files changed, 60 insertions, 0 deletions
diff --git a/PCbuild/get_external.py b/PCbuild/get_external.py new file mode 100644 index 0000000..a682d38 --- /dev/null +++ b/PCbuild/get_external.py @@ -0,0 +1,60 @@ +#!/usr/bin/env python3 + +import argparse +import os +import pathlib +import zipfile +from urllib.request import urlretrieve + + +def fetch_zip(commit_hash, zip_dir, *, org='python', binary=False, verbose): + repo = f'cpython-{"bin" if binary else "source"}-deps' + url = f'https://github.com/{org}/{repo}/archive/{commit_hash}.zip' + reporthook = None + if verbose: + reporthook = print + zip_dir.mkdir(parents=True, exist_ok=True) + filename, headers = urlretrieve( + url, + zip_dir / f'{commit_hash}.zip', + reporthook=reporthook, + ) + return filename + + +def extract_zip(externals_dir, zip_path): + with zipfile.ZipFile(os.fspath(zip_path)) as zf: + zf.extractall(os.fspath(externals_dir)) + return externals_dir / zf.namelist()[0].split('/')[0] + + +def parse_args(): + p = argparse.ArgumentParser() + p.add_argument('-v', '--verbose', action='store_true') + p.add_argument('-b', '--binary', action='store_true', + help='Is the dependency in the binary repo?') + p.add_argument('-O', '--organization', + help='Organization owning the deps repos', default='python') + p.add_argument('-e', '--externals-dir', type=pathlib.Path, + help='Directory in which to store dependencies', + default=pathlib.Path(__file__).parent.parent / 'externals') + p.add_argument('tag', + help='tag of the dependency') + return p.parse_args() + + +def main(): + args = parse_args() + zip_path = fetch_zip( + args.tag, + args.externals_dir / 'zips', + org=args.organization, + binary=args.binary, + verbose=args.verbose, + ) + final_name = args.externals_dir / args.tag + extract_zip(args.externals_dir, zip_path).replace(final_name) + + +if __name__ == '__main__': + main() |