autopub 1.0.0a19__tar.gz → 1.0.0a21__tar.gz

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,21 @@
1
+ Metadata-Version: 2.1
2
+ Name: autopub
3
+ Version: 1.0.0a21
4
+ Summary: Automatic package release upon pull request merge
5
+ Home-page: https://github.com/autopub/autopub
6
+ Author: Justin Mayer
7
+ Author-email: entroP@gmail.com
8
+ Requires-Python: >=3.9.0,<4.0
9
+ Classifier: Programming Language :: Python :: 3
10
+ Classifier: Programming Language :: Python :: 3.9
11
+ Classifier: Programming Language :: Python :: 3.10
12
+ Classifier: Programming Language :: Python :: 3.11
13
+ Classifier: Programming Language :: Python :: 3.12
14
+ Classifier: Programming Language :: Python :: 3.13
15
+ Provides-Extra: github
16
+ Requires-Dist: dunamai (>=1.23.0,<2.0.0)
17
+ Requires-Dist: pydantic (>=2.10.5,<3.0.0)
18
+ Requires-Dist: python-frontmatter (>=1.1.0,<2.0.0)
19
+ Requires-Dist: tomlkit (>=0.13.2,<0.14.0)
20
+ Project-URL: Issue Tracker, https://github.com/autopub/autopub/issues
21
+ Project-URL: Repository, https://github.com/autopub/autopub
@@ -2,11 +2,12 @@ from __future__ import annotations
2
2
 
3
3
  import hashlib
4
4
  import json
5
- from collections.abc import Iterable
5
+ from functools import cached_property
6
6
  from pathlib import Path
7
- from typing import Mapping, TypeAlias
7
+ from typing import Iterable, Mapping, TypeAlias
8
8
 
9
9
  import frontmatter
10
+ import tomlkit
10
11
  from pydantic import ValidationError
11
12
 
