Skip to main content

Python snakes combined with the R logo

R, ready to roll.

A complete R runtime in a Python wheel.

PyPI Python 3.10+ R 4.6.2 Wheels Platforms Licenses: MIT and GPL-2.0-or-later

No system R installation. No runtime dependencies on Python packages. No downloads on import. No changes to your process environment.

Install

pip install r4py

Wheels contain R 4.6.2, base and recommended packages, libR, headers, help files, and R CMD tools. The Windows wheel omits the CRAN uninstaller and combined reference-manual PDF; individual package help and manuals remain included. Version 4.6.2.4 means R 4.6.2, packaging revision 4.

The release workflow targets:

Platform Architectures
Linux, glibc 2.28+ x86-64, ARM64
macOS 15+ Intel, Apple Silicon
Windows 10+ x86-64

Linux wheels are repaired with auditwheel; macOS wheels with delocate. Alpine/musl and Windows ARM64 are not supported. Python 3.10+ is required.

Why r4py?

r4py System R / conda R rpy2
Install pip install r4py OS package manager or conda needs an existing R
Bundles R yes yes no
Call R from Python objects RSession (separate process, plain data) no yes (in-process, R objects)
Best for running R from Python projects and CI with nothing else installed general R work deep in-process integration

rpy2 has not been verified against the bundled R. In our test, rpy2 3.6 crashed while initialising R 4.6 in ABI mode, and its API mode needs a compiler new enough for R 4.6's headers. Use RSession below instead.

Python

from subprocess import run
from r4py import R, R_HOME, R_VERSION, RSCRIPT

print(R_HOME)  # pathlib.Path to the bundled R installation
print(R_VERSION)  # (4, 6, 2)

run([RSCRIPT, "--vanilla", "-e", "cat(mean(1:10))"], check=True)
run([RSCRIPT, "analysis.R", "input.csv"], check=True)
run([R, "CMD", "config", "CC"], check=True)

The executables locate their own runtime, even if the environment is moved. To override a system R environment or configure a child process:

from r4py import get_env

run(
    [RSCRIPT, "--vanilla", "-e", "cat(R.home())"],
    env=get_env({"R_LIBS_USER": "/path/to/my/R/library"}),
    check=True,
    capture_output=True,
    text=True,
)

get_env() copies os.environ, applies your overrides, then sets the bundled R home, include, share, and documentation paths. It removes inherited R sub-architecture and R loader overrides. It never changes os.environ.

r4py is a runtime distribution, not an in-process bridge. Run R with subprocesses or files, or use RSession below for plain-data calls.

Check the installed version with r4py.__version__ (packaging version, e.g. 4.6.2.4) or R_VERSION (bundled R, e.g. (4, 6, 2)). r4py --version is passed through to Rscript and reports R's own version.

Calling R from Python

RSession starts R once and keeps it running, so variables and loaded packages persist between calls. It needs no compiler and no R packages.

from r4py import RSession

with RSession() as r:
    r.assign("x", [1, 2, 3, 4])
    r.eval("mean(x)")  # 2.5
    r.call("stats::sd", [1, 2, 3, 4])  # 1.29...
    r.eval("summary(lm(mpg ~ wt, mtcars))$r.squared")
    df = r.eval("head(mtcars)")  # pandas.DataFrame if pandas is installed
  • eval(code) returns the value of the last expression. print() output goes to sys.stdout, R messages to sys.stderr, and R warnings become RWarning. Pass echo=False to discard printed output.
  • R errors raise RError, and the session remains usable. If R itself dies, RError is raised and restart() starts a fresh process; restart() also discards all R state.
  • Python to R: None, bool, int, float, str, lists and tuples (vectors when the elements share a type, otherwise lists), dicts (named lists), numpy arrays, and pandas data frames. None inside a vector becomes NA.
  • R to Python: NULL and NA are None; length-one vectors are scalars; longer vectors are lists; named vectors and lists are dicts; matrices are lists of rows; factors and dates are strings; data frames are pandas.DataFrame or, without pandas, a dict of column lists. Functions, environments and S4 objects raise RError.
  • Values are copied as text, so this suits results and moderate data, not huge objects. Sessions are not thread-safe. Use subprocess with RSCRIPT for batch scripts.

This is not an in-process bridge like rpy2: R objects stay in R, and only plain data crosses.

Command line

r4py --vanilla -e 'cat(mean(1:10))'
r4py analysis.R input.csv
python -m r4py --vanilla -e 'cat(R.version.string)'
r4py-r                         # interactive R
r4py-r CMD config CC

r4py runs Rscript. r4py-r runs R. Arguments, standard streams, and exit codes are passed through. The launchers do not silently select a system R. R startup files behave normally; use --vanilla for isolated execution.

R packages

Recommended packages, including Matrix, MASS, survival, and lattice, are already included. Install additional packages into a writable library outside the wheel:

r4py --vanilla -e 'lib <- path.expand("~/r4py-library"); dir.create(lib, recursive=TRUE, showWarnings=FALSE); install.packages("jsonlite", lib=lib, repos="https://cloud.r-project.org")'

