Skip to content
Merged
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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ data/tension_chart_13934.pdf
data/*.png
docs/api/
panel/app.html
_version.py

uv.lock

Expand Down
15 changes: 15 additions & 0 deletions docs/dev.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,18 @@ Build the docs:
```sh
uv run sphinx-build docs docs/_build/html
```

Check the version:

```sh
uv run stringcalc --version
```

After adding a new annotated version tag,
you may need to touch one of the files
in order for uv/hatch to detect that a rebuild is needed,
or use:

```sh
uv run --reinstall-package stringcalc stringcalc --version
```
9 changes: 3 additions & 6 deletions panel/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,11 @@
from stringcalc.frets import distances, length_from_distance
from stringcalc.tension import DENSITY_LB_IN, gauge, load_data, suggest_gauge

try:
from stringcalc.util import get_version
except ImportError:

def get_version(*, git: bool = True) -> str:
import stringcalc
def get_version() -> str:
import stringcalc

return getattr(stringcalc, "__version__", "?")
return getattr(stringcalc, "__version__", "?")


WIDTH = 450
Expand Down
25 changes: 21 additions & 4 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[build-system]
requires = ["flit_core >=3.2,<4"]
build-backend = "flit_core.buildapi"
requires = ["hatchling", "hatch-vcs"]
build-backend = "hatchling.build"

[project]
name = "stringcalc"
Expand Down Expand Up @@ -59,8 +59,25 @@ panel = [
[project.scripts]
stringcalc = "stringcalc.cli:app"

[tool.flit.sdist]
exclude = ["data/", ".github/", "panel/", ".gitignore"]
[tool.hatch.version]
source = "vcs"

[tool.hatch.build.hooks.vcs]
version-file = "stringcalc/_version.py"

[tool.hatch.build.targets.sdist]
exclude = [
".flake8",
".gitignore",
".pre-commit-config.yaml",
".readthedocs.yaml",
".github/",
"data/",
"panel/",
]

[tool.hatch.build.targets.wheel]
only-packages = true

[tool.black]
line-length = 100
Expand Down
5 changes: 4 additions & 1 deletion stringcalc/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,7 @@
Calculations for instrument strings
"""

__version__ = "0.1.0.dev18"
try:
from ._version import __version__
except ImportError:
__version__ = "0.0.0"
9 changes: 3 additions & 6 deletions stringcalc/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,18 +99,15 @@ def inner(*args, **kwargs):

def _version_callback(show: bool):
if show:
import subprocess

from . import __version__

v = f"[rgb(184,115,51)]stringcalc[/] [bold blue]{__version__}[/]"
try:
cmd = ["git", "-C", HERE.as_posix(), "rev-parse", "--verify", "--short", "HEAD"]
cp = subprocess.run(cmd, text=True, capture_output=True, check=True)
except Exception:
i = v.index("+")
except ValueError:
pass
else:
v += f" [rgb(100,100,100)]({cp.stdout.strip()})[/]"
v = v[:i] + "[rgb(100,100,100)]" + v[i:] + "[/]"

console.print(v, highlight=False)

Expand Down
2 changes: 2 additions & 0 deletions stringcalc/data/daddario-stp.csv
Original file line number Diff line number Diff line change
Expand Up @@ -588,12 +588,14 @@ XTNW042,0.00031405,0.042,Electric Guitar,Nickel Plated Steel,XTNW
XTNW046,0.00036969,0.046,Electric Guitar,Nickel Plated Steel,XTNW
XTNW049,0.00041459,0.049,Electric Guitar,Nickel Plated Steel,XTNW
XTNW052,0.00046223,0.052,Electric Guitar,Nickel Plated Steel,XTNW
XTNW059,0.00061817,0.059,Electric Guitar,Nickel Plated Steel,XTNW
XTPB022,9.7982e-05,0.022,Acoustic Guitar,Phosphor Bronze,XTPB
XTPB023,0.0001078,0.023,Acoustic Guitar,Phosphor Bronze,XTPB
XTPB024,0.00011612,0.024,Acoustic Guitar,Phosphor Bronze,XTPB
XTPB025,0.00012678,0.025,Acoustic Guitar,Phosphor Bronze,XTPB
XTPB026,0.0001358,0.026,Acoustic Guitar,Phosphor Bronze,XTPB
XTPB027,0.00014707,0.027,Acoustic Guitar,Phosphor Bronze,XTPB
XTPB028,0.00015901,0.028,Acoustic Guitar,Phosphor Bronze,XTPB
XTPB029,0.00017107,0.029,Acoustic Guitar,Phosphor Bronze,XTPB
XTPB032,0.00020607,0.032,Acoustic Guitar,Phosphor Bronze,XTPB
XTPB035,0.00024692,0.035,Acoustic Guitar,Phosphor Bronze,XTPB
Expand Down
32 changes: 0 additions & 32 deletions stringcalc/util.py

This file was deleted.