From 84c355e9616974727e816634bf15b44f5d126cec Mon Sep 17 00:00:00 2001 From: Adam Johnson Date: Mon, 22 Apr 2024 14:21:03 +0100 Subject: [PATCH] Use uv for requirements (#87) --- requirements/compile.py | 236 +++++++++++++++++----------------------- 1 file changed, 102 insertions(+), 134 deletions(-) diff --git a/requirements/compile.py b/requirements/compile.py index 6ceadc9..6fac895 100755 --- a/requirements/compile.py +++ b/requirements/compile.py @@ -4,232 +4,200 @@ import os import subprocess import sys +from functools import partial from pathlib import Path if __name__ == "__main__": os.chdir(Path(__file__).parent) - os.environ["CUSTOM_COMPILE_COMMAND"] = "requirements/compile.py" - os.environ["PIP_REQUIRE_VIRTUALENV"] = "0" common_args = [ - "-m", - "piptools", + "uv", + "pip", "compile", + "--quiet", "--generate-hashes", - "--allow-unsafe", - ] + sys.argv[1:] - subprocess.run( - [ - "python3.8", - *common_args, - "-P", - "Django>=3.2a1,<3.3", - "-o", + "--constraint", + "-", + "requirements.in", + *sys.argv[1:], + ] + run = partial(subprocess.run, check=True) + run( + [ + *common_args, + "--python", + "3.8", + "--output-file", "py38-django32.txt", ], - check=True, - capture_output=True, + input=b"Django>=3.2a1,<3.3", ) - subprocess.run( + run( [ - "python3.8", *common_args, - "-P", - "Django>=4.0a1,<4.1", - "-o", + "--python", + "3.8", + "--output-file", "py38-django40.txt", ], - check=True, - capture_output=True, + input=b"Django>=4.0a1,<4.1", ) - subprocess.run( + run( [ - "python3.8", *common_args, - "-P", - "Django>=4.1a1,<4.2", - "-o", + "--python", + "3.8", + "--output-file", "py38-django41.txt", ], - check=True, - capture_output=True, + input=b"Django>=4.1a1,<4.2", ) - subprocess.run( + run( [ - "python3.8", *common_args, - "-P", - "Django>=4.2a1,<5.0", - "-o", + "--python", + "3.8", + "--output-file", "py38-django42.txt", ], - check=True, - capture_output=True, + input=b"Django>=4.2a1,<5.0", ) - subprocess.run( + run( [ - "python3.9", *common_args, - "-P", - "Django>=3.2a1,<3.3", - "-o", + "--python", + "3.9", + "--output-file", "py39-django32.txt", ], - check=True, - capture_output=True, + input=b"Django>=3.2a1,<3.3", ) - subprocess.run( + run( [ - "python3.9", *common_args, - "-P", - "Django>=4.0a1,<4.1", - "-o", + "--python", + "3.9", + "--output-file", "py39-django40.txt", ], - check=True, - capture_output=True, + input=b"Django>=4.0a1,<4.1", ) - subprocess.run( + run( [ - "python3.9", *common_args, - "-P", - "Django>=4.1a1,<4.2", - "-o", + "--python", + "3.9", + "--output-file", "py39-django41.txt", ], - check=True, - capture_output=True, + input=b"Django>=4.1a1,<4.2", ) - subprocess.run( + run( [ - "python3.9", *common_args, - "-P", - "Django>=4.2a1,<5.0", - "-o", + "--python", + "3.9", + "--output-file", "py39-django42.txt", ], - check=True, - capture_output=True, + input=b"Django>=4.2a1,<5.0", ) - subprocess.run( + run( [ - "python3.10", *common_args, - "-P", - "Django>=3.2a1,<3.3", - "-o", + "--python", + "3.10", + "--output-file", "py310-django32.txt", ], - check=True, - capture_output=True, + input=b"Django>=3.2a1,<3.3", ) - subprocess.run( + run( [ - "python3.10", *common_args, - "-P", - "Django>=4.0a1,<4.1", - "-o", + "--python", + "3.10", + "--output-file", "py310-django40.txt", ], - check=True, - capture_output=True, + input=b"Django>=4.0a1,<4.1", ) - subprocess.run( + run( [ - "python3.10", *common_args, - "-P", - "Django>=4.1a1,<4.2", - "-o", + "--python", + "3.10", + "--output-file", "py310-django41.txt", ], - check=True, - capture_output=True, + input=b"Django>=4.1a1,<4.2", ) - subprocess.run( + run( [ - "python3.10", *common_args, - "-P", - "Django>=4.2a1,<5.0", - "-o", + "--python", + "3.10", + "--output-file", "py310-django42.txt", ], - check=True, - capture_output=True, + input=b"Django>=4.2a1,<5.0", ) - subprocess.run( + run( [ - "python3.10", *common_args, - "-P", - "Django>=5.0a1,<5.1", - "-o", + "--python", + "3.10", + "--output-file", "py310-django50.txt", ], - check=True, - capture_output=True, + input=b"Django>=5.0a1,<5.1", ) - subprocess.run( + run( [ - "python3.11", *common_args, - "-P", - "Django>=4.1a1,<4.2", - "-o", + "--python", + "3.11", + "--output-file", "py311-django41.txt", ], - check=True, - capture_output=True, + input=b"Django>=4.1a1,<4.2", ) - subprocess.run( + run( [ - "python3.11", *common_args, - "-P", - "Django>=4.2a1,<5.0", - "-o", + "--python", + "3.11", + "--output-file", "py311-django42.txt", ], - check=True, - capture_output=True, + input=b"Django>=4.2a1,<5.0", ) - subprocess.run( + run( [ - "python3.11", *common_args, - "-P", - "Django>=5.0a1,<5.1", - "-o", + "--python", + "3.11", + "--output-file", "py311-django50.txt", ], - check=True, - capture_output=True, + input=b"Django>=5.0a1,<5.1", ) - subprocess.run( + run( [ - "python3.12", *common_args, - "-P", - "Django>=4.2a1,<5.0", - "-o", + "--python", + "3.12", + "--output-file", "py312-django42.txt", ], - check=True, - capture_output=True, + input=b"Django>=4.2a1,<5.0", ) - subprocess.run( + run( [ - "python3.12", *common_args, - "-P", - "Django>=5.0a1,<5.1", - "-o", + "--python", + "3.12", + "--output-file", "py312-django50.txt", ], - check=True, - capture_output=True, + input=b"Django>=5.0a1,<5.1", )