-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* V1 progress * Missing lock * Lock in progress * Test implemented * Ready for realease * Pyrgo ready
- Loading branch information
1 parent
94ce4bd
commit 1a6ffd5
Showing
82 changed files
with
978 additions
and
1,991 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
python 3.7.16 | ||
python 3.9 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,37 +6,33 @@ build-backend = "hatchling.build" | |
name = "pyrgo" | ||
version = "0.4.1" | ||
readme = "README.md" | ||
requires-python = ">=3.7" | ||
requires-python = ">=3.9" | ||
classifiers = [ | ||
"Programming Language :: Rust", | ||
"Programming Language :: Python :: Implementation :: CPython", | ||
"Programming Language :: Python :: Implementation :: PyPy", | ||
] | ||
authors = [ | ||
{ name = "Tomas Perez Alvarez", email = "[email protected]"} | ||
{ name = "Tomas Perez Alvarez", email = "[email protected]" }, | ||
] | ||
dependencies = [ | ||
"click", | ||
"ruff", | ||
"mypy", | ||
"black", | ||
"pip-tools", | ||
"pip-tools>=7.0.0", | ||
"pytest", | ||
"mkdocs-material", | ||
"result==0.10.0", | ||
"result", | ||
"build", | ||
"loguru", | ||
"pip-audit>=2.5.5", | ||
] | ||
|
||
[project.optional-dependencies] | ||
dev = [ | ||
"pytest-cov" | ||
] | ||
dev = ["pytest-cov"] | ||
|
||
[project.scripts] | ||
pyrgo = "pyrgo.cli.pyrgo_core.cli:root" | ||
pyrgo-new = "pyrgo.cli.pyrgo_new.cli:new" | ||
pyrgo = "pyrgo.cli.main:cli" | ||
|
||
[project.urls] | ||
Documentation = "https://github.com/Tomperez98/pyrgo#readme" | ||
|
@@ -45,11 +41,7 @@ Source = "https://github.com/Tomperez98/pyrgo" | |
|
||
[tool.ruff] | ||
line-length = 88 | ||
ignore = [ | ||
"ANN101", | ||
"D203", | ||
"D212", | ||
] | ||
ignore = ["ANN101", "D203", "D212"] | ||
select = ["ALL"] | ||
fix = false | ||
exclude = [ | ||
|
@@ -77,7 +69,7 @@ exclude = [ | |
[tool.ruff.per-file-ignores] | ||
"scripts/*.py" = ["INP001"] | ||
"__init__.py" = ["D104"] | ||
"tests/*.py" = ["INP001", "S101"] | ||
"tests/*.py" = ["INP001", "S101", "D"] | ||
|
||
[tool.ruff.isort] | ||
known-first-party = ["pyrgo"] | ||
|
@@ -91,7 +83,6 @@ ban-relative-imports = "all" | |
[tool.ruff.flake8-quotes] | ||
inline-quotes = "double" | ||
|
||
|
||
[tool.black] | ||
line-length = 88 | ||
include = '\.pyi?$' | ||
|
@@ -102,24 +93,15 @@ xfail_strict = true | |
addopts = [ | ||
"--import-mode=importlib", | ||
"--strict-markers", | ||
"--cov-fail-under=5", | ||
"--cov-report=term-missing:skip-covered", | ||
"--cov-config=pyproject.toml", | ||
"--cov=pyrgo", | ||
] | ||
markers = [ | ||
"integration: mark integration tests.", | ||
"unit: mark unittest.", | ||
] | ||
markers = ["integration: mark integration tests.", "unit: mark unittest."] | ||
|
||
[tool.coverage.run] | ||
branch = true | ||
parallel = true | ||
omit = [ | ||
"pyrgo/logging.py", | ||
"pyrgo/cli/**", | ||
"pyrgo/**/__init__.py" | ||
] | ||
relative_files = true | ||
|
||
[tool.coverage.report] | ||
|
@@ -147,3 +129,7 @@ disallow_untyped_decorators = true | |
disallow_untyped_calls = true | ||
disallow_untyped_defs = true | ||
explicit_package_bases = true | ||
|
||
[tool.pyrgo] | ||
extra-paths = ["scripts"] | ||
extra-caches = [".coverage"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
"""Pyrgo. Python package manager.""" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
"""Pyrgo cli module.""" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
"""CLI commands.""" | ||
from __future__ import annotations | ||
|
||
from pyrgo.cli.cmds._audit import audit | ||
from pyrgo.cli.cmds._build import build | ||
from pyrgo.cli.cmds._check import check | ||
from pyrgo.cli.cmds._clean import clean | ||
from pyrgo.cli.cmds._fmt import fmt | ||
from pyrgo.cli.cmds._lock import lock | ||
from pyrgo.cli.cmds._new import new | ||
from pyrgo.cli.cmds._sync import sync | ||
from pyrgo.cli.cmds._test import test | ||
|
||
__all__ = ["lock", "fmt", "check", "sync", "build", "clean", "test", "audit", "new"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
"""Audit command.""" | ||
from __future__ import annotations | ||
|
||
import sys | ||
|
||
import click | ||
from result import Ok | ||
|
||
from pyrgo.cli.cmds._utils import ensure_env_exist_in_lock_file, inform_and_run_program | ||
from pyrgo.command_exec import PythonCommandExec | ||
from pyrgo.conf import PyrgoConf | ||
|
||
|
||
@click.command("audit") | ||
@click.option( | ||
"-e", | ||
"--env", | ||
"env", | ||
type=click.STRING, | ||
required=True, | ||
) | ||
@click.option( | ||
"--fix/--no-fix", | ||
"fix", | ||
type=click.BOOL, | ||
default=False, | ||
show_default=True, | ||
) | ||
def audit(env: str, *, fix: bool) -> None: | ||
config = PyrgoConf.new() | ||
ensure_env_exist_in_lock_file(env=env, config=config) | ||
|
||
pip_audit_cmd = PythonCommandExec.new(program="pip_audit").add_args( | ||
args=[ | ||
"-r", | ||
config.requirements.joinpath(f"{env}.txt") | ||
.relative_to(config.cwd) | ||
.as_posix(), | ||
], | ||
) | ||
if fix: | ||
pip_audit_cmd.add_args(args=["--fix"]) | ||
|
||
program_execution = inform_and_run_program(commands=[pip_audit_cmd]) | ||
if not isinstance(program_execution, Ok): | ||
sys.exit(1) | ||
|
||
sys.exit(0) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
"""Build command.""" | ||
from __future__ import annotations | ||
|
||
import sys | ||
|
||
import click | ||
from result import Ok | ||
|
||
from pyrgo.cli.cmds._utils import inform_and_run_program | ||
from pyrgo.command_exec import PythonCommandExec | ||
from pyrgo.conf import PyrgoConf | ||
|
||
|
||
@click.command("build") | ||
def build() -> None: | ||
"""Build project with `build`.""" | ||
program_execution = inform_and_run_program( | ||
commands=[ | ||
PythonCommandExec.new(program="build").add_args( | ||
[PyrgoConf.new().cwd.as_posix()], | ||
), | ||
], | ||
) | ||
if not isinstance(program_execution, Ok): | ||
sys.exit(1) | ||
|
||
sys.exit(0) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
"""Check command.""" | ||
from __future__ import annotations | ||
|
||
import sys | ||
|
||
import click | ||
from result import Ok | ||
|
||
from pyrgo.cli.cmds._utils import inform_and_run_program | ||
from pyrgo.command_exec import PythonCommandExec | ||
from pyrgo.conf import PyrgoConf | ||
|
||
|
||
@click.command("check") | ||
@click.option( | ||
"-t", | ||
"--timeout", | ||
"timeout", | ||
default=360, | ||
type=click.IntRange(min=60), | ||
) | ||
@click.option( | ||
"--add-noqa", | ||
"add_noqa", | ||
is_flag=True, | ||
default=False, | ||
show_default=True, | ||
type=click.BOOL, | ||
) | ||
@click.option( | ||
"--ignore-noqa", | ||
"ignore_noqa", | ||
is_flag=True, | ||
default=False, | ||
show_default=True, | ||
type=click.BOOL, | ||
) | ||
def check(*, timeout: int, add_noqa: bool, ignore_noqa: bool) -> None: | ||
"""Check code with `mypy` and `ruff`.""" | ||
configuration = PyrgoConf.new() | ||
ruff_command = PythonCommandExec.new(program="ruff") | ||
mypy_command = PythonCommandExec.new(program="mypy.dmypy").add_args( | ||
args=["run", "--timeout", str(timeout), "--"], | ||
) | ||
|
||
if add_noqa: | ||
ruff_command.add_args(args=["--add-noqa"]) | ||
if ignore_noqa: | ||
ruff_command.add_args(args=["--ignore-noqa"]) | ||
|
||
for command in [ruff_command, mypy_command]: | ||
command.add_args(args=configuration.relevant_paths) | ||
|
||
program_execution = inform_and_run_program(commands=[ruff_command, mypy_command]) | ||
if not isinstance(program_execution, Ok): | ||
sys.exit(1) | ||
|
||
sys.exit(0) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
"""Clean command.""" | ||
from __future__ import annotations | ||
|
||
import itertools | ||
import shutil | ||
import sys | ||
|
||
import click | ||
from result import Ok | ||
|
||
from pyrgo.cli.cmds._utils import inform_and_run_program | ||
from pyrgo.command_exec import PythonCommandExec | ||
from pyrgo.conf import PyrgoConf | ||
|
||
|
||
@click.command("clean") | ||
def clean() -> None: | ||
"""Clean project repository.""" | ||
config = PyrgoConf.new() | ||
for folder in itertools.chain(config.artifacts, config.caches): | ||
if folder.exists(): | ||
if folder.is_dir(): | ||
shutil.rmtree(path=folder) | ||
else: | ||
folder.unlink() | ||
|
||
for path in config.relevant_paths: | ||
for pycache in config.cwd.joinpath(path).rglob(pattern="__pycache__"): | ||
shutil.rmtree(pycache) | ||
|
||
for outdated_file in config.locked_envs().difference(config.env_groups): | ||
config.requirements.joinpath(f"{outdated_file}.txt").unlink() | ||
|
||
program_execution = inform_and_run_program( | ||
commands=[PythonCommandExec.new(program="mypy.dmypy").add_args(args=["stop"])], | ||
) | ||
if not isinstance(program_execution, Ok): | ||
sys.exit(1) | ||
sys.exit(0) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
"""Format command.""" | ||
from __future__ import annotations | ||
|
||
import sys | ||
|
||
import click | ||
from result import Ok | ||
|
||
from pyrgo.cli.cmds._utils import inform_and_run_program | ||
from pyrgo.command_exec import PythonCommandExec | ||
from pyrgo.conf import PyrgoConf | ||
|
||
|
||
@click.command("fmt") | ||
def fmt() -> None: | ||
"""Format code with `ruff` and `black`.""" | ||
configuration = PyrgoConf.new() | ||
ruff_command = PythonCommandExec.new(program="ruff").add_args(args=["--fix-only"]) | ||
black_command = PythonCommandExec.new(program="black") | ||
|
||
for command in [ruff_command, black_command]: | ||
command.add_args(args=configuration.relevant_paths) | ||
|
||
program_execution = inform_and_run_program(commands=[ruff_command, black_command]) | ||
if not isinstance(program_execution, Ok): | ||
sys.exit(1) | ||
sys.exit(0) |
Oops, something went wrong.