Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add black and isort #15

Merged
merged 2 commits into from
Nov 13, 2023
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
13 changes: 10 additions & 3 deletions noxfile.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from nox import options, Session, session
from nox import Session, options, parametrize, session

options.sessions = ["test", "test_numpy", "coverage", "lint"]

Expand All @@ -25,5 +25,12 @@ def coverage(s: Session):


@session(venv_backend="none")
def lint(s: Session) -> None:
s.run("ruff", "check", ".")
@parametrize("command", [["ruff", "check", "."], ["ruff", "format", "--check", "."]])
def lint(s: Session, command: list[str]):
s.run(*command)


@session(venv_backend="none")
def format(s: Session) -> None:
s.run("ruff", "check", ".", "--select", "I", "--fix")
s.run("ruff", "format", ".")
3 changes: 2 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,12 @@ source = [

[tool.ruff]
src = ["src"]
line-length = 120
line-length = 99

extend-exclude = ["src/taco/**"]

extend-select = [
"I", # isort
"N", # pep8-naming
]

Expand Down
99 changes: 49 additions & 50 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,36 +1,41 @@
import platform
import subprocess
from distutils.command.build import build
from pathlib import Path

from distutils.command.build import build
from setuptools import setup, find_packages
from setuptools import find_packages, setup
from wheel.bdist_wheel import bdist_wheel

project_dir = Path(__file__).parent.resolve()
taco_source_dir = project_dir.joinpath('src/taco')
taco_build_dir = project_dir.joinpath('build/taco/')
taco_install_dir = project_dir.joinpath('src/tensora/taco/')
taco_source_dir = project_dir.joinpath("src/taco")
taco_build_dir = project_dir.joinpath("build/taco/")
taco_install_dir = project_dir.joinpath("src/tensora/taco/")


class TensoraBuild(build):
def run(self):
# Build taco
os = platform.system()
if os == "Linux":
install_path = r'-DCMAKE_INSTALL_RPATH=\$ORIGIN/../lib'
install_path = r"-DCMAKE_INSTALL_RPATH=\$ORIGIN/../lib"
elif os == "Darwin":
install_path = r'-DCMAKE_INSTALL_RPATH=@loader_path/../lib'
install_path = r"-DCMAKE_INSTALL_RPATH=@loader_path/../lib"
else:
raise NotImplementedError(f'Tensora cannot be installed on {os}')
raise NotImplementedError(f"Tensora cannot be installed on {os}")

taco_build_dir.mkdir(parents=True, exist_ok=True)
subprocess.check_call(['cmake', str(taco_source_dir),
'-DCMAKE_BUILD_TYPE=Release',
f'-DCMAKE_INSTALL_PREFIX={taco_install_dir}',
install_path],
cwd=taco_build_dir)
subprocess.check_call(['make', '-j8'], cwd=taco_build_dir)
subprocess.check_call(['make', 'install'], cwd=taco_build_dir)
subprocess.check_call(
[
"cmake",
str(taco_source_dir),
"-DCMAKE_BUILD_TYPE=Release",
f"-DCMAKE_INSTALL_PREFIX={taco_install_dir}",
install_path,
],
cwd=taco_build_dir,
)
subprocess.check_call(["make", "-j8"], cwd=taco_build_dir)
subprocess.check_call(["make", "install"], cwd=taco_build_dir)

super().run()

Expand All @@ -44,44 +49,38 @@ def finalize_options(self):


setup(
name='tensora',
version='0.0.8',

description='Library for dense and sparse tensors built on the tensor algebra compiler.',
long_description=Path('README.md').read_text(encoding='utf-8'),
long_description_content_type='text/markdown',
keywords='tensor sparse matrix array',

author='David Hagen',
author_email='david@drhagen.com',
url='https://github.com/drhagen/tensora',
license='MIT',

package_dir={'': 'src'},
packages=find_packages('src'),
package_data={'tensora': ['taco/bin/taco', 'taco/lib/libtaco.*']},

install_requires=Path('requirements.txt').read_text(encoding='utf-8').splitlines(),
extras_require={'numpy': ['numpy'], 'scipy': ['scipy']},

name="tensora",
version="0.0.8",
description="Library for dense and sparse tensors built on the tensor algebra compiler.",
long_description=Path("README.md").read_text(encoding="utf-8"),
long_description_content_type="text/markdown",
keywords="tensor sparse matrix array",
author="David Hagen",
author_email="david@drhagen.com",
url="https://github.com/drhagen/tensora",
license="MIT",
package_dir={"": "src"},
packages=find_packages("src"),
package_data={"tensora": ["taco/bin/taco", "taco/lib/libtaco.*"]},
install_requires=Path("requirements.txt").read_text(encoding="utf-8").splitlines(),
extras_require={"numpy": ["numpy"], "scipy": ["scipy"]},
classifiers=[
'Development Status :: 3 - Alpha',
'Intended Audience :: Science/Research',
'Intended Audience :: Developers',
'Topic :: Software Development :: Libraries',
'License :: OSI Approved :: MIT License',
'Operating System :: POSIX :: Linux',
'Operating System :: MacOS',
'Programming Language :: Python',
'Programming Language :: Python :: 3',
'Programming Language :: Python :: 3 :: Only',
'Programming Language :: Python :: 3.10',
'Programming Language :: Python :: 3.11',
"Development Status :: 3 - Alpha",
"Intended Audience :: Science/Research",
"Intended Audience :: Developers",
"Topic :: Software Development :: Libraries",
"License :: OSI Approved :: MIT License",
"Operating System :: POSIX :: Linux",
"Operating System :: MacOS",
"Programming Language :: Python",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3 :: Only",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
],

cmdclass={
'build': TensoraBuild,
'bdist_wheel': TensoraBdistWheel,
"build": TensoraBuild,
"bdist_wheel": TensoraBdistWheel,
},
zip_safe=False,
)
4 changes: 2 additions & 2 deletions src/tensora/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
from .format import Mode, Format # noqa: F401
from .format import Format, Mode # noqa: F401
from .function import evaluate, tensor_method # noqa: F401
from .tensor import Tensor # noqa: F401
from .function import tensor_method, evaluate # noqa: F401
Loading