File: gen_requirements.py

package info (click to toggle)
python-license-expression 30.4.1-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 1,588 kB
  • sloc: python: 6,130; sh: 315; makefile: 51
file content (57 lines) | stat: -rw-r--r-- 1,724 bytes parent folder | download
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
# -*- coding: utf-8 -*-
#
# 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.6/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()