Skip to content

Commit

Permalink
Merge pull request #663 from google/uv-port
Browse files Browse the repository at this point in the history
python: poetry => uv port
  • Loading branch information
reyammer authored Sep 12, 2024
2 parents a38d958 + 8663565 commit a80ad6b
Show file tree
Hide file tree
Showing 28 changed files with 941 additions and 41 deletions.
28 changes: 12 additions & 16 deletions .github/workflows/python-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,38 +22,34 @@ jobs:
unit-testing:
strategy:
matrix:
python-version: [ "3.8.x", "3.9.x", "3.10.x", "3.11.x", "3.12.x" ]
python-version: [ "3.8", "3.9", "3.10", "3.11", "3.12" ]
os: [ "ubuntu-latest", "macos-latest" ]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # pin@v4

- name: Setup Python
uses: actions/setup-python@39cd14951b08e74b54015e9e001cdefcf80e669f # pin@v5
with:
python-version: '${{ matrix.python-version }}'
- name: Install uv
run: curl -LsSf https://astral.sh/uv/0.4.0/install.sh | sh

- name: Install poetry
uses: abatilo/actions-poetry@7b6d33e44b4f08d7021a1dee3c044e9c253d6439 # pin@v3
with:
poetry-version: "1.7.1"
- name: Set up Python ${{ matrix.python-version }}
run: uv python install ${{ matrix.python-version }}

- name: Install the project dependencies
- name: Install the project
working-directory: python
run: poetry install
run: uv sync --all-extras --dev

- name: Run ruff check
working-directory: python
run: poetry run ruff check --verbose
run: uv run ruff check --verbose

- name: Run ruff format check
working-directory: python
run: poetry run ruff format --check --verbose
run: uv run ruff format --check --verbose

- name: Run mypy
working-directory: python
run: poetry run mypy magika tests
run: uv run mypy src/magika tests

- name: Run pytest
- name: Run tests
working-directory: python
run: poetry run pytest tests -m "not slow"
run: uv run pytest tests -m "not slow"
53 changes: 28 additions & 25 deletions python/pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,37 +1,40 @@
[tool.poetry]
[project]
name = "magika"
version = "0.6.0-dev"
description = "A tool to determine the content type of a file with deep learning"
authors = ["Magika Developers <[email protected]>"]
authors = [
{author = "Magika Developers", email = "[email protected]"},
]
readme = "README.md"
license = "Apache License 2.0"
packages = [{include = "magika"}]
license = "Apache-2.0"
requires-python = ">=3.8"
dynamic = ["version"]

[tool.poetry.dependencies]
python = "^3.8,<3.13"
click = "^8.1.3"
onnxruntime = "^1.19.0"
numpy = [
{version = "^1.24", python = ">=3.8,<3.9"},
{version = "^1.26", python = ">=3.9,<3.10"},
{version = "^2.1.0", python = ">=3.10,<3.13"},
dependencies = [
"click>=8.1.7",
"onnxruntime>=1.19.0",
"numpy>=1.24; python_version >= '3.8' and python_version < '3.9'",
"numpy>=1.26; python_version >= '3.9' and python_version < '3.10'",
"numpy>=2.1.0; python_version >= '3.10'",
"python-dotenv>=1.0.1",
"requests>=2.32.3",
]
python-dotenv = "^1.0.1"
mypy = "1.11.2"

[tool.poetry.group.dev.dependencies]
pytest = "^8.3.2"
ipython = [
{version = "^8.12.3", python = ">=3.8,<3.9"},
{version = "^8.18.1", python = ">=3.9,<3.10"},
{version = "^8.21.0", python = ">=3.10,<3.13"}
[tool.uv]
dev-dependencies = [
"mypy>=1.11.2",
"ipython>=8.12.3; python_version >= '3.8' and python_version < '3.9'",
"ipython>=8.18.1; python_version >= '3.9' and python_version < '3.10'",
"ipython>=8.21.0; python_version >= '3.10'",
"pytest>=8.3.2",
"ruff>=0.6.3",
]
ruff = ">=0.2.2,<0.7.0"
mypy = "^1.11.2"

[build-system]
requires = ["poetry-core"]
build-backend = "poetry.core.masonry.api"
requires = ["hatchling"]
build-backend = "hatchling.build"

[tool.hatch.version]
path = "src/magika/__init__.py"

[tool.ruff.lint]
# Enable Pyflakes (`F`) and a subset of the pycodestyle (`E`) codes by default.
Expand Down
3 changes: 3 additions & 0 deletions python/magika/__init__.py → python/src/magika/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@
# limitations under the License.


__version__ = "0.6.0-dev0"


import dotenv

from magika import magika
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Empty file added python/src/magika/py.typed
Empty file.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
7 changes: 7 additions & 0 deletions python/tests/test_magika_python_module.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,13 @@
from tests import utils


@pytest.mark.smoketest
def test_magika_module_check_version() -> None:
import magika as magika_module

assert isinstance(magika_module.__version__, str)


@pytest.mark.smoketest
def test_magika_module_one_basic_test() -> None:
model_dir = utils.get_default_model_dir()
Expand Down
1 change: 1 addition & 0 deletions python/tests/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ def get_default_model_dir() -> Path:

model_dir = (
Path(__file__).parent.parent
/ "src"
/ "magika"
/ "models"
/ Magika.get_default_model_name()
Expand Down
890 changes: 890 additions & 0 deletions python/uv.lock

Large diffs are not rendered by default.

0 comments on commit a80ad6b

Please sign in to comment.