diff --git a/MANIFEST.in b/MANIFEST.in new file mode 100644 index 0000000..76bf25b --- /dev/null +++ b/MANIFEST.in @@ -0,0 +1 @@ +recursive-include greater_tables/data *.csv *.md diff --git a/docs/versions.rst b/docs/versions.rst index 78cce21..f6f6561 100644 --- a/docs/versions.rst +++ b/docs/versions.rst @@ -1,6 +1,21 @@ Versions and Change Log ========================== +.. remember + +.. test cases + * tex and or html in data, index, columns, escaped/unescaped + * long cols + * text with multiindex columns + +.. TODO + * self.padl and r / 12 in make html width adj s/b elsewhere + +5.1.0 +------ +* Added gtfont, a rust text to point size utility using fontdue https://docs.rs/fontdue/latest/fontdue/index.html. +* Removed scm version, moved setuptools to maturin build system. + 5.0.0 ------- * Introduced ``knowledge_df`` as source of all formatting instructions @@ -10,14 +25,6 @@ Versions and Change Log * Moved logging setup to separate file, called from cli but optional for use in other situation. GPT recommended approach. * Removed ``gt`` prefix from module file names, except logging. -.. * test cases - * tex and or html in data, index, columns, escaped/unescaped - * long cols - * text with multiindex columns - -.. * TODO - * self.padl and r / 12 in make html width adj s/b elsewhere - 4.0.0 ------- * Moved constants out of magic strings and into config diff --git a/greater_tables/_version.py b/greater_tables/_version.py index 0079903..7e28f64 100644 --- a/greater_tables/_version.py +++ b/greater_tables/_version.py @@ -1,21 +1 @@ -# 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.0.0' -__version_tuple__ = version_tuple = (5, 0, 0) +__version__ = "5.0.1.dev1+gc3d2dfc.d20250626" diff --git a/greater_tables/core.py b/greater_tables/core.py index 3dda2d4..1d023df 100644 --- a/greater_tables/core.py +++ b/greater_tables/core.py @@ -938,6 +938,8 @@ class GT(object): tikz = self.tex_knowledge_df['tikz_colw'].sum() tex = self.tex_knowledge_df['scaled_tabs'].sum() mtw = self.max_table_width_em + mtiw = self.config.max_table_inch_width + pts = self.config.table_font_pt_size bit = pd.DataFrame({ 'text natural': self.text_knowledge_df.natural_width, 'text minimum': self.text_knowledge_df.minimum_width, @@ -957,7 +959,10 @@ class GT(object): 'tikz recommended': tikz, }) bit.loc['total', :] = ser - print(f"requested width = {mtw}\n" + print(f"requested width = {mtw} em\n" + f"max tbl inch w = {mtiw} inches\n" + f"font pts = {pts} pts\n" + f"width in em chk = {mtiw * 72 / pts} em\n" f"width mode = {self.config.table_width_mode}\n" f"header relax = {self.config.table_width_header_adjust}\n" f"header chars = {self.config.table_width_header_relax}") diff --git a/gtfont/Cargo.lock b/gtfont/Cargo.lock new file mode 100644 index 0000000..886d066 --- /dev/null +++ b/gtfont/Cargo.lock @@ -0,0 +1,366 @@ +# 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 new file mode 100644 index 0000000..99cfc21 --- /dev/null +++ b/inject_version.py @@ -0,0 +1,27 @@ +"""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 df5046c..a42960b 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,14 +1,10 @@ [build-system] -requires = [ - "setuptools", - "build", - "setuptools_scm[toml]>=7.0" - ] -build-backend = "setuptools.build_meta" +requires = ["maturin>=1.4", "tomlkit"] +build-backend = "maturin" [project] name = "greater_tables" -dynamic = ["version"] +version = "5.0.1.dev1+gc3d2dfc.d20250626" description = "Perfect tables from pandas dataframes." authors = [{name = "Stephen J Mildehall", email = "mynl@me.com" }] readme = {file = "README.md", content-type = "text/markdown"} @@ -27,33 +23,25 @@ dependencies = [ classifiers = [ "Development Status :: 4 - Beta", "Programming Language :: Python :: 3", - "Programming Language :: Python :: 3.10", + "Programming Language :: Python :: 3.12", + "Programming Language :: Python :: 3.13", "Topic :: Office/Business" ] -[tool.setuptools_scm] -write_to = "greater_tables/_version.py" -version_scheme = "post-release" -local_scheme = "node-and-date" # "no-local-version" - - -[tool.setuptools.packages.find] -include = ["greater_tables", "greater_tables.data"] -exclude = ["img", "tests", "docs"] - -[tool.setuptools.package-data] -"greater_tables" = ["data/*.csv", "data/*.md"] - -[tool.setuptools.dynamic] -version = { attr = "greater_tables.__version__" } - [project.urls] "Source Code" = "https://github.com/mynl/greater_tables_project" "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" + [project.optional-dependencies] dev = [ + "setuptools_scm[toml]>=7.0", + "tomlkit", "docutils<0.17", "jupyter-sphinx", "myst_parser", @@ -74,10 +62,3 @@ dev = [ [project.scripts] gt = "greater_tables.cli:cli" -[tool.flake8] -max-line-length = 144 -ignore = ["E501", "E201", "W503"] - -[tool.pycodestyle] -max_line_length = 144 -ignore = ["E501", "E201", "W503"]