vercel-celery-bundle 0.7.2__tar.gz → 0.7.3__tar.gz

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.
@@ -1,3 +1,16 @@
1
+ Metadata-Version: 2.4
2
+ Name: vercel-celery-bundle
3
+ Version: 0.7.3
4
+ Summary: Celery integration for Vercel Queue and Runtime Cache
5
+ License-Expression: MIT
6
+ License-File: LICENSE
7
+ Requires-Python: >=3.10
8
+ Requires-Dist: celery<6,>=5.3
9
+ Requires-Dist: vercel-cache-bundle>=0.7.2
10
+ Requires-Dist: vercel-internal-shared-vendored-deps>=0.1.1
11
+ Requires-Dist: vercel-queue-bundle>=0.7.3
12
+ Description-Content-Type: text/markdown
13
+
1
14
  # vercel-celery-bundle
2
15
 
3
16
  This is a version of `vercel-celery` with third-party dependencies bundled. For normal use, install the unbundled `vercel-celery` package instead: https://pypi.org/project/vercel-celery/
@@ -38,6 +51,25 @@ poll delivery otherwise. Set `broker_url = "vercel-push://"` to force push
38
51
  delivery, or `broker_url = "vercel-poll://"` for forced polling workers, local
39
52
  workers, and background workers.
40
53
 
54
+ To deploy a Celery worker on Vercel, declare a module that exposes the Celery
55
+ app as a queue subscriber in `pyproject.toml`:
56
+
57
+ ```python
58
+ # worker.py
59
+ from tasks import app
60
+
61
+ __all__ = ["app"]
62
+ ```
63
+
64
+ ```toml
65
+ [[tool.vercel.subscribers]]
66
+ entrypoint = "worker:app"
67
+ ```
68
+
69
+ The Vercel build introspects the app's queues and compiles the subscriber into
70
+ a queue-triggered function; no `vercel.json` trigger configuration is needed.
71
+ With no `topics` filter, the subscriber consumes every queue the app declares.
72
+
41
73
  Pass `register_queues=False` to skip automatic Vercel Queue trigger
42
74
  registration. When using that mode, manually register each Celery app whose
43
75
  queues should receive Vercel Queue push deliveries:
@@ -1,16 +1,3 @@
1
- Metadata-Version: 2.4
2
- Name: vercel-celery-bundle
3
- Version: 0.7.2
4
- Summary: Celery integration for Vercel Queue and Runtime Cache
5
- License-Expression: MIT
6
- License-File: LICENSE
7
- Requires-Python: >=3.10
8
- Requires-Dist: celery<6,>=5.3
9
- Requires-Dist: vercel-cache-bundle>=0.7.1
10
- Requires-Dist: vercel-internal-shared-vendored-deps>=0.1.1
11
- Requires-Dist: vercel-queue-bundle>=0.7.2
12
- Description-Content-Type: text/markdown
13
-
14
1
  # vercel-celery-bundle
15
2
 
16
3
  This is a version of `vercel-celery` with third-party dependencies bundled. For normal use, install the unbundled `vercel-celery` package instead: https://pypi.org/project/vercel-celery/
@@ -51,6 +38,25 @@ poll delivery otherwise. Set `broker_url = "vercel-push://"` to force push
51
38
  delivery, or `broker_url = "vercel-poll://"` for forced polling workers, local
52
39
  workers, and background workers.
53
40
 
41
+ To deploy a Celery worker on Vercel, declare a module that exposes the Celery
42
+ app as a queue subscriber in `pyproject.toml`:
43
+
44
+ ```python
45
+ # worker.py
46
+ from tasks import app
47
+
48
+ __all__ = ["app"]
49
+ ```
50
+
51
+ ```toml
52
+ [[tool.vercel.subscribers]]
53
+ entrypoint = "worker:app"
54
+ ```
55
+
56
+ The Vercel build introspects the app's queues and compiles the subscriber into
57
+ a queue-triggered function; no `vercel.json` trigger configuration is needed.
58
+ With no `topics` filter, the subscriber consumes every queue the app declares.
59
+
54
60
  Pass `register_queues=False` to skip automatic Vercel Queue trigger
55
61
  registration. When using that mode, manually register each Celery app whose
56
62
  queues should receive Vercel Queue push deliveries:
@@ -8,6 +8,7 @@ from typing import Any
8
8
 
9
9
  from hatchling.metadata.plugin.interface import MetadataHookInterface
10
10
  from packaging.requirements import Requirement
11
+ from packaging.specifiers import SpecifierSet
11
12
 
12
13
  try:
13
14
  import tomllib