Set R_LIBS_USER to that directory for subsequent runs. Package installation uses the network. Unix wheels include a CA certificate bundle so HTTPS downloads do not depend on the build machine's certificate paths; set CURL_CA_BUNDLE to use your own PEM certificate bundle. Compiling source packages requires native build tools and any package-specific system libraries; Windows uses Rtools. R CMD config also requires make on Unix. These tools are not bundled. Neither RStudio nor a desktop GUI is included. Headless PDF and PNG graphics are supported.

Troubleshooting

  • No matching distribution found: wheels require Python 3.10+, glibc 2.28+ on Linux, and macOS 15+. Alpine/musl and Windows ARM64 are unsupported; pip falls back to the source distribution, which contains no R.
  • bundled R is missing: you installed the source distribution or are running from a checkout. Install a platform wheel or run build_r_runtime.py.
  • Wrong R or library picked up: use get_env() for child processes, and --vanilla to skip user startup files.
  • Package compilation fails: install native build tools (Rtools on Windows); they are not bundled.

Build and test

uv sync --no-install-project
uv run --no-sync ruff check .
uv run --no-sync pyright
uv run --no-sync pytest -m 'not runtime'
uv run --no-sync python build_r_runtime.py
uv build --wheel

Optional: install the git hooks with uvx pre-commit install. They run ruff, pyright and basic file checks; uv sync --no-install-project must have been run first for pyright.

Unix builds need a C/C++/Fortran toolchain, make, tar, a CA certificate bundle, and development files for curl, bzip2, xz, zlib, PCRE2, ICU, readline, Cairo, PNG, JPEG, and TIFF. For example, use the manylinux container recipe in the wheel workflow. --jobs N controls compilation parallelism. --source-archive PATH uses a local tarball with the same pinned SHA-256 verification.

On Windows, or to reuse a native R installation:

uv run --no-sync python build_r_runtime.py --runtime /path/to/R/home

The builder checks the R version, copies the installation, and makes the Unix launchers relocatable. It refuses to overwrite an existing runtime. Wheel builds fail if the runtime is missing or the R version does not match. Source distributions contain build tooling, not R.

Local builds inherit the host's OS and library requirements. On Unix, repair the wheel before distributing it; the release workflow does this automatically. For a local Linux build:

AUDITWHEEL_LD_LIBRARY_PATH="$PWD/src/r4py/r-runtime/lib" \
  uvx --from auditwheel --with patchelf auditwheel repair --strip \
  -w wheelhouse dist/r4py-*.whl
uv run --no-sync pytest
R4PY_REQUIRE_RUNTIME=1 uv run --no-sync pytest -m runtime
uv run --no-sync python tests/smoke_wheel.py wheelhouse/r4py-*.whl

Without a built runtime, integration tests skip. Release CI requires them, installs each repaired wheel in a path with spaces, hides the original runtime, and tests R execution, recommended native packages, graphics, R CMD on Unix, user-library package installation, and exit codes.

Licensing

r4py's Python code is MIT licensed. Bundled R is GPL-2.0-or-later; its packages and linked libraries retain their own licenses. Do not treat the wheel as MIT-only. The Unix wheel recipes retain dependency license notices and the exact RPM or Homebrew source-package inventory.

R source: R-4.6.2.tar.gz (SHA-256 c297040f6392b1dac6e5c0eb398422cfdaedf540ae2205edb9ad0d10cb10ee00). The build script contains the launcher modifications and is also included in the bundled runtime. Preserve R's COPYING and package notices when redistributing. Binary redistribution must comply with R and dependency source-distribution requirements; linking or embedding R may impose further GPL obligations.

The logo, shown above and included in the source distribution, combines the Python two-snakes device, a trademark of the Python Software Foundation, with the R logo, copyright 2016 The R Foundation. The R artwork and composite arrangement are CC BY-SA 4.0; the R artwork is scaled and layered with the Python device. The Python device retains its original shape and colors and remains subject to the PSF trademark usage policy. Neither foundation's endorsement is implied.

Releases and PyPI

Release each supported stable R version separately: r4py 4.6.2.4 and tag v4.6.2.4 bundle R 4.6.2, with packaging revision 4. Changes to r4py itself, whether fixes or features, increment the fourth component. Keep previous releases available so users can pin their R runtime.

For the first PyPI upload, add a pending publisher at PyPI account publishing:

Field Value
PyPI project name r4py
Repository owner JGalego
Repository name r4py
Workflow filename wheels.yml
Environment name pypi

The workflow's display name is Wheels, but PyPI needs its filename, wheels.yml, without the .github/workflows/ prefix. No PyPI API token is needed.

A release tag builds and tests the source distribution and five wheels without publishing. Once trusted publishing is configured and the release's corresponding source materials are available, run Wheels manually on that tag with publish enabled:

gh workflow run wheels.yml --ref v4.6.2.4 -f publish=true

Publishing uses the pypi GitHub environment. Add required reviewers if the repository's billing plan supports them; otherwise the explicit manual publish input is the release gate. Before publishing, verify third-party notices and make the exact corresponding sources for R and bundled dependencies available alongside the binaries.

Metadata

