Skip to content
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
21 changes: 9 additions & 12 deletions .github/workflows/publish-docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,22 +19,19 @@ jobs:
- name: Checkout Github Repository
uses: actions/checkout@v4

- name: Set up Python
uses: actions/setup-python@v5
- name: Install uv
uses: astral-sh/setup-uv@v4
with:
python-version: ${{ matrix.python-version }}
cache: 'pip'
enable-cache: true

- name: Set up Python
run: uv python install ${{ matrix.python-version }}

- name: Install Python Packages
# if: steps.pip-cache.outputs.cache-hit != 'true'
run: |
python -m pip install --upgrade pip
pip install -r requirements-dev.txt
pip install -r requirements.txt
- name: Install dependencies
run: uv sync --extra doc

- name: Run build-sphinx
run: |
make doc
run: make doc

- name: Deploy gh-pages
uses: peaceiris/actions-gh-pages@v3
Expand Down
107 changes: 45 additions & 62 deletions .github/workflows/run-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,22 +19,19 @@ jobs:
- name: Checkout Github Repository
uses: actions/checkout@v4

- name: Set up Python
uses: actions/setup-python@v5
- name: Install uv
uses: astral-sh/setup-uv@v4
with:
python-version: ${{ matrix.python-version }}
cache: 'pip'
enable-cache: true

- name: Set up Python
run: uv python install ${{ matrix.python-version }}

- name: Install Python Packages
run: |
python -m pip install --upgrade pip
pip install -r requirements-dev.txt
pip install -r requirements.txt
pip install -r requirements-msgpack.txt
- name: Install dependencies
run: uv sync --all-extras

- name: Run unit-test
run: |
make test
run: make test

- name: Upload coverage to Codecov
uses: codecov/codecov-action@v4
Expand All @@ -57,23 +54,19 @@ jobs:
- name: Checkout Github Repository
uses: actions/checkout@v4

- name: Set up Python
uses: actions/setup-python@v5
- name: Install uv
uses: astral-sh/setup-uv@v4
with:
python-version: ${{ matrix.python-version }}
cache: 'pip'
enable-cache: true

- name: Install Python Packages
# if: steps.pip-cache.outputs.cache-hit != 'true'
run: |
python -m pip install --upgrade pip
pip install -r requirements-dev.txt
pip install -r requirements.txt
pip install -r requirements-msgpack.txt
- name: Set up Python
run: uv python install ${{ matrix.python-version }}

- name: Install dependencies
run: uv sync --all-extras

- name: Run style-check
run: |
make style_check
run: make style_check

static:
runs-on: ${{ matrix.os }}
Expand All @@ -87,23 +80,19 @@ jobs:
- name: Checkout Github Repository
uses: actions/checkout@v4

- name: Set up Python
uses: actions/setup-python@v5
- name: Install uv
uses: astral-sh/setup-uv@v4
with:
python-version: ${{ matrix.python-version }}
cache: 'pip'
enable-cache: true

- name: Install Python Packages
# if: steps.pip-cache.outputs.cache-hit != 'true'
run: |
python -m pip install --upgrade pip
pip install -r requirements-dev.txt
pip install -r requirements.txt
pip install -r requirements-msgpack.txt
- name: Set up Python
run: uv python install ${{ matrix.python-version }}

- name: Install dependencies
run: uv sync --all-extras

- name: Run static-check
run: |
make static_check
run: make static_check

security:
runs-on: ${{ matrix.os }}
Expand All @@ -117,23 +106,20 @@ jobs:
- name: Checkout Github Repository
uses: actions/checkout@v4

- name: Set up Python
uses: actions/setup-python@v5
- name: Install uv
uses: astral-sh/setup-uv@v4
with:
python-version: ${{ matrix.python-version }}
cache: 'pip'
enable-cache: true

- name: Set up Python
run: uv python install ${{ matrix.python-version }}

- name: Install Python Packages
run: |
python -m pip install --upgrade pip
pip install -r requirements-dev.txt
pip install -r requirements.txt
pip install -r requirements-msgpack.txt
- name: Install dependencies
run: uv sync --all-extras

- name: Run bandit-check
continue-on-error: true
run: |
make bandit_check
run: make bandit_check

- name: Expose SARIF Results
uses: actions/upload-artifact@v4
Expand All @@ -158,23 +144,20 @@ jobs:
- name: Checkout Github Repository
uses: actions/checkout@v4

- name: Set up Python
uses: actions/setup-python@v5
- name: Install uv
uses: astral-sh/setup-uv@v4
with:
python-version: ${{ matrix.python-version }}
cache: 'pip'
enable-cache: true

- name: Set up Python
run: uv python install ${{ matrix.python-version }}

- name: Install Python Packages
run: |
python -m pip install --upgrade pip
pip install -r requirements-dev.txt
pip install -r requirements.txt
pip install -r requirements-msgpack.txt
- name: Install dependencies
run: uv sync --all-extras

- name: Run pyre-check
continue-on-error: true
run: |
make pyre_check
run: make pyre_check

- name: Expose SARIF Results
uses: actions/upload-artifact@v4
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,4 @@ bandit-sarif.json
venv
.venv
.tests
.python-version
28 changes: 14 additions & 14 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,46 +2,46 @@ PACKAGE := megstore
VERSION := $(shell cat ${PACKAGE}/version.py | sed -n -E 's/.*=//; s/ //g; s/"//g; p')

