Commit Graph

25526 Commits

Author SHA1 Message Date
toofar d701f327dd Recompile requirements with uv pip compile
Changes in this commit should be limited to:
* lines changing order (they are sorted now)
* jaraco.text, jaraco.collections, autocommand, inflect, typeguard are
  gone now (setuptools vendored packages that were being included from
  the venv)
* comments added showing why dependencies are included
2025-04-25 18:57:52 +12:00
toofar 161ce7bfce Allow setuptools and pip in compiled requirements files
This aligns with the direction of pip-compile and uv, and removes some
code from this script. See:

    https://github.com/astral-sh/uv/issues/1353
    https://github.com/jazzband/pip-tools/issues/989#issuecomment-1134985118

The code being removed worked fine. So if it turns out that installing a
newer setuptools or pip in virtualenvs break stuff, it's fine to add
back.
2025-04-25 18:38:01 +12:00
toofar ea9619bfb3 Remove pip freeze based requirements compilation method 2025-04-25 18:38:01 +12:00
toofar a753d671a1 join strings safely 2025-04-25 18:38:00 +12:00
toofar 8575b9856d Specify tox requirement file name in full
Substring matches when you are actually only trying to match one
specific item is a smell, its unclear what's intended and causes the
reader to have to stop and think.
2025-04-25 18:38:00 +12:00
toofar f254a2ae94 Simplify empty lint check in recompile requirements
This is for parsing diffs like:

        # via importlib-metadata
    +
    + # The following packages were excluded from the output:
    + # setuptools

Otherwise further parsing breaks because it is looking for a package
name on the line.
2025-04-25 18:38:00 +12:00
toofar 5d8779a61e undo adaptations for setuptools vendored packages
see 433074c681, adf39e9f72, db83a82fe1 & 78a74a2e2a

Now that we are using pip-compile to build requirements lock files,
instead of pip-freeze, these things shouldn't be showing up in the
results.

Looks like `typeguard` was dropped in a192a3d9c7d0e87 "initial compile based bump"
I guess that was being pulled in by pip freeze too.
2025-04-25 18:38:00 +12:00
toofar a16ea8f710 Enable delightful pip compile lineage annotations
I find these comments useful to show why packages are included in the
final compiled requirements files.

Required a small change to `recompile_requirements` to ignore these new
comment line (it was saying there was a new requirement with an empty
name that needed a changelog entry).

The addition of the `os.path.realpath()` is to clean up the paths of the
requirements files in the annotations, eg:

     check-manifest==0.49
    -    # via -r scripts/dev/../../misc/requirements/requirements-check-manifest.txt-raw
    +    # via -r misc/requirements/requirements-check-manifest.txt-raw
2025-04-25 18:38:00 +12:00
toofar ac77f2b187 Remove slow test with poor isolation
It would have been convenient to have an end2end test to make sure that
the output of the two requirements file compilation methods had the same
results. But I think there is a bit too much stuff going on in
`recompile_requirements` for that atm.

Making the local repo in the temp path and install fake packages there
works fine, although setting up the virtualenv isn't quick. But the
script currently installs pip, setuptools and wheel which means we have
to either 1) hit pypi.org in the tests to get them, or 2) download them at
the start of the test suite and put them in the local repo.

Not sure it's worth the effort to go down this rabbit hole when we
already have a dozen real requirements files to verify the change with.

I'm leaving this in the commit history because it was fun to get the
local repo working!
2025-04-25 18:38:00 +12:00
toofar 48c15d3e1c Add pip and setuptools back to tox requirement file
For the pip freeze backend pip is being passed `--all` when the tox
requirements file is being processed so that pip and setuptools are
included in the requirements file. This was added in 922dca039b
for reasons I haven't fully grokked.

This commit adds similar behaviour for the pip compile backend via:
1. don't add the --no-emit-package args for the tox requirements file
2. add pip and setuptools to the tox requirements file

It seems that pip and setuptools aren't even requirements of tox, but
they are being included in the compiled requirements file anyway. Why
aren't the included in the raw requirements file? I don't know, but from
what I can figure it's not going to harm anything to have them in there.
2025-04-25 18:38:00 +12:00
toofar 2ee9f561af Exclude setuptools from pip-compile output
This is to match the `pip freeze` requirements compilation method. It's
not clear to me if we actually want this behaviour or not.

