Skip to content
Closed
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
19 changes: 11 additions & 8 deletions .github/workflows/python-package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,29 +20,30 @@ jobs:

steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v3
with:
python-version: ${{ matrix.python-version }}
cache: "pip"
- name: Install dependencies
run: |
python -m pip install --upgrade pip
python -m pip install flake8 pytest
pip install "numpy<2.0" numba
- name: Install torch
run: pip install torch --index-url https://download.pytorch.org/whl/cpu
run: |
pip install torch --index-url https://download.pytorch.org/whl/cpu
pip install -e .[dev]
- name: Lint with flake8
run: |
# stop the build if there are Python syntax errors or undefined names
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
- name: Build CPP extension with g++
run: |
python -m pip install -e .
- name: Test with pytest
run: |
pytest
pytes

build-macos:
if: github.event_name == 'pull_request'
Expand All @@ -54,18 +55,20 @@ jobs:

steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v3
with:
python-version: ${{ matrix.python-version }}
cache: "pip"
- name: Install libomp
run: |
brew install libomp
- name: Install dependencies
run: |
python -m pip install --upgrade pip
python -m pip install flake8 pytest
pip install "numpy<2.0" numba torch
- name: Lint with flake8
run: |
# stop the build if there are Python syntax errors or undefined names
Expand All @@ -77,7 +80,7 @@ jobs:
export CXX=$(brew --prefix llvm@15)/bin/clang++
export LDFLAGS="-L/usr/local/opt/libomp/lib"
export CPPFLAGS="-I/usr/local/opt/libomp/include"
python -m pip install -e .
pip install -e .[dev]
- name: Test with pytest
run: |
pytest
3 changes: 3 additions & 0 deletions .github/workflows/python-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,13 @@ jobs:

steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Set up Python
uses: actions/setup-python@v3
with:
python-version: '3.x'
cache: "pip"
- name: Install dependencies
run: |
python -m pip install --upgrade pip
Expand Down
33 changes: 33 additions & 0 deletions .github/workflows/version.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
name: Display version

on:
push:
branches: [ "dev", "main", "alpha", "beta" ]
pull_request:
branches: [ "dev", "main", "alpha", "beta" ]

permissions:
contents: read

jobs:
build:

runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.x'
cache: 'pip' # caching pip dependencies
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install build "setuptools-git-versioning>=2,<3"
pip install torch --index-url https://download.pytorch.org/whl/cpu
- name: Display version
run: |
setuptools-git-versioning -v >> $GITHUB_STEP_SUMMARY
4 changes: 1 addition & 3 deletions MANIFEST.in
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,4 @@ recursive-include torchlpc *.h
recursive-include torchlpc *.cpp
recursive-include torchlpc *.c
recursive-include torchlpc *.cu
recursive-include tests *.py
recursive-exclude * __pycache__
recursive-exclude * *.pyc
recursive-include torchlpc *.txt
72 changes: 71 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,3 +1,73 @@
[build-system]
requires = ["setuptools", "torch", "numpy"]
requires = [
"setuptools >= 77.0.3",
"setuptools-git-versioning>=2.0,<3",
"wheel",
"torch",
"numpy",
]
build-backend = "setuptools.build_meta"

[tool.setuptools-git-versioning]
enabled = true
# change the file path
version_file = "torchlpc/VERSION.txt"
count_commits_from_version_file = true # <--- enable commits tracking
dev_template = "{tag}.{branch}{ccount}" # suffix for versions will be .dev
dirty_template = "{tag}.{branch}{ccount}" # same thing here
# Temporarily disable branch formatting due to issues with regex in _version.py
# branch_formatter = "torchlpc._version:format_branch_name"

[tool.setuptools.package-data]
# include VERSION file to a package
torchlpc = ["VERSION"]

[tool.setuptools.packages.find]
where = ["."]
exclude = ["tests", "tests.*"]

[tool.setuptools]
# this package will read some included files in runtime, avoid installing it as .zip
zip-safe = false

[project]
dynamic = ["version"]
name = "torchlpc"
dependencies = ["torch >= 2.0.0", "numpy", "numba"]
requires-python = ">=3.9"
authors = [{ name = "Chin-Yun Yu", email = "chin-yun.yu@qmul.ac.uk" }]
maintainers = [{ name = "Chin-Yun Yu", email = "chin-yun.yu@qmul.ac.uk" }]
description = "Fast, efficient, and differentiable time-varying LPC filtering in PyTorch."
readme = "README.md"
license = "MIT"
license-files = ["LICENSE"]
classifiers = [
"Development Status :: 3 - Alpha",
"Intended Audience :: Developers",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
]

[project.optional-dependencies]
dev = ["pytest >= 6.0", "scipy", "numpy", "pytest-cov"]


[tool.pytest.ini_options]
testpaths = ["tests"]
python_files = ["test_*.py"]
python_classes = ["Test*"]
python_functions = ["test_*"]
addopts = [
"--tb=short",
"--strict-markers",
"--cov=torchlpc",
"--cov-report=term-missing:skip-covered",
]
markers = [
"slow: marks tests as slow (deselect with '-m \"not slow\"')",
"integration: marks tests as integration tests",
"unit: marks tests as unit tests",
]
26 changes: 2 additions & 24 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,6 @@
)

library_name = "torchlpc"
VERSION = "0.8dev"
MAINTAINER = "Chin-Yun Yu"
EMAIL = "chin-yun.yu@qmul.ac.uk"


with open("README.md", "r") as fh:
long_description = fh.read()


# if torch.__version__ >= "2.6.0":
Expand Down Expand Up @@ -49,7 +42,8 @@ def get_extensions():
ext_modules = [
extension(
f"{library_name}._C",
sources,
# sources,
[os.path.relpath(s, this_dir) for s in sources],
extra_compile_args=extra_compile_args,
extra_link_args=extra_link_args,
py_limited_api=py_limited_api,
Expand All @@ -60,22 +54,6 @@ def get_extensions():


setuptools.setup(
name=library_name,
version=VERSION,
author=MAINTAINER,
author_email=EMAIL,
description="Fast, efficient, and differentiable time-varying LPC filtering in PyTorch.",
long_description=long_description,
long_description_content_type="text/markdown",
url="https://github.com/DiffAPF/torchlpc",
packages=["torchlpc"],
install_requires=["torch>=2.0", "numpy", "numba"],
classifiers=[
"Programming Language :: Python :: 3",
"Operating System :: MacOS :: MacOS X",
"Operating System :: POSIX",
],
license="MIT",
ext_modules=get_extensions(),
cmdclass={"build_ext": BuildExtension},
options={"bdist_wheel": {"py_limited_api": "cp39"}} if py_limited_api else {},
Expand Down
1 change: 1 addition & 0 deletions torchlpc/VERSION.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
0.8
18 changes: 18 additions & 0 deletions torchlpc/_version.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import re


def format_branch_name(name):
# "(fix|feat)/issue-name" or CICD's branch "HEAD"
pattern = re.compile("^((fix|feat)\/(?P<branch>.+))|((head|HEAD))")

match = pattern.search(name)
if match:
return f"dev+{match.group(0)}" # => dev+"(fix|feat)/issue-name"

# function is called even if branch name is not used in a current template
# just left properly named branches intact
if name in ["master", "dev", "main"]:
return name

# fail in case of wrong branch names like "bugfix/issue-unknown"
raise ValueError(f"Wrong branch name: {name}")
Loading