python-update-checker 0.6__py3-none-any.whl → 0.7__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
puc/dependencies.py CHANGED
@@ -4,6 +4,7 @@
4
4
 
5
5
  import subprocess
6
6
  import re
7
+ import logging
7
8
  from packaging.requirements import Requirement
8
9
  from packaging.markers import Variable, MarkerList
9
10
  from packaging.version import parse as parse_version
@@ -12,9 +13,9 @@ from .logging import logger
12
13
 
13
14
  def get_latest_version(
14
15
  package: str,
15
- exclude_newer: None | str = None,
16
- exclude_newer_package: None | str = None,
17
- constraint_file: None | str = None,
16
+ exclude_newer: str | None = None,
17
+ exclude_newer_package: str | None = None,
18
+ constraint_file: str | None = None,
18
19
  python_platform: str | None = None,
19
20
  python_version: str | None = None,
20
21
  ) -> str:
@@ -28,12 +29,15 @@ def get_latest_version(
28
29
  "compile",
29
30
  "-",
30
31
  "--color=never",
31
- "--quiet",
32
32
  "--no-deps",
33
33
  "--no-header",
34
34
  "--no-annotate",
35
35
  "--no-progress",
36
36
  ]
37
+ if logger.getEffectiveLevel() <= logging.DEBUG:
38
+ cmd.append("--verbose")
39
+ else:
40
+ cmd.append("--quiet")
37
41
  if exclude_newer:
38
42
  cmd.extend(("--exclude-newer", exclude_newer))
39
43
  if exclude_newer_package:
@@ -122,9 +126,9 @@ def get_min_python_version_from_req(pkg_req: Requirement) -> str | None:
122
126
 
123
127
  def parse_requirement(
124
128
  line: str,
125
- exclude_newer: None | str = None,
126
- constraint_file: None | str = None,
127
- ) -> None | str | Requirement:
129
+ exclude_newer: str | None = None,
130
+ constraint_file: str | None = None,
131
+ ) -> str | Requirement | None:
128
132
  """Parse one line of a requirements.txt file."""
129
133
  line = line.strip()
130
134
  if not line or line.startswith("#"):
puc/pyprojecttoml.py CHANGED
@@ -5,6 +5,7 @@
5
5
  import subprocess
6
6
  import os
7
7
  import tomllib
8
+ import logging
8
9
  from packaging.utils import canonicalize_name
9
10
  from packaging.requirements import Requirement
10
11
 
@@ -14,16 +15,17 @@ from .dependencies import (
14
15
  get_python_platform_from_req,
15
16
  get_min_python_version_from_req,
16
17
  check_requirement,
18
+ is_newer_version,
17
19
  )
18
20
 
19
21
 
20
22
  def handle_pyproject_toml(
21
23
  pyproject_path: str,
22
- command: None | str = None,
24
+ command: str | None = None,
23
25
  packages=None,
24
- exclude_newer: None | str = None,
25
- exclude_newer_package: None | str = None,
26
- constraint_file: None | str = None,
26
+ exclude_newer: str | None = None,
27
+ exclude_newer_package: str | None = None,
28
+ constraint_file: str | None = None,
27
29
  color: bool = True,
28
30
  ) -> int:
