deepspeed

Форк
0
/
check-extraindexurl.py 
42 строки · 1.3 Кб
1
#!/usr/bin/env python3
2
# Copyright (c) Microsoft Corporation.
3
# SPDX-License-Identifier: Apache-2.0
4

5
# DeepSpeed Team
6

7
from __future__ import annotations
8
'''Copyright The Microsoft DeepSpeed Team'''
9
"""
10
Checks each file in sys.argv for the string "--extra-index-url".
11
Modified from https://github.com/jlebar/pre-commit-hooks/blob/master/check_do_not_submit.py
12
"""
13

14
import subprocess
15
import sys
16

17

18
def err(s: str) -> None:
19
    print(s, file=sys.stderr)
20

21

22
print(*sys.argv[1:])
23

24
# There are many ways we could search for the string "--extra-index-url", but `git
25
# grep --no-index` is nice because
26
#  - it's very fast (as compared to iterating over the file in Python)
27
#  - we can reasonably assume it's available on all machines
28
#  - unlike plain grep, which is slower and has different flags on MacOS versus
29
#    Linux, git grep is always the same.
30
res = subprocess.run(
31
    ["git", "grep", "-Hn", "--no-index", "-e", r"--extra-index-url", *sys.argv[1:]],
32
    capture_output=True,
33
)
34
if res.returncode == 0:
35
    err('Error: The string "--extra-index-url" was found.\nPlease replace all calls to --extra-index-url with "--index-url"'
36
        )
37
    err(res.stdout.decode("utf-8"))
38
    sys.exit(1)
39
elif res.returncode == 2:
40
    err(f"Error invoking grep on {', '.join(sys.argv[1:])}:")
41
    err(res.stderr.decode("utf-8"))
42
    sys.exit(2)
43

Использование cookies

Мы используем файлы cookie в соответствии с Политикой конфиденциальности и Политикой использования cookies.

Нажимая кнопку «Принимаю», Вы даете АО «СберТех» согласие на обработку Ваших персональных данных в целях совершенствования нашего веб-сайта и Сервиса GitVerse, а также повышения удобства их использования.

Запретить использование cookies Вы можете самостоятельно в настройках Вашего браузера.