test:
pytest \
uv run pytest \
--cov=${PACKAGE} --cov-config=pyproject.toml --cov-report=html:html_cov/ --cov-report=term-missing --cov-report=xml --no-cov-on-fail \
--durations=10 \
tests/

format:
ruff check --fix ${PACKAGE} tests scripts pyproject.toml
ruff format ${PACKAGE} tests scripts pyproject.toml
uv run ruff check --fix ${PACKAGE} tests scripts pyproject.toml
uv run ruff format ${PACKAGE} tests scripts pyproject.toml

style_check:
ruff check ${PACKAGE} tests scripts pyproject.toml
ruff format --check ${PACKAGE} tests scripts pyproject.toml
uv run ruff check ${PACKAGE} tests scripts pyproject.toml
uv run ruff format --check ${PACKAGE} tests scripts pyproject.toml

static_check:
make pytype_check

pytype_check:
pytype
uv run pytype

bandit_check:
bandit --quiet --format=sarif --recursive megfile/ > bandit-sarif.json || echo
uv run bandit --quiet --format=sarif --recursive megstore/ > bandit-sarif.json || echo

pyre_check:
pyre --version=none --output=json check > pyre-errors.json || echo
uv run pyre --version=none --output=json check > pyre-errors.json || echo
cat pyre-errors.json | ./scripts/convert_results_to_sarif.py > pyre-sarif.json

mut:
@echo Mutation testing...
mutmut run || echo
mutmut show all
mutmut junitxml > mutmut.xml
uv run mutmut run || echo
uv run mutmut show all
uv run mutmut junitxml > mutmut.xml

doc:
PYTHONPATH=. sphinx-build --fresh-env docs html_doc
PYTHONPATH=. uv run sphinx-build --fresh-env docs html_doc

release:
git tag ${VERSION}
git push origin ${VERSION}

rm -rf build dist
python3 -m build --wheel
uv build --wheel

twine upload dist/${PACKAGE}-${VERSION}-py3-none-any.whl --username='${PYPI_USERNAME}' --password='${PYPI_PASSWORD}'
uv run twine upload dist/${PACKAGE}-${VERSION}-py3-none-any.whl --username='${PYPI_USERNAME}' --password='${PYPI_PASSWORD}'
6 changes: 3 additions & 3 deletions docs/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
Sphinx >= 2.0.1, < 3.0.0
-r ../requirements.txt
m2r
# This file is kept for Read the Docs compatibility
# For local development, use: uv sync --extra doc
megstore[doc]
76 changes: 59 additions & 17 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,15 +1,12 @@
[build-system]
requires = ["setuptools>=64", "wheel"]
build-backend = "setuptools.build_meta"

[project]
name = "megstore"
dynamic = ["version", "dependencies", "optional-dependencies", "readme"]
dynamic = ["version"]
description = "Common Formats. Uncommon Speed."
readme = "README.md"
authors = [
{ name = "megvii-reng", email = "megvii-reng@googlegroups.com" }
]
urls = { Homepage = "https://github.com/megvii-research/megstore" }
requires-python = ">=3.10"
classifiers = [
"Development Status :: 5 - Production/Stable",
"Environment :: Console",
Expand All @@ -25,20 +22,66 @@ classifiers = [
"Programming Language :: Python :: 3.13",
"Programming Language :: Python :: 3.14",
]
requires-python = ">=3.10"
dependencies = [
"megfile",
"orjson",
]

[tool.setuptools.packages.find]
include = ["megstore*"]
# Better dependencies layout for uv:
# - Put user dependencies into project.optional-dependencies;
# - Put dev dependencies into dependency-group.
# However, since pytype doesn't work well with dependency-group,
# we still stick to project.optional-dependencies for now.
[project.optional-dependencies]
msgpack = [
"msgpack>=0.6.0",
"msgpack-numpy>=0.4.6",
]
doc = [
"Sphinx>=7.3.7; python_version >= '3.10'",
"Sphinx; python_version < '3.10'",
"m2r2",
"sphinx-rtd-theme~=2.0",
"sphinxcontrib-jquery",
"sphinx-click",
]
test = [
"pytest",
"pytest-cov",
"pytest-mock>3.6.0",
"pytest-socket",
"pytest-retry",
"moto[s3]>=5.0.0",
"cryptography>=3.3.2",
"mutmut",
"pyfakefs>=4.5",
"mock",
"requests-mock",
]
lint = [
"ruff",
"black",
]
typecheck = [
"msgspec>=0.19.0; python_version >= '3.13'",
"pytype",
"pyre-check~=0.9.22",
"bandit",
"bandit-sarif-formatter",
]
dev = [
"megstore[msgpack,doc,test,lint,typecheck]",
]

[tool.setuptools.dynamic]
version = {attr = "megstore.version.VERSION"}
readme = {file = ["README.md"], content-type = "text/markdown"}
[project.urls]
Homepage = "https://github.com/megvii-research/megstore"

[tool.setuptools.dynamic.dependencies]
file = ["requirements.txt"]
[build-system]
requires = ["hatchling"]
build-backend = "hatchling.build"

[tool.setuptools.dynamic.optional-dependencies]
msgpack = { file = ["requirements-msgpack.txt"] }
[tool.hatch.version]
path = "megstore/version.py"

[tool.ruff]
line-length = 88
Expand All @@ -62,7 +105,6 @@ extend-select = ["I"]
quote-style = "double"

[tool.pytype]

# Space-separated list of files or directories to exclude.
exclude = [
"tests/"
Expand Down
Loading
Loading