diff --git a/Cargo.toml b/Cargo.toml deleted file mode 100644 index a74f031..0000000 --- a/Cargo.toml +++ /dev/null @@ -1,17 +0,0 @@ -[package] -name = "gtfont" -version = "0.1.0" -edition = "2021" - -[lib] -crate-type = ["cdylib"] - -[dependencies] -pyo3 = { version = "0.21", features = ["extension-module", "abi3-py38"] } -fontdue = "0.8" - -[package.metadata.maturin] -name = "gtfont" - -[env] -PYO3_USE_ABI3_FORWARD_COMPATIBILITY = "1" diff --git a/greater_tables/_version.py b/greater_tables/_version.py index 0d72820..7dd7be1 100644 --- a/greater_tables/_version.py +++ b/greater_tables/_version.py @@ -1 +1,21 @@ -__version__ = "5.1.0" +# file generated by setuptools-scm +# don't change, don't track in version control + +__all__ = ["__version__", "__version_tuple__", "version", "version_tuple"] + +TYPE_CHECKING = False +if TYPE_CHECKING: + from typing import Tuple + from typing import Union + + VERSION_TUPLE = Tuple[Union[int, str], ...] +else: + VERSION_TUPLE = object + +version: str +__version__: str +__version_tuple__: VERSION_TUPLE +version_tuple: VERSION_TUPLE + +__version__ = version = '5.1.0.post3+dirty' +__version_tuple__ = version_tuple = (5, 1, 0, 'post3', 'dirty') diff --git a/gtfont/Cargo.lock b/gtfont/Cargo.lock deleted file mode 100644 index 886d066..0000000 --- a/gtfont/Cargo.lock +++ /dev/null @@ -1,366 +0,0 @@ -# This file is automatically @generated by Cargo. -# It is not intended for manual editing. -version = 4 - -[[package]] -name = "ahash" -version = "0.8.12" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5a15f179cd60c4584b8a8c596927aadc462e27f2ca70c04e0071964a73ba7a75" -dependencies = [ - "cfg-if", - "once_cell", - "version_check", - "zerocopy", -] - -[[package]] -name = "allocator-api2" -version = "0.2.21" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "683d7910e743518b0e34f1186f92494becacb047c7b6bf616c96772180fef923" - -[[package]] -name = "autocfg" -version = "1.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c08606f8c3cbf4ce6ec8e28fb0014a2c086708fe954eaa885384a6165172e7e8" - -[[package]] -name = "bitflags" -version = "2.9.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1b8e56985ec62d17e9c1001dc89c88ecd7dc08e47eba5ec7c29c7b5eeecde967" - -[[package]] -name = "cfg-if" -version = "1.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9555578bc9e57714c812a1f84e4fc5b4d21fcb063490c624de019f7464c91268" - -[[package]] -name = "fontdue" -version = "0.8.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9099a2f86b8e674b75d03ff154b3fe4c5208ed249ced8d69cc313a9fa40bb488" -dependencies = [ - "hashbrown", - "ttf-parser", -] - -[[package]] -name = "gtfont" -version = "0.1.0" -dependencies = [ - "fontdue", - "pyo3", -] - -[[package]] -name = "hashbrown" -version = "0.14.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e5274423e17b7c9fc20b6e7e208532f9b19825d82dfd615708b70edd83df41f1" -dependencies = [ - "ahash", - "allocator-api2", -] - -[[package]] -name = "heck" -version = "0.4.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "95505c38b4572b2d910cecb0281560f54b440a19336cbbcb27bf6ce6adc6f5a8" - -[[package]] -name = "indoc" -version = "2.0.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f4c7245a08504955605670dbf141fceab975f15ca21570696aebe9d2e71576bd" - -[[package]] -name = "libc" -version = "0.2.174" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1171693293099992e19cddea4e8b849964e9846f4acee11b3948bcc337be8776" - -[[package]] -name = "lock_api" -version = "0.4.13" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "96936507f153605bddfcda068dd804796c84324ed2510809e5b2a624c81da765" -dependencies = [ - "autocfg", - "scopeguard", -] - -[[package]] -name = "memoffset" -version = "0.9.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "488016bfae457b036d996092f6cb448677611ce4449e970ceaf42695203f218a" -dependencies = [ - "autocfg", -] - -[[package]] -name = "once_cell" -version = "1.21.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "42f5e15c9953c5e4ccceeb2e7382a716482c34515315f7b03532b8b4e8393d2d" - -[[package]] -name = "parking_lot" -version = "0.12.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "70d58bf43669b5795d1576d0641cfb6fbb2057bf629506267a92807158584a13" -dependencies = [ - "lock_api", - "parking_lot_core", -] - -[[package]] -name = "parking_lot_core" -version = "0.9.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bc838d2a56b5b1a6c25f55575dfc605fabb63bb2365f6c2353ef9159aa69e4a5" -dependencies = [ - "cfg-if", - "libc", - "redox_syscall", - "smallvec", - "windows-targets", -] - -[[package]] -name = "portable-atomic" -version = "1.11.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f84267b20a16ea918e43c6a88433c2d54fa145c92a811b5b047ccbe153674483" - -[[package]] -name = "proc-macro2" -version = "1.0.95" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "02b3e5e68a3a1a02aad3ec490a98007cbc13c37cbe84a3cd7b8e406d76e7f778" -dependencies = [ - "unicode-ident", -] - -[[package]] -name = "pyo3" -version = "0.21.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a5e00b96a521718e08e03b1a622f01c8a8deb50719335de3f60b3b3950f069d8" -dependencies = [ - "cfg-if", - "indoc", - "libc", - "memoffset", - "parking_lot", - "portable-atomic", - "pyo3-build-config", - "pyo3-ffi", - "pyo3-macros", - "unindent", -] - -[[package]] -name = "pyo3-build-config" -version = "0.21.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7883df5835fafdad87c0d888b266c8ec0f4c9ca48a5bed6bbb592e8dedee1b50" -dependencies = [ - "once_cell", - "target-lexicon", -] - -[[package]] -name = "pyo3-ffi" -version = "0.21.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "01be5843dc60b916ab4dad1dca6d20b9b4e6ddc8e15f50c47fe6d85f1fb97403" -dependencies = [ - "libc", - "pyo3-build-config", -] - -[[package]] -name = "pyo3-macros" -version = "0.21.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "77b34069fc0682e11b31dbd10321cbf94808394c56fd996796ce45217dfac53c" -dependencies = [ - "proc-macro2", - "pyo3-macros-backend", - "quote", - "syn", -] - -[[package]] -name = "pyo3-macros-backend" -version = "0.21.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "08260721f32db5e1a5beae69a55553f56b99bd0e1c3e6e0a5e8851a9d0f5a85c" -dependencies = [ - "heck", - "proc-macro2", - "pyo3-build-config", - "quote", - "syn", -] - -[[package]] -name = "quote" -version = "1.0.40" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1885c039570dc00dcb4ff087a89e185fd56bae234ddc7f056a945bf36467248d" -dependencies = [ - "proc-macro2", -] - -[[package]] -name = "redox_syscall" -version = "0.5.13" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0d04b7d0ee6b4a0207a0a7adb104d23ecb0b47d6beae7152d0fa34b692b29fd6" -dependencies = [ - "bitflags", -] - -[[package]] -name = "scopeguard" -version = "1.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49" - -[[package]] -name = "smallvec" -version = "1.15.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "67b1b7a3b5fe4f1376887184045fcf45c69e92af734b7aaddc05fb777b6fbd03" - -[[package]] -name = "syn" -version = "2.0.104" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "17b6f705963418cdb9927482fa304bc562ece2fdd4f616084c50b7023b435a40" -dependencies = [ - "proc-macro2", - "quote", - "unicode-ident", -] - -[[package]] -name = "target-lexicon" -version = "0.12.16" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "61c41af27dd6d1e27b1b16b489db798443478cef1f06a660c96db617ba5de3b1" - -[[package]] -name = "ttf-parser" -version = "0.20.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "17f77d76d837a7830fe1d4f12b7b4ba4192c1888001c7164257e4bc6d21d96b4" - -[[package]] -name = "unicode-ident" -version = "1.0.18" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5a5f39404a5da50712a4c1eecf25e90dd62b613502b7e925fd4e4d19b5c96512" - -[[package]] -name = "unindent" -version = "0.2.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7264e107f553ccae879d21fbea1d6724ac785e8c3bfc762137959b5802826ef3" - -[[package]] -name = "version_check" -version = "0.9.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0b928f33d975fc6ad9f86c8f283853ad26bdd5b10b7f1542aa2fa15e2289105a" - -[[package]] -name = "windows-targets" -version = "0.52.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9b724f72796e036ab90c1021d4780d4d3d648aca59e491e6b98e725b84e99973" -dependencies = [ - "windows_aarch64_gnullvm", - "windows_aarch64_msvc", - "windows_i686_gnu", - "windows_i686_gnullvm", - "windows_i686_msvc", - "windows_x86_64_gnu", - "windows_x86_64_gnullvm", - "windows_x86_64_msvc", -] - -[[package]] -name = "windows_aarch64_gnullvm" -version = "0.52.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "32a4622180e7a0ec044bb555404c800bc9fd9ec262ec147edd5989ccd0c02cd3" - -[[package]] -name = "windows_aarch64_msvc" -version = "0.52.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "09ec2a7bb152e2252b53fa7803150007879548bc709c039df7627cabbd05d469" - -[[package]] -name = "windows_i686_gnu" -version = "0.52.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8e9b5ad5ab802e97eb8e295ac6720e509ee4c243f69d781394014ebfe8bbfa0b" - -[[package]] -name = "windows_i686_gnullvm" -version = "0.52.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0eee52d38c090b3caa76c563b86c3a4bd71ef1a819287c19d586d7334ae8ed66" - -[[package]] -name = "windows_i686_msvc" -version = "0.52.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "240948bc05c5e7c6dabba28bf89d89ffce3e303022809e73deaefe4f6ec56c66" - -[[package]] -name = "windows_x86_64_gnu" -version = "0.52.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "147a5c80aabfbf0c7d901cb5895d1de30ef2907eb21fbbab29ca94c5b08b1a78" - -[[package]] -name = "windows_x86_64_gnullvm" -version = "0.52.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "24d5b23dc417412679681396f2b49f3de8c1473deb516bd34410872eff51ed0d" - -[[package]] -name = "windows_x86_64_msvc" -version = "0.52.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec" - -[[package]] -name = "zerocopy" -version = "0.8.26" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1039dd0d3c310cf05de012d8a39ff557cb0d23087fd44cad61df08fc31907a2f" -dependencies = [ - "zerocopy-derive", -] - -[[package]] -name = "zerocopy-derive" -version = "0.8.26" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9ecf5b4cc5364572d7f4c329661bcc82724222973f2cab6f050a4e5c22f75181" -dependencies = [ - "proc-macro2", - "quote", - "syn", -] diff --git a/inject_version.py b/inject_version.py deleted file mode 100644 index 99cfc21..0000000 --- a/inject_version.py +++ /dev/null @@ -1,27 +0,0 @@ -"""Inject latest version from git describe into toml.""" -# inject_version.py - -import setuptools_scm -import tomlkit -from pathlib import Path - -def main(): - root = Path(__file__).parent - pyproject_path = root / "pyproject.toml" - version_file = root / "greater_tables" / "_version.py" - - # Get version from Git - version = setuptools_scm.get_version(root=str(root)) - - # Update pyproject.toml - pyproject = tomlkit.parse(pyproject_path.read_text()) - pyproject["project"]["version"] = version - pyproject_path.write_text(tomlkit.dumps(pyproject)) - print(f"✅ Injected version: {version}") - - # Write to _version.py - version_file.write_text(f'__version__ = "{version}"\n') - print(f"✅ Wrote version to {version_file}") - -if __name__ == "__main__": - main() diff --git a/pyproject.toml b/pyproject.toml index 648d658..050735d 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,10 +1,10 @@ [build-system] -requires = ["maturin>=1.4", "tomlkit"] -build-backend = "maturin" +requires = ["setuptools>=62.3", "setuptools_scm[toml]>=7.0"] +build-backend = "setuptools.build_meta" [project] name = "greater_tables" -version = "5.1.0" +dynamic = ["version"] description = "Perfect tables from pandas dataframes." authors = [{name = "Stephen J Mildehall", email = "mynl@me.com" }] readme = {file = "README.md", content-type = "text/markdown"} @@ -33,10 +33,16 @@ classifiers = [ "Documentation" = "https://greater-tables-project.readthedocs.io/en/latest/" "Changelog" = "https://greater-tables-project.readthedocs.io/en/latest/versions.html" -[tool.maturin] -module-name = "greater_tables.gtfont" -python-source = "." -cargo-manifest = "gtfont/Cargo.toml" +[tool.setuptools_scm] +version_file = "greater_tables/_version.py" +local_scheme = "dirty-tag" # affects the "+gHASH" part +version_scheme = "post-release" # affects dev version style + +[tool.setuptools.packages.find] +include = ["greater_tables", "greater_tables.*"] + +[tool.setuptools.package-data] +"greater_tables" = ["data/*.csv", "data/*.md"] [project.optional-dependencies] dev = [ diff --git a/src/lib.rs b/src/lib.rs deleted file mode 100644 index d8f27ee..0000000 --- a/src/lib.rs +++ /dev/null @@ -1,59 +0,0 @@ -use fontdue::Font; -use pyo3::prelude::*; - -#[pyclass] -struct FontMeasurer { - font: Font, -} - -#[pymethods] -impl FontMeasurer { - #[new] - fn new(font_bytes: &[u8]) -> PyResult { - let font = Font::from_bytes(font_bytes, fontdue::FontSettings::default()) - .map_err(|e| pyo3::exceptions::PyValueError::new_err(format!("Font error: {e}")))?; - Ok(Self { font }) - } - - fn measure(&self, text: &str, px: f32) -> f32 { - text.chars() - .map(|c| self.font.metrics(c, px).advance_width) - .sum() - } - - fn max_word_width(&self, text: &str, px: f32) -> f32 { - text.split(' ') - .map(|word| word.chars() - .map(|c| self.font.metrics(c, px).advance_width) - .sum::()) - .fold(0.0, f32::max) - } - fn measure_and_max_word(&self, text: &str, px: f32) -> (f32, f32) { - let mut total: f32 = 0.0; - let mut max_word: f32 = 0.0; - - for word in text.split(' ') { - let word_width: f32 = word.chars() - .map(|c| self.font.metrics(c, px).advance_width) - .sum(); - total += word_width + self.font.metrics(' ', px).advance_width; - max_word = max_word.max(word_width); - } - - if text.ends_with(' ') { - // trailing space is valid - } else if total > 0.0 { - total -= self.font.metrics(' ', px).advance_width; - } - - (total, max_word) - } - - -} - -#[pymodule] -fn gtfont(_py: &Bound<'_, PyModule>) -> PyResult<()> { - _py.add_class::()?; - Ok(()) -} diff --git a/uv b/uv deleted file mode 100644 index 9797785..0000000 --- a/uv +++ /dev/null @@ -1,11 +0,0 @@ -Obtaining file:///C:/S/TELOS/Python/greater_tables_project - Installing build dependencies: started - Installing build dependencies: finished with status 'done' - Checking if build backend supports build_editable: started - Checking if build backend supports build_editable: finished with status 'done' - Getting requirements to build editable: started - Getting requirements to build editable: finished with status 'done' - Preparing editable metadata (pyproject.toml): started - Preparing editable metadata (pyproject.toml): finished with status 'done' -Collecting bs4 (from greater_tables==4.0.0) - Using cached bs4-0.0.2-py2.py3-none-any.whl.metadata (411 bytes)