Skip to content

Commit bb355b0

Browse files
committed
add imports
1 parent 328c038 commit bb355b0

File tree

6 files changed

+27
-5
lines changed

6 files changed

+27
-5
lines changed

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ projspec = "projspec.__main__:main"
3939
po_test = ["pytest"]
4040

4141
[tool.poetry]
42-
# poetry can't resolve hatch's dynamic version but needs a value
42+
# poetry can't resolve hatch's dynamic versioning but needs a value.
4343
version="0.0.1"
4444

4545
[tool.hatch.version]

src/projspec/__main__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
import projspec.proj
99

10-
# TODO: allow subcommands to list known types and set config
10+
# TODO: allow subcommands to execute artifacts, list known types and set config
1111

1212

1313
@click.command()

src/projspec/cli.py

Whitespace-only changes.

src/projspec/proj/__init__.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
from .base import Project, ProjectSpec
22
from .conda_package import CondaRecipe, RattlerRecipe
33
from .conda_project import CondaProject
4+
from .documentation import RTD, MDBook
45
from .git import GitRepo
56
from .pixi import Pixi
67
from .poetry import PoetryProject
78
from .pyscript import PyScriptSpec
89
from .python_code import PythonCode, PythonLibrary
10+
from .rust import Rust, RustPython
911
from .uv import UVProject
1012

1113
__all__ = [
@@ -14,11 +16,15 @@
1416
"CondaRecipe",
1517
"CondaProject",
1618
"GitRepo",
19+
"MDBook",
1720
"PoetryProject",
1821
"RattlerRecipe",
1922
"Pixi",
2023
"PyScriptSpec",
2124
"PythonCode",
2225
"PythonLibrary",
26+
"RTD",
27+
"Rust",
28+
"RustPython",
2329
"UVProject",
2430
]

src/projspec/proj/documentation.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import re
2+
13
from projspec.proj import ProjectSpec
24

35

@@ -18,5 +20,10 @@ class RTD(ProjectSpec):
1820

1921
def match(self) -> bool:
2022
basenames = [_.rsplit("/", 1)[-1] for _ in self.root.filelist]
23+
return any(re.match("[.]?readthedocs.y[a]?ml", _) for _ in basenames)
24+
25+
def parse(self) -> None:
2126
# supports mkdocs and sphinx builders
22-
return ".readthedocs.yaml" in basenames
27+
# build env usually in `python.install[*].requirements`, which can
28+
# point to a requirements.txt or conda.environment for conda env.
29+
pass

src/projspec/utils.py

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -132,8 +132,7 @@ def __contains__(self, item):
132132

133133

134134
def _yaml_no_jinja(fileobj):
135-
# TODO: rather than skip jinja stuff, we can copy conda code to parse it, but
136-
# templates can involve function calls and reference to env vars we don't have
135+
"""Read YAML text from the given file, attempting to evaluate jinja2 templates."""
137136
txt = fileobj.read().decode()
138137
lines = []
139138
variables = {}
@@ -194,3 +193,13 @@ def flatten(x: Iterable):
194193
except TypeError:
195194
out.add(item)
196195
return out
196+
197+
198+
def sort_version_strings(versions: Iterable[str]) -> list[str]:
199+
def int_or(x):
200+
try:
201+
return int(x)
202+
except ValueError:
203+
return x
204+
205+
return sorted(versions, key=lambda s: [int_or(_) for _ in s.split(".")])

0 commit comments

Comments
 (0)