Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,28 +44,28 @@ jobs:
matrix:
os: [ubuntu-22.04]
openfoam-version: [9, 14, 2006, 2606]
python-version: ['3.9', '3.15']
python-version: ['3.10', '3.15']
dependency-resolution: [highest]
include:
- os: ubuntu-22.04
openfoam-version: 9
python-version: '3.9'
python-version: '3.10'
dependency-resolution: lowest-direct
- os: ubuntu-22.04
openfoam-version: 2006
python-version: '3.9'
python-version: '3.10'
dependency-resolution: lowest-direct
- os: macos-latest
openfoam-version: 2112
python-version: '3.9'
python-version: '3.10'
dependency-resolution: lowest-direct
- os: macos-latest
openfoam-version: 2112
python-version: '3.15'
dependency-resolution: highest
- os: macos-latest
openfoam-version: 2606
python-version: '3.9'
python-version: '3.10'
dependency-resolution: lowest-direct
- os: macos-latest
openfoam-version: 2606
Expand Down
11 changes: 5 additions & 6 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ license = "GPL-3.0-only"
license-files = ["LICENSE.txt"]
description = "Package manager for OpenFOAM"
readme = "README.md"
requires-python = ">=3.9"
requires-python = ">=3.10"
authors = [{name = "Gabriel S. Gerlero", email = "ggerlero@cimec.unl.edu.ar"}]
classifiers = [
"Development Status :: 4 - Beta",
Expand All @@ -18,7 +18,6 @@ classifiers = [
"Operating System :: MacOS :: MacOS X",
"Operating System :: POSIX :: Linux",
"Programming Language :: Python :: 3 :: Only",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
Expand All @@ -31,9 +30,9 @@ classifiers = [
"Typing :: Typed",
]
dependencies = [
"aiohttp>=3.6,<4",
"aiohttp>=3.8,<4",
"aioshutil>=1,<2",
"cyclopts>=3.24,<5",
"cyclopts>=4,<5",
"dulwich>=0.24,<2",
"typing_extensions>=4.4,<5; python_version < '3.12'",
]
Expand All @@ -49,10 +48,10 @@ styro = "styro.__main__:app"
lint = ["ruff>=0.16.5,<0.18"]
typing = ["ty>=0.0.76,<0.1"]
test = [
"pytest>=8,<10",
"pytest>=9,<10",
"pytest-cov>=7,<8",
]
binary = ["pyinstaller>=5,<7"]
binary = ["pyinstaller>=6,<7"]
dev = [
{include-group = "lint"},
{include-group = "typing"},
Expand Down
2 changes: 0 additions & 2 deletions src/styro/__main__.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
"""Package manager for OpenFOAM."""

from __future__ import annotations

import cyclopts

from styro import __version__
Expand Down
7 changes: 1 addition & 6 deletions src/styro/_openfoam.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,11 @@
from __future__ import annotations

import os
import sys
from collections.abc import Generator
from contextlib import ExitStack, contextmanager
from pathlib import Path
from typing import TYPE_CHECKING

from styro._utils.paths import get_changed_files

if TYPE_CHECKING:
from collections.abc import Generator


def platform_path() -> Path:
try:
Expand Down
35 changes: 16 additions & 19 deletions src/styro/_packages/_base.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
from __future__ import annotations

import asyncio
import contextlib
import os
Expand All @@ -25,12 +23,11 @@
if TYPE_CHECKING:
from styro._packages._self import Styro


_NAME_REGEX = re.compile(r"^(?!.*--)[a-z0-9]+(-[a-z0-9]+)*$")
_install_lock = asyncio.Lock()


def _check_for_duplicate_names(pkgs: set[Package], /) -> None:
def _check_for_duplicate_names(pkgs: set["Package"], /) -> None:
duplicate_names = {
pkg.name for pkg in pkgs if len([p for p in pkgs if p.name == pkg.name]) > 1
}
Expand All @@ -42,7 +39,7 @@ def _check_for_duplicate_names(pkgs: set[Package], /) -> None:
sys.exit(1)


async def _detect_cycles(pkgs: set[Package], /, *, upgrade: bool = False) -> None:
async def _detect_cycles(pkgs: set["Package"], /, *, upgrade: bool = False) -> None:
"""
Detect cycles in the dependency graph before installation.

Expand All @@ -63,7 +60,7 @@ class State(Enum):
path: list[Package] = []

async def visit(
pkg: Package,
pkg: "Package",
/,
*,
pkg_upgrade: bool = False,
Expand Down Expand Up @@ -171,18 +168,18 @@ def _parse_package_str(
return None, package

@staticmethod
def all_installed() -> set[Package]:
def all_installed() -> set["Package"]:
with lock as installed:
return {Package(name) for name in installed.get("packages", {})}

@staticmethod
@lock
async def resolve_all(
pkgs: set[Package],
pkgs: set["Package"],
/,
*,
upgrade: bool = False,
) -> set[Package]:
) -> set["Package"]:
_check_for_duplicate_names(pkgs)

# Detect cycles before attempting resolution
Expand All @@ -199,7 +196,7 @@ async def resolve_all(

@staticmethod
@lock
async def install_all(pkgs: set[Package], /, *, upgrade: bool = False) -> None:
async def install_all(pkgs: set["Package"], /, *, upgrade: bool = False) -> None:
to_install = {
pkg: asyncio.Event()
for pkg in await Package.resolve_all(pkgs, upgrade=upgrade)
Expand All @@ -219,7 +216,7 @@ async def install_all(pkgs: set[Package], /, *, upgrade: bool = False) -> None:

@staticmethod
@lock
async def uninstall_all(pkgs: set[Package], /) -> None:
async def uninstall_all(pkgs: set["Package"], /) -> None:
dependents = set()
for pkg in pkgs:
dependents.update(pkg.installed_dependents())
Expand All @@ -236,12 +233,12 @@ async def uninstall_all(pkgs: set[Package], /) -> None:
)

@overload
def __new__(cls, package: Literal["styro"], /) -> Styro: ...
def __new__(cls, package: Literal["styro"], /) -> "Styro": ...

@overload
def __new__(cls, package: str, /) -> Package: ...
def __new__(cls, package: str, /) -> "Package": ...

def __new__(cls, package: str, /) -> Package: # noqa: PYI034
def __new__(cls, package: str, /) -> "Package": # noqa: PYI034
if cls is not Package:
return super().__new__(cls)

Expand Down Expand Up @@ -371,8 +368,8 @@ async def resolve(
*,
upgrade: bool = False,
_force_reinstall: bool = False,
_resolved: set[Package] | None = None,
) -> set[Package]:
_resolved: set["Package"] | None = None,
) -> set["Package"]:
if _resolved is None:
_resolved = set()
elif self in _resolved:
Expand Down Expand Up @@ -442,11 +439,11 @@ def installed_sha(self) -> str | None:
except KeyError:
return None

def requested_dependencies(self) -> set[Package]:
def requested_dependencies(self) -> set["Package"]:
assert self._metadata is not None
return {Package(name) for name in self._metadata.get("requires", [])}

def installed_dependents(self) -> set[Package]:
def installed_dependents(self) -> set["Package"]:
with lock as installed:
return {
Package(name)
Expand All @@ -466,7 +463,7 @@ async def install(
*,
upgrade: bool = False,
_force_reinstall: bool = False,
_deps: bool | dict[Package, asyncio.Event] = True,
_deps: bool | dict["Package", asyncio.Event] = True,
) -> None:
from styro._packages._local import LocalPackage

Expand Down
2 changes: 0 additions & 2 deletions src/styro/_packages/_git.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
from __future__ import annotations

import json
import sys

Expand Down
2 changes: 0 additions & 2 deletions src/styro/_packages/_indexed.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
from __future__ import annotations

import sys

if sys.version_info >= (3, 12):
Expand Down
2 changes: 0 additions & 2 deletions src/styro/_packages/_local.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
from __future__ import annotations

import json
import sys
from pathlib import Path
Expand Down
8 changes: 2 additions & 6 deletions src/styro/_packages/_lock.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,13 @@
from __future__ import annotations

import fcntl
import json
import sys
from collections.abc import Generator
from copy import deepcopy
from typing import TYPE_CHECKING, Any
from typing import Any

from styro._openfoam import platform_path
from styro._utils.context import reentrantcontextmanager

if TYPE_CHECKING:
from collections.abc import Generator


@reentrantcontextmanager
def _lock() -> Generator[dict[str, Any], None, None]:
Expand Down
2 changes: 0 additions & 2 deletions src/styro/_packages/_self.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
from __future__ import annotations

import asyncio
import io
import platform
Expand Down
14 changes: 3 additions & 11 deletions src/styro/_utils/context.py
Original file line number Diff line number Diff line change
@@ -1,26 +1,18 @@
from __future__ import annotations

import sys
from collections.abc import Callable, Generator
from contextlib import AbstractContextManager, ContextDecorator
from functools import wraps
from typing import TYPE_CHECKING, Any, TypeVar, cast
from types import TracebackType
from typing import Any, ParamSpec, TypeVar, cast

if sys.version_info < (3, 15):
import inspect

if sys.version_info >= (3, 10):
from typing import ParamSpec
else:
from typing_extensions import ParamSpec

if sys.version_info >= (3, 12):
from typing import override
else:
from typing_extensions import override

if TYPE_CHECKING:
from collections.abc import Callable, Generator
from types import TracebackType

P = ParamSpec("P")
R = TypeVar("R")
Expand Down
2 changes: 0 additions & 2 deletions src/styro/_utils/git.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
from __future__ import annotations

import asyncio
import os
from pathlib import Path
Expand Down
7 changes: 1 addition & 6 deletions src/styro/_utils/paths.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,7 @@
from __future__ import annotations

import sys
from collections.abc import Generator
from contextlib import contextmanager
from pathlib import Path
from typing import TYPE_CHECKING

if TYPE_CHECKING:
from collections.abc import Generator


def path_from_uri(uri: str, /) -> Path:
Expand Down
10 changes: 3 additions & 7 deletions src/styro/_utils/status.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
from __future__ import annotations

import asyncio
import sys
import time
from contextlib import AbstractContextManager
from io import TextIOBase
from typing import TYPE_CHECKING, ClassVar, TextIO
from types import TracebackType
from typing import ClassVar, TextIO

if sys.version_info >= (3, 11):
from typing import Self
Expand All @@ -17,9 +16,6 @@
else:
from typing_extensions import override

if TYPE_CHECKING:
from types import TracebackType


class _StreamWrapper(TextIOBase):
def __init__(self, stream: TextIO, /) -> None:
Expand All @@ -44,7 +40,7 @@ def flush(self) -> None:


class Status(AbstractContextManager["Status"]):
_statuses: ClassVar[list[Status]] = []
_statuses: ClassVar[list["Status"]] = []
_printed_lines: ClassVar[int] = 0
_dots: ClassVar[int] = 3
_animation_task: ClassVar[asyncio.Task]
Expand Down
9 changes: 2 additions & 7 deletions src/styro/_utils/subprocess.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,11 @@
from __future__ import annotations

import asyncio
import shlex
import subprocess
from collections import deque
from io import StringIO
from typing import TYPE_CHECKING

if TYPE_CHECKING:
from pathlib import Path
from pathlib import Path

from styro._utils.status import Status
from styro._utils.status import Status


async def run(
Expand Down
Loading
Loading