{"id":13714765,"url":"https://github.com/sqreen/PyMiniRacer","last_synced_at":"2025-05-07T03:30:55.678Z","repository":{"id":10163127,"uuid":"61648905","full_name":"sqreen/PyMiniRacer","owner":"sqreen","description":"PyMiniRacer is a V8 bridge in Python.","archived":false,"fork":false,"pushed_at":"2024-06-15T20:09:00.000Z","size":2744,"stargazers_count":739,"open_issues_count":19,"forks_count":74,"subscribers_count":15,"default_branch":"master","last_synced_at":"2025-04-14T03:08:38.907Z","etag":null,"topics":["python","v8-javascript-engine"],"latest_commit_sha":null,"homepage":"https://blog.sqreen.com/embedding-javascript-into-python/","language":"Python","has_issues":false,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"isc","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/sqreen.png","metadata":{"files":{"readme":"README.rst","changelog":"HISTORY.rst","contributing":"CONTRIBUTING.rst","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":"AUTHORS.rst","dei":null,"publiccode":null,"codemeta":null}},"created_at":"2016-06-21T16:19:51.000Z","updated_at":"2025-04-12T15:16:47.000Z","dependencies_parsed_at":"2024-03-20T15:45:52.241Z","dependency_job_id":"c9c70bfd-7cba-439e-b58d-2c4c5772a60f","html_url":"https://github.com/sqreen/PyMiniRacer","commit_stats":{"total_commits":302,"total_committers":15,"mean_commits":"20.133333333333333","dds":0.5794701986754967,"last_synced_commit":"f7b9da0d4987ca7d1982af7f24da423f06da9894"},"previous_names":[],"tags_count":25,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sqreen%2FPyMiniRacer","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sqreen%2FPyMiniRacer/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sqreen%2FPyMiniRacer/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sqreen%2FPyMiniRacer/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/sqreen","download_url":"https://codeload.github.com/sqreen/PyMiniRacer/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252806400,"owners_count":21807198,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["python","v8-javascript-engine"],"created_at":"2024-08-03T00:00:46.658Z","updated_at":"2025-05-07T03:30:55.013Z","avatar_url":"https://github.com/sqreen.png","language":"Python","readme":"**This package is now deprecated. Go to https://github.com/bpcreech/PyMiniRacer for an up-to-date version.**\n\n.. image:: https://img.shields.io/pypi/v/py_mini_racer.svg\n        :target: https://pypi.python.org/pypi/py_mini_racer\n\n.. image:: https://github.com/sqreen/PyMiniRacer/actions/workflows/build.yml/badge.svg\n        :target: https://github.com/sqreen/PyMiniRacer/actions/workflows/build.yml\n\n.. image:: https://img.shields.io/badge/License-ISC-blue.svg\n        :target: https://opensource.org/licenses/ISC\n\nMinimal, modern embedded V8 for Python.\n\nFeatures\n--------\n\n* Latest ECMAScript support\n* Web Assembly support\n* Unicode support\n* Thread safe\n* Re-usable contexts\n\nMiniRacer can be easily used by Django or Flask projects to minify assets, run\nbabel or WASM modules.\n\nExamples\n--------\n\nMiniRacer is straightforward to use:\n\n.. code-block:: python\n\n    \u003e\u003e\u003e from py_mini_racer import MiniRacer\n    \u003e\u003e\u003e ctx = MiniRacer()\n    \u003e\u003e\u003e ctx.eval(\"1+1\")\n    2\n    \u003e\u003e\u003e ctx.eval(\"var x = {company: 'Sqreen'}; x.company\")\n    'Sqreen'\n    \u003e\u003e\u003e print(ctx.eval(\"'\\N{HEAVY BLACK HEART}'\"))\n    ❤\n    \u003e\u003e\u003e ctx.eval(\"var fun = () =\u003e ({ foo: 1 });\")\n\nVariables are kept inside of a context:\n\n.. code-block:: python\n\n    \u003e\u003e\u003e ctx.eval(\"x.company\")\n    'Sqreen'\n\n\nWhile ``eval`` only supports returning primitive data types such as\nstrings, ``call`` supports returning composite types such as objects:\n\n.. code-block:: python\n\n    \u003e\u003e\u003e ctx.call(\"fun\")\n    {'foo': 1}\n\n\nComposite values are serialized using JSON.\nUse a custom JSON encoder when sending non-JSON encodable parameters:\n\n.. code-block:: python\n\n    import json\n\n    from datetime import datetime\n\n    class CustomEncoder(json.JSONEncoder):\n\n            def default(self, obj):\n                if isinstance(obj, datetime):\n                    return obj.isoformat()\n\n                return json.JSONEncoder.default(self, obj)\n\n\n.. code-block:: python\n\n    \u003e\u003e\u003e ctx.eval(\"var f = function(args) { return args; }\")\n    \u003e\u003e\u003e ctx.call(\"f\", datetime.now(), encoder=CustomEncoder)\n    '2017-03-31T16:51:02.474118'\n\n\nMiniRacer is ES6 capable:\n\n.. code-block:: python\n\n    \u003e\u003e\u003e ctx.execute(\"[1,2,3].includes(5)\")\n    False\n\nV8 heap information can be retrieved:\n\n.. code-block:: python\n\n    \u003e\u003e\u003e ctx.heap_stats()\n    {'total_physical_size': 1613896,\n     'used_heap_size': 1512520,\n     'total_heap_size': 3997696,\n     'total_heap_size_executable': 3145728,\n     'heap_size_limit': 1501560832}\n\n\nA WASM example is available in the `tests`_.\n\n.. _`tests`: https://github.com/sqreen/PyMiniRacer/blob/master/tests/test_wasm.py\n\n\nCompatibility\n-------------\n\nPyMiniRacer is compatible with Python 2 \u0026 3 and based on ctypes.\n\nThe binary builds have been tested on x86_64 with:\n\n* macOS \u003e= 10.13\n* Ubuntu \u003e= 16.04\n* Debian \u003e= 9\n* CentOS \u003e= 7\n* Alpine \u003e= 3.11\n* Windows 10\n\nIt should work on any Linux with a libc \u003e= 2.12 and a wheel compatible pip (\u003e= 8.1).\n\nIf you're running Alpine Linux, you may need to install required dependencies manually using the following command:\n\n.. code-block:: bash\n\n    $ apk add libgcc libstdc++\n\nIf you have a up-to-date pip and it doesn't use a wheel, you might have an environment for which no wheel is built. Please open an issue.\n\nInstallation\n------------\n\nWe built Python wheels (prebuilt binaries) for macOS 64 bits, Linux 64 bits and Windows 64 bits.\n\n.. code:: bash\n\n    $ pip install py-mini-racer\n\nBuild\n-----\n\n**Warning**: building this package from source takes several GB of disk space and takes ~60 minutes.\n\nFirst check that your current Python executable is version 2.7. This is required\nby the V8 build system.\n\n.. code:: bash\n\n    $ python --version\n    Python 2.7.16\n\nYou can build the extension with the following command:\n\n.. code:: bash\n\n    $ python helpers/v8_build.py\n\nYou can generate a wheel for whatever Python version with the command:\n\n.. code:: bash\n\n    $ python3 helpers/build_package.py wheel dist\n\nIt will then build V8, the extension, and generates a wheel for your current\nPython version. The V8 builds are cached in the ``py_mini_racer/extension/v8/``\ndirectory.\n\nNotes for building on macOS\n'''''''''''''''''''''''''''\n\nThe legacy Python binary builds (OSX 10.6) need to be downloaded from:\n    https://www.python.org/downloads/\n\nThey will allow to build a wheel compatible with former OSX versions.\n\nTests\n-----\n\nIf you want to run the tests, you need to build the extension first, first install pytest:\n\n.. code-block:: bash\n\n    $ python -m pip install pytest\n\nThen launch:\n\n.. code:: bash\n\n    $ python -m pytest tests\n\nCredits\n-------\n\nBuilt with love by Sqreen_.\n\n.. _Sqreen: https://www.sqreen.com\n\nPyMiniRacer launch was described in `this blog post`_.\n\n.. _`this blog post`: https://blog.sqreen.com/embedding-javascript-into-python/\n\nPyMiniRacer is inspired by mini_racer_, built for the Ruby world by Sam Saffron.\n\n.. _`mini_racer`: https://github.com/SamSaffron/mini_racer\n\n`Cookiecutter-pypackage`_ was used as this package skeleton.\n\n.. _`Cookiecutter-pypackage`: https://github.com/audreyr/cookiecutter-pypackage\n","funding_links":[],"categories":["Uncategorized","Python"],"sub_categories":["Uncategorized"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsqreen%2FPyMiniRacer","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsqreen%2FPyMiniRacer","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsqreen%2FPyMiniRacer/lists"}