Add script to compare with pip(-tools) (#335)

Add a script to compare with pip-tools and pydantic input we can compare
with it. Below is the output for `pydantic.in`, created from pydantic's
pyproject.toml, which i added for that purpose:

```console
$ scripts/compare_with_pip.sh scripts/benchmarks/requirements/pydantic.in
      Finished dev [unoptimized + debuginfo] target(s) in 0.08s
       Running `target/debug/puffin pip-compile scripts/benchmarks/requirements/pydantic.in`
  Resolved 85 packages in 1.61s

  real    0m1,733s
  user    0m1,714s
  sys     0m0,048s

  real    0m10,843s
  user    0m4,811s
  sys     0m0,399s
  --- /tmp/tmp.Y3FzvQ2xxo/pip-compile.txt 2023-11-06 15:47:29.221834123 +0100
  +++ /tmp/tmp.Y3FzvQ2xxo/puffin.txt      2023-11-06 15:47:18.377408860 +0100
  @@ -31,7 +31,7 @@
   mdurl==0.1.2
   memray==1.10.0
   mergedeep==1.3.4
  -mike @ git+https://github.com/jimporter/mike.git
  +mike @ git+https://github.com/jimporter/mike.git@076a4af3270a448f6aeb880c9c6c2fc0d80f603f
   mkdocs==1.5.3
   mkdocs-autorefs==0.5.0
   mkdocs-embed-external-markdown==3.0.1
  @@ -52,7 +52,7 @@
   py-cpuinfo==9.0.0
   pydantic==2.4.2
   pydantic-core==2.10.1
  -pydantic-extra-types @ git+https://github.com/pydantic/pydantic-extra-types.git@main
  +pydantic-extra-types @ git+https://github.com/pydantic/pydantic-extra-types.git@a973b7942112df731e2618336e55e3343a2e1c32
   pydantic-settings==2.0.3
   pyflakes==3.1.0
   pygments==2.16.1
  @@ -61,7 +61,7 @@
   pytest==7.4.3
   pytest-benchmark==4.0.0
   pytest-examples==0.0.10
  -pytest-memray==1.5.0 ; platform_system != "Windows"
  +pytest-memray==1.5.0
   pytest-mock==3.12.0
   pytest-pretty==1.2.0
   python-dateutil==2.8.2
```
This commit is contained in:
konsti 2023-11-07 16:32:12 +01:00 committed by GitHub
parent 692d2eb26f
commit 91d0fdbbdf
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 59 additions and 0 deletions

View file

@ -0,0 +1,42 @@
# Based on https://github.com/pydantic/pydantic/blob/1e32b011ed0ad260d0b94939ac84585ce0a229e1/pyproject.toml
# Replaced pydantic-core==2.11.0 with pydantic-core==2.10.1 to make it resolve because we lack the root pydantic from
# main here that exists when resolving the actual project
annotated-types>=0.4.0
ansi2html
autoflake
cloudpickle
coverage[toml]
devtools
dirty-equals
email-validator>=2.0.0
faker>=18.13.0
greenlet>=3.0.0rc3
importlib_metadata; python_version=='3.7'
mike @ git+https://github.com/jimporter/mike.git
mkdocs
mkdocs-embed-external-markdown
mkdocs-embed-external-markdown>=2.3.0
mkdocs-exclude
mkdocs-material
mkdocs-redirects
mkdocs-simple-hooks
mkdocstrings-python
mypy
mypy~=1.1.1
pydantic-core==2.10.1
pydantic-extra-types @ git+https://github.com/pydantic/pydantic-extra-types.git@main
pydantic-settings>=2.0.0
pydantic-settings>=2.0b1
pytest
pytest-benchmark>=4.0.0
pytest-examples
pytest-examples>=0.0.10
pytest-memray; platform_system != 'Windows'
pytest-memray==1.5.0
pytest-mock
pytest-pretty
pyupgrade
ruff==0.1.3
sqlalchemy>=2.0,<3.0
tomli
typing-extensions>=4.6.1

17
scripts/compare_with_pip.sh Executable file
View file

@ -0,0 +1,17 @@
#!/usr/bin/env bash
# Compare the resolutions of pip(-tools) and puffin, e.g.
# ```bash
# scripts/compare_with_pip.sh scripts/benchmarks/requirements/pydantic.in
# ```
set -euo pipefail
TEMPD=$(mktemp -d)
# `| grep -v " *#"` to ignore the comment when diffing
time RUST_LOG=puffin=debug cargo run --bin puffin -- pip-compile ${1} | grep -v " *#" > $TEMPD/puffin.txt
# > WARNING: --strip-extras is becoming the default in version 8.0.0. To silence this warning, either use --strip-extras
# > to opt into the new default or use --no-strip-extras to retain the existing behavior.
time pip-compile --strip-extras -o - -q ${1} | grep -v " *#" > $TEMPD/pip-compile.txt
diff -u $TEMPD/pip-compile.txt $TEMPD/puffin.txt