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 601751b
Show file tree
Hide file tree
Showing 10 changed files with 910 additions and 137 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
6 changes: 3 additions & 3 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ jobs:
fetch-depth: 0

- name: Build wheels
uses: pypa/cibuildwheel@v2.8.0
uses: pypa/cibuildwheel@v2.20.0
- uses: actions/upload-artifact@v3
with:
name: Wheels
Expand All @@ -44,7 +44,7 @@ jobs:
- uses: actions/setup-python@v2
with:
# Update according to NEP-29
python-version: '3.8'
python-version: '3.10'
cache: 'pip'
- name: Install package
run: |
Expand Down Expand Up @@ -88,7 +88,7 @@ jobs:
fetch-depth: 0
- uses: actions/setup-python@v2
with:
python-version: 'pypy-3.8'
python-version: 'pypy-3.10'
cache: 'pip'
- name: Install package
run: |
Expand Down
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,6 @@ build/
default.profraw
uarray/_version.py
*.pyd
# pixi environments
.pixi
*.egg-info
13 changes: 13 additions & 0 deletions 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
uarray/small_dynamic_array.h
uarray/vectorcall.h
uarray/vectorcall.cxx
uarray/_uarray_dispatch.cxx
)
set_property(TARGET _uarray PROPERTY CXX_STANDARD 11)
install(TARGETS _uarray DESTINATION ${SKBUILD_PROJECT_NAME})
811 changes: 811 additions & 0 deletions pixi.lock

Large diffs are not rendered by default.

85 changes: 76 additions & 9 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,28 +1,95 @@
[build-system]
requires = ["setuptools>=45", "wheel", "setuptools_scm[toml]>=6.2"]
requires = ["scikit-build-core", "setuptools", "setuptools_scm"]
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",
]

[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"

[tool.setuptools.packages.find]
where = ["."]
include = ["uarray", "uarray.*"]

[tool.setuptools_scm]
write_to = "uarray/_version.py"
[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"]

[tool.cibuildwheel.config-settings]
"cmake.verbose" = true
"logging.level" = "INFO"
[tool.pixi.project]
channels = ["conda-forge"]
platforms = ["osx-arm64"]

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

[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=".")
12 changes: 0 additions & 12 deletions uarray/tests/plugin.py

This file was deleted.

0 comments on commit 601751b

Please sign in to comment.