-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit c6a51e8
Showing
15 changed files
with
631 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
name: Lint | ||
on: | ||
pull_request: | ||
push: | ||
branches: | ||
- main | ||
concurrency: | ||
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} | ||
cancel-in-progress: true | ||
|
||
jobs: | ||
formatting-check: | ||
name: Formatting Check | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- name: Run clang-format style check for C/C++/Protobuf programs. | ||
uses: jidicula/[email protected] | ||
with: | ||
clang-format-version: '14' | ||
check-path: 'src' | ||
fallback-style: 'Google' # optional |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
name: Run isort | ||
on: | ||
pull_request: | ||
push: | ||
branches: | ||
- main | ||
concurrency: | ||
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} | ||
cancel-in-progress: true | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- uses: isort/isort-action@v1 | ||
with: | ||
sortPaths: "src" # only sort files in the src directory |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
name: Lint | ||
on: | ||
pull_request: | ||
push: | ||
branches: | ||
- main | ||
concurrency: | ||
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} | ||
cancel-in-progress: true | ||
|
||
jobs: | ||
ruff: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- uses: chartboost/ruff-action@v1 | ||
black: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- uses: psf/black@stable |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
name: Pytest | ||
on: | ||
pull_request: | ||
push: | ||
branches: | ||
- main | ||
concurrency: | ||
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} | ||
cancel-in-progress: true | ||
|
||
|
||
jobs: | ||
uv-test: | ||
name: python | ||
runs-on: ubuntu-latest | ||
|
||
strategy: | ||
matrix: | ||
python-version: | ||
- "3.10" | ||
- "3.11" | ||
- "3.12" | ||
|
||
steps: | ||
- uses: actions/checkout@v4 | ||
|
||
- name: Install uv | ||
uses: astral-sh/setup-uv@v3 | ||
with: | ||
# Install a specific version of uv. | ||
version: "0.5.1" | ||
enable-cache: true | ||
cache-dependency-glob: "uv.lock" | ||
|
||
- name: Setup Python ${{ matrix.python-version }} | ||
run: uv python install ${{ matrix.python-version }} | ||
|
||
- name: Install the project | ||
run: uv sync --all-extras --dev | ||
|
||
- name: Run tests | ||
run: uv run pytest |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
build/* | ||
*/__pycache__/ | ||
*.py[oc] | ||
build/ | ||
dist/ | ||
wheels/ | ||
*.egg-info | ||
# venv | ||
.venv |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
# See https://pre-commit.com for more information | ||
# See https://pre-commit.com/hooks.html for more hooks | ||
repos: | ||
- repo: https://github.com/pre-commit/pre-commit-hooks | ||
rev: v4.6.0 | ||
hooks: | ||
- id: check-yaml | ||
args: ['--unsafe'] | ||
- id: end-of-file-fixer | ||
- id: trailing-whitespace | ||
- repo: https://github.com/pycqa/isort | ||
rev: 5.13.2 | ||
hooks: | ||
- id: isort | ||
name: isort (python) | ||
- repo: https://github.com/psf/black | ||
rev: 24.3.0 | ||
hooks: | ||
- id: black | ||
- repo: https://github.com/charliermarsh/ruff-pre-commit | ||
# Ruff version. | ||
rev: "v0.3.5" | ||
hooks: | ||
- id: ruff | ||
- repo: https://github.com/pre-commit/mirrors-clang-format | ||
rev: v14.0.6 | ||
hooks: | ||
- id: clang-format |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
cmake_minimum_required(VERSION 3.15) | ||
project(${SKBUILD_PROJECT_NAME} LANGUAGES CXX) | ||
|
||
set(PYBIND11_FINDPYTHON ON) | ||
find_package(pybind11 CONFIG REQUIRED) | ||
|
||
pybind11_add_module(_core MODULE src/main.cpp) | ||
install(TARGETS _core DESTINATION ${SKBUILD_PROJECT_NAME}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
# Cytnx-core | ||
This is the core compoment of the cytnx library | ||
|
||
## Develop | ||
|
||
### Package Management | ||
We use [uv](https://docs.astral.sh/uv/getting-started/installation/) to manage the package. | ||
|
||
```bash | ||
uv sync --all-extras --dev | ||
``` | ||
|
||
### Building Dependency: | ||
|
||
- c++ compiler | ||
- cmake 3.15 (see CMakeList.txt) | ||
|
||
* most of the deps should be able to install via pypi. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
[project] | ||
name = "cytnx-core" | ||
version = "0.1.0" | ||
description = "Core component of cytnx" | ||
readme = "README.md" | ||
authors = [ | ||
{ name = "kaihsin", email = "[email protected]" } | ||
] | ||
requires-python = ">=3.10" | ||
dependencies = [] | ||
|
||
[tool.scikit-build] | ||
minimum-version = "build-system.requires" | ||
build-dir = "build/{wheel_tag}" | ||
|
||
[tool.black] | ||
line-length = 88 | ||
|
||
[tool.ruff] | ||
target-version = "py310" | ||
exclude = [ | ||
".bzr", | ||
".direnv", | ||
".eggs", | ||
".git", | ||
".hg", | ||
".mypy_cache", | ||
".nox", | ||
".pants.d", | ||
".pytype", | ||
".ruff_cache", | ||
".svn", | ||
".tox", | ||
".venv", | ||
"__pypackages__", | ||
"_build", | ||
"buck-out", | ||
"build", | ||
"dist", | ||
"node_modules", | ||
"venv", | ||
] | ||
|
||
[tool.ruff.lint] | ||
dummy-variable-rgx = "^(_+|(_+[a-zA-Z0-9_]*[a-zA-Z0-9]+?))$" | ||
|
||
[tool.isort] | ||
profile = "black" | ||
combine_as_imports = true | ||
multi_line_output = 3 | ||
src_paths = ["src/cytnx_core"] | ||
|
||
[build-system] | ||
requires = ["scikit-build-core>=0.10", "pybind11"] | ||
build-backend = "scikit_build_core.build" | ||
|
||
[dependency-groups] | ||
dev = [ | ||
"isort>=5.13.2", | ||
"lint>=1.2.1", | ||
"pre-commit>=4.0.1", | ||
"pytest>=8.3.3", | ||
"ruff>=0.7.4", | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
from cytnx_core._core import hello_from_bin | ||
|
||
|
||
def hello() -> str: | ||
return hello_from_bin() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
from __future__ import annotations | ||
|
||
def hello_from_bin() -> str: ... |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
#include <pybind11/pybind11.h> | ||
|
||
std::string hello_from_bin() { return "Hello from test-build!"; } | ||
|
||
namespace py = pybind11; | ||
|
||
PYBIND11_MODULE(_core, m) { | ||
m.doc() = "pybind11 hello module"; | ||
|
||
m.def("hello_from_bin", &hello_from_bin, R"pbdoc( | ||
A function that returns a Hello string. | ||
)pbdoc"); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
from cytnx_core import hello | ||
|
||
|
||
def test_str(): | ||
assert isinstance(hello(), str) |
Oops, something went wrong.