Skip to content

Commit

Permalink
build: project
Browse files Browse the repository at this point in the history
fix configuration loading

feat: fix settings (rust)

 fix configuration loading

feat: fix settings (rust)

feat: rust code debugging

feat: rust code debugging

feat: rust code debugging

feat: rust code debugging

feat: rust code debugging

 fix configuration loading

feat: fix settings (rust)

 fix configuration loading

feat: fix settings (rust)

feat: rust code debugging

feat: rust code debugging

feat: rust code debugging

feat: rust code debugging

feat: rust code debugging

build: rust setup

build: project

revert unintended change

feat: rust code

fix configuration loading

feat: fix settings (rust)

 fix configuration loading

feat: fix settings (rust)

feat: rust code debugging

feat: rust code debugging

feat: rust code debugging

feat: rust code debugging

feat: rust code debugging

 fix configuration loading

feat: fix settings (rust)

 fix configuration loading

feat: fix settings (rust)

feat: rust code debugging

feat: rust code debugging

feat: rust code debugging

feat: rust code debugging

feat: rust code debugging

build: project

build: project

build: project
  • Loading branch information
subotic committed Feb 22, 2025
1 parent b989179 commit 910cdee
Show file tree
Hide file tree
Showing 8 changed files with 1,175 additions and 65 deletions.
3 changes: 1 addition & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ MANIFEST
pip-log.txt
pip-delete-this-directory.txt

# Unit test / coverage reports
# Unit tests / coverage reports
htmlcov/
.tox/
.coverage
Expand Down Expand Up @@ -103,7 +103,6 @@ venv.bak/
# mypy
.mypy_cache/
/.idea
/python/test/settings.pkl

# mac
.DS_Store
32 changes: 14 additions & 18 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,21 @@ In the sample registry file, the redirect URLs are DSP-API URLs,
but it is recommended that in production, redirect URLs should refer to
human-readable representations provided by a user interface.

Prerequisites:

- Python 3
- [Sanic](https://sanic.readthedocs.io/en/latest/)
- [Requests](https://docs.python-requests.org/en/master/)
## Requirements / local setup

First, install `uv`, which will automatically handle your Python installations,
virtual environments, and dependencies:

```bash
curl -LsSf https://astral.sh/uv/install.sh | sh
```

Then, create the virtual environment and install the dependencies with:

```bash
uv sync
```


## Examples for using the ark-resolver on the command-line
Expand Down Expand Up @@ -115,17 +125,3 @@ To use, run:
$ docker run daschswiss/ark-resolver
```


## Requirements

To install the requirements:

```bash
$ pip3 install -r requirements.txt
```

To generate the requirements file (requirements.txt), that you commit with the project, do:

```bash
$ pip3 freeze > requirements.txt
```
33 changes: 22 additions & 11 deletions justfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,19 @@ COMMIT_HASH := `git log --pretty=format:'%h' -n 1`
GIT_TAG := `git describe --tags --exact-match 2>/dev/null || true`
IMAGE_TAG := if GIT_TAG == "" { CARGO_VERSION + "-" + COMMIT_HASH } else { CARGO_VERSION }
DOCKER_IMAGE := DOCKER_REPO + ":" + IMAGE_TAG
DOCKER_LATEST := DOCKER_REPO + ":latest"

# List all recipes
default:
just --list --unsorted

# Install python requirements
python-install-requirements:
python3 -m pip install --upgrade pip
pip3 install -r requirements.txt
# Install python packages (as defined in pyproject.toml and uv.lock)
install:
uv sync

# Upgrade python packages (uv.lock)
upgrade:
uv lock --upgrade

# Run all fmt and clippy checks
check:
Expand All @@ -23,31 +27,38 @@ check:
# Format all rust code
fmt:
cargo +nightly fmt
cd web-frontend && yarn fmt

# Fix justfile formatting. Warning: will change existing file. Please first use check.
fix:
just --fmt --unstable

# Build Rust using maturin
build:
maturin develop
build: install
uv run maturin develop

# Run ark-resolver Python unit tests which require Rust code
test: python-install-requirements build
pytest
pytest: build
uv run pytest

# Run Rust unit tests
test: build
cargo test

# Run smoke tests that will spinn up a Docker container and call the health endpoint
smoke-test: build
cargo test --tests smoke_test

# Clean up build artifacts
clean:
cargo clean

# Build linux/amd64 Docker image locally
docker-build-intel:
docker buildx build --platform linux/amd64 -t {{ DOCKER_IMAGE }} --load .
docker buildx build --platform linux/amd64 -t {{ DOCKER_IMAGE }} -t {{ DOCKER_LATEST }} --load .

# Build linux/arm64 Docker image locally
docker-build-arm:
docker buildx build --platform linux/arm64 -t {{ DOCKER_IMAGE }} --load .
docker buildx build --platform linux/arm64 -t {{ DOCKER_IMAGE }} -t {{ DOCKER_LATEST }} --load .

# Build and push linux/amd64 and linux/arm64 Docker images to Docker hub
docker-publish-intel:
Expand Down
54 changes: 53 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,61 @@ name = "ark-resolver"
version = "0.1.0"
description = "ARK Resolver implemented in Python and Rust"
readme = "README.md"
requires-python = ">=3.8"
requires-python = ">=3.11"
license = "Apache-2.0"

dependencies = [
"sanic",
"Sanic-Cors",
"Sanic-Plugins-Framework",
"sanic-routing",
"aiofiles",
"anyio",
"certifi",
"chardet",
"charset-normalizer",
"h11",
"html5tagger",
"httpcore",
"httptools",
"httpx",
"idna",
"maturin",
"multidict",
"opentelemetry-api",
"opentelemetry-sdk",
"requests",
"rfc3986",
"sentry-sdk[opentelemetry, sanic]",
"sniffio",
"toml",
"tracerite",
"types-requests",
"types-urllib3",
"typing_extensions",
"urllib3",
"uvloop",
"websockets",
]
[dependency-groups]
dev = [
"maturin",
"pytest",
"black",
"flake8",
"mypy",
"pre-commit"
]

[tool.maturin]
bindings = "pyo3"
module-name = "ark_resolver._rust"

[tool.pytest.ini_options]
minversion = "7.0"
addopts = "--verbose -s"
pythonpath = [".", "python/src", "python/tests"]

[tool.mypy]
strict = true

4 changes: 0 additions & 4 deletions pytest.ini

This file was deleted.

29 changes: 0 additions & 29 deletions requirements.txt

This file was deleted.

8 changes: 8 additions & 0 deletions rust-toolchain.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
[toolchain]
channel = "1.83.0" # or "stable", "nightly", etc.
components = ["rustfmt", "clippy"] # Optional: specify additional components
targets = [
"x86_64-apple-darwin", # Intel Mac
"aarch64-apple-darwin", # Apple Silicon Mac (if applicable)
"x86_64-unknown-linux-gnu" # Production (Intel Linux)
]
Loading

0 comments on commit 910cdee

Please sign in to comment.