-
-
Notifications
You must be signed in to change notification settings - Fork 721
Expand file tree
/
Copy pathgen_requirements.py
More file actions
executable file
·57 lines (48 loc) · 1.67 KB
/
gen_requirements.py
File metadata and controls
executable file
·57 lines (48 loc) · 1.67 KB
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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#!/usr/bin/env python
#
# Copyright (c) nexB Inc. and others. All rights reserved.
# ScanCode is a trademark of nexB Inc.
# SPDX-License-Identifier: Apache-2.0
# See http://www.apache.org/licenses/LICENSE-2.0 for the license text.
# See https://github.com/aboutcode-org/skeleton for support or download.
# See https://aboutcode.org for more information about nexB OSS projects.
#
import argparse
import pathlib
import utils_requirements
"""
Utilities to manage requirements files.
NOTE: this should use ONLY the standard library and not import anything else
because this is used for boostrapping with no requirements installed.
"""
def gen_requirements():
description = """
Create or replace the `--requirements-file` file FILE requirements file with all
locally installed Python packages.all Python packages found installed in `--site-packages-dir`
"""
parser = argparse.ArgumentParser(description=description)
parser.add_argument(
"-s",
"--site-packages-dir",
dest="site_packages_dir",
type=pathlib.Path,
required=True,
metavar="DIR",
help="Path to the 'site-packages' directory where wheels are installed "
"such as lib/python3.12/site-packages",
)
parser.add_argument(
"-r",
"--requirements-file",
type=pathlib.Path,
metavar="FILE",
default="requirements.txt",
help="Path to the requirements file to update or create.",
)
args = parser.parse_args()
utils_requirements.lock_requirements(
site_packages_dir=args.site_packages_dir,
requirements_file=args.requirements_file,
)
if __name__ == "__main__":
gen_requirements()