Skip to content

Commit

Permalink
Initial attempt.
Browse files Browse the repository at this point in the history
  • Loading branch information
hameerabbasi committed Sep 6, 2024
1 parent 9e62c9c commit bc4a4e8
Show file tree
Hide file tree
Showing 26 changed files with 987 additions and 155 deletions.
2 changes: 2 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
uarray/_version.py export-subst
# GitHub syntax highlighting
pixi.lock linguist-language=YAML linguist-generated=true
30 changes: 15 additions & 15 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,13 @@ jobs:
os: [ubuntu-latest, windows-latest, macos-latest]

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Build wheels
uses: pypa/cibuildwheel@v2.8.0
- uses: actions/upload-artifact@v3
uses: pypa/cibuildwheel@v2.20.0
- uses: actions/upload-artifact@v4
with:
name: Wheels
path: ./wheelhouse/*.whl
Expand All @@ -38,13 +38,13 @@ jobs:
name: Documentation, Linting and Coverage
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: actions/setup-python@v2
- uses: actions/setup-python@v5
with:
# Update according to NEP-29
python-version: '3.8'
python-version: '3.10'
cache: 'pip'
- name: Install package
run: |
Expand All @@ -56,7 +56,7 @@ jobs:
run: |
doc8
- name: Upload documentation
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: Documentation
path: _build/html
Expand All @@ -67,12 +67,12 @@ jobs:
run: |
mypy uarray
- name: Run clang-format style check for C/C++ code.
uses: jidicula/clang-format-action@v4.3.1
uses: jidicula/clang-format-action@v4.13.0
with:
clang-format-version: '13'
check-path: 'uarray'
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v2
uses: codecov/codecov-action@v4
with:
directory: 'coverage/coverage*.xml'
env_vars: OS,PYTHON
Expand All @@ -83,12 +83,12 @@ jobs:
name: Tests for PyPy3
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: actions/setup-python@v2
- uses: actions/setup-python@v5
with:
python-version: 'pypy-3.8'
python-version: 'pypy-3.10'
cache: 'pip'
- name: Install package
run: |
Expand All @@ -101,11 +101,11 @@ jobs:
name: Run SciPy FFT tests
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v2
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
# Update according to NEP-29
python-version: '3.8'
python-version: '3.10'
cache: 'pip'
- name: Install package
run: |
Expand Down
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,8 @@ sandbox.py
*.so
build/
default.profraw
uarray/_version.py
src/uarray/_version.py
*.pyd
# pixi environments
.pixi
*.egg-info
5 changes: 0 additions & 5 deletions MANIFEST.in

This file was deleted.

867 changes: 867 additions & 0 deletions pixi.lock

Large diffs are not rendered by default.

93 changes: 84 additions & 9 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,28 +1,103 @@
[build-system]
requires = ["setuptools>=45", "wheel", "setuptools_scm[toml]>=6.2"]
requires = ["scikit-build-core", "setuptools_scm>=8"]
build-backend = "scikit_build_core.setuptools.build_meta"

[tool.black]
exclude = 'uarray/_version.py'
[project]
name = "uarray"
dynamic = ["version"]
description = "Array interface object for Python with pluggable backends and a multiple-dispatch mechanism for defining down-stream functions"
readme = "README.md"
dependencies = []
maintainers = [{ name = "Hameer Abbasi", email = "[email protected]" }]
requires-python = ">=3.10"
license = { file = "LICENSE" }
keywords = ["uarray", "scipy", "multiple-dispatch"]
classifiers = [
"Development Status :: 2 - Pre-Alpha",
"Operating System :: OS Independent",
"License :: OSI Approved :: BSD License",
"Programming Language :: Python",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"Programming Language :: Python :: 3.13",
"Programming Language :: Python :: 3 :: Only",
"Intended Audience :: Developers",
"Intended Audience :: Science/Research",
"Typing :: Typed",
]

[tool.setuptools_scm]
write_to = "uarray/_version.py"
version_file = "src/uarray/_version.py"

[tool.scikit-build]
wheel.packages = ["src/uarray"]
metadata.version.provider = "scikit_build_core.metadata.setuptools_scm"
sdist.include = ["src/package/_version.py"]

[project.urls]
Documentation = "https://uarray.org/"
Source = "https://github.com/Quansight-Labs/uarray/"
Repository = "https://github.com/Quansight-Labs/uarray.git"
"Issue Tracker" = "https://github.com/Quansight-Labs/uarray/issues"

[project.optional-dependencies]
docs = [
"sphinx",
"sphinx_rtd_theme",
"doc8",
]
tests = [
"pytest>=3.5",
"pytest-flake8",
"pytest-cov",
"mypy>=0.930",
]
optional = []
all = [
"uarray[docs]",
"uarray[tests]",
"uarray[optional]",
]

[tool.mypy]
show_error_codes = true
no_implicit_reexport = true
disallow_any_unimported = true

[[tool.mypy.overrides]]
module = [
"pytest_black.*",
]
ignore_missing_imports = true
disallow_any_unimported = false

[tool.cibuildwheel]
build = "{cp3{8..10}-*,pp3{8..9}-*}"
build = "{cp3{10..13}-*,pp310-*}"
build-frontend = "build"
free-threaded-support = true
test-command = "pip install -r {project}/requirements/tests.txt && pytest --pyargs uarray"

[tool.cibuildwheel.macos]
archs = ["x86_64", "universal2"]
archs = ["universal2"]

[tool.cibuildwheel.config-settings]
"cmake.verbose" = true
"logging.level" = "INFO"

[tool.pixi.project]
channels = ["conda-forge"]
platforms = ["osx-arm64"]

[tool.pixi.feature.all.dependencies]
pip = "*"

[tool.pixi.pypi-dependencies]
uarray = { path = "." }

[tool.pixi.environments]
default = { solve-group = "default" }
all = { features = ["all", "docs", "tests", "optional"], solve-group = "default" }
docs = { features = ["docs"], solve-group = "default" }
optional = { features = ["optional"], solve-group = "default" }
tests = { features = ["tests"], solve-group = "default" }

[tool.pixi.tasks]
1 change: 0 additions & 1 deletion requirements/tests.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
pytest>=3.5
pytest-flake8
pytest-cov
pytest-black; platform_python_implementation == 'CPython'
mypy>=0.930
10 changes: 0 additions & 10 deletions setup.cfg

This file was deleted.

104 changes: 2 additions & 102 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,103 +1,3 @@
#!/usr/bin/env python
from setuptools import setup

from setuptools import setup, find_packages, Extension
from setuptools.command.build_ext import build_ext
from pathlib import Path
import sys
import os
from typing import List

cwd = Path(os.path.dirname(os.path.abspath(__file__)))


def open_reqs_file(file, reqs_path=Path(cwd)):
with (reqs_path / file).open() as f:
reqs = list(f.read().strip().split("\n"))

i = 0
while i < len(reqs):
if reqs[i].startswith("-r"):
reqs[i : i + 1] = open_reqs_file(reqs[i][2:].strip(), reqs_path=reqs_path)
else:
i += 1

return reqs


extras_require = {}
reqs = [] # type: List[str]


def parse_requires():
reqs_path = cwd / "requirements"
reqs.extend(open_reqs_file("requirements.txt"))

for f in reqs_path.iterdir():
extras_require[f.stem] = open_reqs_file(f.parts[-1], reqs_path=reqs_path)


parse_requires()

with open("README.md") as f:
long_desc = f.read()


class build_cpp11_ext(build_ext):
def build_extension(self, ext):
cc = self.compiler
if cc.compiler_type == "unix":
ext.extra_compile_args.append("--std=c++11")
if self.plat_name.startswith("macosx"):
ext.extra_compile_args.append("-mmacosx-version-min=10.9")
ext.extra_link_args.append("-mmacosx-version-min=10.9")
build_ext.build_extension(self, ext)


extensions = [
Extension(
"uarray._uarray",
sources=["uarray/_uarray_dispatch.cxx", "uarray/vectorcall.cxx"],
depends=["uarray/small_dynamic_array.h", "uarray/vectorcall.h"],
language="c++",
)
]

setup(
name="uarray",
cmdclass={"build_ext": build_cpp11_ext},
description="Array interface object for Python with pluggable backends and a multiple-dispatch"
"mechanism for defining down-stream functions",
url="https://github.com/Quansight-Labs/uarray/",
maintainer="Hameer Abbasi",
maintainer_email="[email protected]",
license="BSD 3-Clause License (Revised)",
keywords="uarray,numpy,scipy,pytorch,cupy,tensorflow",
packages=find_packages(include=["uarray", "uarray.*"]),
long_description=long_desc,
long_description_content_type="text/markdown",
install_requires=reqs,
extras_require=extras_require,
zip_safe=False,
classifiers=[
"Development Status :: 2 - Pre-Alpha",
"Operating System :: OS Independent",
"License :: OSI Approved :: BSD License",
"Programming Language :: Python",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3 :: Only",
"Intended Audience :: Developers",
"Intended Audience :: Science/Research",
"Typing :: Typed",
],
package_data={"uarray": ["*.pyi", "py.typed"]},
project_urls={
"Documentation": "https://uarray.org/",
"Source": "https://github.com/Quansight-Labs/uarray/",
"Tracker": "https://github.com/Quansight-Labs/uarray/issues",
},
python_requires=">=3.8, <4",
ext_modules=extensions,
)
setup(cmake_source_dir="./src")
13 changes: 13 additions & 0 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
cmake_minimum_required(VERSION 3.15...3.30)
project(${SKBUILD_PROJECT_NAME} LANGUAGES CXX)

find_package(Python COMPONENTS Interpreter Development.Module REQUIRED)

Python_add_library(_uarray MODULE
small_dynamic_array.h
vectorcall.h
vectorcall.cxx
_uarray_dispatch.cxx
WITH_SOABI)
set_property(TARGET _uarray PROPERTY CXX_STANDARD 11)
install(TARGETS _uarray LIBRARY DESTINATION uarray)
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.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
12 changes: 0 additions & 12 deletions uarray/tests/plugin.py

This file was deleted.

0 comments on commit bc4a4e8

Please sign in to comment.