rtex


Namertex JSON
Version 0.0.3 PyPI version JSON
download
home_page
Summary*Unofficial* client for the Rtex API server
upload_time2023-11-19 03:29:22
maintainer
docs_urlNone
author
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": "",
    "name": "rtex",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.11",
    "maintainer_email": "",
    "keywords": "rtex,latex,math",
    "author": "",
    "author_email": "Estelle Poulin <dev@inspiredby.es>",
    "download_url": "https://files.pythonhosted.org/packages/57/2d/3e8d8925fe5986aa2678a807ea791946884b580d5b6506c1247b6b5bec2a/rtex-0.0.3.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.3",
    "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": "bc2439bdeb9db86bcbe05283fa8ec85b0b52c8c5abec647ff71150142a829154",
                "md5": "05b156e029a88a9eeb4a2a87f22cf9c0",
                "sha256": "b4a6d8d3849123a905969d142c260dce4094839b13ab576ff80bdb52b5c45ac8"
            },
            "downloads": -1,
            "filename": "rtex-0.0.3-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "05b156e029a88a9eeb4a2a87f22cf9c0",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.11",
            "size": 5511,
            "upload_time": "2023-11-19T03:29:21",
            "upload_time_iso_8601": "2023-11-19T03:29:21.116426Z",
            "url": "https://files.pythonhosted.org/packages/bc/24/39bdeb9db86bcbe05283fa8ec85b0b52c8c5abec647ff71150142a829154/rtex-0.0.3-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "572d3e8d8925fe5986aa2678a807ea791946884b580d5b6506c1247b6b5bec2a",
                "md5": "9901c241dcb1d145fbb3eec2898bb197",
                "sha256": "4dc3fed8dfce83f85152676ef92bbdf8cb95a03e7847f25543f668095f7103aa"
            },
            "downloads": -1,
            "filename": "rtex-0.0.3.tar.gz",
            "has_sig": false,
            "md5_digest": "9901c241dcb1d145fbb3eec2898bb197",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.11",
            "size": 6920,
            "upload_time": "2023-11-19T03:29:22",
            "upload_time_iso_8601": "2023-11-19T03:29:22.103060Z",
            "url": "https://files.pythonhosted.org/packages/57/2d/3e8d8925fe5986aa2678a807ea791946884b580d5b6506c1247b6b5bec2a/rtex-0.0.3.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-11-19 03:29:22",
    "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: 0.14160s