If seems `pip freeze` will exclude dependencies of itself: https://pip.pypa.io/en/stable/cli/pip_freeze/#cmdoption-all
Even if there are other packages installed that depend on those
dependencies.

`uv pip compile`, and now the original `pip-compile` both have decided
to include setuptools in generated requirements files:

    https://github.com/astral-sh/uv/issues/1353
    https://github.com/jazzband/pip-tools/issues/989#issuecomment-1134985118

So I'm not sure if we have a reason for going against this here or if
they were just being excluded because that's what pip freeze does.

Hopefully we can drop this commit and use the default behaviour in the
future. For now when I'm trying to provide the new backend it's here to
make the diff of generated files more precise.

This message prefix to identify a pip compile comment was taken from
these examples:

    # The following packages were excluded from the output:
    # setuptool

    # The following packages are considered to be unsafe in a requirements file:
    # setuptools==41.4.0        # via protobuf
2025-04-25 18:38:00 +12:00
toofar ae884a6da4 normalize package names pip freeze output too
This lets us more easily compare the output of runs of the different
requirements compiling methods.
2025-04-25 18:38:00 +12:00
toofar 857448ee77 normalize package names in requirements lock files
`pip freeze` writes out package names as specified by the packages, `pip
compile` writes out normalized package names. Sticking to normalized
names in robot written files lets us more easily compare the output of
the two different requirement compiling methods and also mean we can
stop worrying about packages changing between `_` and `-` in dependency
updates.

Script used to do this change was:

    import re
    import glob

    def normalize_pkg(name):
        """Normalize a package name for comparisons.

        From https://packaging.python.org/en/latest/specifications/name-normalization/#name-normalization
        `pip freeze` passes file names though in whatever case they are in in the
        package, pip-compile will normalize them.
        """
        if "/" in name:  # don't change file paths
            return name
        return re.sub(r"[-_.]+", "-", name).lower()

    def normalize_line(line):
        if not line or not line.strip():
            return line
        if "==" not in line.split()[0]:
            return line

        pkg, version = line.split("==", maxsplit=1)
        return "==".join([normalize_pkg(pkg), version])

    for name in ["requirements.txt"] + glob.glob("misc/requirements/requirements*.txt"):
        with open(name) as f:
          before_lines = f.readlines()
        after_lines = [normalize_line(line) for line in before_lines]
        with open(name, mode="w") as f:
          f.writelines(after_lines)
2025-04-25 18:37:58 +12:00
toofar c0d1ae7661 Add tests for comments supported by recompile_requirements
Since I was looking at how hard it would be to support using pip-compile
to recompute requirements, I was worried that I would break the markers
we support in the raw requirements files.

This adds two tests:
* disabled_test_markers_real_pip_and_venv
  A test that sets up a local python index and runs the real pip/uv
  binaries. It works (and it was fun to setup a package index factory)
  but has a couple of downsides:
  1. it hits the real pypi index, which is not great in a test. This can
     be prevented by removing the EXTRA bit from the INDEX_URL env vars
     and pre-downloading pip, wheel, setuptools and uv to the test repo
     (and adding index.htmls for them). But because of the next item I'm
     not sure it's worth the effort of keeping this test around
  2. it's slow because of having to download packages from the internet
     (even if we pre-cached them it would still have to download them, I
     guess we could include a zip of fixed/vendored versions, but that
     will probably require maintenance over time) and because it cals
     venv to make new virtual environments, which isn't the quickest
     operation (maybe uv venv is quicker?)
* test_markers_in_comments
  Tests just the comment reading and line manipulation logic. Could be
  made a bit more pure by just calling read_comments() and
  convert_line(), but that wouldn't test that "add" marker.
2025-04-25 18:36:45 +12:00
toofar 8251b0f134 Combine the two "build_requirements" methods
There was a fair bit of duplicate code, so I've pulled out the "take a
list of requirements, give me a new one" out to separate methods. The
stuff around parsing the output can stay common thankfully!

