Skip to content

Commit 3a44478

Browse files
committed
Fix: Resolve build errors and deprecation warnings
This commit addresses several issues to ensure a clean and compliant build process. - **Fix build error:** Corrects the "Multiple top-level packages discovered" error by explicitly configuring package discovery in `pyproject.toml`. This prevents `setuptools` from accidentally including non-source directories like `activate`. - **Fix versioning:** Deletes the redundant `__version__.py` file to establish `pyproject.toml` as the single source of truth for the package version. This resolves conflicts where the build process was producing an incorrect version number. - **Fix deprecation warnings:** Updates `pyproject.toml` to use a simplified SPDX license expression ("MIT") and removes the deprecated license classifier. This ensures future compatibility with `setuptools`. These changes guarantee that the GitHub release workflow will successfully build and publish the package with the correct version.
1 parent 5946a37 commit 3a44478

4 files changed

Lines changed: 35 additions & 5 deletions

File tree

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

pyproject.toml

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ description = "PDF Table Extraction for Humans."
55
authors = [
66
{name = "Vinayak Mehta", email = "vmehta94@gmail.com"},
77
]
8-
license = {text = "MIT"}
8+
license = "MIT"
99
readme = "README.md"
1010
classifiers = [
1111
"Development Status :: 5 - Production/Stable",
@@ -15,7 +15,6 @@ classifiers = [
1515
"Programming Language :: Python :: 3.11",
1616
"Programming Language :: Python :: 3.12",
1717
"Programming Language :: Python :: 3.13",
18-
"License :: OSI Approved :: MIT License",
1918
]
2019
requires-python = ">=3.8"
2120
dependencies = [
@@ -40,6 +39,11 @@ dependencies = [
4039
requires = ["setuptools"]
4140
build-backend = "setuptools.build_meta"
4241

42+
[tool.setuptools.packages.find]
43+
where = ["."]
44+
include = ["camelot*"]
45+
exclude = ["activate"]
46+
4347
[project.urls]
4448
Homepage = "https://github.com/camelot-dev/camelot"
4549
Repository = "https://github.com/camelot-dev/camelot"

0 commit comments

Comments
 (0)