Skip to content

Commit ae5ff37

Browse files
committed
πŸŽ‰ init: initial project
0 parents  commit ae5ff37

21 files changed

+603
-0
lines changed

β€Ž.clang-formatβ€Ž

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# Run manually to reformat a file:
2+
# clang-format -i --style=file <file>
3+
Language: Cpp
4+
BasedOnStyle: Google
5+
AllowShortBlocksOnASingleLine: false
6+
AlignConsecutiveMacros: true
7+
AllowShortLoopsOnASingleLine: false
8+
AllowShortFunctionsOnASingleLine: false
9+
AllowShortLambdasOnASingleLine: false

β€Ž.editorconfigβ€Ž

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# EditorConfig
2+
# https://editorconfig.org/
3+
4+
root = true
5+
6+
[*]
7+
indent_style = space
8+
indent_size = 2
9+
end_of_line = lf
10+
charset = utf-8
11+
trim_trailing_whitespace = true
12+
insert_final_newline = true
13+
14+
[*.{py,pyi,pxd,pyx,sh}]
15+
indent_size = 4
16+
17+
[*.md]
18+
indent_size = 3
19+
20+
[*.json]
21+
insert_final_newline = ignore
22+
23+
[Makefile]
24+
indent_style = tab
25+
26+
[*.bat]
27+
indent_style = tab

β€Ž.gitignoreβ€Ž

Lines changed: 119 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,119 @@
1+
# Byte-compiled / optimized / DLL files
2+
__pycache__/
3+
*.py[cod]
4+
*$py.class
5+
6+
# C extensions
7+
*.so
8+
9+
# Distribution / packaging
10+
.Python
11+
build/
12+
develop-eggs/
13+
dist/
14+
downloads/
15+
eggs/
16+
.eggs/
17+
lib64/
18+
parts/
19+
sdist/
20+
var/
21+
wheels/
22+
share/python-wheels/
23+
*.egg-info/
24+
.installed.cfg
25+
*.egg
26+
MANIFEST
27+
28+
# PyInstaller
29+
# Usually these files are written by a python script from a template
30+
# before PyInstaller builds the exe, so as to inject date/other infos into it.
31+
*.manifest
32+
*.spec
33+
34+
# Installer logs
35+
pip-log.txt
36+
pip-delete-this-directory.txt
37+
38+
# Unit test / coverage reports
39+
htmlcov/
40+
.tox/
41+
.nox/
42+
.coverage
43+
.coverage.*
44+
.cache
45+
nosetests.xml
46+
coverage.xml
47+
*.cover
48+
.hypothesis/
49+
.pytest_cache/
50+
51+
# Translations
52+
*.mo
53+
*.pot
54+
55+
# Django stuff:
56+
*.log
57+
local_settings.py
58+
db.sqlite3
59+
60+
# Flask stuff:
61+
instance/
62+
.webassets-cache
63+
64+
# Scrapy stuff:
65+
.scrapy
66+
67+
# Sphinx documentation
68+
docs/_build/
69+
70+
# Jupyter Notebook
71+
.ipynb_checkpoints
72+
73+
# IPython
74+
profile_default/
75+
ipython_config.py
76+
77+
# pyenv
78+
.python-version
79+
80+
# celery beat schedule file
81+
celerybeat-schedule
82+
83+
# SageMath parsed files
84+
*.sage.py
85+
86+
# Environments
87+
.env
88+
.venv
89+
env/
90+
venv/
91+
ENV/
92+
env.bak/
93+
venv.bak/
94+
95+
# Spyder project settings
96+
.spyderproject
97+
.spyproject
98+
99+
# Rope project settings
100+
.ropeproject
101+
102+
# mkdocs documentation
103+
/site
104+
105+
# mypy
106+
.mypy_cache/
107+
.dmypy.json
108+
dmypy.json
109+
110+
# Pyre type checker
111+
.pyre/
112+
113+
# macOS
114+
.DS_Store
115+
116+
# build files
117+
target/core
118+
target/*.o
119+
lib/core.cpp

β€Ž.vscode/settings.jsonβ€Ž

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"python.defaultInterpreterPath": "${workspaceFolder}/.venv/bin/python",
3+
"python.formatting.provider": "black",
4+
"python.formatting.blackArgs": ["--line-length", "120"],
5+
"python.analysis.typeCheckingMode": "strict",
6+
"C_Cpp.default.cStandard": "c17",
7+
"C_Cpp.default.cppStandard": "c++20",
8+
"C_Cpp.clang_format_fallbackStyle": "{ BasedOnStyle: Google, AllowShortBlocksOnASingleLine: false, AlignConsecutiveMacros: true, AllowShortLoopsOnASingleLine: false, AllowShortFunctionsOnASingleLine: false, AllowShortLambdasOnASingleLine: false}"
9+
}

β€ŽMakefileβ€Ž

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
CXX = clang++
2+
CORE_FILE = lib/libcore.cpp
3+
CORE_TARGET = target/libcore.o
4+
SOURCE_MAIN = lib/test_libcore.cpp
5+
TARGET = target/core
6+
LDFLAGS_COMMON = -std=c++20
7+
8+
all:
9+
$(CXX) -c $(CORE_FILE) $(LDFLAGS_COMMON) -o $(CORE_TARGET)
10+
$(CXX) $(SOURCE_MAIN) $(CORE_TARGET) $(LDFLAGS_COMMON) -o $(TARGET)
11+
12+
run:
13+
./$(TARGET)
14+
15+
clean:
16+
rm -rf *.o $(TARGET)

β€ŽREADME.mdβ€Ž

Whitespace-only changes.

β€Žbuild.pyβ€Ž

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
from typing import Any
2+
3+
from Cython.Build import cythonize
4+
from setuptools.command.build_ext import build_ext
5+
from setuptools.extension import Extension
6+
7+
ext_modules = [
8+
Extension(
9+
"demo.core",
10+
sources=["lib/core.pyx", "lib/libcore.cpp"],
11+
language="c++",
12+
extra_compile_args=["-std=c++17"],
13+
extra_link_args=["-std=c++17"],
14+
),
15+
]
16+
17+
18+
def build(setup_kwargs: dict[str, Any]):
19+
setup_kwargs.update(
20+
{
21+
"ext_modules": cythonize(ext_modules),
22+
"cmdclass": {"build_ext": build_ext},
23+
}
24+
)

β€Ždemo/__init__.pyβ€Ž

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
__version__ = '0.1.0'

β€Ždemo/__main__.pyβ€Ž

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
from demo.core import test_cython_connect
2+
3+
def test_python_code():
4+
test_cython_connect(1)
5+
print("test_python_code in python code.")
6+
7+
def main():
8+
test_python_code()
9+
10+
11+
if __name__ == "__main__":
12+
main()

β€Ždemo/core.pyiβ€Ž

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
def test_cython_connect(n: int) -> None: ...

0 commit comments

Comments
Β (0)