Even if we drop one of the methods this level of abstraction is probably
fine to keep.
2025-04-25 18:36:45 +12:00
toofar be12df63cb Normalize module level CHANGELOG_URLS for misc check
The CHANGELOG_URLS variable is imported by the
`./scripts/dev/misc_checks.py changelog-urls` check. Since there is a
bit of churn in package name case in this change (and a while back when
a bunch of packages switched between underscores and hyphens), update
this variable at import time so that that checker will be looking at
normalized names too.
2025-04-25 18:36:45 +12:00
toofar b4c8f06a97 Use pip compile to find new deps instead of install and freeze
In #8269 we saw some packages leaking into the pip freeze output that we
don't want in the requirements files (if setuptools isn't supposed to be
in there, why should its dependencies).
I've also greatly missed the comments that pip-compile puts in
requirements.txt files explaining where indirect dependencies come from.
So I took the opportunity to switch our tooling for updating and parsing
new dependencies and their versions to use pip-compile instead of `pip -U
install && pip freeze`.

It turned out to not be a big change because the pip freeze output is
largely compatible with requirements files (we are writing directly to
one after all). So we just need to switch what commands we are running
and triage any compatibility issues.

I chose `uv pip compile` instead of `pip-compile` because I like what uv
is doing (fast, aiming for compatibility, consolidating a confusing
ecosystem into a single tool). But pip-compile/tools should do the same
job if we want to go that route.

The biggest differences are:
* outputs normalized names: this generally results in a larger diff than
  otherwise (I propose we go through an regenerate all the requirements
  files in one go, and maybe add that commit to a blame ignore file) and
  requires our comparison logic to deal with normalized package names
  everywhere
* setuptools and pip not included in tox requirement file - not sure
  what to do about that yet, should they be in the .text-raw file?

TODO:
* remove support for pip_args?
* change markers in raw files to lower case? Ideally don't require, if a human
  can write them in any case and a robot can normalize we should do that. If
  if there are patterns with `._` in them as part of names, how do we handle
  that?
* pull out similar bits of `build_requirements*` methods
  * maybe make it so you can pass `requirements=None` to `init_venv` to
    make it not install stuff, install uv, do the uv invocation, gate
    all that behind a `--method="freeze|compile"` arg?
* add pip and setuptools to tox requirements file?
* basename requirements file names so they don't have
* `script_path/../../` in them in the annotated version
* add tests for the markers (with inputs of differing cases) to make
  sure they all still work
* update changelog check used in CI to normalize names too
2025-04-25 18:36:45 +12:00
toofar b3138d1be8
Merge pull request #8553 from qutebrowser/update-dependencies
Update dependencies
2025-04-25 18:36:08 +12:00
toofar e67aea60e8 Update changelog link for mypy extensions 2025-04-25 16:50:07 +12:00
toofar 67e7677523 Downgrade hypothesis
Skip this hypothesis version pending https://github.com/HypothesisWorks/hypothesis/issues/4375
Our test suite is currently failing due to running python with `-b` and
being configured to fail on warnings.

We'll pick it up on the next update run or so.
2025-04-25 16:47:01 +12:00
qutebrowser bot 9249c5cb0e Update dependencies 2025-04-25 04:33:28 +00:00
Florian Bruhin c601bd0c7a
Merge pull request #8545 from qutebrowser/update-dependencies
Update dependencies
2025-04-17 11:19:31 +02:00
Florian Bruhin f9933d2f3e userscripts: Properly avoid tldextract warning
The previous fix in 3dc212a815 was insufficient,
as the inner `getattr(extract_result, "registered_domain")` was always evaluated
first (thus triggering the deprecation warning again).

We also cannot do:

    getattr(extract_result, "top_domain_under_public_suffix", None) or extract_result.registered_domain

as `""` is a valid value for it.
2025-04-17 11:11:33 +02:00
qutebrowser bot 95f9472a6b Update dependencies 2025-04-14 04:21:48 +00:00
toofar 701046cd9f
Merge pull request #8537 from qutebrowser/update-dependencies
Update dependencies
2025-04-14 12:08:02 +12:00
Florian Bruhin aa41b6719f tests: Ignore another message 2025-04-13 14:53:21 +02:00
Florian Bruhin 05b42c57ee ci: Fix config properly... 2025-04-13 13:40:37 +02:00
Florian Bruhin 77b5c0c1cd ci: Fix config 2025-04-13 13:37:44 +02:00
Florian Bruhin 84ec45c13f ci: Try Python 3.14 again
Cache is now cleared, so it might just work
2025-04-13 13:28:34 +02:00
Florian Bruhin ecbca59dea Update changelog 2025-04-13 10:25:43 +02:00
qutebrowser bot 67d8e012a3 Release v3.5.0 2025-04-12 21:28:50 +00:00
Florian Bruhin dea1de5dab Update changelog 2025-04-12 21:33:19 +02:00
Florian Bruhin 9aa53ea205 tests: Wait for tab-close being run properly
Leaks into the next test otherwise, making it flaky.
2025-04-12 21:28:30 +02:00
Florian Bruhin 7bc6c33bb5 Reapply "tests: Try to stabilize test_auto_leave_insert_mode"
This reverts commit 1d2faf2fa2.

