flashflow 0.1.0__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.
- flashflow-0.1.0/LICENSE +21 -0
- flashflow-0.1.0/PKG-INFO +77 -0
- flashflow-0.1.0/README.md +41 -0
- flashflow-0.1.0/flashflow/__init__.py +0 -0
- flashflow-0.1.0/flashflow/__main__.py +9 -0
- flashflow-0.1.0/flashflow/commands/project.py +173 -0
- flashflow-0.1.0/flashflow/commands/release.py +360 -0
- flashflow-0.1.0/flashflow/confirm.py +4 -0
- flashflow-0.1.0/flashflow/parser.py +72 -0
- flashflow-0.1.0/flashflow/process.py +81 -0
- flashflow-0.1.0/flashflow.egg-info/PKG-INFO +77 -0
- flashflow-0.1.0/flashflow.egg-info/SOURCES.txt +16 -0
- flashflow-0.1.0/flashflow.egg-info/dependency_links.txt +1 -0
- flashflow-0.1.0/flashflow.egg-info/entry_points.txt +2 -0
- flashflow-0.1.0/flashflow.egg-info/requires.txt +7 -0
- flashflow-0.1.0/flashflow.egg-info/top_level.txt +1 -0
- flashflow-0.1.0/pyproject.toml +62 -0
- flashflow-0.1.0/setup.cfg +4 -0
flashflow-0.1.0/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Pedro Alberto Rosquete Ares
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
flashflow-0.1.0/PKG-INFO
ADDED
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: flashflow
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: "flashflow" is a set of programs written in python to make easier everyday workflow
|
|
5
|
+
Author-email: Pedro Alberto Rosquete Ares <rosquetearespedro06@gmail.com>
|
|
6
|
+
License: MIT License
|
|
7
|
+
|
|
8
|
+
Copyright (c) 2026 Pedro Alberto Rosquete Ares
|
|
9
|
+
|
|
10
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
11
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
12
|
+
in the Software without restriction, including without limitation the rights
|
|
13
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
14
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
15
|
+
furnished to do so, subject to the following conditions:
|
|
16
|
+
|
|
17
|
+
The above copyright notice and this permission notice shall be included in all
|
|
18
|
+
copies or substantial portions of the Software.
|
|
19
|
+
|
|
20
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
21
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
22
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
23
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
24
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
25
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
26
|
+
SOFTWARE.
|
|
27
|
+
|
|
28
|
+
Requires-Python: >=3.9
|
|
29
|
+
Description-Content-Type: text/markdown
|
|
30
|
+
License-File: LICENSE
|
|
31
|
+
Requires-Dist: tomli>=2; python_version < "3.11"
|
|
32
|
+
Provides-Extra: dev
|
|
33
|
+
Requires-Dist: pytest>=8.0; extra == "dev"
|
|
34
|
+
Requires-Dist: ruff>=0.1.0; extra == "dev"
|
|
35
|
+
Dynamic: license-file
|
|
36
|
+
|
|
37
|
+
# fastflow
|
|
38
|
+
|
|
39
|
+
A small collection of Python commands for everyday development tasks.
|
|
40
|
+
|
|
41
|
+
## Install for development
|
|
42
|
+
|
|
43
|
+
```powershell
|
|
44
|
+
python -m pip install -e ".[dev]"
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
## Create a project scaffold
|
|
48
|
+
|
|
49
|
+
Run this from the directory where you want the initial project files:
|
|
50
|
+
|
|
51
|
+
```powershell
|
|
52
|
+
fastflow project "My Project"
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
The command creates a virtual environment, `.gitignore`, `README.md`, `LICENSE`,
|
|
56
|
+
and a valid `pyproject.toml` in the current directory. It refuses to overwrite
|
|
57
|
+
any of those files if they already exist. Choose an actual license before
|
|
58
|
+
distributing a generated project.
|
|
59
|
+
|
|
60
|
+
## Release a Python project
|
|
61
|
+
|
|
62
|
+
Run the command from the project root after choosing a new `X.Y.Z` version:
|
|
63
|
+
|
|
64
|
+
```powershell
|
|
65
|
+
fastflow release 1.2.3
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
The release command requires valid static `[project].version` metadata and a
|
|
69
|
+
clean Git working tree. It updates the version, builds distributions from an
|
|
70
|
+
isolated copy of the project, commits the version change locally, and uploads
|
|
71
|
+
only those fresh artifacts to PyPI. After a successful upload, it asks whether
|
|
72
|
+
to push the commit and whether to create and push a version tag.
|
|
73
|
+
|
|
74
|
+
If the build fails, the previous version is restored. If the PyPI upload fails,
|
|
75
|
+
the command attempts to remove its own release commit and restore the preceding
|
|
76
|
+
commit, but reports that PyPI may have accepted the upload before the failure
|
|
77
|
+
was returned. Verify the package on PyPI before retrying in that situation.
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
# fastflow
|
|
2
|
+
|
|
3
|
+
A small collection of Python commands for everyday development tasks.
|
|
4
|
+
|
|
5
|
+
## Install for development
|
|
6
|
+
|
|
7
|
+
```powershell
|
|
8
|
+
python -m pip install -e ".[dev]"
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Create a project scaffold
|
|
12
|
+
|
|
13
|
+
Run this from the directory where you want the initial project files:
|
|
14
|
+
|
|
15
|
+
```powershell
|
|
16
|
+
fastflow project "My Project"
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
The command creates a virtual environment, `.gitignore`, `README.md`, `LICENSE`,
|
|
20
|
+
and a valid `pyproject.toml` in the current directory. It refuses to overwrite
|
|
21
|
+
any of those files if they already exist. Choose an actual license before
|
|
22
|
+
distributing a generated project.
|
|
23
|
+
|
|
24
|
+
## Release a Python project
|
|
25
|
+
|
|
26
|
+
Run the command from the project root after choosing a new `X.Y.Z` version:
|
|
27
|
+
|
|
28
|
+
```powershell
|
|
29
|
+
fastflow release 1.2.3
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
The release command requires valid static `[project].version` metadata and a
|
|
33
|
+
clean Git working tree. It updates the version, builds distributions from an
|
|
34
|
+
isolated copy of the project, commits the version change locally, and uploads
|
|
35
|
+
only those fresh artifacts to PyPI. After a successful upload, it asks whether
|
|
36
|
+
to push the commit and whether to create and push a version tag.
|
|
37
|
+
|
|
38
|
+
If the build fails, the previous version is restored. If the PyPI upload fails,
|
|
39
|
+
the command attempts to remove its own release commit and restore the preceding
|
|
40
|
+
commit, but reports that PyPI may have accepted the upload before the failure
|
|
41
|
+
was returned. Verify the package on PyPI before retrying in that situation.
|
|
File without changes
|
|
@@ -0,0 +1,173 @@
|
|
|
1
|
+
"""Create a safe, usable initial structure for a Python project."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
import json
|
|
6
|
+
import re
|
|
7
|
+
import shutil
|
|
8
|
+
import sys
|
|
9
|
+
from argparse import Namespace
|
|
10
|
+
from dataclasses import dataclass
|
|
11
|
+
from pathlib import Path
|
|
12
|
+
|
|
13
|
+
from ..process import CommandExecutionError, ProcessRunner
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
@dataclass(frozen=True)
|
|
17
|
+
class Configuration:
|
|
18
|
+
"""Select which project files and environment should be created."""
|
|
19
|
+
|
|
20
|
+
create_venv: bool = True
|
|
21
|
+
create_gitignore: bool = True
|
|
22
|
+
create_pyproject_toml: bool = True
|
|
23
|
+
create_readme: bool = True
|
|
24
|
+
create_license: bool = True
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
class ProjectError(RuntimeError):
|
|
28
|
+
"""An expected failure while creating a project scaffold."""
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
class ProjectManager:
|
|
32
|
+
"""Create project files without overwriting existing user data."""
|
|
33
|
+
|
|
34
|
+
def __init__(
|
|
35
|
+
self,
|
|
36
|
+
project_name: str,
|
|
37
|
+
config: Configuration | None = None,
|
|
38
|
+
project_dir: Path | str | None = None,
|
|
39
|
+
runner: ProcessRunner | None = None,
|
|
40
|
+
) -> None:
|
|
41
|
+
self.name = project_name.strip()
|
|
42
|
+
if not self.name or re.fullmatch(r"[A-Za-z0-9][A-Za-z0-9._ -]*", self.name) is None:
|
|
43
|
+
raise ProjectError(
|
|
44
|
+
"Project name must start with a letter or digit and contain only "
|
|
45
|
+
"letters, digits, spaces, '.', '_' or '-'."
|
|
46
|
+
)
|
|
47
|
+
|
|
48
|
+
self.distribution_name = re.sub(r"[-_. ]+", "-", self.name).strip("-")
|
|
49
|
+
if not self.distribution_name:
|
|
50
|
+
raise ProjectError("Project name must contain at least one letter or digit.")
|
|
51
|
+
|
|
52
|
+
self.config = config or Configuration()
|
|
53
|
+
self.project_dir = Path.cwd() if project_dir is None else Path(project_dir).resolve()
|
|
54
|
+
self.runner = runner or ProcessRunner()
|
|
55
|
+
self._created_paths: list[Path] = []
|
|
56
|
+
|
|
57
|
+
def _file_contents(self) -> dict[str, str]:
|
|
58
|
+
files: dict[str, str] = {}
|
|
59
|
+
|
|
60
|
+
if self.config.create_gitignore:
|
|
61
|
+
files[".gitignore"] = (
|
|
62
|
+
"__pycache__/\n"
|
|
63
|
+
"*.py[cod]\n"
|
|
64
|
+
".venv/\n"
|
|
65
|
+
".vscode/\n"
|
|
66
|
+
".cache/\n"
|
|
67
|
+
"build/\n"
|
|
68
|
+
"dist/\n"
|
|
69
|
+
"*.egg-info/\n"
|
|
70
|
+
)
|
|
71
|
+
if self.config.create_readme:
|
|
72
|
+
files["README.md"] = f"# {self.name}\n\nA short description of this project.\n"
|
|
73
|
+
if self.config.create_license:
|
|
74
|
+
files["LICENSE"] = "Choose and add a license before distributing this project.\n"
|
|
75
|
+
if self.config.create_pyproject_toml:
|
|
76
|
+
files["pyproject.toml"] = self._pyproject_contents()
|
|
77
|
+
|
|
78
|
+
return files
|
|
79
|
+
|
|
80
|
+
def _pyproject_contents(self) -> str:
|
|
81
|
+
lines = [
|
|
82
|
+
"[build-system]",
|
|
83
|
+
'requires = ["setuptools>=68"]',
|
|
84
|
+
'build-backend = "setuptools.build_meta"',
|
|
85
|
+
"",
|
|
86
|
+
"[project]",
|
|
87
|
+
f"name = {json.dumps(self.distribution_name)}",
|
|
88
|
+
'version = "0.1.0"',
|
|
89
|
+
f"description = {json.dumps('A Python project named ' + self.name + '.')}",
|
|
90
|
+
'requires-python = ">=3.9"',
|
|
91
|
+
"dependencies = []",
|
|
92
|
+
]
|
|
93
|
+
if self.config.create_readme:
|
|
94
|
+
lines.append('readme = "README.md"')
|
|
95
|
+
lines.append("")
|
|
96
|
+
return "\n".join(lines)
|
|
97
|
+
|
|
98
|
+
def _preflight(self, files: dict[str, str]) -> None:
|
|
99
|
+
if not self.project_dir.is_dir():
|
|
100
|
+
raise ProjectError(f"Project directory does not exist: {self.project_dir}")
|
|
101
|
+
|
|
102
|
+
requested_paths = [self.project_dir / filename for filename in files]
|
|
103
|
+
if self.config.create_venv:
|
|
104
|
+
requested_paths.append(self.project_dir / ".venv")
|
|
105
|
+
|
|
106
|
+
conflicts = [
|
|
107
|
+
path.name for path in requested_paths if path.exists() or path.is_symlink()
|
|
108
|
+
]
|
|
109
|
+
if conflicts:
|
|
110
|
+
joined = ", ".join(conflicts)
|
|
111
|
+
raise ProjectError(
|
|
112
|
+
f"Refusing to overwrite existing project content in {self.project_dir}: "
|
|
113
|
+
f"{joined}"
|
|
114
|
+
)
|
|
115
|
+
|
|
116
|
+
def create(self) -> list[Path]:
|
|
117
|
+
"""Create the selected scaffold, rolling back only files created by this run."""
|
|
118
|
+
files = self._file_contents()
|
|
119
|
+
self._preflight(files)
|
|
120
|
+
self._created_paths = []
|
|
121
|
+
|
|
122
|
+
try:
|
|
123
|
+
for filename, content in files.items():
|
|
124
|
+
path = self.project_dir / filename
|
|
125
|
+
with path.open("x", encoding="utf-8", newline="\n") as project_file:
|
|
126
|
+
self._created_paths.append(path)
|
|
127
|
+
project_file.write(content)
|
|
128
|
+
|
|
129
|
+
if self.config.create_venv:
|
|
130
|
+
self._create_venv()
|
|
131
|
+
except (OSError, CommandExecutionError, ProjectError) as exc:
|
|
132
|
+
rollback_errors = self._rollback()
|
|
133
|
+
message = f"Project creation failed: {exc}"
|
|
134
|
+
if rollback_errors:
|
|
135
|
+
message += "\nCleanup was incomplete:\n" + "\n".join(rollback_errors)
|
|
136
|
+
raise ProjectError(message) from exc
|
|
137
|
+
|
|
138
|
+
return list(self._created_paths)
|
|
139
|
+
|
|
140
|
+
def _create_venv(self) -> None:
|
|
141
|
+
venv_path = self.project_dir / ".venv"
|
|
142
|
+
venv_path.mkdir()
|
|
143
|
+
self._created_paths.append(venv_path)
|
|
144
|
+
prompt = f"{self.distribution_name}-dev-venv"
|
|
145
|
+
self.runner.run(
|
|
146
|
+
[sys.executable, "-m", "venv", str(venv_path), "--prompt", prompt],
|
|
147
|
+
cwd=self.project_dir,
|
|
148
|
+
)
|
|
149
|
+
|
|
150
|
+
def _rollback(self) -> list[str]:
|
|
151
|
+
rollback_errors: list[str] = []
|
|
152
|
+
for path in reversed(self._created_paths):
|
|
153
|
+
try:
|
|
154
|
+
if path.is_dir() and not path.is_symlink():
|
|
155
|
+
shutil.rmtree(path)
|
|
156
|
+
else:
|
|
157
|
+
path.unlink(missing_ok=True)
|
|
158
|
+
except OSError as exc:
|
|
159
|
+
rollback_errors.append(f"{path}: {exc}")
|
|
160
|
+
self._created_paths.clear()
|
|
161
|
+
return rollback_errors
|
|
162
|
+
|
|
163
|
+
|
|
164
|
+
def main(args: Namespace) -> None:
|
|
165
|
+
"""Entry point for the project command."""
|
|
166
|
+
try:
|
|
167
|
+
created = ProjectManager(args.name).create()
|
|
168
|
+
except ProjectError as exc:
|
|
169
|
+
print(f"Project creation failed: {exc}")
|
|
170
|
+
raise SystemExit(1) from exc
|
|
171
|
+
|
|
172
|
+
for path in created:
|
|
173
|
+
print(f"Created {path.name}.")
|
|
@@ -0,0 +1,360 @@
|
|
|
1
|
+
"""Build and publish a new release of the current Python project."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
import os
|
|
6
|
+
import re
|
|
7
|
+
import shutil
|
|
8
|
+
import subprocess
|
|
9
|
+
import sys
|
|
10
|
+
import tempfile
|
|
11
|
+
from argparse import Namespace
|
|
12
|
+
from collections.abc import Sequence
|
|
13
|
+
from pathlib import Path
|
|
14
|
+
from typing import Callable
|
|
15
|
+
|
|
16
|
+
try:
|
|
17
|
+
import tomllib
|
|
18
|
+
except ModuleNotFoundError: # Python 3.9 and 3.10
|
|
19
|
+
import tomli as tomllib # type: ignore
|
|
20
|
+
|
|
21
|
+
from ..confirm import confirm
|
|
22
|
+
from ..process import CommandExecutionError, ProcessRunner
|
|
23
|
+
|
|
24
|
+
_VERSION_RE = re.compile(r"(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)\Z")
|
|
25
|
+
_SECTION_RE = re.compile(r"^\s*\[([^\]]+)]\s*(?:#.*)?$")
|
|
26
|
+
_VERSION_LINE_RE = re.compile(
|
|
27
|
+
r"""(?P<prefix>\s*version\s*=\s*)(?P<quote>["'])(?P<version>[^"']+)(?P=quote)"""
|
|
28
|
+
r"""(?P<suffix>\s*(?:\#.*)?)(?P<newline>\r?\n?)\Z"""
|
|
29
|
+
)
|
|
30
|
+
Confirmer = Callable[[str], bool]
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
class ReleaseError(RuntimeError):
|
|
34
|
+
"""An expected failure while preparing or publishing a release."""
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
class ReleaseManager:
|
|
38
|
+
"""Coordinate release validation, local build/commit, and optional publication."""
|
|
39
|
+
|
|
40
|
+
def __init__(
|
|
41
|
+
self,
|
|
42
|
+
version: str,
|
|
43
|
+
project_dir: Path | str | None = None,
|
|
44
|
+
runner: ProcessRunner | None = None,
|
|
45
|
+
confirmer: Confirmer = confirm,
|
|
46
|
+
) -> None:
|
|
47
|
+
self.version = version.strip()
|
|
48
|
+
self.project_dir = Path.cwd() if project_dir is None else Path(project_dir).resolve()
|
|
49
|
+
self.pyproject_path = self.project_dir / "pyproject.toml"
|
|
50
|
+
self._runner = runner or ProcessRunner()
|
|
51
|
+
self._confirm = confirmer
|
|
52
|
+
|
|
53
|
+
@staticmethod
|
|
54
|
+
def validate_version(version: str) -> tuple[int, int, int]:
|
|
55
|
+
"""Validate and return a strict numeric X.Y.Z version."""
|
|
56
|
+
match = _VERSION_RE.fullmatch(version)
|
|
57
|
+
if match is None:
|
|
58
|
+
raise ReleaseError("Version must follow semantic versioning: X.Y.Z.")
|
|
59
|
+
return tuple(map(int, match.groups())) # type: ignore
|
|
60
|
+
|
|
61
|
+
@classmethod
|
|
62
|
+
def is_version_increase(cls, new_version: str, current_version: str) -> bool:
|
|
63
|
+
"""Return whether a valid version is greater than the current version."""
|
|
64
|
+
return cls.validate_version(new_version) > cls.validate_version(current_version)
|
|
65
|
+
|
|
66
|
+
def read_current_version(self) -> str:
|
|
67
|
+
"""Read the static project version from valid TOML project metadata."""
|
|
68
|
+
if not self.pyproject_path.is_file():
|
|
69
|
+
raise ReleaseError(f"{self.pyproject_path} not found.")
|
|
70
|
+
|
|
71
|
+
content = self._read_pyproject_content()
|
|
72
|
+
try:
|
|
73
|
+
metadata = tomllib.loads(content)
|
|
74
|
+
except tomllib.TOMLDecodeError as exc:
|
|
75
|
+
raise ReleaseError(f"Invalid TOML in {self.pyproject_path}: {exc}") from exc
|
|
76
|
+
|
|
77
|
+
project = metadata.get("project")
|
|
78
|
+
if not isinstance(project, dict) or not isinstance(project.get("version"), str):
|
|
79
|
+
raise ReleaseError(f"A static [project].version is required in {self.pyproject_path}.")
|
|
80
|
+
|
|
81
|
+
version = project["version"]
|
|
82
|
+
self.validate_version(version)
|
|
83
|
+
return version
|
|
84
|
+
|
|
85
|
+
def update_version(self, version: str) -> None:
|
|
86
|
+
"""Atomically replace only [project].version, preserving the rest of the file."""
|
|
87
|
+
self.validate_version(version)
|
|
88
|
+
content = self._read_pyproject_content()
|
|
89
|
+
lines = content.splitlines(keepends=True)
|
|
90
|
+
project_start = None
|
|
91
|
+
project_end = len(lines)
|
|
92
|
+
|
|
93
|
+
for index, line in enumerate(lines):
|
|
94
|
+
section = _SECTION_RE.fullmatch(line.rstrip("\r\n"))
|
|
95
|
+
if section is None:
|
|
96
|
+
continue
|
|
97
|
+
if section.group(1) == "project":
|
|
98
|
+
project_start = index + 1
|
|
99
|
+
elif project_start is not None:
|
|
100
|
+
project_end = index
|
|
101
|
+
break
|
|
102
|
+
|
|
103
|
+
if project_start is None:
|
|
104
|
+
raise ReleaseError(f"[project].version not found in {self.pyproject_path}.")
|
|
105
|
+
|
|
106
|
+
for index in range(project_start, project_end):
|
|
107
|
+
match = _VERSION_LINE_RE.fullmatch(lines[index])
|
|
108
|
+
if match is not None:
|
|
109
|
+
lines[index] = (
|
|
110
|
+
f"{match.group('prefix')}{match.group('quote')}{version}"
|
|
111
|
+
f"{match.group('quote')}{match.group('suffix')}{match.group('newline')}"
|
|
112
|
+
)
|
|
113
|
+
self._write_atomically("".join(lines))
|
|
114
|
+
return
|
|
115
|
+
|
|
116
|
+
raise ReleaseError(f"[project].version must be a static string in {self.pyproject_path}.")
|
|
117
|
+
|
|
118
|
+
def _read_pyproject_content(self) -> str:
|
|
119
|
+
try:
|
|
120
|
+
return self.pyproject_path.read_text(encoding="utf-8")
|
|
121
|
+
except OSError as exc:
|
|
122
|
+
raise ReleaseError(f"Could not read {self.pyproject_path}: {exc}") from exc
|
|
123
|
+
|
|
124
|
+
def _write_atomically(self, content: str) -> None:
|
|
125
|
+
temporary_path: Path | None = None
|
|
126
|
+
try:
|
|
127
|
+
with tempfile.NamedTemporaryFile(
|
|
128
|
+
mode="w",
|
|
129
|
+
encoding="utf-8",
|
|
130
|
+
newline="",
|
|
131
|
+
dir=self.project_dir,
|
|
132
|
+
prefix=".pyproject-",
|
|
133
|
+
suffix=".tmp",
|
|
134
|
+
delete=False,
|
|
135
|
+
) as temporary_file:
|
|
136
|
+
temporary_path = Path(temporary_file.name)
|
|
137
|
+
temporary_file.write(content)
|
|
138
|
+
temporary_file.flush()
|
|
139
|
+
os.fsync(temporary_file.fileno())
|
|
140
|
+
os.chmod(temporary_path, self.pyproject_path.stat().st_mode)
|
|
141
|
+
os.replace(temporary_path, self.pyproject_path)
|
|
142
|
+
except OSError as exc:
|
|
143
|
+
if temporary_path is not None:
|
|
144
|
+
try:
|
|
145
|
+
temporary_path.unlink(missing_ok=True)
|
|
146
|
+
except OSError as cleanup_error:
|
|
147
|
+
raise ReleaseError(
|
|
148
|
+
f"Could not update {self.pyproject_path}; failed to remove "
|
|
149
|
+
f"{temporary_path}: {cleanup_error}"
|
|
150
|
+
) from cleanup_error
|
|
151
|
+
raise ReleaseError(f"Could not update {self.pyproject_path}: {exc}") from exc
|
|
152
|
+
|
|
153
|
+
def _run(
|
|
154
|
+
self, command: Sequence[str], cwd: Path | None = None
|
|
155
|
+
) -> subprocess.CompletedProcess[str]:
|
|
156
|
+
try:
|
|
157
|
+
return self._runner.run(command, cwd=cwd or self.project_dir)
|
|
158
|
+
except CommandExecutionError as exc:
|
|
159
|
+
raise ReleaseError(str(exc)) from exc
|
|
160
|
+
|
|
161
|
+
def check_git_state(self) -> None:
|
|
162
|
+
"""Require a Git checkout with a clean working tree."""
|
|
163
|
+
branch = self._run(["git", "branch", "--show-current"]).stdout.strip()
|
|
164
|
+
if not branch:
|
|
165
|
+
raise ReleaseError("Cannot release from a detached HEAD.")
|
|
166
|
+
if branch != "main" and not self._confirm(
|
|
167
|
+
f"You are on branch '{branch}', not 'main'. Continue anyway?"
|
|
168
|
+
):
|
|
169
|
+
raise ReleaseError("Release cancelled.")
|
|
170
|
+
|
|
171
|
+
status = self._run(["git", "status", "--porcelain"]).stdout.strip()
|
|
172
|
+
if status:
|
|
173
|
+
raise ReleaseError(
|
|
174
|
+
f"Working tree is not clean; commit or stash changes first:\n{status}"
|
|
175
|
+
)
|
|
176
|
+
|
|
177
|
+
def build(self, output_dir: Path, source_dir: Path) -> list[Path]:
|
|
178
|
+
"""Build a copied source tree so backends leave no generated files in the project."""
|
|
179
|
+
output_dir.mkdir(parents=True, exist_ok=True)
|
|
180
|
+
self._run(
|
|
181
|
+
[
|
|
182
|
+
sys.executable,
|
|
183
|
+
"-m",
|
|
184
|
+
"build",
|
|
185
|
+
"--outdir",
|
|
186
|
+
str(output_dir),
|
|
187
|
+
],
|
|
188
|
+
cwd=source_dir,
|
|
189
|
+
)
|
|
190
|
+
artifacts = sorted(path for path in output_dir.iterdir() if path.is_file())
|
|
191
|
+
if not artifacts:
|
|
192
|
+
raise ReleaseError("Build completed but produced no distribution files.")
|
|
193
|
+
return artifacts
|
|
194
|
+
|
|
195
|
+
def commit(self) -> tuple[str, str]:
|
|
196
|
+
"""Commit the version change locally and return its parent and new commit IDs."""
|
|
197
|
+
parent = self._run(["git", "rev-parse", "HEAD"]).stdout.strip()
|
|
198
|
+
# -- prevents ambiguity and ensures Git treats pyproject.toml as a path,
|
|
199
|
+
# not as a git option.
|
|
200
|
+
self._run(["git", "add", "--", "pyproject.toml"])
|
|
201
|
+
self._run(["git", "commit", "-m", f"Release v{self.version}"])
|
|
202
|
+
release_commit = self._run(["git", "rev-parse", "HEAD"]).stdout.strip()
|
|
203
|
+
if not parent or not release_commit or parent == release_commit:
|
|
204
|
+
raise ReleaseError("Could not verify the local release commit.")
|
|
205
|
+
return parent, release_commit
|
|
206
|
+
|
|
207
|
+
def upload(self, artifacts: Sequence[Path]) -> None:
|
|
208
|
+
"""Upload only artifacts produced by this release build."""
|
|
209
|
+
self._run(
|
|
210
|
+
[
|
|
211
|
+
sys.executable,
|
|
212
|
+
"-m",
|
|
213
|
+
"twine",
|
|
214
|
+
"upload",
|
|
215
|
+
"--verbose",
|
|
216
|
+
*(str(path) for path in artifacts),
|
|
217
|
+
]
|
|
218
|
+
)
|
|
219
|
+
|
|
220
|
+
def publish_to_git(self) -> None:
|
|
221
|
+
"""Offer optional branch push and version-tag publication."""
|
|
222
|
+
if self._confirm("Push the release commit to origin?"):
|
|
223
|
+
try:
|
|
224
|
+
self._run(["git", "push"])
|
|
225
|
+
except ReleaseError as exc:
|
|
226
|
+
raise ReleaseError(
|
|
227
|
+
f"PyPI upload succeeded, but pushing the release commit failed: {exc}"
|
|
228
|
+
) from exc
|
|
229
|
+
print("Pushed release commit.")
|
|
230
|
+
|
|
231
|
+
tag = f"v{self.version}"
|
|
232
|
+
if self._confirm(f"Create and push git tag {tag}?"):
|
|
233
|
+
try:
|
|
234
|
+
self._run(["git", "tag", tag])
|
|
235
|
+
self._run(["git", "push", "origin", tag])
|
|
236
|
+
except ReleaseError as exc:
|
|
237
|
+
raise ReleaseError(
|
|
238
|
+
f"PyPI upload succeeded, but publishing Git tag {tag} failed: {exc}"
|
|
239
|
+
) from exc
|
|
240
|
+
print(f"Pushed tag {tag}.")
|
|
241
|
+
|
|
242
|
+
def release(self) -> None:
|
|
243
|
+
"""Validate, build, commit, upload, and optionally publish to Git."""
|
|
244
|
+
self.validate_version(self.version)
|
|
245
|
+
current_version = self.read_current_version()
|
|
246
|
+
if not self.is_version_increase(self.version, current_version):
|
|
247
|
+
raise ReleaseError(
|
|
248
|
+
f"Invalid version bump from {current_version} to {self.version}."
|
|
249
|
+
)
|
|
250
|
+
self.check_git_state()
|
|
251
|
+
|
|
252
|
+
original_content = self._read_pyproject_content()
|
|
253
|
+
self.update_version(self.version)
|
|
254
|
+
print(f"Updated version to {self.version} in pyproject.toml.")
|
|
255
|
+
|
|
256
|
+
with tempfile.TemporaryDirectory(prefix="fastflow-release-") as temporary_dir:
|
|
257
|
+
build_root = Path(temporary_dir)
|
|
258
|
+
output_dir = build_root / "dist"
|
|
259
|
+
source_dir = build_root / "source"
|
|
260
|
+
try:
|
|
261
|
+
print("Building package...")
|
|
262
|
+
shutil.copytree(
|
|
263
|
+
self.project_dir,
|
|
264
|
+
source_dir,
|
|
265
|
+
ignore=self._ignore_build_files,
|
|
266
|
+
)
|
|
267
|
+
artifacts = self.build(output_dir, source_dir)
|
|
268
|
+
except (OSError, ReleaseError) as exc:
|
|
269
|
+
self._write_atomically(original_content)
|
|
270
|
+
raise ReleaseError(
|
|
271
|
+
f"Build failed; restored the original project version. {exc}"
|
|
272
|
+
) from exc
|
|
273
|
+
print("Build completed.")
|
|
274
|
+
|
|
275
|
+
try:
|
|
276
|
+
parent_commit, release_commit = self.commit()
|
|
277
|
+
except ReleaseError as exc:
|
|
278
|
+
self._restore_after_commit_failure(original_content)
|
|
279
|
+
raise ReleaseError(
|
|
280
|
+
f"Local release commit failed; restored the original project version. {exc}"
|
|
281
|
+
) from exc
|
|
282
|
+
print(f"Committed release v{self.version}.")
|
|
283
|
+
|
|
284
|
+
print("Uploading to PyPI...")
|
|
285
|
+
try:
|
|
286
|
+
self.upload(artifacts)
|
|
287
|
+
except ReleaseError as exc:
|
|
288
|
+
try:
|
|
289
|
+
self._rollback_release_commit(parent_commit, release_commit)
|
|
290
|
+
except ReleaseError as rollback_error:
|
|
291
|
+
raise ReleaseError(
|
|
292
|
+
f"PyPI upload failed: {exc}\n"
|
|
293
|
+
f"Could not safely roll back the local release commit: {rollback_error}"
|
|
294
|
+
) from exc
|
|
295
|
+
raise ReleaseError(
|
|
296
|
+
"PyPI upload failed; the local release commit was removed and "
|
|
297
|
+
f"the previous version restored. PyPI may have accepted the upload "
|
|
298
|
+
f"before the failure was reported. {exc}"
|
|
299
|
+
) from exc
|
|
300
|
+
print("Upload completed.")
|
|
301
|
+
|
|
302
|
+
self.publish_to_git()
|
|
303
|
+
print(f"Release v{self.version} successful.")
|
|
304
|
+
|
|
305
|
+
@staticmethod
|
|
306
|
+
def _ignore_build_files(directory: str, names: list[str]) -> set[str]:
|
|
307
|
+
del directory
|
|
308
|
+
ignored = {
|
|
309
|
+
".git",
|
|
310
|
+
".venv",
|
|
311
|
+
".cache",
|
|
312
|
+
".pytest_cache",
|
|
313
|
+
".ruff_cache",
|
|
314
|
+
"__pycache__",
|
|
315
|
+
"build",
|
|
316
|
+
"dist",
|
|
317
|
+
}
|
|
318
|
+
return {
|
|
319
|
+
name
|
|
320
|
+
for name in names
|
|
321
|
+
if name in ignored or name.endswith(".egg-info")
|
|
322
|
+
}
|
|
323
|
+
|
|
324
|
+
def _rollback_release_commit(self, parent_commit: str, release_commit: str) -> None:
|
|
325
|
+
head = self._run(["git", "rev-parse", "HEAD"]).stdout.strip()
|
|
326
|
+
if head != release_commit:
|
|
327
|
+
raise ReleaseError(
|
|
328
|
+
"HEAD changed after the release commit; refusing to reset unrelated history."
|
|
329
|
+
)
|
|
330
|
+
|
|
331
|
+
status = self._run(["git", "status", "--porcelain"]).stdout.strip()
|
|
332
|
+
if status:
|
|
333
|
+
raise ReleaseError(
|
|
334
|
+
"The working tree changed after the release commit; refusing to discard "
|
|
335
|
+
f"those changes:\n{status}"
|
|
336
|
+
)
|
|
337
|
+
|
|
338
|
+
self._run(["git", "reset", "--hard", parent_commit])
|
|
339
|
+
|
|
340
|
+
def _restore_after_commit_failure(self, original_content: str) -> None:
|
|
341
|
+
unstage_error = None
|
|
342
|
+
try:
|
|
343
|
+
self._run(["git", "restore", "--staged", "--", "pyproject.toml"])
|
|
344
|
+
except ReleaseError as exc:
|
|
345
|
+
unstage_error = exc
|
|
346
|
+
self._write_atomically(original_content)
|
|
347
|
+
if unstage_error is not None:
|
|
348
|
+
raise ReleaseError(
|
|
349
|
+
"Restored the project version but could not unstage pyproject.toml: "
|
|
350
|
+
f"{unstage_error}"
|
|
351
|
+
) from unstage_error
|
|
352
|
+
|
|
353
|
+
|
|
354
|
+
def main(args: Namespace) -> None:
|
|
355
|
+
"""Entry point for the release command."""
|
|
356
|
+
try:
|
|
357
|
+
ReleaseManager(args.version).release()
|
|
358
|
+
except ReleaseError as exc:
|
|
359
|
+
print(f"Release failed: {exc}")
|
|
360
|
+
raise SystemExit(1) from exc
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Module to centralize all handling of arguments throug CLI
|
|
3
|
+
"""
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
from argparse import ArgumentParser, Namespace
|
|
7
|
+
|
|
8
|
+
from .commands import project, release
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
class Parser:
|
|
12
|
+
"""A class to manage all the argument parser and command features."""
|
|
13
|
+
|
|
14
|
+
def __init__(self) -> None:
|
|
15
|
+
"""Initialize the CLIApp attributes."""
|
|
16
|
+
self.main_parser = self.build_parser()
|
|
17
|
+
|
|
18
|
+
def build_parser(self) -> ArgumentParser:
|
|
19
|
+
"""Create the main parser and sub-commands."""
|
|
20
|
+
parser = ArgumentParser(
|
|
21
|
+
prog="fastflow",
|
|
22
|
+
description="\"fastflow\" is a set of programs written in python \
|
|
23
|
+
to make easier everyday workflow",
|
|
24
|
+
allow_abbrev=False,
|
|
25
|
+
epilog="Thanks for using %(prog)s, all feedback is appreciated"
|
|
26
|
+
)
|
|
27
|
+
|
|
28
|
+
sub_commands = parser.add_subparsers(title="Programs", help="Programs available")
|
|
29
|
+
|
|
30
|
+
# PROJECT
|
|
31
|
+
new_project_parser = sub_commands.add_parser(
|
|
32
|
+
"project",
|
|
33
|
+
help = "Create the initial structure for a new project in the current directory"
|
|
34
|
+
)
|
|
35
|
+
|
|
36
|
+
new_project_parser.add_argument(
|
|
37
|
+
"name", type=str, help="Name of the project to be created."
|
|
38
|
+
)
|
|
39
|
+
|
|
40
|
+
new_project_parser.set_defaults(func=project.main)
|
|
41
|
+
|
|
42
|
+
# RELEASE
|
|
43
|
+
release_parser = sub_commands.add_parser(
|
|
44
|
+
"release",
|
|
45
|
+
help = "Release an especific version of a program/package to PyPi."
|
|
46
|
+
)
|
|
47
|
+
|
|
48
|
+
release_parser.add_argument(
|
|
49
|
+
"version", type=str, help="Version of the program to be uploaded"
|
|
50
|
+
)
|
|
51
|
+
release_parser.set_defaults(func=release.main)
|
|
52
|
+
|
|
53
|
+
return parser
|
|
54
|
+
|
|
55
|
+
def start_parsing(self) -> None:
|
|
56
|
+
"""Parses the arguments passed."""
|
|
57
|
+
args: Namespace
|
|
58
|
+
try:
|
|
59
|
+
args = self.main_parser.parse_args()
|
|
60
|
+
except ValueError as exc:
|
|
61
|
+
self.main_parser.error(str(exc))
|
|
62
|
+
|
|
63
|
+
if not hasattr(args, "func"):
|
|
64
|
+
# in case user invokes the program without arguments like:
|
|
65
|
+
# >>> fastflow
|
|
66
|
+
self.main_parser.print_help()
|
|
67
|
+
return
|
|
68
|
+
|
|
69
|
+
try:
|
|
70
|
+
return args.func(args)
|
|
71
|
+
except (KeyError, ValueError) as exc:
|
|
72
|
+
self.main_parser.error(str(exc))
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
"""Shared, shell-free subprocess execution for fastflow commands."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
import subprocess
|
|
6
|
+
from collections.abc import Callable, Sequence
|
|
7
|
+
from pathlib import Path
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
class CommandExecutionError(RuntimeError):
|
|
11
|
+
"""A subprocess could not be started or exited unsuccessfully."""
|
|
12
|
+
|
|
13
|
+
def __init__(
|
|
14
|
+
self,
|
|
15
|
+
command: Sequence[str],
|
|
16
|
+
returncode: int | None,
|
|
17
|
+
stdout: str | None = None,
|
|
18
|
+
stderr: str | None = None,
|
|
19
|
+
cause: OSError | subprocess.CalledProcessError | None = None,
|
|
20
|
+
) -> None:
|
|
21
|
+
self.command = tuple(command)
|
|
22
|
+
self.returncode = returncode
|
|
23
|
+
self.stdout = stdout or ""
|
|
24
|
+
self.stderr = stderr or ""
|
|
25
|
+
|
|
26
|
+
command_text = subprocess.list2cmdline(self.command)
|
|
27
|
+
if returncode is None:
|
|
28
|
+
message = f"Could not start command ({command_text}): {cause}"
|
|
29
|
+
else:
|
|
30
|
+
message = f"Command ({command_text}) exited with status {returncode}."
|
|
31
|
+
if self.stdout.strip():
|
|
32
|
+
message += f"\nstdout:\n{self.stdout.strip()}"
|
|
33
|
+
if self.stderr.strip():
|
|
34
|
+
message += f"\nstderr:\n{self.stderr.strip()}"
|
|
35
|
+
super().__init__(message)
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
CommandExecutor = Callable[..., subprocess.CompletedProcess[str]]
|
|
39
|
+
|
|
40
|
+
class ProcessRunner:
|
|
41
|
+
"""Run argument-list commands and surface complete, actionable failures."""
|
|
42
|
+
|
|
43
|
+
def __init__(self, executor: CommandExecutor = subprocess.run) -> None:
|
|
44
|
+
self._executor = executor
|
|
45
|
+
|
|
46
|
+
def run(
|
|
47
|
+
self,
|
|
48
|
+
command: Sequence[str],
|
|
49
|
+
*,
|
|
50
|
+
cwd: Path | str | None = None,
|
|
51
|
+
) -> subprocess.CompletedProcess[str]:
|
|
52
|
+
if not command or any(not isinstance(part, str) for part in command):
|
|
53
|
+
raise ValueError("Commands must be non-empty sequences of strings.")
|
|
54
|
+
|
|
55
|
+
try:
|
|
56
|
+
result = self._executor(
|
|
57
|
+
list(command),
|
|
58
|
+
cwd=cwd,
|
|
59
|
+
check=False,
|
|
60
|
+
capture_output=True,
|
|
61
|
+
text=True,
|
|
62
|
+
)
|
|
63
|
+
except subprocess.CalledProcessError as exc:
|
|
64
|
+
raise CommandExecutionError(
|
|
65
|
+
command,
|
|
66
|
+
exc.returncode,
|
|
67
|
+
stdout=exc.stdout,
|
|
68
|
+
stderr=exc.stderr,
|
|
69
|
+
cause=exc,
|
|
70
|
+
) from exc
|
|
71
|
+
except OSError as exc:
|
|
72
|
+
raise CommandExecutionError(command, None, cause=exc) from exc
|
|
73
|
+
|
|
74
|
+
if result.returncode:
|
|
75
|
+
raise CommandExecutionError(
|
|
76
|
+
command,
|
|
77
|
+
result.returncode,
|
|
78
|
+
stdout=result.stdout,
|
|
79
|
+
stderr=result.stderr,
|
|
80
|
+
)
|
|
81
|
+
return result
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: flashflow
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: "flashflow" is a set of programs written in python to make easier everyday workflow
|
|
5
|
+
Author-email: Pedro Alberto Rosquete Ares <rosquetearespedro06@gmail.com>
|
|
6
|
+
License: MIT License
|
|
7
|
+
|
|
8
|
+
Copyright (c) 2026 Pedro Alberto Rosquete Ares
|
|
9
|
+
|
|
10
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
11
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
12
|
+
in the Software without restriction, including without limitation the rights
|
|
13
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
14
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
15
|
+
furnished to do so, subject to the following conditions:
|
|
16
|
+
|
|
17
|
+
The above copyright notice and this permission notice shall be included in all
|
|
18
|
+
copies or substantial portions of the Software.
|
|
19
|
+
|
|
20
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
21
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
22
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
23
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
24
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
25
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
26
|
+
SOFTWARE.
|
|
27
|
+
|
|
28
|
+
Requires-Python: >=3.9
|
|
29
|
+
Description-Content-Type: text/markdown
|
|
30
|
+
License-File: LICENSE
|
|
31
|
+
Requires-Dist: tomli>=2; python_version < "3.11"
|
|
32
|
+
Provides-Extra: dev
|
|
33
|
+
Requires-Dist: pytest>=8.0; extra == "dev"
|
|
34
|
+
Requires-Dist: ruff>=0.1.0; extra == "dev"
|
|
35
|
+
Dynamic: license-file
|
|
36
|
+
|
|
37
|
+
# fastflow
|
|
38
|
+
|
|
39
|
+
A small collection of Python commands for everyday development tasks.
|
|
40
|
+
|
|
41
|
+
## Install for development
|
|
42
|
+
|
|
43
|
+
```powershell
|
|
44
|
+
python -m pip install -e ".[dev]"
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
## Create a project scaffold
|
|
48
|
+
|
|
49
|
+
Run this from the directory where you want the initial project files:
|
|
50
|
+
|
|
51
|
+
```powershell
|
|
52
|
+
fastflow project "My Project"
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
The command creates a virtual environment, `.gitignore`, `README.md`, `LICENSE`,
|
|
56
|
+
and a valid `pyproject.toml` in the current directory. It refuses to overwrite
|
|
57
|
+
any of those files if they already exist. Choose an actual license before
|
|
58
|
+
distributing a generated project.
|
|
59
|
+
|
|
60
|
+
## Release a Python project
|
|
61
|
+
|
|
62
|
+
Run the command from the project root after choosing a new `X.Y.Z` version:
|
|
63
|
+
|
|
64
|
+
```powershell
|
|
65
|
+
fastflow release 1.2.3
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
The release command requires valid static `[project].version` metadata and a
|
|
69
|
+
clean Git working tree. It updates the version, builds distributions from an
|
|
70
|
+
isolated copy of the project, commits the version change locally, and uploads
|
|
71
|
+
only those fresh artifacts to PyPI. After a successful upload, it asks whether
|
|
72
|
+
to push the commit and whether to create and push a version tag.
|
|
73
|
+
|
|
74
|
+
If the build fails, the previous version is restored. If the PyPI upload fails,
|
|
75
|
+
the command attempts to remove its own release commit and restore the preceding
|
|
76
|
+
commit, but reports that PyPI may have accepted the upload before the failure
|
|
77
|
+
was returned. Verify the package on PyPI before retrying in that situation.
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
LICENSE
|
|
2
|
+
README.md
|
|
3
|
+
pyproject.toml
|
|
4
|
+
flashflow/__init__.py
|
|
5
|
+
flashflow/__main__.py
|
|
6
|
+
flashflow/confirm.py
|
|
7
|
+
flashflow/parser.py
|
|
8
|
+
flashflow/process.py
|
|
9
|
+
flashflow.egg-info/PKG-INFO
|
|
10
|
+
flashflow.egg-info/SOURCES.txt
|
|
11
|
+
flashflow.egg-info/dependency_links.txt
|
|
12
|
+
flashflow.egg-info/entry_points.txt
|
|
13
|
+
flashflow.egg-info/requires.txt
|
|
14
|
+
flashflow.egg-info/top_level.txt
|
|
15
|
+
flashflow/commands/project.py
|
|
16
|
+
flashflow/commands/release.py
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
flashflow
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["setuptools>=68"]
|
|
3
|
+
build-backend = "setuptools.build_meta"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "flashflow"
|
|
7
|
+
version = "0.1.0"
|
|
8
|
+
description = "\"flashflow\" is a set of programs written in python to make easier everyday workflow"
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
requires-python = ">=3.9"
|
|
11
|
+
authors = [{name = "Pedro Alberto Rosquete Ares", email = "rosquetearespedro06@gmail.com"}]
|
|
12
|
+
license = { file = "LICENSE" }
|
|
13
|
+
dependencies = ["tomli>=2; python_version < '3.11'"]
|
|
14
|
+
|
|
15
|
+
[project.optional-dependencies]
|
|
16
|
+
dev = ["pytest>=8.0", "ruff>=0.1.0"]
|
|
17
|
+
|
|
18
|
+
[project.urls]
|
|
19
|
+
|
|
20
|
+
[project.scripts]
|
|
21
|
+
flashflow = "flashflow.__main__:main"
|
|
22
|
+
|
|
23
|
+
[tool.setuptools.packages.find]
|
|
24
|
+
include = ["flashflow*"]
|
|
25
|
+
|
|
26
|
+
# PYTEST
|
|
27
|
+
|
|
28
|
+
[tool.pytest.ini_options]
|
|
29
|
+
testpaths = ["tests"]
|
|
30
|
+
pythonpath = ["."]
|
|
31
|
+
addopts = "-ra"
|
|
32
|
+
cache_dir = "./.cache/pytest"
|
|
33
|
+
|
|
34
|
+
# RUFF
|
|
35
|
+
|
|
36
|
+
[tool.ruff]
|
|
37
|
+
target-version = "py39"
|
|
38
|
+
line-length = 100
|
|
39
|
+
output-format = "grouped" # (groups by file), default is 'full'
|
|
40
|
+
show-fixes = true
|
|
41
|
+
extend-exclude = ["tests/*"]
|
|
42
|
+
cache-dir = "./.cache/ruff"
|
|
43
|
+
|
|
44
|
+
[tool.ruff.lint]
|
|
45
|
+
select = [
|
|
46
|
+
"E", # pycodestyle
|
|
47
|
+
"F", # Pyflakes
|
|
48
|
+
"I", # isort
|
|
49
|
+
"B", # flake8-bugbear
|
|
50
|
+
"UP", # pyupgrade
|
|
51
|
+
"SIM", # flake8-simplify
|
|
52
|
+
"C4", # flake8-comprehensions
|
|
53
|
+
]
|
|
54
|
+
ignore = [
|
|
55
|
+
'DTZ001', 'DTZ005', 'DTZ007', 'DTZ011', # datetime-timezone-checks
|
|
56
|
+
'E101' # indentation contains mixed spaces and tabs
|
|
57
|
+
]
|
|
58
|
+
|
|
59
|
+
[tool.ruff.format]
|
|
60
|
+
quote-style = "double"
|
|
61
|
+
indent-style = "space"
|
|
62
|
+
docstring-code-format = true
|