Skip to content

fix: Address issues in installing and first steps with Tesseract #30

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Feb 25, 2025
Merged
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
34 changes: 30 additions & 4 deletions inject_runtime_pyproject.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,40 @@

RUNTIME_PYPROJECT_PATH = "tesseract_core/runtime/meta/pyproject.toml"

BASE_OPTIONAL_DEPS = {
"dev": [
"fastapi",
"httpx", # required by fastapi test client
"jsf",
"requests",
"numpy",
"pre-commit",
"pytest",
"pytest-cov",
"pytest-mock",
"moto[server]",
"aiobotocore>=2.19.0", # without this pip dependency resolution fails
"typeguard",
"detect-secrets[gibberish]",
# also add all other extras here
"tesseract-core[runtime]",
],
"runtime": [],
}

BASE_SCRIPTS = {
"tesseract": "tesseract_core.sdk.cli:entrypoint",
}


class RuntimeDepenencyHook(MetadataHookInterface):
PLUGIN_NAME = "runtime-deps"

def update(self, metadata):
runtime_metadata = toml.load(Path(self.root) / RUNTIME_PYPROJECT_PATH)
metadata["optional-dependencies"]["runtime"] = runtime_metadata["project"][
"dependencies"
]
metadata["scripts"].update(runtime_metadata["project"]["scripts"])
metadata["optional-dependencies"] = {
**BASE_OPTIONAL_DEPS,
"runtime": runtime_metadata["project"]["dependencies"],
}
metadata["scripts"] = {**BASE_SCRIPTS, **runtime_metadata["project"]["scripts"]}
return metadata
32 changes: 6 additions & 26 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,38 +17,18 @@ dependencies = [
"numpy",
"requests",
]
dynamic = ["version"]

[project.optional-dependencies]
# Populated by our custom hook based on dependencies in `tesseract_core/runtime/meta/pyproject.toml`
# Changes to this list will be ignored
runtime = []

dev = [
"fastapi",
"httpx", # required by fastapi test client
"jsf",
"requests",
"numpy",
"pre-commit",
"pytest",
"pytest-cov",
"pytest-mock",
"moto[server]",
"aiobotocore>=2.19.0", # without this pip dependency resolution fails
"typeguard",
"detect-secrets[gibberish]",
# also add all other extras here
"tesseract-core[runtime]",
dynamic = [
# Injected via hatch-vcs
"version",
# Injected via inject_runtime_pyproject.py
"optional-dependencies",
"scripts",
]

[project.urls]
Homepage = "https://github.com/pasteurlabs/tesseract-core"
Documentation = "https://pasteur-labs-tesseract-core.readthedocs-hosted.com/en/latest/"

[project.scripts]
tesseract = "tesseract_core.sdk.cli:entrypoint"

[build-system]
requires = ["hatchling", "hatch-vcs", "toml"]
build-backend = "hatchling.build"
Expand Down
2 changes: 1 addition & 1 deletion tesseract_core/sdk/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ def _validate_tesseract_name(name: str | None) -> str:
def version_callback(value: bool | None) -> None:
"""Typer callback for version option."""
if value:
from . import __version__
from tesseract_core import __version__

typer.echo(__version__)
raise typer.Exit()
Expand Down
8 changes: 8 additions & 0 deletions tests/sdk_tests/test_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,11 @@ def test_suggestion_on_misspelled_command(cli_runner):
assert result.exit_code == 2, result.stdout
assert "No such command 'wellbloodygreatinnit'." in result.stderr
assert "Did you mean" not in result.stderr


def test_version(cli_runner):
from tesseract_core import __version__

result = cli_runner.invoke(cli, ["--version"])
assert result.exit_code == 0, result.stdout
assert __version__ in result.stdout
Loading