Release files for r4py 4.6.2.4

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for r4py 4.6.2.4
File Size Uploaded Provenance Actions
r4py-4.6.2.4.tar.gz 42.4 kB With provenance Details for r4py-4.6.2.4.tar.gz

Built distributions (wheels)

Table of built distributions (wheels) for r4py 4.6.2.4
File Actions
r4py-4.6.2.4-py3-none-win_amd64.whl Python 3 none Windows x86-64 Details for r4py-4.6.2.4-py3-none-win_amd64.whl
r4py-4.6.2.4-py3-none-manylinux_2_28_x86_64.whl Python 3 none Linux glibc 2.28+ x86-64 Details for r4py-4.6.2.4-py3-none-manylinux_2_28_x86_64.whl
r4py-4.6.2.4-py3-none-manylinux_2_28_aarch64.whl Python 3 none Linux glibc 2.28+ ARM64 Details for r4py-4.6.2.4-py3-none-manylinux_2_28_aarch64.whl
r4py-4.6.2.4-py3-none-macosx_15_0_x86_64.whl Python 3 none macOS 15.0+ x86-64 Details for r4py-4.6.2.4-py3-none-macosx_15_0_x86_64.whl
r4py-4.6.2.4-py3-none-macosx_15_0_arm64.whl Python 3 none macOS 15.0+ ARM64 Details for r4py-4.6.2.4-py3-none-macosx_15_0_arm64.whl

Total release size: 428.5 MB

Release files / r4py-4.6.2.4.tar.gz

Download URL r4py-4.6.2.4.tar.gz
Size 42.4 kB
Tags Source
SHA-256 checksum
How to use checksums
cf01c8519aedb3c1c6fe6608032919ad821933c0735175047da9006c505d10bf
BLAKE2b-256 checksum
How to use checksums
deb85fe809d9a4ff6d13917ae7ada04e44aa4987a2a930e6e17e4bb53d7ec53c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 16, 2026.

Transparency log

Release files / r4py-4.6.2.4-py3-none-win_amd64.whl

Download URL r4py-4.6.2.4-py3-none-win_amd64.whl
Size 99.1 MB
Tags Python 3 Windows x86-64
SHA-256 checksum
How to use checksums
8f3e090cb4d4f1c0ff96ffbb78ca6bf42d097ad3db326d21647cb33950e5ce50
BLAKE2b-256 checksum
How to use checksums
c17577c78afe071a2cfb52671427f6bba8ce44f3fd8abeb47621c1ec6493d961
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 16, 2026.

Transparency log

Release files / r4py-4.6.2.4-py3-none-manylinux_2_28_x86_64.whl

Download URL r4py-4.6.2.4-py3-none-manylinux_2_28_x86_64.whl
Size 82.3 MB
Tags Linux glibc 2.28+ x86-64 Python 3
SHA-256 checksum
How to use checksums
e3de99e978566fcae5d0155e0c7f6c6585d107db0f5fd450589d11ecba727191
BLAKE2b-256 checksum
How to use checksums
470999f6fd6ef5f63694f65cbfecdfd42e6750f4dbb5ca22692e417b9b0dbb8e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 16, 2026.

Transparency log

Release files / r4py-4.6.2.4-py3-none-manylinux_2_28_aarch64.whl

Download URL r4py-4.6.2.4-py3-none-manylinux_2_28_aarch64.whl
Size 80.6 MB
Tags Linux glibc 2.28+ ARM64 Python 3
SHA-256 checksum
How to use checksums
77360f61da688516d358d1a36b52e80904f619e15929f5d1417e9040931d164d
BLAKE2b-256 checksum
How to use checksums
e2b01f86f25a11eca46028e316e413658140b1d6d8251b2aedf3913185a903db
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 16, 2026.

Transparency log

Release files / r4py-4.6.2.4-py3-none-macosx_15_0_x86_64.whl

Download URL r4py-4.6.2.4-py3-none-macosx_15_0_x86_64.whl
Size 84.1 MB
Tags Python 3 macOS 15.0+ x86-64
SHA-256 checksum
How to use checksums
f2ef9e5e1bfe2f7ce2ad196141077aa1720e378c8692be9cd99e96f4c39e4212
BLAKE2b-256 checksum
How to use checksums
ad086653681a1b815b6a88aa3ca6c97503e3a8c6c9db6f3bcb6fa61ead796ac0
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 16, 2026.

Transparency log

Release files / r4py-4.6.2.4-py3-none-macosx_15_0_arm64.whl

Download URL r4py-4.6.2.4-py3-none-macosx_15_0_arm64.whl
Size 82.3 MB
Tags Python 3 macOS 15.0+ ARM64
SHA-256 checksum
How to use checksums
3948b926ddf6db1b259c8d11c784fb8e72a5b9749f621c0a00092b43b8be07fc
BLAKE2b-256 checksum
How to use checksums
b9fcd26e812c441695271fd6e8b8b39c3a20b7c0c31202bd73005ab8cb72f571
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 16, 2026.

Transparency log

Security for r4py 4.6.2.4

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

All 6 files in this release have been uploaded with provenance metadata.

Select from 6 files

Attestation for r4py-4.6.2.4.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 16, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page