12
13
  from autopub.exceptions import (
@@ -21,6 +22,7 @@ from autopub.exceptions import (
21
22
  ReleaseTypeInvalid,
22
23
  ReleaseTypeMissing,
23
24
  )
25
+ from autopub.plugin_loader import load_plugins
24
26
  from autopub.plugins import (
25
27
  AutopubPackageManagerPlugin,
26
28
  AutopubPlugin,
@@ -35,12 +37,27 @@ ConfigType = Mapping[str, ConfigValue]
35
37
 
36
38
 
37
39
  class Autopub:
38
- config: ConfigType = {}
39
40
  RELEASE_FILE_PATH = "RELEASE.md"
41
+ plugins: list[AutopubPlugin]
40
42
 
41
43
  def __init__(self, plugins: Iterable[type[AutopubPlugin]] = ()) -> None:
42
44
  self.plugins = [plugin_class() for plugin_class in plugins]
43
45
 
46
+ self.load_plugins()
47
+
48
+ @cached_property
49
+ def config(self) -> ConfigType:
50
+ pyproject_path = Path.cwd() / "pyproject.toml"
51
+
52
+ if not Path("pyproject.toml").exists():
53
+ return {}
54
+
55
+ content = pyproject_path.read_text()
56
+
57
+ data = tomlkit.parse(content)
58
+
59
+ return data.get("tool", {}).get("autopub", {}) # type: ignore
60
+
44
61
  @property
45
62
  def release_file(self) -> Path:
46
63
  return Path.cwd() / self.RELEASE_FILE_PATH
@@ -69,6 +86,17 @@ class Autopub:
69
86
 
70
87
  return ReleaseInfo.from_dict(release_info)
71
88
 
89
+ def load_plugins(self, default_plugins: list[str] | None = None) -> None:
90
+ default_plugins = default_plugins or []
91
+
92
+ additional_plugins: list[str] = self.config.get("plugins", []) # type: ignore
93
+
94
+ all_plugins = default_plugins + additional_plugins
95
+
96
+ plugins = load_plugins(all_plugins)
97
+
98
+ self.plugins += [plugin_class() for plugin_class in plugins]
99
+
72
100
  def check(self) -> None:
73
101
  release_file = Path(self.RELEASE_FILE_PATH)
74
102
 
@@ -9,7 +9,6 @@ from rich.panel import Panel
9
9
  from typing_extensions import Annotated
10
10
 
11
11
  from autopub import Autopub
12
- from autopub.cli.plugins import find_plugins
13
12
  from autopub.exceptions import AutopubException, InvalidConfiguration
14
13
 
15
14
  app = typer.Typer()
@@ -19,14 +18,15 @@ class State(TypedDict):
19
18
  plugins: list[str]
20
19
 
21
20
 
22
- state: State = {"plugins": []}
21
+ class AutoPubCLI(typer.Context):
22
+ obj: Autopub
23
23
 
24
24
 
25
25
  @app.command()
26
- def check():
26
+ def check(context: AutoPubCLI):
27
27
  """This commands checks if the current PR has a valid release file."""
28
28
 
29
- autopub = Autopub(plugins=find_plugins(state["plugins"]))
29
+ autopub = context.obj
30
30
 
31
31
  try:
32
32
  autopub.validate_config()
@@ -38,7 +38,8 @@ def check():
38
38
  for id_ in e.validation_errors:
39
39
  error = e.validation_errors[id_]
40
40
  parts.append("")
41
- parts.append(f"[bold]Plugin:[/] {id_}")
41
+ parts.append(f"[bold on bright_magenta] Plugin: [/] {id_}")
42
+ parts.append("")
42
43
 
43
44
  errors: list[RenderableType] = []
44
45
 
@@ -46,7 +47,8 @@ def check():
46
47
  location = " -> ".join(map(str, error["loc"]))
47
48
  message = error["msg"]
48
49
 
49
- errors.append(f"[bold blue]{location}[/]: {message}")
50
+ errors.append(f"[bold on blue] {location} [/]: {message}")
51
+ errors.append("")
50
52
 
51
53
  parts.append(Padding(Group(*errors), (0, 2)))
52
54
 
@@ -82,8 +84,8 @@ def check():
82
84
 
83
85
 
84
86
  @app.command()
85
- def build():
86
- autopub = Autopub(plugins=find_plugins(state["plugins"]))
87
+ def build(context: AutoPubCLI):
88
+ autopub = context.obj
87
89
 
88
90
  try:
89
91
  autopub.build()
@@ -96,8 +98,8 @@ def build():
96
98
 
97
99
 
98
100
  @app.command()
99
- def prepare():
100
- autopub = Autopub(plugins=find_plugins(state["plugins"]))
101
+ def prepare(context: AutoPubCLI):
102
+ autopub = context.obj
101
103
 
102
104
  try:
103
105
  autopub.prepare()
@@ -111,12 +113,13 @@ def prepare():
111
113
 
112
114
  @app.command()
113
115
  def publish(
116
+ context: AutoPubCLI,
114
117
  repository: Annotated[
115
118
  Optional[str],
116
119
  typer.Option("--repository", "-r", help="Repository to publish to"),
117
120
  ] = None,
118
121
  ):
119
- autopub = Autopub(plugins=find_plugins(state["plugins"]))
122
+ autopub = context.obj
120
123
 
121
124
  try:
122
125
  autopub.publish(repository=repository)
@@ -130,28 +133,20 @@ def publish(
130
133
 
131
134
  @app.callback(invoke_without_command=True)
132
135
  def main(
133
- plugins: list[str] = typer.Option(
134
- [],
135
- "--plugin",
136
- "-p",
137
- help="List of plugins to use",
138
- ),
136
+ context: AutoPubCLI,
139
137
  should_show_version: Annotated[
140
138
  Optional[bool], typer.Option("--version", is_eager=True)
141
139
  ] = None,
142
140
  ):
143
- state["plugins"] = plugins
144
- state["plugins"].extend(
145
- [
146
- "git",
147
- "update_changelog",
148
- "bump_version",
149
- ]
150
- )
151
-
152
141
  if should_show_version:
153
142
  from importlib.metadata import version
154
143
 
155
144
  print(version("autopub"))
156
145
 
157
146
  raise typer.Exit()
147
+
148
+ autopub = Autopub()
149
+ # default plugins we always want to load (?)
150
+ autopub.load_plugins(["git", "update_changelog", "bump_version"])
151
+
152
+ context.obj = autopub
@@ -60,7 +60,7 @@ def _find_plugin(plugin: str) -> type[AutopubPlugin] | None:
60
60
  return None
61
61
 
62
62
 
63
- def find_plugins(names: list[str]) -> list[type[AutopubPlugin]]:
63
+ def load_plugins(names: list[str]) -> list[type[AutopubPlugin]]:
64
64
  sys.path.append(os.getcwd())
65
65
 
66
66
  plugins: list[type] = []
@@ -0,0 +1,34 @@
1
+ from __future__ import annotations
2
+
3
+ from typing import Any
4
+
5
+ from autopub.plugins import AutopubPackageManagerPlugin, AutopubPlugin
6
+
7
+
8
+ class UvPlugin(AutopubPlugin, AutopubPackageManagerPlugin):
9
+ def build(self) -> None:
10
+ self.run_command(["uv", "build"])
11
+
12
+ def publish(self, repository: str | None = None, **kwargs: Any) -> None:
13
+ additional_args: list[str] = []
14
+
15
+ if repository:
16
+ raise ValueError("Not yet implemented")
17
+
18
+ if publish_url := kwargs.get("publish_url"):
19
+ additional_args.append("--publish-url")
20
+ additional_args.append(publish_url)
21
+
22
+ if username := kwargs.get("username"):
23
+ additional_args.append("--username")
24
+ additional_args.append(username)
25
+
26
+ if password := kwargs.get("password"):
27
+ additional_args.append("--password")
28
+ additional_args.append(password)
29
+
30
+ if token := kwargs.get("token"):
31
+ additional_args.append("--token")
32
+ additional_args.append(token)
33
+
34
+ self.run_command(["uv", "publish", *additional_args])
@@ -1,15 +1,15 @@
1
1
  [project]
2
- requires-python = ">=3.8"
3
-
4
- [tool.poetry]
2
+ requires-python = ">=3.9.0,<4.0"
5
3
  name = "autopub"
6
- version = "1.0.0-alpha.19"
4
+ version = "1.0.0-alpha.21"
7
5
  description = "Automatic package release upon pull request merge"
8
- authors = ["Justin Mayer <entroP@gmail.com>", "Patrick Arminio <patrick.arminio@gmail.com>"]
6
+ authors = [
7
+ { name = "Justin Mayer", email = "entroP@gmail.com" },
8
+ { name = "Patrick Arminio", email = "patrick.arminio@gmail.com" },
9
+ ]
9
10
  license = "AGPL-3.0"
10
11
  readme = "README.md"
11
12
  keywords = ["automatic", "packaging", "publish", "release", "version"]
12
- repository = "https://github.com/autopub/autopub"
13
13
 
14
14
  classifiers = [
15
15
  "Development Status :: 4 - Beta",
@@ -21,29 +21,34 @@ classifiers = [
21
21
  "Topic :: System :: Systems Administration",
22
22
  ]
23
23
 
24
+ [tool.poetry]
25
+ repository = "https://github.com/autopub/autopub"
24
26
  include = ["autopub/py.typed"]
25
-
27
+ name = "autopub"
28
+ version = "1.0.0-alpha.21"
29
+ description = "Automatic package release upon pull request merge"
30
+ authors = [
31
+ "Justin Mayer <entroP@gmail.com>",
32
+ "Patrick Arminio <patrick.arminio@gmail.com>",
33
+ ]
26
34
 
27
35
  [tool.poetry.urls]
28
36
  "Issue Tracker" = "https://github.com/autopub/autopub/issues"
29
37
 
30
38
  [tool.poetry.dependencies]
31
- python = "^3.8"
32
- tomlkit = ">= 0.5, < 2.0"
33
- githubrelease = {version = "^1.5.9", optional = true}
34
- httpx = {version = "=0.16.1", optional = true}
35
- typer = "^0.9.0"
36
- rich = "^12.5.1"
37
- python-frontmatter = "^1.0.0"
38
- build = "^0.10.0"
39
- twine = "^4.0.2"
40
- dunamai = "^1.17.0"
41
- time-machine = "^2.13.0"
42
- pydantic = ">=2"
39
+ python = ">=3.9.0,<4.0"
40
+ python-frontmatter = "^1.1.0"
41
+ tomlkit = "^0.13.2"
42
+ pydantic = "^2.10.5"
43
+ dunamai = "^1.23.0"
43
44
 
44
- [tool.poetry.dev-dependencies]
45
- githubrelease = "^1.5"
46
45
 
46
+ [tool.poetry.dev-dependencies]
47
+ backoff = { version = "~=2.1.2", optional = true }
48
+ click = { version = "*", optional = true }
49
+ linkheader = { version = "*", optional = true }
50
+ requests = { version = "*", optional = true }
51
+ httpx = { version = "*", optional = true }
47
52
  # Tasks
48
53
  invoke = "^1.6"
49
54
 
@@ -60,7 +65,7 @@ pytest = "^7.1.2"
60
65
  pytest-httpserver = "^1.0.8"
61
66
 
62
67
  [tool.poetry.extras]
63
- github = ["githubrelease", "httpx"]
68
+ github = ["backoff", "click", "linkheader", "requests", "httpx"]
64
69
 
65
70
  [tool.poetry.scripts]
66
71
  autopub = "autopub.cli:app"
@@ -68,21 +73,17 @@ autopub = "autopub.cli:app"
68
73
  [tool.poetry.group.dev.dependencies]
69
74
  pytest-cov = "^4.1.0"
70
75
  pytest-mock = "^3.12.0"
76
+ time-machine = "^2.16.0"
71
77
 
72
78
  [tool.autopub]
73
79
  project-name = "AutoPub"
74
80
  git-username = "botpub"
75
- git-email = "botpub@autopub.rocks"
81
+ git-email = "52496925+botpub@users.noreply.github.com"
76
82
  append-github-contributor = true
77
83
 
78
84
 
79
85
  [tool.ruff]
80
- select = [
81
- "I",
82
- "E",
83
- "F",
84
- "UP",
85
- ]
86
+ select = ["I", "E", "F", "UP"]
86
87
  exclude = ["typings"]
87
88
  force-exclude = true
88
89
 
autopub-1.0.0a19/PKG-INFO DELETED
@@ -1,94 +0,0 @@
1
- Metadata-Version: 2.1
2
- Name: autopub
3
- Version: 1.0.0a19
4
- Summary: Automatic package release upon pull request merge
5
- Home-page: https://github.com/autopub/autopub
6
- License: AGPL-3.0
7
- Keywords: automatic,packaging,publish,release,version
8
- Author: Justin Mayer
9
- Author-email: entroP@gmail.com
10
- Requires-Python: >=3.8,<4.0
11
- Classifier: Development Status :: 4 - Beta
12
- Classifier: Environment :: Console
13
- Classifier: Intended Audience :: Developers
14
- Classifier: License :: OSI Approved :: GNU Affero General Public License v3
15
- Classifier: Operating System :: OS Independent
16
- Classifier: Programming Language :: Python :: 3
17
- Classifier: Programming Language :: Python :: 3.8
18
- Classifier: Programming Language :: Python :: 3.9
19
- Classifier: Programming Language :: Python :: 3.10
20
- Classifier: Programming Language :: Python :: 3.11
21
- Classifier: Topic :: Software Development :: Libraries :: Python Modules
22
- Classifier: Topic :: System :: Software Distribution
23
- Classifier: Topic :: System :: Systems Administration
24
- Provides-Extra: github
25
- Requires-Dist: build (>=0.10.0,<0.11.0)
26
- Requires-Dist: dunamai (>=1.17.0,<2.0.0)
27
- Requires-Dist: githubrelease (>=1.5.9,<2.0.0) ; extra == "github"
28
- Requires-Dist: httpx (==0.16.1) ; extra == "github"
29
- Requires-Dist: pydantic (>=2)
30
- Requires-Dist: python-frontmatter (>=1.0.0,<2.0.0)
31
- Requires-Dist: rich (>=12.5.1,<13.0.0)
32
- Requires-Dist: time-machine (>=2.13.0,<3.0.0)
33
- Requires-Dist: tomlkit (>=0.5,<2.0)
34
- Requires-Dist: twine (>=4.0.2,<5.0.0)
35
- Requires-Dist: typer (>=0.9.0,<0.10.0)
36
- Project-URL: Issue Tracker, https://github.com/autopub/autopub/issues
37
- Project-URL: Repository, https://github.com/autopub/autopub
38
- Description-Content-Type: text/markdown
39
-
40
- # AutoPub
41
-
42
- [![Build Status](https://img.shields.io/circleci/build/github/autopub/autopub)](https://circleci.com/gh/autopub/autopub) [![PyPI Version](https://img.shields.io/pypi/v/autopub)](https://pypi.org/project/autopub/)
43
-
44
- AutoPub enables project maintainers to release new package versions to PyPI by merging pull requests.
45
-
46
- ## Environment
47
-
48
- AutoPub is intended for use with continuous integration (CI) systems such as [GitHub Actions][], [CircleCI][], or [Travis CI][]. Projects used with AutoPub are built via [build][] and published via [Twine][]. Contributions that add support for other CI and build systems are welcome.
49
-
50
- ## Configuration
51
-
52
- AutoPub settings can be configured via the `[tool.autopub]` table in the target project’s `pyproject.toml` file. Required settings include Git username and email address:
53
-
54
- ```toml
55
- [tool.autopub]
56
- git-username = "Your Name"
57
- git-email = "your_email@example.com"
58
- ```
59
-
60
- ## Release Files
61
-
62
- Contributors should include a `RELEASE.md` file in their pull requests with two bits of information:
63
-
64
- * Release type: major, minor, or patch
65
- * Description of the changes, to be used as the changelog entry
66
-
67
- Example:
68
-
69
- Release type: patch
70
-
71
- Add function to update version strings in multiple files.
72
-
73
- ## Usage
74
-
75
- The following `autopub` sub-commands can be used as steps in your CI flows:
76
-
77
- * `autopub check`: Check whether release file exists.
78
- * `autopub prepare`: Update version strings and add entry to changelog.
79
- * `autopub build`: Build the project.
80
- * `autopub commit`: Add, commit, and push incremented version and changelog changes.
81
- * `autopub githubrelease`: Create a new release on GitHub.
82
- * `autopub publish`: Publish a new release.
83
-
84
- For systems such as Travis CI in which only one deployment step is permitted, there is a single command that runs the above steps in sequence:
85
-
86
- * `autopub deploy`: Run `prepare`, `build`, `commit`, `githubrelease`, and `publish` in one invocation.
87
-
88
-
89
- [GitHub Actions]: https://github.com/features/actions
90
- [CircleCI]: https://circleci.com
91
- [Travis CI]: https://travis-ci.org
92
- [build]: https://pypa-build.readthedocs.io
93
- [Twine]: https://twine.readthedocs.io/
94
-
@@ -1,54 +0,0 @@
1
- # AutoPub
2
-
3
- [![Build Status](https://img.shields.io/circleci/build/github/autopub/autopub)](https://circleci.com/gh/autopub/autopub) [![PyPI Version](https://img.shields.io/pypi/v/autopub)](https://pypi.org/project/autopub/)
4
-
5
- AutoPub enables project maintainers to release new package versions to PyPI by merging pull requests.
6
-
7
- ## Environment
8
-
9
- AutoPub is intended for use with continuous integration (CI) systems such as [GitHub Actions][], [CircleCI][], or [Travis CI][]. Projects used with AutoPub are built via [build][] and published via [Twine][]. Contributions that add support for other CI and build systems are welcome.
10
-
11
- ## Configuration
12
-
13
- AutoPub settings can be configured via the `[tool.autopub]` table in the target project’s `pyproject.toml` file. Required settings include Git username and email address:
14
-
15
- ```toml
16
- [tool.autopub]
17
- git-username = "Your Name"
18
- git-email = "your_email@example.com"
19
- ```
20
-
21
- ## Release Files
22
-
23
- Contributors should include a `RELEASE.md` file in their pull requests with two bits of information:
24
-
25
- * Release type: major, minor, or patch
26
- * Description of the changes, to be used as the changelog entry
27
-
28
- Example:
29
-
30
- Release type: patch
31
-
32
- Add function to update version strings in multiple files.
33
-
34
- ## Usage
35
-
36
- The following `autopub` sub-commands can be used as steps in your CI flows:
37
-
38
- * `autopub check`: Check whether release file exists.
39
- * `autopub prepare`: Update version strings and add entry to changelog.
40
- * `autopub build`: Build the project.
41
- * `autopub commit`: Add, commit, and push incremented version and changelog changes.
42
- * `autopub githubrelease`: Create a new release on GitHub.
43
- * `autopub publish`: Publish a new release.
44
-
45
- For systems such as Travis CI in which only one deployment step is permitted, there is a single command that runs the above steps in sequence:
46
-
47
- * `autopub deploy`: Run `prepare`, `build`, `commit`, `githubrelease`, and `publish` in one invocation.
48
-
49
-
50
- [GitHub Actions]: https://github.com/features/actions
51
- [CircleCI]: https://circleci.com
52
- [Travis CI]: https://travis-ci.org
53
- [build]: https://pypa-build.readthedocs.io
54
- [Twine]: https://twine.readthedocs.io/
File without changes
File without changes
File without changes