Skip to content

Commit

Permalink
Merge pull request #12 from Yikai-Liao/switch-pyproject
Browse files Browse the repository at this point in the history
Switch setup.py to pyproject.toml and switch building backend to scikit-build
  • Loading branch information
lzqlzzq authored Dec 22, 2023
2 parents 20d218d + dec5193 commit d64b2cf
Show file tree
Hide file tree
Showing 3 changed files with 126 additions and 33 deletions.
15 changes: 11 additions & 4 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,17 @@ include_directories(3rdparty/minimidi/include)
include_directories(3rdparty/pdqsort)
include_directories(3rdparty/zpp_bits)

# set(Python_LIBRARIES "${PYTHON_LIBRARIES}")
# find_package(Python REQUIRED COMPONENTS Interpreter Development.Module)
find_package(Python REQUIRED COMPONENTS Interpreter Development.Module)
find_package(pybind11 CONFIG REQUIRED)

add_subdirectory(3rdparty/pybind11 EXCLUDE_FROM_ALL)
# add_subdirectory(3rdparty/pybind11 EXCLUDE_FROM_ALL)

pybind11_add_module(core src/symusic.cpp)
if(MSVC)
add_compile_options(-bigobj)
endif()

python_add_library(core MODULE src/symusic.cpp WITH_SOABI)
target_link_libraries(core PRIVATE pybind11::headers)

if(BUILD_TEST)
add_executable(note_count test/note_count.cpp)
Expand All @@ -26,3 +31,5 @@ if(NOT MSVC AND NOT ${CMAKE_BUILD_TYPE} MATCHES Debug|RelWithDebInfo)
# Strip unnecessary sections of the binary on Linux/macOS
pybind11_strip(core)
endif()

install(TARGETS core LIBRARY DESTINATION symusic)
115 changes: 115 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
[build-system]
requires = [
"setuptools>=42",
"scikit-build>=0.13",
"scikit-build-core>=0.3.3",
"pybind11>=2.10.0",
"cmake>=3.20",
"ninja",
]
build-backend = "scikit_build_core.build"

[project]
name = "symusic"
authors = [
{name = "Yikai Liao", email = "lyk-boya@outlook.com"},
{name = "Zhongqi Luo", email = "luozhongqi@mail.com"},
{name = "Nathan Fradet"}
]
maintainers = [
{name = "Yikai Liao", email = "lyk-boya@outlook.com"},
{name = "Zhongqi Luo", email = "luozhongqi@mail.com"},
{name = "Nathan Fradet"}
]
description = "A high performance MIDI file parser with comprehensible interface."
readme = {file = "README.md", content-type = "text/markdown"}
license = {file = "LICENSE"}
keywords = ["midi",
"music",
"mir"]
classifiers = [
"Development Status :: 3 - Alpha",
"Programming Language :: C++",
"Programming Language :: Python",
"Intended Audience :: Developers",
"Intended Audience :: Science/Research",
"Topic :: File Formats",
"Topic :: Multimedia :: Sound/Audio :: MIDI",
"License :: OSI Approved :: MIT License",
"Programming Language :: Python :: 3 :: Only",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"Operating System :: MacOS",
"Operating System :: Microsoft :: Windows",
"Operating System :: POSIX",
"Operating System :: Unix",
]
dependencies = ["numpy"]
dynamic = ["version"]

[project.urls]
Homepage = "https://github.com/Yikai-Liao/symusic"
Repository = "https://github.com/Yikai-Liao/symusic.git"
Issues = "https://github.com/Yikai-Liao/symusic/issues"

[tool.scikit-build]
cmake.minimum-version = "3.26.1"
ninja.minimum-version = "1.11"

[tool.scikit-build.metadata]
version.provider = "scikit_build_core.metadata.regex"
version.input = "symusic/__init__.py"

[tool.skbuild]
packages = ["symusic"]
cmake-args = []

[project.optional-dependencies]
test = ["pytest-cov", "pytest-xdist"]

[tool.pytest.ini_options]
minversion = "6.0"
addopts = ["-ra", "--showlocals", "--strict-markers", "--strict-config"]
xfail_strict = true
log_cli_level = "INFO"
filterwarnings = [
"error",
]
testpaths = ["tests"]

[tool.ruff]
target-version = "py38"
exclude = ["3rdparty"]

[tool.ruff.lint]
extend-select = [
"ARG",
"A",
"B",
# "E",
"F",
"G",
"I",
"INT",
# "N",
"NPY",
"PERF",
# "PTH",
"PIE",
"Q",
"RUF",
# "S",
# "SIM",
"T",
"UP",
"W",
]

[tool.ruff.lint.per-file-ignores]
"tests/**" = [
"S101", # allow assertions in tests
"T201", # print allowed
]
29 changes: 0 additions & 29 deletions ruff.toml

This file was deleted.

0 comments on commit d64b2cf

Please sign in to comment.