@@ -29,8 +30,10 @@ class WorkspaceDependenciesMetadataHook(MetadataHookInterface):
29
30
  }
30
31
  workspace_root = _find_workspace_root(Path(self.root))
31
32
 
33
+ package = pyproject.get("project", {}).get("name", str(self.root))
34
+
32
35
  metadata["dependencies"] = [
33
- _rewrite_dependency(requirement, workspace_names, workspace_root)
36
+ _rewrite_dependency(requirement, workspace_names, workspace_root, package)
34
37
  for requirement in dependency_table.get("dependencies", [])
35
38
  ]
36
39
 
@@ -55,24 +58,56 @@ def _rewrite_dependency(
55
58
  requirement: str,
56
59
  workspace_names: set[str],
57
60
  workspace_root: Path | None,
61
+ package: str,
58
62
  ) -> str:
59
63
  parsed = Requirement(requirement)
60
64
  normalized = parsed.name.lower().replace("_", "-")
61
65
  if normalized not in workspace_names or workspace_root is None:
62
66
  return requirement
63
- return _with_lower_bound(parsed, _read_workspace_version(workspace_root, normalized))
67
+ version = _read_workspace_version(workspace_root, normalized)
68
+ return _with_lower_bound(parsed, version, requirement, package)
64
69
 
65
70
 
66
- def _with_lower_bound(requirement: Requirement, version: str) -> str:
71
+ def _with_lower_bound(requirement: Requirement, version: str, declared: str, package: str) -> str:
67
72
  extras = f"[{','.join(sorted(requirement.extras))}]" if requirement.extras else ""
68
73
  specifiers = [
69
74
  str(specifier) for specifier in requirement.specifier if specifier.operator != ">="
70
75
  ]
71
76
  specifier_text = ",".join([f">={version}", *specifiers])
77
+ _reject_unsatisfiable(package, requirement.name, declared, specifier_text, version)
72
78
  marker = f" ; {requirement.marker}" if requirement.marker else ""
73
79
  return f"{requirement.name}{extras}{specifier_text}{marker}"
74
80
 
75
81
 
82
+ def _reject_unsatisfiable(
83
+ package: str, dependency: str, declared: str, specifier_text: str, version: str
84
+ ) -> None:
85
+ """Refuse to publish a bound that no version of *dependency* can satisfy.
86
+
87
+ The lower bound is generated from the sibling's current version while the
88
+ rest of the specifier is whatever the package declared, so a hand-written
89
+ upper bound that the sibling has since reached produces something like
90
+ ``>=0.3.0,<0.3.0``. Nothing rejects that later: the wheel builds, uploads,
91
+ and only fails when someone tries to install it. Fail the build instead --
92
+ CI builds every package, so the bump that crosses the bound is caught by
93
+ its own pull request.
94
+
95
+ The test is that the sibling version *being released* satisfies the bound,
96
+ which is narrower than the range being non-empty: `>=0.7.1,!=0.7.1` leaves
97
+ room for a later version, but says the release under way is unusable.
98
+ """
99
+ # `prereleases=True` so a workspace version like `0.4.0b1` is judged
100
+ # against its own bound rather than excluded for being a prerelease.
101
+ if SpecifierSet(specifier_text).contains(version, prereleases=True):
102
+ return
103
+ raise RuntimeError(
104
+ f"{package} declares {declared!r}, but {dependency} is at {version} in "
105
+ f"the workspace, so publishing would pin {dependency}{specifier_text} — "
106
+ f"which excludes {version} itself, the version being released. "
107
+ f"Raise the upper bound in [tool.vercel.release.dependencies] of {package}."
108
+ )
109
+
110
+
76
111
  def _read_workspace_version(workspace_root: Path, package_name: str) -> str:
77
112
  for pattern in ("src/*/pyproject.toml", "integrations/*/pyproject.toml"):
78
113
  for pyproject_path in workspace_root.glob(pattern):
@@ -21,8 +21,8 @@ path = "hatch_build.py"
21
21
  [tool.vercel.release.dependencies]
22
22
  dependencies = [
23
23
  "celery>=5.3,<6",
24
- "vercel-cache-bundle>=0.7.1",
25
- "vercel-queue-bundle>=0.7.2",
24
+ "vercel-cache-bundle>=0.7.2",
25
+ "vercel-queue-bundle>=0.7.3",
26
26
  "vercel-internal-shared-vendored-deps>=0.1.1",
27
27
  ]
28
28
 
@@ -1,3 +1,3 @@
1
1
  """Package version metadata."""
2
2
 
3
- __version__ = "0.7.2"
3
+ __version__ = "0.7.3"