Skip to content

Commit c6ccffa

Browse files
authored
Merge branch 'master' into update-readme
2 parents 11caff3 + fa259a0 commit c6ccffa

21 files changed

+189
-95
lines changed

.github/workflows/constraints.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
lockfile<0.13.0,>=0.12.2
22
pip==25.0.1
3-
nox==2025.2.9
4-
virtualenv==20.29.3
3+
nox==2025.5.1
4+
virtualenv==20.33.1
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
name: Dependabot Auto-Approve
2+
3+
on:
4+
pull_request_target: # Use pull_request_target to get write permissions for approval
5+
types:
6+
- opened
7+
- synchronize
8+
- reopened
9+
10+
permissions:
11+
pull-requests: write # Needed to approve PRs
12+
13+
jobs:
14+
auto-approve:
15+
runs-on: ubuntu-latest
16+
# Only run for PRs authored by dependabot[bot]
17+
if: github.actor == 'dependabot[bot]' || github.actor == 'dependabot'
18+
steps:
19+
- name: Checkout code (not strictly necessary for just approval)
20+
uses: actions/checkout@v4
21+
# no further steps needed for just approval
22+
23+
- name: Auto-approve Dependabot PR
24+
run: |
25+
gh pr review --approve "$PR_URL"
26+
echo "Approved Dependabot PR: $PR_URL"
27+
env:
28+
GH_TOKEN: ${{ github.token }}
29+
PR_URL: ${{ github.event.pull_request.html_url }}

.github/workflows/labeler.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,6 @@ jobs:
1313
uses: actions/checkout@v4
1414

1515
- name: Run Labeler
16-
uses: crazy-max/ghaction-github-labeler@v5.2.0
16+
uses: crazy-max/ghaction-github-labeler@v5.3.0
1717
with:
1818
skip-delete: true

.github/workflows/release.yml

Lines changed: 47 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -1,95 +1,75 @@
1-
name: Publish Python 🐍 distribution 📦 to PyPI
1+
name: Release Drafter and Publish Python 🐍 distribution 📦 to PyPI
22

3-
on: push
3+
on:
4+
push:
5+
branches:
6+
- master
7+
release:
8+
types: [published]
49

510
jobs:
6-
build:
7-
name: Build distribution 📦
11+
release-drafter:
12+
name: Draft Release Notes
813
runs-on: ubuntu-latest
9-
14+
if: github.event_name == 'push'
15+
permissions:
16+
contents: write
17+
pull-requests: write
1018
steps:
11-
- uses: actions/checkout@v4
12-
with:
13-
persist-credentials: false
14-
- name: Set up Python
15-
uses: actions/setup-python@v5
16-
with:
17-
python-version: "3.x"
18-
- name: Install pypa/build
19-
run: >-
20-
python3 -m
21-
pip install
22-
build
23-
--user
24-
- name: Build a binary wheel and a source tarball
25-
run: python3 -m build
26-
- name: Store the distribution packages
27-
uses: actions/upload-artifact@v4
19+
- name: Draft Release
20+
uses: release-drafter/release-drafter@v6
2821
with:
29-
name: python-package-distributions
30-
path: dist/
22+
publish: false
23+
env:
24+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
3125

32-
publish-to-pypi:
33-
name: >-
34-
Publish Python 🐍 distribution 📦 to PyPI
35-
if: startsWith(github.ref, 'refs/tags/') # only publish to PyPI on tag pushes
36-
needs:
37-
- build
26+
build-and-publish:
27+
name: Build, Sign, and Publish to PyPI 📦
3828
runs-on: ubuntu-latest
29+
if: github.event_name == 'release'
3930
environment:
4031
name: pypi
4132
url: https://pypi.org/p/camelot-py
4233
permissions:
43-
id-token: write # IMPORTANT: mandatory for trusted publishing
44-
34+
id-token: write
35+
contents: write
4536
steps:
46-
- name: Download all the dists
47-
uses: actions/download-artifact@v4
37+
- name: Checkout repository
38+
uses: actions/checkout@v4
4839
with:
49-
name: python-package-distributions
50-
path: dist/
51-
- name: Publish distribution 📦 to PyPI
52-
uses: pypa/gh-action-pypi-publish@release/v1
40+
ref: ${{ github.event.release.tag_name }}
41+
fetch-depth: 0
5342

