Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Extremely fast with uv #35

Merged
merged 1 commit into from
Feb 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ dependencies = [
"click < 9",
"ruff < 1",
"mypy < 2",
"pip-tools < 8",
"pytest < 8",
"result < 1",
"build < 2",
Expand All @@ -28,6 +27,7 @@ dependencies = [
"tomlkit < 1",
"pdoc < 15",
"mashumaro[orjson,toml] < 4",
"uv < 1",
]

[project.optional-dependencies]
Expand Down
12 changes: 5 additions & 7 deletions pyrgo/cmds/lock.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,14 @@ def _initial_args(
*,
upgrade: bool,
) -> list[str]:
base_args = ["compile"]
base_args = ["pip", "compile"]
if upgrade:
base_args.append("-U")
base_args.append("--upgrade")

if env == core_deps_alias:
return base_args

base_args.extend(["--no-strip-extras", "--extra", env])
base_args.extend(["--extra", env])
return base_args


Expand All @@ -45,8 +45,6 @@ def _complete_cmd(

cmd.add_args(
args=[
"--strip-extras",
"--resolver=backtracking",
"-o",
config.requirements.joinpath(f"{env}.txt")
.relative_to(config.cwd)
Expand Down Expand Up @@ -98,7 +96,7 @@ def lock(*, generate_hashes: bool, envs: tuple[str, ...], upgrade: bool) -> None
all_commands.extend(
_complete_cmd(
cmd=PythonCommandExec(
program="piptools",
program="uv",
).add_args(
args=_initial_args(
env=env,
Expand All @@ -121,7 +119,7 @@ def lock(*, generate_hashes: bool, envs: tuple[str, ...], upgrade: bool) -> None
all_commands.append(
_complete_cmd(
cmd=PythonCommandExec(
program="piptools",
program="uv",
).add_args(
args=_initial_args(
env=env,
Expand Down
21 changes: 7 additions & 14 deletions pyrgo/cmds/sync.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,36 +19,29 @@
type=click.STRING,
required=True,
)
@click.option(
"--editable/--no-editable",
"editable",
type=click.BOOL,
default=True,
show_default=True,
)
def sync(env: str, *, editable: bool) -> None:
def sync(env: str) -> None:
"""Sync current python environment to locked deps."""
config = PyrgoConf()
ensure_env_exist(env=env, config=config, where="lock-files")

piptools_command = PythonCommandExec(
program="piptools",
program="uv",
).add_args(
args=[
"pip",
"sync",
config.requirements.joinpath(f"{env}.txt")
.relative_to(config.cwd)
.as_posix(),
],
)
pip_command = PythonCommandExec(
program="pip",
program="uv",
).add_args(
args=["install", "--no-deps"],
args=["pip", "install"],
)
if editable:
pip_command.add_args(args=["-e"])
pip_command.add_args(args=["."])

pip_command.add_args(args=["-e", "."])

program_execution = inform_and_run_program(
commands=[
Expand Down
3 changes: 1 addition & 2 deletions pyrgo/typing.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@
PyrgoProgram: TypeAlias = Literal[
"ruff",
"mypy.dmypy",
"piptools",
"pip",
"uv",
"build",
"pytest",
"pip_audit",
Expand Down
47 changes: 9 additions & 38 deletions requirements/core.txt
Original file line number Diff line number Diff line change
@@ -1,27 +1,15 @@
#
# This file is autogenerated by pip-compile with Python 3.9
# by the following command:
#
# pip-compile --output-file=requirements/core.txt --strip-extras pyproject.toml
#
# This file was autogenerated by uv v0.1.0 via the following command:
# uv pip compile --upgrade -o requirements/core.txt pyproject.toml
boolean-py==4.0
# via license-expression
build==1.0.3
# via
# pip-tools
# pyrgo (pyproject.toml)
cachecontrol==0.14.0
# via
# cachecontrol
# pip-audit
# via pip-audit
certifi==2024.2.2
# via requests
charset-normalizer==3.3.2
# via requests
click==8.1.7
# via
# pip-tools
# pyrgo (pyproject.toml)
cyclonedx-python-lib==6.4.1
# via pip-audit
defusedxml==0.7.1
Expand Down Expand Up @@ -49,18 +37,14 @@ markupsafe==2.1.5
# jinja2
# pdoc
mashumaro==3.12
# via
# mashumaro
# pyrgo (pyproject.toml)
mdurl==0.1.2
# via markdown-it-py
msgpack==1.0.7
# via cachecontrol
mypy==1.8.0
# via pyrgo (pyproject.toml)
mypy-extensions==1.0.0
# via mypy
orjson==3.9.13
orjson==3.9.14
# via mashumaro
packageurl-python==0.13.4
# via cyclonedx-python-lib
Expand All @@ -71,18 +55,16 @@ packaging==23.2
# pip-requirements-parser
# pytest
pdoc==14.4.0
# via pyrgo (pyproject.toml)
pip==24.0
# via pip-api
pip-api==0.0.30
# via pip-audit
pip-audit==2.7.0
# via pyrgo (pyproject.toml)
pip-audit==2.7.1
pip-requirements-parser==32.0.1
# via pip-audit
pip-tools==7.3.0
# via pyrgo (pyproject.toml)
pluggy==1.4.0
# via pytest
py-serializable==1.0.0
py-serializable==1.0.1
# via cyclonedx-python-lib
pygments==2.17.2
# via
Expand All @@ -93,17 +75,14 @@ pyparsing==3.1.1
pyproject-hooks==1.0.0
# via build
pytest==7.4.4
# via pyrgo (pyproject.toml)
requests==2.31.0
# via
# cachecontrol
# pip-audit
result==0.16.0
# via pyrgo (pyproject.toml)
rich==13.7.0
# via pip-audit
ruff==0.2.1
# via pyrgo (pyproject.toml)
six==1.16.0
# via html5lib
sortedcontainers==2.4.0
Expand All @@ -115,30 +94,22 @@ tomli==2.0.1
# build
# mashumaro
# mypy
# pip-tools
# pyproject-hooks
# pytest
# vulture
tomli-w==1.0.0
# via mashumaro
tomlkit==0.12.3
# via pyrgo (pyproject.toml)
typing-extensions==4.9.0
# via
# mashumaro
# mypy
# result
urllib3==2.2.0
# via requests
uv==0.1.0
vulture==2.11
# via pyrgo (pyproject.toml)
webencodings==0.5.1
# via html5lib
wheel==0.42.0
# via pip-tools
zipp==3.17.0
# via importlib-metadata

# The following packages are considered to be unsafe in a requirements file:
# pip
# setuptools
56 changes: 11 additions & 45 deletions requirements/dev.txt
Original file line number Diff line number Diff line change
@@ -1,31 +1,17 @@
#
# This file is autogenerated by pip-compile with Python 3.9
# by the following command:
#
# pip-compile --extra=dev --output-file=requirements/dev.txt --strip-extras pyproject.toml
#
# This file was autogenerated by uv v0.1.0 via the following command:
# uv pip compile --upgrade --extra dev -o requirements/dev.txt pyproject.toml
boolean-py==4.0
# via license-expression
build==1.0.3
# via
# pip-tools
# pyrgo (pyproject.toml)
cachecontrol==0.14.0
# via
# cachecontrol
# pip-audit
# via pip-audit
certifi==2024.2.2
# via requests
charset-normalizer==3.3.2
# via requests
click==8.1.7
# via
# pip-tools
# pyrgo (pyproject.toml)
coverage==7.4.1
# via
# coverage
# pytest-cov
# via pytest-cov
cyclonedx-python-lib==6.4.1
# via pip-audit
defusedxml==0.7.1
Expand Down Expand Up @@ -53,18 +39,14 @@ markupsafe==2.1.5
# jinja2
# pdoc
mashumaro==3.12
# via
# mashumaro
# pyrgo (pyproject.toml)
mdurl==0.1.2
# via markdown-it-py
msgpack==1.0.7
# via cachecontrol
mypy==1.8.0
# via pyrgo (pyproject.toml)
mypy-extensions==1.0.0
# via mypy
orjson==3.9.13
orjson==3.9.14
# via mashumaro
packageurl-python==0.13.4
# via cyclonedx-python-lib
Expand All @@ -75,18 +57,16 @@ packaging==23.2
# pip-requirements-parser
# pytest
pdoc==14.4.0
# via pyrgo (pyproject.toml)
pip==24.0
# via pip-api
pip-api==0.0.30
# via pip-audit
pip-audit==2.7.0
# via pyrgo (pyproject.toml)
pip-audit==2.7.1
pip-requirements-parser==32.0.1
# via pip-audit
pip-tools==7.3.0
# via pyrgo (pyproject.toml)
pluggy==1.4.0
# via pytest
py-serializable==1.0.0
py-serializable==1.0.1
# via cyclonedx-python-lib
pygments==2.17.2
# via
Expand All @@ -97,21 +77,16 @@ pyparsing==3.1.1
pyproject-hooks==1.0.0
# via build
pytest==7.4.4
# via
# pyrgo (pyproject.toml)
# pytest-cov
# via pytest-cov
pytest-cov==4.1.0
# via pyrgo (pyproject.toml)
requests==2.31.0
# via
# cachecontrol
# pip-audit
result==0.16.0
# via pyrgo (pyproject.toml)
rich==13.7.0
# via pip-audit
ruff==0.2.1
# via pyrgo (pyproject.toml)
six==1.16.0
# via html5lib
sortedcontainers==2.4.0
Expand All @@ -124,32 +99,23 @@ tomli==2.0.1
# coverage
# mashumaro
# mypy
# pip-tools
# pyproject-hooks
# pytest
# vulture
tomli-w==1.0.0
# via mashumaro
tomlkit==0.12.3
# via pyrgo (pyproject.toml)
types-toml==0.10.8.7
# via pyrgo (pyproject.toml)
typing-extensions==4.9.0
# via
# mashumaro
# mypy
# result
urllib3==2.2.0
# via requests
uv==0.1.0
vulture==2.11
# via pyrgo (pyproject.toml)
webencodings==0.5.1
# via html5lib
wheel==0.42.0
# via pip-tools
zipp==3.17.0
# via importlib-metadata

# The following packages are considered to be unsafe in a requirements file:
# pip
# setuptools
4 changes: 2 additions & 2 deletions tests/test_command_exec.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@ def test_new(self, program: PyrgoProgram) -> None:
argnames=["command", "args", "expected"],
argvalues=[
(
PythonCommandExec(program="pip"),
PythonCommandExec(program="uv"),
["1", "2"],
["pip", "1", "2"],
["uv", "1", "2"],
),
],
)
Expand Down
Loading