File: vendoring.py

package info (click to toggle)
python-py 1.11.0-5
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 1,512 kB
  • sloc: python: 11,660; makefile: 119; sh: 7
file content (41 lines) | stat: -rw-r--r-- 1,033 bytes parent folder | download | duplicates (22)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
from __future__ import absolute_import, print_function
import os.path
import shutil
import subprocess
import sys

VENDOR_TARGET = "py/_vendored_packages"
GOOD_FILES = ('README.md', '__init__.py')


def remove_libs():
    print("removing vendored libs")
    for filename in os.listdir(VENDOR_TARGET):
        if filename not in GOOD_FILES:
            path = os.path.join(VENDOR_TARGET, filename)
            print(" ", path)
            if os.path.isfile(path):
                os.remove(path)
            else:
                shutil.rmtree(path)


def update_libs():
    print("installing libs")
    subprocess.check_call((
        sys.executable, '-m', 'pip', 'install',
        '--target', VENDOR_TARGET, 'apipkg', 'iniconfig',
    ))
    subprocess.check_call(('git', 'add', VENDOR_TARGET))
    print("Please commit to finish the update after running the tests:")
    print()
    print('    git commit -am "Updated vendored libs"')


def main():
    remove_libs()
    update_libs()


if __name__ == '__main__':
    exit(main())