29
31
  """Check or update pinned dependencies of a pyproject.toml file.
@@ -96,13 +98,13 @@ def update_pyproject_dependencies(
96
98
  dependencies: list[str | dict],
97
99
  project_dir: str,
98
100
  projectname: str,
99
- group: None | str = None,
101
+ group: str | None = None,
100
102
  optional=False,
101
- command: None | str = None,
103
+ command: str | None = None,
102
104
  packages=None,
103
- exclude_newer: None | str = None,
104
- exclude_newer_package: None | str = None,
105
- constraint_file: None | str = None,
105
+ exclude_newer: str | None = None,
106
+ exclude_newer_package: str | None = None,
107
+ constraint_file: str | None = None,
106
108
  color: bool = True,
107
109
  ) -> int:
108
110
  """Update given dependency list of a pyproject.toml file."""
@@ -140,6 +142,10 @@ def update_pyproject_dependencies(
140
142
  spec = next(s for s in pkg_req.specifier)
141
143
  if latest_version is not None and latest_version != spec.version:
142
144
  updatable += 1
145
+ if not is_newer_version(spec.version, latest_version):
146
+ logger.warning(
147
+ f"{pkg_req.name} latest version {latest_version} is older than specified version {spec.version}"
148
+ )
143
149
  version = (
144
150
  colorize_updated_version(spec.version, latest_version)
145
151
  if color
@@ -160,7 +166,7 @@ def update_pyproject_pkg(
160
166
  dependency: str,
161
167
  package: str,
162
168
  projectdir: str,
163
- group: None | str = None,
169
+ group: str | None = None,
164
170
  optional: bool = False,
165
171
  ) -> None:
166
172
  """Update one package in pyproject.toml."""
@@ -169,11 +175,15 @@ def update_pyproject_pkg(
169
175
  "add",
170
176
  "--project",
171
177
  projectdir,
172
- "--quiet",
173
178
  "--frozen",
174
179
  "--color=never",
175
- f"--upgrade-package={package}",
180
+ "--upgrade-package",
181
+ package,
176
182
  ]
183
+ if logger.getEffectiveLevel() <= logging.DEBUG:
184
+ command.append("--verbose")
185
+ else:
186
+ command.append("--quiet")
177
187
  if optional and group:
178
188
  command.append("--optional")
179
189
  command.append(group)
puc/requirementstxt.py CHANGED
@@ -14,6 +14,7 @@ from .dependencies import (
14
14
  get_python_platform_from_req,
15
15
  get_min_python_version_from_req,
16
16
  parse_requirement,
17
+ is_newer_version,
17
18
  )
18
19
 
19
20
 
@@ -23,11 +24,11 @@ max_rec_level = 5
23
24
 
24
25
  def handle_requirements_txt(
25
26
  requirements_txt_path: str,
26
- command: None | str = None,
27
+ command: str | None = None,
27
28
  packages=None,
28
- exclude_newer: None | str = None,
29
- exclude_newer_package: None | str = None,
30
- constraint_file: None | str = None,
29
+ exclude_newer: str | None = None,
30
+ exclude_newer_package: str | None = None,
31
+ constraint_file: str | None = None,
31
32
  color: bool = True,
32
33
  rec_level: int = 0,
33
34
  handled_files: list[str] | None = None,
@@ -91,6 +92,10 @@ def handle_requirements_txt(
91
92
  output.write(line)
92
93
  elif latest_version is not None and latest_version != spec.version:
93
94
  updatable += 1
95
+ if not is_newer_version(spec.version, latest_version):
96
+ logger.warning(
97
+ f"{pkg_req.name} latest version {latest_version} is older than specified version {spec.version}"
98
+ )
94
99
  version = (
95
100
  colorize_updated_version(spec.version, latest_version)
96
101
  if color
puc/uvlock.py CHANGED
@@ -16,11 +16,11 @@ from .dependencies import (
16
16
 
17
17
  def handle_uv_lock(
18
18
  uvlock_path: str,
19
- command: None | str = None,
19
+ command: str | None = None,
20
20
  packages=None,
21
- exclude_newer: None | str = None,
22
- exclude_newer_package: None | str = None,
23
- constraint_file: None | str = None,
21
+ exclude_newer: str | None = None,
22
+ exclude_newer_package: str | None = None,
23
+ constraint_file: str | None = None,
24
24
  color: bool = True,
25
25
  ) -> int:
26
26
  """Check or update pinned dependencies of a uv.lock file."""
@@ -69,11 +69,11 @@ def update_uvlock_dependency(
69
69
  package,
70
70
  version,
71
71
  project_dir: str,
72
- command: None | str = None,
72
+ command: str | None = None,
73
73
  packages=None,
74
- exclude_newer: None | str = None,
75
- exclude_newer_package: None | str = None,
76
- constraint_file: None | str = None,
74
+ exclude_newer: str | None = None,
75
+ exclude_newer_package: str | None = None,
76
+ constraint_file: str | None = None,
77
77
  color: bool = True,
78
78
  ) -> int:
79
79
  """Update uv lock dependency."""
@@ -114,7 +114,7 @@ def update_uvlock_dependency(
114
114
  def update_uvlock_pkg(
115
115
  package: str,
116
116
  projectdir: str,
117
- exclude_newer: None | str = None,
117
+ exclude_newer: str | None = None,
118
118
  ) -> None:
119
119
  """Update one package in pyproject.toml."""
120
120
  command = [
@@ -124,7 +124,8 @@ def update_uvlock_pkg(
124
124
  projectdir,
125
125
  "--quiet",
126
126
  "--color=never",
127
- f"--upgrade-package={package}",
127
+ "--upgrade-package",
128
+ package,
128
129
  ]
129
130
  if exclude_newer:
130
131
  command.extend(
@@ -1,10 +1,10 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: python-update-checker
3
- Version: 0.6
3
+ Version: 0.7
4
4
  License-Expression: GPL-3.0-only
5
+ Classifier: Development Status :: 4 - Beta
5
6
  Classifier: Environment :: Console
6
7
  Classifier: Intended Audience :: Developers
7
- Classifier: Development Status :: 4 - Beta
8
8
  Classifier: Operating System :: OS Independent
9
9
  Classifier: Programming Language :: Python :: 3 :: Only
10
10
  Classifier: Programming Language :: Python :: 3.11
@@ -16,21 +16,25 @@ Requires-Dist: packaging>=26.1
16
16
  Requires-Python: >=3.11
17
17
  Description-Content-Type: text/markdown
18
18
 
19
- python-update-checker
20
- ======================
19
+ # python-update-checker
20
+
21
21
  Python-update-checker (puc) checks or updates pinned dependencies
22
22
  in `pyproject.toml`, `requirements.txt` or `uv.lock` files.
23
23
 
24
- See https://github.com/astral-sh/uv/issues/6794 for a discussion
25
- about different pinning strategies.
24
+ If you are developing an application you should pin all dependencies.
25
+ When developing a library, only development dependencies should be pinned.
26
+ Since puc updates pinned dependencies, it is mostly suitable
27
+ when developing applications.
26
28
 
29
+ See [https://github.com/astral-sh/uv/issues/6794] for a discussion
30
+ about different pinning strategies.
27
31
 
28
- Features
29
- ---------
32
+ ## Features
30
33
 
31
34
  * updates pinned dependencies, ignores unpinned dependencies
32
35
  * supports pyproject.toml, uv.lock and requirements.txt formats
33
- * supports `[project.dependencies]`, `[project.optional-dependencies]` and `[dependency-groups]` in pyproject.toml
36
+ * supports `[project.dependencies]`, `[project.optional-dependencies]`
37
+ and `[dependency-groups]` in pyproject.toml
34
38
  * supports recursive references (-r) in requirements.txt formats
35
39
  * can run in check only mode, ie. it checks if updates are available
36
40
  * limit updates to specific packages
@@ -39,11 +43,18 @@ Features
39
43
  * (limited) support for environment markers, ie. `"pywin32==311; os_name=='nt'"`
40
44
  * runs on Linux, MacOS and Windows platforms
41
45
 
46
+ ## Quickstart
47
+
48
+ ```bash
49
+
50
+ uvx --from python-update-checker puc --exclude-newer "1 day" update pyproject.toml
51
+ uv sync
52
+ ```
42
53
 
43
- Examples
44
- ---------
54
+ ## Examples
45
55
 
46
56
  ```bash
57
+
47
58
  $ # check all pinned packages for updates in pyproject.toml
48
59
  $ puc check pyproject.toml
49
60
  puc INFO: check pyproject file pyproject.toml
@@ -55,6 +66,8 @@ $ puc --exclude-newer="7 days" update pyproject.toml
55
66
  puc INFO: update pyproject file pyproject.toml
56
67
  puc INFO: updating 'ty==0.0.29' --> 0.0.31
57
68
  puc INFO: Wrote 1 updated package version(s) to pyproject.toml
69
+ $ # update the project environment after upgrading pyproject.toml
70
+ $ uv sync
58
71
 
59
72
  $ # check all pinned packages for updates in requirements.txt
60
73
  $ puc check requirements.txt
@@ -65,52 +78,49 @@ puc WARNING: found update 'Django==5.2.0' --> 6.0.4
65
78
  $ # update only the django package version in requirements.txt
66
79
  $ # limit updates to django versions less than 6
67
80
  $ puc --package="Django" --constraints="Django<6" update requirements.txt
68
- INFO: update requirements file requirements.txt
69
- INFO: updating 'Django==5.2.0' --> 5.2.13
70
- INFO: Wrote 1 updated package version(s) to requirements.txt
81
+ puc INFO: update requirements file requirements.txt
82
+ puc INFO: updating 'Django==5.2.0' --> 5.2.13
83
+ puc INFO: Wrote 1 updated package version(s) to requirements.txt
71
84
  ```
72
85
 
73
- Script behaviour
74
- -----------------
86
+ ## Script behaviour
75
87
 
76
88
  The exit code of `puc check` is non-zero when updates are available.
77
89
 
78
90
  Checking a `pyproject.toml` or `uv.lock`file with `puc` should be done
79
91
  from the directory of the `pyproject.toml` file,
80
- especially if your project relies on a [project directory](https://docs.astral.sh/uv/concepts/projects/layout/) (for example to define additional package indexes in pyproject.toml).
92
+ especially if your project relies on a [project directory](https://docs.astral.sh/uv/concepts/projects/layout/)
93
+ (for example to define additional package indexes in pyproject.toml).
81
94
 
82
95
  After updating versions in pyproject.toml, run `uv lock --upgrade` to update
83
- the transitive dependencies in `uv.lock`.
84
-
85
- Pinned dependencies are packages with `==` or `===` constraints and no wildcards in the version.
96
+ the transitive dependencies in `uv.lock` and `uv sync` to update your
97
+ virtual environment.
86
98
 
99
+ Pinned dependencies are packages with `==` or `===` constraints
100
+ and no wildcards in the version.
87
101
 
88
- Installation
89
- -------------
102
+ ## Installation
90
103
 
91
104
  1) Install [python uv](https://docs.astral.sh/uv/getting-started/installation/)
92
- 2) Install puc with `uv pip install python-update-checker`.
105
+ 2) Install puc with `uv pip install python-update-checker`
106
+ or run with `uvx --from python-update-checker puc ...`
93
107
 
94
-
95
-
96
- Architecture
97
- -------------
108
+ ## Architecture
98
109
 
99
110
  Dependencies are
100
111
 
101
112
  * [uv](https://docs.astral.sh/uv/):
102
113
  The uv binary must be available for the script to call.
103
114
  puc uses `echo "package" | uv pip compile -` to get latest package versions.
104
- puc uses `uv add "package==<version>"` to update pyproject.toml dependencies.
115
+ puc uses `uv add "package==<version>"` to update pyproject.toml
116
+ dependencies and `uv lock --upgrade-package` to update uv.lock dependencies.
105
117
 
106
118
  * [packaging](https://packaging.pypa.io/):
107
119
  Parses dependencies with the packaging.requirements.Requirement class.
108
120
 
109
121
  puc needs Python >= 3.11 since it uses the tomllib Python module.
110
122
 
111
-
112
- Limitations
113
- ------------
123
+ ## Limitations
114
124
 
115
125
  * No support for custom dependency formats in pyproject.toml
116
126
  (eg. `[tool.poetry.dependencies]`).
@@ -0,0 +1,11 @@
1
+ puc/__init__.py,sha256=QCJeo6rsztgAeIuufaaId2f-x_XYLjs4UywOPp4w7ks,67
2
+ puc/cli.py,sha256=mzbs7TZsuI0_PgRgIAzHRxmKDa02cBrLjtn7qTE2wwQ,7417
3
+ puc/dependencies.py,sha256=4XLPiCnulGVT29bVB6Blkh9irjUGxfChP01YqqofYTw,6717
4
+ puc/logging.py,sha256=VBojYqr7-l-aLeNqrBqTJyHuEINzdBx1CObQg5XiC-k,2222
5
+ puc/pyprojecttoml.py,sha256=pJxA9oZoxiiB7b06yr0hub7um1A1eyrKf7WgPf1KBEU,6905
6
+ puc/requirementstxt.py,sha256=xzEKVmWvZVbIQt9lZ0hVykOapn8xX24a7FixX1dY4lU,5076
7
+ puc/uvlock.py,sha256=O_y3iwJ4pfq0wtrDYJoOdmAHn2XY71N0Iql0ycrRoW0,4160
8
+ python_update_checker-0.7.dist-info/WHEEL,sha256=y6e-a5KI2W-qDAJKfh9Xr81bin8NgUdfWgz3VSXXpe4,80
9
+ python_update_checker-0.7.dist-info/entry_points.txt,sha256=mQuGfBukyjyo7ssOHSIycAlRdQkrA1ewAth6tsV_T60,38
10
+ python_update_checker-0.7.dist-info/METADATA,sha256=5rmVjEA_PA4so2oFay-ZbrocnMn7TlYWZQ_cxe1yGxE,4883
11
+ python_update_checker-0.7.dist-info/RECORD,,
@@ -1,4 +1,4 @@
1
1
  Wheel-Version: 1.0
2
- Generator: uv 0.11.14
2
+ Generator: uv 0.12.9
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
@@ -1,11 +0,0 @@
1
- puc/__init__.py,sha256=QCJeo6rsztgAeIuufaaId2f-x_XYLjs4UywOPp4w7ks,67
2
- puc/cli.py,sha256=mzbs7TZsuI0_PgRgIAzHRxmKDa02cBrLjtn7qTE2wwQ,7417
3
- puc/dependencies.py,sha256=RySjC6TLJVypWBQpiW-7RmoKm1qGbb_4eR-3C3UtEkw,6597
4
- puc/logging.py,sha256=VBojYqr7-l-aLeNqrBqTJyHuEINzdBx1CObQg5XiC-k,2222
5
- puc/pyprojecttoml.py,sha256=EgcJrKU4oz5sa16PyARKacjSL9AJt7xaXkv8lOVk4OA,6515
6
- puc/requirementstxt.py,sha256=Tv6-b14ko9HLmaYRanqtH7y0WSXUxNi8I5QqzbbjbyY,4788
7
- puc/uvlock.py,sha256=NCrottrNvId2Klwt4eI9Gi8ZIVQ_3pEC_uYLM-nqDW4,4154
8
- python_update_checker-0.6.dist-info/WHEEL,sha256=fWriCkzqm-pffF5af4gJC9iI5FMFaJTuN9UxxxzOmdY,81
9
- python_update_checker-0.6.dist-info/entry_points.txt,sha256=mQuGfBukyjyo7ssOHSIycAlRdQkrA1ewAth6tsV_T60,38
10
- python_update_checker-0.6.dist-info/METADATA,sha256=bEEB2OTxGN15FAeGv-JY57FT_nXkVerT1dfxQd8Sa2s,4350
11
- python_update_checker-0.6.dist-info/RECORD,,