This seems to be correct, the issue is the previous test not waiting until it's
finished properly.
2025-04-12 21:25:11 +02:00
Florian Bruhin 9e0f7ccc51 tests: Make sure we don't leave stale download managers behind
Speculative fix for test_early_timeout_handler in
tests/unit/utils/usertypes/test_timer.py failing:

    >  assert len(caplog.messages) == 1
    E  AssertionError: assert 5 == 1

due to:

    ------------------------------ Captured log call -------------------------------
    WARNING  misc:usertypes.py:467 Timer download-update (id 620757000) triggered too early: interval 500 but only -609.805s passed
    WARNING  misc:usertypes.py:467 Timer download-update (id 922746881) triggered too early: interval 500 but only -609.429s passed
    WARNING  misc:usertypes.py:467 Timer download-update (id 1056964613) triggered too early: interval 500 but only -609.537s passed
    WARNING  misc:usertypes.py:467 Timer download-update (id 1912602631) triggered too early: interval 500 but only -609.671s passed
    WARNING  misc:usertypes.py:467 Timer t (id -1) triggered too early: interval 3 but only 0.001s passed
2025-04-12 21:16:30 +02:00
Florian Bruhin 1d2faf2fa2 Revert "tests: Try to stabilize test_auto_leave_insert_mode"
This reverts commit f6f2a1252b.

Does more harm than good, for reasons I don't entirely understand yet.
2025-04-11 19:45:41 +02:00
Florian Bruhin f6f2a1252b tests: Try to stabilize test_auto_leave_insert_mode
We sometimes tried to use hints before the page was fully rendered (?), thus
causing no elements to be found.

It also doesn't make much sense to test leaving insert mode if we aren't in
insert mode yet, so make sure we entered it first.

See #5390
2025-04-11 17:28:31 +02:00
Florian Bruhin 86c89e00c5 Qt 6.9: Skip more qutescheme tests
If the renderer process crash happens, rerunning
doesn't seem to fix anything, even if the page is
opened in a new tab.

See #8536
2025-04-11 17:18:51 +02:00
Florian Bruhin 4f4ad4147a Revert "tests: Try to combat Qt 6.9 flakiness more"
This reverts commit 7204168684.

Doesn't actually help on CI...
2025-04-11 17:18:32 +02:00
Florian Bruhin 13b87e5968 ci: Avoid Python 3.14 Alpha 7
See https://www.riverbankcomputing.com/pipermail/pyqt/2025-April/046210.html and #8529
2025-04-11 17:18:06 +02:00
Florian Bruhin 7204168684 tests: Try to combat Qt 6.9 flakiness more
See #8536
2025-04-11 16:00:45 +02:00
Florian Bruhin 3dc212a815 userscripts: Avoid tldextract warning 2025-04-11 15:41:59 +02:00
Florian Bruhin 351fef8c1e Update comment 2025-04-10 15:52:50 +02:00
Florian Bruhin 4053249229 tests: Fix deprecated usage 2025-04-08 21:11:43 +02:00
Florian Bruhin 8b820f015b ci/tox/requirements: Update for Qt 6.9 2025-04-08 21:09:32 +02:00
Florian Bruhin afeb1ebbaa tests: Fix TestYamlMigrations.test_user_agent 2025-04-08 20:50:13 +02:00
Florian Bruhin 6b5ebe7187 Add a test for js_async crash
Follow-up to c32f5afcc4
See #3895 and #8400.
2025-04-08 20:47:54 +02:00
Florian Bruhin c073a30afe Update changelog 2025-04-08 20:38:50 +02:00
Florian Bruhin b16551548f Remove QtWebEngine/... from default UA
Good old https://webaim.org/blog/user-agent-string-history/ strikes yet again.
Let's just masquerade as Chromium instead of the constant pointless fight.
2025-04-08 20:28:15 +02:00
Florian Bruhin 961a9390da Remove the ua-slack site specific quirk
Closes #8510
2025-04-08 20:19:34 +02:00