Skip to content

Commit a6745ea

Browse files
committed
Migrate to uv and modernize things
1 parent e4a8511 commit a6745ea

File tree

8 files changed

+69
-104
lines changed

8 files changed

+69
-104
lines changed

.github/workflows/main.yml

+11-56
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,15 @@
11
name: json-store
22
on: [push, pull_request]
33

4-
env:
5-
pip-cache-key: 2023.02.03
6-
74
jobs:
85
lint:
96
runs-on: ubuntu-latest
107

118
steps:
129
- uses: actions/checkout@v4
1310

14-
- name: pip cache
15-
uses: actions/cache@v4
16-
with:
17-
path: ~/.cache/pip
18-
key: ${{ runner.os }}-pip-${{ github.job }}-${{ env.pip-cache-key }}
19-
restore-keys: |
20-
${{ runner.os }}-pip-
11+
- name: Install uv
12+
uses: astral-sh/setup-uv@v2
2113

2214
- name: pre-commit cache
2315
uses: actions/cache@v4
@@ -27,40 +19,20 @@ jobs:
2719
restore-keys: |
2820
${{ runner.os }}-pre-commit-
2921
30-
- name: Display Python version
31-
run: python -c "import sys; print(sys.version)"
32-
33-
- name: Install ${{ github.job }} dependencies
34-
run: pip install --disable-pip-version-check pre-commit
35-
3622
- name: Run pre-commit tests
37-
run: pre-commit run -a
23+
run: uv tool run pre-commit run -a
3824

3925
build:
4026
runs-on: ubuntu-latest
4127

4228
steps:
4329
- uses: actions/checkout@v4
4430

45-
- name: pip cache
46-
uses: actions/cache@v4
47-
with:
48-
path: ~/.cache/pip
49-
key: ${{ runner.os }}-pip-${{ github.job }}-${{ env.pip-cache-key }}
50-
restore-keys: |
51-
${{ runner.os }}-pip-
52-
53-
- name: Display Python version
54-
run: python -c "import sys; print(sys.version)"
55-
56-
- name: Upgrade pip and setuptools
57-
run: python -m pip install --upgrade pip setuptools
58-
59-
- name: Install ${{ github.job }} dependencies
60-
run: pip --disable-pip-version-check install wheel build
31+
- name: Install uv
32+
uses: astral-sh/setup-uv@v2
6133

6234
- name: Build package
63-
run: python -m build
35+
run: uv build
6436

6537
- name: Store build artifacts
6638
uses: actions/upload-artifact@v4
@@ -79,37 +51,20 @@ jobs:
7951
steps:
8052
- uses: actions/checkout@v4
8153

82-
- name: pip cache
83-
uses: actions/cache@v4
84-
with:
85-
path: ~/.cache/pip
86-
key: ${{ runner.os }}-pip-${{ github.job }}-${{ env.pip-cache-key }}
87-
restore-keys: |
88-
${{ runner.os }}-pip-
54+
- name: Install uv
55+
uses: astral-sh/setup-uv@v2
8956

9057
- name: Set up Python ${{ matrix.python-version }}
9158
uses: actions/setup-python@v5
9259
with:
9360
python-version: ${{ matrix.python-version }}
9461

95-
- name: Download build artifacts
96-
uses: actions/download-artifact@v4
97-
with:
98-
name: dist
99-
path: dist
100-
10162
- name: Install ${{ github.job }} dependencies
10263
run: |
103-
pip install --disable-pip-version-check pytest
104-
105-
- name: Install json-store package
106-
shell: bash # so this works on both Linux and Windows
107-
run: |
108-
pip install --disable-pip-version-check dist/json_store-*.whl
64+
uv sync --dev
10965
11066
- name: Test with pytest
111-
run: pytest
67+
run: uv run pytest
11268

11369
- name: Test shelve2json
114-
if: ${{ matrix.os != 'windows-latest' }} # shelve.open has an internal traceback on Windows
115-
run: sh tests/test_shelve2json.sh
70+
run: uv run sh tests/test_shelve2json.sh

pyproject.toml

+51
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
[project]
2+
dynamic = ["version"]
3+
name = "json-store"
4+
requires-python = ">=3.8"
5+
dependencies = []
6+
7+
authors = [{name = "jeremy avnet", email = "[email protected]"}]
8+
description = "A shelve-like store using JSON serialization."
9+
readme = "README.md"
10+
license = {file = "LICENSE.txt"}
11+
keywords = ["json", "shelve"]
12+
13+
classifiers = [
14+
"Development Status :: 5 - Production/Stable",
15+
16+
"Intended Audience :: Developers",
17+
"Topic :: Software Development :: Libraries",
18+
19+
"License :: OSI Approved :: MIT License",
20+
21+
"Operating System :: OS Independent",
22+
"Programming Language :: Python :: 3",
23+
"Programming Language :: Python :: 3.10",
24+
"Programming Language :: Python :: 3.11",
25+
"Programming Language :: Python :: 3.12",
26+
"Programming Language :: Python :: 3.8",
27+
"Programming Language :: Python :: 3.9",
28+
"Programming Language :: Python :: Implementation :: CPython",
29+
"Programming Language :: Python :: Implementation :: PyPy",
30+
]
31+
32+
[project.urls]
33+
Homepage = "https://github.com/brainsik/json-store"
34+
Repository = "https://github.com/brainsik/json-store.git"
35+
Issues = "https://github.com/brainsik/json-store/issues"
36+
Changelog = "https://github.com/brainsik/json-store/releases"
37+
38+
[project.scripts]
39+
shelve2json = "json_store.shelve2json:main"
40+
41+
[build-system]
42+
requires = ["hatchling"]
43+
build-backend = "hatchling.build"
44+
45+
[tool.hatch.version]
46+
path = "src/json_store/__init__.py"
47+
48+
[tool.uv]
49+
dev-dependencies = [
50+
"pytest >=8.3"
51+
]

setup.cfg

-2
This file was deleted.

setup.py

-40
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
from .json_store import JSONStore
22

3-
__version__ = "4.0"
3+
__version__ = "4.1"
44

55
open = JSONStore
File renamed without changes.

json_store/shelve2json.py renamed to src/json_store/shelve2json.py

+4-3
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,14 @@
99
import json_store
1010

1111

12-
def convert(oldfile):
12+
def convert(oldfile: str):
1313
if not os.path.isfile(oldfile):
1414
raise ValueError("No such file: {}".format(oldfile))
1515

16-
data = shelve.open(oldfile)
16+
name = oldfile.rsplit(".db")[0]
17+
data = shelve.open(name)
1718

18-
newfile = oldfile.rsplit(".db")[0] + ".json"
19+
newfile = name + ".json"
1920
store = json_store.open(newfile)
2021
store.update(data)
2122
store.sync()

tests/test_shelve2json.sh

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,6 @@ set -e -x
33

44
tmp=$(mktemp)
55
rm -f "$tmp"
6-
python -c 'import shelve; db=shelve.open("'"$tmp"'", flag="n"); db["eggs"] = "eggs"; db.close()'
7-
shelve2json "$tmp"
6+
python3 -c 'import shelve; db=shelve.open("'"$tmp"'", flag="n"); db["eggs"] = "eggs"; db.sync(); db.close()'
7+
shelve2json "$tmp".db
88
rm -f "$tmp" "$tmp.json"

0 commit comments

Comments
 (0)