54-
github-release:
55-
name: >-
56-
Sign the Python 🐍 distribution 📦 with Sigstore
57-
and upload them to GitHub Release
58-
needs:
59-
- publish-to-pypi
60-
runs-on: ubuntu-latest
43+
- name: Set up Python
44+
uses: actions/setup-python@v5
45+
with:
46+
python-version: "3.10"
6147

62-
permissions:
63-
contents: write # IMPORTANT: mandatory for making GitHub Releases
64-
id-token: write # IMPORTANT: mandatory for sigstore
48+
- name: Install build dependencies
49+
run: python -m pip install build
50+
51+
- name: Build a binary wheel and a source tarball
52+
run: python -m build
6553

66-
steps:
67-
- name: Download all the dists
68-
uses: actions/download-artifact@v4
69-
with:
70-
name: python-package-distributions
71-
path: dist/
7254
- name: Sign the dists with Sigstore
73-
uses: sigstore/[email protected].0
55+
uses: sigstore/[email protected].1
7456
with:
7557
inputs: >-
7658
./dist/*.tar.gz
7759
./dist/*.whl
78-
- name: Create GitHub Release
79-
env:
80-
GITHUB_TOKEN: ${{ github.token }}
81-
run: >-
82-
gh release create
83-
"$GITHUB_REF_NAME"
84-
--repo "$GITHUB_REPOSITORY"
85-
--notes ""
60+
8661
- name: Upload artifact signatures to GitHub Release
8762
env:
8863
GITHUB_TOKEN: ${{ github.token }}
89-
# Upload to GitHub Release using the `gh` CLI.
90-
# `dist/` contains the built packages, and the
91-
# sigstore-produced signatures and certificates.
9264
run: >-
9365
gh release upload
94-
"$GITHUB_REF_NAME" dist/**
66+
"${{ github.event.release.tag_name }}" ./dist/*
9567
--repo "$GITHUB_REPOSITORY"
68+
69+
- name: Remove Sigstore files
70+
run: rm -f dist/*.sig dist/*.crt dist/*.sigstore.json
71+
72+
- name: Publish Python 🐍 distribution 📦 to PyPI
73+
uses: pypa/gh-action-pypi-publish@release/v1
74+
with:
75+
packages-dir: "dist"

.github/workflows/tests.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ jobs:
3131
- { python: "3.10", os: "macos-latest", session: "tests" }
3232
- { python: "3.10", os: "ubuntu-latest", session: "typeguard" }
3333
- { python: "3.10", os: "ubuntu-latest", session: "xdoctest" }
34-
- { python: "3.10", os: "ubuntu-latest", session: "docs-build" }
34+
- { python: "3.13", os: "ubuntu-latest", session: "docs-build" }
3535

3636
env:
3737
NOXSESSION: ${{ matrix.session }}
@@ -62,7 +62,7 @@ jobs:
6262
print(f"VIRTUALENV_PIP={pip.__version__}", file=io)
6363
6464
- name: Install uv
65-
uses: astral-sh/setup-uv@v5
65+
uses: astral-sh/setup-uv@v6
6666

6767
- name: Install Nox
6868
run: |
@@ -149,15 +149,15 @@ jobs:
149149
pip --version
150150
151151
- name: Install uv
152-
uses: astral-sh/setup-uv@v5
152+
uses: astral-sh/setup-uv@v6
153153

154154
- name: Install Nox
155155
run: |
156156
pipx install --pip-args=--constraint=${PWD}/.github/workflows/constraints.txt nox
157157
nox --version
158158
159159
- name: Download coverage data
160-
uses: actions/download-artifact@v4
160+
uses: actions/download-artifact@v5
161161
with:
162162
pattern: coverage-data-*
163163
merge-multiple: true

.readthedocs.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ version: 2
22
build:
33
os: ubuntu-20.04
44
tools:
5-
python: "3.10"
5+
python: "3.13"
66
sphinx:
77
configuration: docs/conf.py
88
formats: all

README.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616

1717
Try it yourself in our interactive quickstart notebook. [![image](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/camelot-dev/camelot/blob/master/examples/camelot-quickstart-notebook.ipynb)
1818

19-
Or check out a simple example using [this pdf](https://github.com/camelot-dev/camelot/blob/main/docs/_static/pdf/foo.pdf).
19+
Or check out a simple example using [this pdf](https://github.com/camelot-dev/camelot/blob/master/docs/_static/pdf/foo.pdf).
2020

2121
<pre>
2222
>>> import camelot
@@ -48,7 +48,7 @@ Or check out a simple example using [this pdf](https://github.com/camelot-dev/ca
4848

4949
Camelot also comes packaged with a [command-line interface](https://camelot-py.readthedocs.io/en/latest/user/cli.html)!
5050

51-
Refer to the [QuickStart Guide](https://github.com/camelot-dev/camelot/blob/main/docs/user/quickstart.rst#quickstart) to quickly get started with Camelot, extract tables from PDFs and explore some basic options.
51+
Refer to the [QuickStart Guide](https://github.com/camelot-dev/camelot/blob/master/docs/user/quickstart.rst#quickstart) to quickly get started with Camelot, extract tables from PDFs and explore some basic options.
5252

5353
**Tip:** Visit the `parser-comparison-notebook` to get an overview of all the packed parsers and their features. [![image](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/camelot-dev/camelot/blob/master/examples/parser-comparison-notebook.ipynb)
5454

@@ -124,3 +124,4 @@ Camelot uses [Semantic Versioning](https://semver.org/). For the available versi
124124
This project is licensed under the MIT License, see the [LICENSE](https://github.com/camelot-dev/camelot/blob/master/LICENSE) file for details.
125125

126126
The documentation theme is licensed under a seperate BSD-like License, see the [LICENSE](https://github.com/camelot-dev/camelot/blob/master/docs/_themes/LICENSE) file for details.
127+

camelot/__init__.py

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,23 @@
1+
import importlib.metadata
12
import logging
3+
from typing import Optional
24

3-
from .__version__ import __version__ # noqa D100, F400
45
from .io import read_pdf
56
from .plotting import PlotMethods
67

78

9+
def get_version() -> Optional[str]:
10+
"""Retrieve the version number from package metadata."""
11+
try:
12+
return importlib.metadata.version("camelot-py")
13+
except importlib.metadata.PackageNotFoundError:
14+
# Fallback for development environments
15+
return "0.0.0+unknown"
16+
17+
18+
__version__ = get_version()
19+
20+
821
# set up logging
922
logger = logging.getLogger("camelot")
1023

camelot/__version__.py

Lines changed: 0 additions & 1 deletion
This file was deleted.

camelot/cli.py

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,9 @@
1212
else:
1313
_HAS_MPL = True
1414

15-
from . import __version__
15+
import importlib.metadata
16+
from typing import Optional
17+
1618
from . import plot
1719
from . import read_pdf
1820

@@ -21,6 +23,18 @@
2123
logger.setLevel(logging.INFO)
2224

2325

26+
def get_version() -> Optional[str]:
27+
"""Get the version information."""
28+
try:
29+
return importlib.metadata.version("camelot-py")
30+
except importlib.metadata.PackageNotFoundError:
31+
# Package is not installed in editable mode or in the current environment
32+
return None
33+
34+
35+
__version__ = get_version() or "0.0.0+unknown"
36+
37+
2438
class Config:
2539
"""Class method for creating a new class."""
2640

0 commit comments

Comments
 (0)