Skip to content

Commit 457ebb3

Browse files
committed
Updated a bunch of stuff for build
1 parent 59cd7e3 commit 457ebb3

File tree

5 files changed

+126
-10
lines changed

5 files changed

+126
-10
lines changed

pyaudiosynth/__init__.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
from .synthesizer import Synthesizer
33
from .wave import Wave
44

5-
__version__ = "0.2.1"
65
__all__ = ["Note", "Synthesizer", "Wave"]
76

87
if __name__ == "__main__":

pyproject.toml

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,25 @@
11
[build-system]
22
requires = [
3-
"hatchling",
3+
"poetry-core",
44
"sphinx>=4.0",
55
"sphinx-immaterial",
6-
"hatch"
6+
"poetry",
7+
"cleo"
78
]
8-
build-backend = "hatchling.build"
9+
build-backend = "poetry.core.masonry.api"
910

1011
[project]
12+
1113
name = "pyaudiosynth"
12-
dynamic = [ "version" ]
14+
dynamic = [ "version" ] # Managed by Hatch
1315
description = "A simple package for audio synthesis"
1416
license = "MIT"
1517
readme = "README.txt"
16-
requires-python = ">=3.10"
1718
authors = [
1819
{ name = "Wdboyes13", email = "willdev2025@outlook.com" }
1920
]
21+
22+
requires-python = ">=3.10,<4.0"
2023
dependencies = [
2124
"librosa>=0.9.0",
2225
"sounddevice>=0.1.0",
@@ -26,6 +29,12 @@ dependencies = [
2629

2730
[project.urls]
2831
repository = "https://github.com/Wdboyes13/pysynth"
32+
documentation = "https://weelam.ca/docs/pyaudiosynth/"
33+
34+
[tool.poetry]
35+
version = "0.2.5"
36+
37+
[tool.poetry.scripts]
38+
docs = "scripts.docs:main"
2939

30-
[tool.hatch.version]
31-
path = "pyaudiosynth/__init__.py"
40+
[tool.setuptools_scm]

release.sh

Lines changed: 69 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,72 @@
11
#!/bin/bash
22

3+
bump_version=""
4+
build_docs=false
5+
release=true
6+
commit_msg="Updated $(date)"
7+
remaining_args=()
38

4-
ver="$(hatch project metadata 2>/dev/null | jq '.version' | sed 's/\"//g')"
5-
gh release create $ver --target Main --generate-notes --latest -t v${ver}
9+
while [[ $# -gt 0 ]]; do
10+
case "$1" in
11+
-nr|--no-release)
12+
release=false
13+
shift
14+
;;
15+
-m|--msg)
16+
if [[ -n "$2" && ! "$2" =~ ^- ]]; then
17+
commit_msg="$2"
18+
shift 2
19+
else
20+
echo "Error: msg requires a message argument"
21+
exit 1
22+
fi
23+
;;
24+
-b|--bump)
25+
if [[ -n "$2" && ! "$2" =~ ^- ]]; then
26+
bump_version="$2"
27+
shift 2
28+
else
29+
echo "Error: bump requires a version argument"
30+
exit 1
31+
fi
32+
;;
33+
-d|--docs)
34+
build_docs=true
35+
shift
36+
;;
37+
-h|--help)
38+
echo "Usage: $0 [OPTIONS]"
39+
echo "Options:"
40+
echo " -b, --bump VERSION Bump version (patch, minor, major, or specific version)"
41+
echo " -d, --docs Build documentation"
42+
echo " -h, --help Show this help message"
43+
echo " -nr, --no-release Do not create a github/pypi release"
44+
echo " -m, --msg MESSAGE Set the commit message to use"
45+
exit 0
46+
;;
47+
*)
48+
remaining_args+=("$1")
49+
shift
50+
;;
51+
esac
52+
done
53+
54+
if [[ -n "$bump_version" ]]; then
55+
echo "Bumping version to: $bump_version"
56+
poetry version "$bump_version"
57+
fi
58+
59+
if [[ "$build_docs" == true ]]; then
60+
echo "Building documentation..."
61+
poetry run docs html
62+
fi
63+
64+
if [[ "$release" == true ]]; then
65+
echo "Uploading to GitHub: Message \"${commit_msg}\""
66+
git add .
67+
git commit -m "${commit_msg}"
68+
git push
69+
echo "Creating GitHub (and PyPI) release"
70+
ver="$(poetry version --short)"
71+
gh release create $ver --target Main --generate-notes --latest -t v${ver}
72+
fi

scripts/__init__.py

Whitespace-only changes.

scripts/docs.py

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
import subprocess
2+
import sys
3+
from os import path
4+
from platform import system
5+
6+
from cleo.application import Application
7+
from cleo.commands.command import Command
8+
9+
sp = "/" if system() != "Windows" else "\\"
10+
def getdocs():
11+
if path.exists(f"docs{sp}"):
12+
return path.abspath(f"docs{sp}")
13+
elif path.exists(f"..{sp}docs{sp}"):
14+
return path.abspath(f"..{sp}docs{sp}")
15+
else:
16+
raise FileNotFoundError("Could not find documentation directory")
17+
18+
mkcmd = [f"{getdocs()}\\make.bat"] if system() == "Windows" else ["make", "-C", getdocs()]
19+
20+
class HTMLCommand(Command):
21+
name = "html"
22+
description = "Build all HTML documentation"
23+
24+
def handle(self) -> int:
25+
result = subprocess.run([*mkcmd, "html"], check=False)
26+
return result.returncode
27+
class CleanCommand(Command):
28+
name = "clean"
29+
description = "Build all HTML documentation"
30+
31+
def handle(self) -> int:
32+
result = subprocess.run([*mkcmd, "clean"], check=False)
33+
return result.returncode
34+
35+
36+
def main():
37+
app = Application()
38+
app.set_display_name("docs")
39+
app.add(HTMLCommand())
40+
app.add(CleanCommand())
41+
sys.exit(app.run())

0 commit comments

Comments
 (0)