diff --git a/.github/actions/setup-tinygrad/action.yml b/.github/actions/setup-tinygrad/action.yml index 0b2dbc05a5..dcd74db056 100644 --- a/.github/actions/setup-tinygrad/action.yml +++ b/.github/actions/setup-tinygrad/action.yml @@ -61,7 +61,7 @@ runs: uses: actions/cache@v4 with: path: ${{ github.workspace }}/.venv - key: venv-${{ runner.os }}-python-${{ steps.setup-python.outputs.python-version }}-${{ inputs.deps }}-${{ inputs.pydeps }}-${{ hashFiles('**/setup.py') }}-${{ env.PYTHON_CACHE_VERSION }} + key: venv-${{ runner.os }}-python-${{ steps.setup-python.outputs.python-version }}-${{ inputs.deps }}-${{ inputs.pydeps }}-${{ hashFiles('**/pyproject.toml') }}-${{ env.PYTHON_CACHE_VERSION }} # **** Caching downloads **** diff --git a/.github/workflows/python-publish.yml b/.github/workflows/python-publish.yml index 22f36f2335..8f56f3eed7 100644 --- a/.github/workflows/python-publish.yml +++ b/.github/workflows/python-publish.yml @@ -20,11 +20,11 @@ jobs: - name: Install dependencies run: | python -m pip install --upgrade pip - pip install setuptools wheel twine + pip install setuptools wheel build twine - name: Build and publish env: TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }} TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }} run: | - python setup.py sdist bdist_wheel + python -m build twine upload dist/* diff --git a/mypy.ini b/mypy.ini deleted file mode 100644 index 8a838bd232..0000000000 --- a/mypy.ini +++ /dev/null @@ -1,10 +0,0 @@ -[mypy] -warn_unused_configs = True -files = tinygrad -ignore_missing_imports = True -check_untyped_defs = True -explicit_package_bases = True -warn_unreachable = True -warn_redundant_casts = True -# NOTE: had to comment this out to make mypy pass on both CI and OSX -#warn_unused_ignores = True diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 0000000000..95d3e8ee8c --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,143 @@ +[project] +name = "tinygrad" +version = "0.11.0" +description = "You like pytorch? You like micrograd? You love tinygrad! <3" +authors = [{ name = "George Hotz" }] + +classifiers = ["Programming Language :: Python :: 3"] + +license = 'MIT' +readme = "README.md" +requires-python = ">=3.11" +dependencies = [] + +[build-system] +requires = ["setuptools"] +build-backend = "setuptools.build_meta" + +[tool.setuptools] +include-package-data = true +packages = [ + 'tinygrad', + 'tinygrad.apps', + 'tinygrad.codegen', + 'tinygrad.codegen.opt', + 'tinygrad.codegen.late', + 'tinygrad.engine', + 'tinygrad.mixin', + 'tinygrad.nn', + 'tinygrad.renderer', + 'tinygrad.runtime', + 'tinygrad.runtime.autogen', + 'tinygrad.runtime.autogen.am', + 'tinygrad.runtime.autogen.nv', + 'tinygrad.runtime.graph', + 'tinygrad.runtime.support', + 'tinygrad.runtime.support.am', + 'tinygrad.runtime.support.nv', + 'tinygrad.schedule', + 'tinygrad.uop', + 'tinygrad.viz', +] + +[tool.setuptools.package-data] +tinygrad = ["py.typed"] +"tinygrad.viz" = ["index.html", "assets/**/*", "js/*"] + + +[project.optional-dependencies] +arm = ["unicorn"] +triton = ["triton-nightly>=2.1.0.dev20231014192330"] +linting = [ + "pylint", + "mypy==1.18.1", + "typing-extensions", + "pre-commit", + "ruff", + "numpy", + "typeguard", +] +# mlperf = [ +# "mlperf-logging @ git+https://github.com/mlperf/logging.git@5.0.0-rc3", +# ] +testing_minimal = [ + "numpy", + "torch==2.9.0", + "pytest", + "pytest-xdist", + "pytest-timeout", + "pytest-split", + "hypothesis", + "z3-solver", +] +testing_unit = ["tinygrad[testing_minimal]", "tqdm", "safetensors", "tabulate"] +testing = [ + "tinygrad[testing_minimal]", + "pillow", + "onnx==1.18.0", + "onnx2torch", + "onnxruntime", + "opencv-python", + "tabulate", + "tqdm", + "safetensors", + "transformers", + "sentencepiece", + "tiktoken", + "blobfile", + "librosa", + # librosa needs numba but uv ignores python upper bounds and some numba versions require =0.55", + "networkx", + "nibabel", + "bottle", + "ggml-python", + "capstone", + "pycocotools", + "boto3", + "pandas", + "influxdb3-python", +] +docs = [ + "mkdocs", + "mkdocs-material", + "mkdocstrings[python]", + "markdown-callouts", + "markdown-exec[ansi]", + "black", + "numpy", +] + + +[tool.mutmut] +paths_to_mutate = ["tinygrad/"] +do_not_mutate = [ + "tinygrad/apps/*", + "tinygrad/codegen/*", + "tinygrad/engine/*", + "tinygrad/nn/*", + "tinygrad/renderer/*", + "tinygrad/runtime/*", + "tinygrad/schedule/*", + "tinygrad/uop/*", + "tinygrad/viz/*", + "tinygrad/device.py", + "tinygrad/dtype.py", + "tinygrad/gradient.py", + "tinygrad/helpers.py", + "tinygrad/tensor.py", +] +tests_dir = ["test/test_tiny.py", "test/test_ops.py"] +debug = true + + +[tool.mypy] +warn_unused_configs = true +files = ["tinygrad"] +ignore_missing_imports = true +check_untyped_defs = true +explicit_package_bases = true +warn_unreachable = true +warn_redundant_casts = true +# NOTE: had to comment this out to make mypy pass on both CI and OSX +#warn_unused_ignores = true diff --git a/setup.cfg b/setup.cfg deleted file mode 100644 index d10ab4ded6..0000000000 --- a/setup.cfg +++ /dev/null @@ -1,21 +0,0 @@ -[mutmut] -paths_to_mutate=tinygrad -do_not_mutate= - tinygrad/apps/* - tinygrad/codegen/* - tinygrad/engine/* - tinygrad/nn/* - tinygrad/renderer/* - tinygrad/runtime/* - tinygrad/schedule/* - tinygrad/uop/* - tinygrad/viz/* - tinygrad/device.py - tinygrad/dtype.py - tinygrad/gradient.py - tinygrad/helpers.py - tinygrad/tensor.py -tests_dir= - test/test_tiny.py - test/test_ops.py -debug=true diff --git a/setup.py b/setup.py deleted file mode 100644 index 412209a8de..0000000000 --- a/setup.py +++ /dev/null @@ -1,111 +0,0 @@ -#!/usr/bin/env python3 - -from pathlib import Path -from setuptools import setup - -directory = Path(__file__).resolve().parent -with open(directory / 'README.md', encoding='utf-8') as f: - long_description = f.read() - -testing_minimal = [ - "numpy", - "torch==2.9.0", - "pytest", - "pytest-xdist", - "pytest-timeout", - "pytest-split", - "hypothesis", - "z3-solver", -] - -setup(name='tinygrad', - version='0.11.0', - description='You like pytorch? You like micrograd? You love tinygrad! <3', - author='George Hotz', - license='MIT', - long_description=long_description, - long_description_content_type='text/markdown', - packages = [ - 'tinygrad', - 'tinygrad.apps', - 'tinygrad.codegen', - 'tinygrad.codegen.opt', - 'tinygrad.codegen.late', - 'tinygrad.engine', - 'tinygrad.mixin', - 'tinygrad.nn', - 'tinygrad.renderer', - 'tinygrad.runtime', - 'tinygrad.runtime.autogen', - 'tinygrad.runtime.autogen.am', - 'tinygrad.runtime.autogen.nv', - 'tinygrad.runtime.graph', - 'tinygrad.runtime.support', - 'tinygrad.runtime.support.am', - 'tinygrad.runtime.support.nv', - 'tinygrad.schedule', - 'tinygrad.uop', - 'tinygrad.viz', - ], - package_data = {'tinygrad': ['py.typed'], 'tinygrad.viz': ['index.html', 'assets/**/*', 'js/*']}, - classifiers=[ - "Programming Language :: Python :: 3", - "License :: OSI Approved :: MIT License" - ], - install_requires=[], - python_requires='>=3.11', - extras_require={ - 'arm': ["unicorn"], - 'triton': ["triton-nightly>=2.1.0.dev20231014192330"], - 'linting': [ - "pylint", - "mypy==1.18.1", - "typing-extensions", - "pre-commit", - "ruff", - "numpy", - "typeguard", - ], - #'mlperf': ["mlperf-logging @ git+https://github.com/mlperf/logging.git@5.0.0-rc3"], - 'testing_minimal': testing_minimal, - 'testing_unit': testing_minimal + [ - "tqdm", - "safetensors", - "tabulate", # for sz.py - ], - 'testing': testing_minimal + [ - "pillow", - "onnx==1.18.0", - "onnx2torch", - "onnxruntime", - "opencv-python", - "tabulate", - "tqdm", - "safetensors", - "transformers", - "sentencepiece", - "tiktoken", - "blobfile", - "librosa", - "numba>=0.55", # librosa needs numba but uv ignores python upper bounds and some numba versions require