rtex


Namertex JSON
Version 0.0.5 PyPI version JSON
download
home_pageNone
Summary*Unofficial* client for the Rtex API server
upload_time2024-08-24 00:58:42
maintainerNone
docs_urlNone
authorNone
requires_python>=3.11
licenseMIT
keywords rtex latex math
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # Async Python Client to The RTEX API Server

## Installation

```bash
pip install rtex
```

## Usage

The API surface of Rtex is spartan so this is basically the whole thing.

```python
import asyncio

from rtex.client import AsyncRtexClient

async def amain():
  async with AsyncRtexClient() as rtex:
    res = rtex.create_render("\(x^2 + x - 1\)")

    if res.status == "success":
      with open("equation.png") as output_fd:
        await res.save_render(
          res.filename,
          output_fd
        )

def main():
  asyncio.run(amain())

if __name__ == "__main__":
  main()
```

## No Thoughts, Just Render

```python
async def amain():
  async with AsyncRtexClient() as rtex:
    buf = await rtex.render_math("e^x + 1")

    # `buf` now contains the bytes of the PNG
```

## Do I look like I know what a Jay-Peg is?

```python
async def amain():
  async with AsyncRtexClient() as rtex:
    # The render methods accept a format parameter.
    # Supported values are "png", "jpg" and "pdf"
    buf = await rtex.render_math("e^x + 1", format="jpg")
```

## Self-Hoster

Set the environment variable `RTEX_API_HOST` or do the following.

```python

async def amain():
  async with AsyncRtexClient(api_host="https://myserver.ru") as rtex:
    buf = await rtex.render_math("e^x + 1")
```


## I Can Tell By The Pixels

`quality` in Rtex speak is an abstract notion of compression for the given
format where `100` is the least compressed and `0` is the most. At the time of
writing the default is `85`.

`density` in Rtex speak is how much to sample the rendered PDF when generating
an image. This has no effect on the `"pdf"` format. At the time of writing the
default is `200`.

```python

async def amain():
  async with AsyncRtexClient(api_host="https://myserver.ru") as rtex:
    needs_more_jpeg = await rtex.render_math(
      "e^x + 1",
      density=50,
      quality=1
    )
```


            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "rtex",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.11",
    "maintainer_email": null,
    "keywords": "rtex, latex, math",
    "author": null,
    "author_email": "Estelle Poulin <dev@inspiredby.es>",
    "download_url": "https://files.pythonhosted.org/packages/12/7f/7d70e139a28883aa8e00d43cba9756f623eadb8b05099fa77a88623e2c2b/rtex-0.0.5.tar.gz",
    "platform": null,
    "description": "# Async Python Client to The RTEX API Server\n\n## Installation\n\n```bash\npip install rtex\n```\n\n## Usage\n\nThe API surface of Rtex is spartan so this is basically the whole thing.\n\n```python\nimport asyncio\n\nfrom rtex.client import AsyncRtexClient\n\nasync def amain():\n  async with AsyncRtexClient() as rtex:\n    res = rtex.create_render(\"\\(x^2 + x - 1\\)\")\n\n    if res.status == \"success\":\n      with open(\"equation.png\") as output_fd:\n        await res.save_render(\n          res.filename,\n          output_fd\n        )\n\ndef main():\n  asyncio.run(amain())\n\nif __name__ == \"__main__\":\n  main()\n```\n\n## No Thoughts, Just Render\n\n```python\nasync def amain():\n  async with AsyncRtexClient() as rtex:\n    buf = await rtex.render_math(\"e^x + 1\")\n\n    # `buf` now contains the bytes of the PNG\n```\n\n## Do I look like I know what a Jay-Peg is?\n\n```python\nasync def amain():\n  async with AsyncRtexClient() as rtex:\n    # The render methods accept a format parameter.\n    # Supported values are \"png\", \"jpg\" and \"pdf\"\n    buf = await rtex.render_math(\"e^x + 1\", format=\"jpg\")\n```\n\n## Self-Hoster\n\nSet the environment variable `RTEX_API_HOST` or do the following.\n\n```python\n\nasync def amain():\n  async with AsyncRtexClient(api_host=\"https://myserver.ru\") as rtex:\n    buf = await rtex.render_math(\"e^x + 1\")\n```\n\n\n## I Can Tell By The Pixels\n\n`quality` in Rtex speak is an abstract notion of compression for the given\nformat where `100` is the least compressed and `0` is the most. At the time of\nwriting the default is `85`.\n\n`density` in Rtex speak is how much to sample the rendered PDF when generating\nan image. This has no effect on the `\"pdf\"` format. At the time of writing the\ndefault is `200`.\n\n```python\n\nasync def amain():\n  async with AsyncRtexClient(api_host=\"https://myserver.ru\") as rtex:\n    needs_more_jpeg = await rtex.render_math(\n      \"e^x + 1\",\n      density=50,\n      quality=1\n    )\n```\n\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "*Unofficial* client for the Rtex API server",
    "version": "0.0.5",
    "project_urls": {
        "changelog": "https://github.com/estheruary/python-rtex/-/blob/main/CHANGELOG.md",
        "homepage": "https://github.com/estheruary/python-rtex",
        "repository": "https://github.com/estheruary/python-rtex"
    },
    "split_keywords": [
        "rtex",
        " latex",
        " math"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "2f0ea5f1e4eeef2c66a47770a99a664014869d180f42c86083818b7c1919b53a",
                "md5": "49bf3279cde8e7bc1a59e2bd7b99f8cd",
                "sha256": "ea4583e7da1f8cec8f92a08498304b7e86e043e83576d9aa05f5448c35bc4d79"
            },
            "downloads": -1,
            "filename": "rtex-0.0.5-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "49bf3279cde8e7bc1a59e2bd7b99f8cd",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.11",
            "size": 5510,
            "upload_time": "2024-08-24T00:58:41",
            "upload_time_iso_8601": "2024-08-24T00:58:41.347222Z",
            "url": "https://files.pythonhosted.org/packages/2f/0e/a5f1e4eeef2c66a47770a99a664014869d180f42c86083818b7c1919b53a/rtex-0.0.5-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "127f7d70e139a28883aa8e00d43cba9756f623eadb8b05099fa77a88623e2c2b",
                "md5": "a95fb4b092ee21475085480b3671b594",
                "sha256": "116a4aba1295e9951689c290f761ca45ab89a68ff286ab7dba160f0d7ef9013c"
            },
            "downloads": -1,
            "filename": "rtex-0.0.5.tar.gz",
            "has_sig": false,
            "md5_digest": "a95fb4b092ee21475085480b3671b594",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.11",
            "size": 6928,
            "upload_time": "2024-08-24T00:58:42",
            "upload_time_iso_8601": "2024-08-24T00:58:42.463485Z",
            "url": "https://files.pythonhosted.org/packages/12/7f/7d70e139a28883aa8e00d43cba9756f623eadb8b05099fa77a88623e2c2b/rtex-0.0.5.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-08-24 00:58:42",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "estheruary",
    "github_project": "python-rtex",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "requirements": [],
    "lcname": "rtex"
}
        
Elapsed time: 1.80654s