r4py 4.6.2.1__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,27 @@
1
+ name: Python
2
+
3
+ on:
4
+ push:
5
+ pull_request:
6
+
7
+ permissions:
8
+ contents: read
9
+
10
+ jobs:
11
+ check:
12
+ runs-on: ubuntu-latest
13
+ strategy:
14
+ matrix:
15
+ python: ["3.10", "3.14"]
16
+ steps:
17
+ - uses: actions/checkout@v4
18
+ - uses: astral-sh/setup-uv@v6
19
+ with:
20
+ python-version: ${{ matrix.python }}
21
+ enable-cache: true
22
+ - run: uv sync --locked --no-install-project
23
+ - run: uv run --no-sync ruff check .
24
+ - run: uv run --no-sync ruff format --check .
25
+ - run: uv run --no-sync pyright
26
+ - run: uv run --no-sync pytest -m "not runtime"
27
+
@@ -0,0 +1,181 @@
1
+ name: Wheels
2
+
3
+ on:
4
+ workflow_dispatch:
5
+ inputs:
6
+ publish:
7
+ description: Publish to PyPI after configuring trusted publishing (run on a release tag)
8
+ type: boolean
9
+ default: false
10
+ push:
11
+ tags: ["v*"]
12
+ pull_request:
13
+
14
+ permissions:
15
+ contents: read
16
+
17
+ jobs:
18
+ source:
19
+ runs-on: ubuntu-latest
20
+ steps:
21
+ - uses: actions/checkout@v4
22
+ - uses: astral-sh/setup-uv@v6
23
+ with:
24
+ python-version: "3.12"
25
+ - name: Check release tag
26
+ run: |
27
+ VERSION=$(python -c 'import runpy; print(runpy.run_path("src/r4py/__init__.py")["__version__"])')
28
+ if [ "$GITHUB_REF_TYPE" = tag ]; then
29
+ test "$GITHUB_REF_NAME" = "v$VERSION"
30
+ fi
31
+ - run: uv build --sdist
32
+ - uses: actions/upload-artifact@v4
33
+ with:
34
+ name: source
35
+ path: dist/*.tar.gz
36
+
37
+ linux:
38
+ runs-on: ${{ matrix.runner }}
39
+ strategy:
40
+ fail-fast: false
41
+ matrix:
42
+ include:
43
+ - runner: ubuntu-24.04
44
+ arch: x86_64
45
+ - runner: ubuntu-24.04-arm
46
+ arch: aarch64
47
+ steps:
48
+ - uses: actions/checkout@v4
49
+ - name: Build and repair
50
+ run: |
51
+ docker run --rm -v "$PWD:/work" -w /work \
52
+ quay.io/pypa/manylinux_2_28_${{ matrix.arch }} \
53
+ bash -euxc '
54
+ dnf install -y libcurl-devel bzip2-devel xz-devel zlib-devel \
55
+ pcre2-devel libicu-devel readline-devel cairo-devel \
56
+ libpng-devel libjpeg-turbo-devel libtiff-devel
57
+ PY=/opt/python/cp312-cp312/bin/python
58
+ "$PY" -m pip install build
59
+ "$PY" build_r_runtime.py --jobs 4
60
+ cp -a /usr/share/licenses src/r4py/r-runtime/dependency-licenses
61
+ rpm -qa --qf "%{NAME} %{VERSION}-%{RELEASE} %{SOURCERPM}\n" \
62
+ > src/r4py/r-runtime/dependency-sources.txt
63
+ "$PY" -m build --wheel
64
+ AUDITWHEEL_LD_LIBRARY_PATH=/work/src/r4py/r-runtime/lib \
65
+ auditwheel repair --strip --plat manylinux_2_28_${{ matrix.arch }} \
66
+ -w wheelhouse dist/*.whl
67
+ '
68
+ - uses: actions/setup-python@v5
69
+ with:
70
+ python-version: "3.12"
71
+ - name: Test installed wheel
72
+ run: python tests/smoke_wheel.py wheelhouse/*.whl
73
+ - uses: actions/upload-artifact@v4
74
+ with:
75
+ name: wheels-linux-${{ matrix.arch }}
76
+ path: wheelhouse/*.whl
77
+
78
+ native:
79
+ runs-on: ${{ matrix.runner }}
80
+ env:
81
+ MACOSX_DEPLOYMENT_TARGET: "15.0"
82
+ defaults:
83
+ run:
84
+ shell: bash
85
+ strategy:
86
+ fail-fast: false
87
+ matrix:
88
+ runner: [macos-15, macos-15-intel, windows-latest]
89
+ steps:
90
+ - uses: actions/checkout@v4
91
+ - uses: actions/setup-python@v5
92
+ with:
93
+ python-version: "3.12"
94
+ - run: python -m pip install build
95
+ - name: Select R version
96
+ id: r
97
+ run: |
98
+ VERSION=$(python -c 'import runpy; print(".".join(runpy.run_path("src/r4py/__init__.py")["__version__"].split(".")[:3]))')
99
+ echo "version=$VERSION" >> "$GITHUB_OUTPUT"
100
+ - uses: r-lib/actions/setup-r@v2
101
+ if: runner.os == 'Windows'
102
+ with:
103
+ r-version: ${{ steps.r.outputs.version }}
104
+ use-public-rspm: false
105
+ - name: Copy Windows R
106
+ if: runner.os == 'Windows'
107
+ run: |
108
+ R_HOME=$(Rscript --vanilla -e 'cat(R.home())')
109
+ python build_r_runtime.py --runtime "$R_HOME"
110
+ - name: Build macOS R
111
+ if: runner.os == 'macOS'
112
+ run: |
113
+ brew install gcc@14 pkgconf curl pcre2 xz icu4c readline cairo \
114
+ libpng jpeg-turbo libtiff
115
+ FC="$(brew --prefix gcc@14)/bin/gfortran-14"
116
+ test -x "$FC"
117
+ PKG_CONFIG_PATH="$(brew --prefix)/lib/pkgconfig:$(brew --prefix curl)/lib/pkgconfig:$(brew --prefix icu4c)/lib/pkgconfig:$(brew --prefix readline)/lib/pkgconfig"
118
+ CPPFLAGS="-I$(brew --prefix)/include -I$(brew --prefix curl)/include -I$(brew --prefix readline)/include -I$(brew --prefix icu4c)/include"
119
+ LDFLAGS="-L$(brew --prefix)/lib -L$(brew --prefix curl)/lib -L$(brew --prefix readline)/lib -L$(brew --prefix icu4c)/lib"
120
+ export FC PKG_CONFIG_PATH CPPFLAGS LDFLAGS
121
+ python build_r_runtime.py --jobs 4
122
+ brew info --json=v2 --installed \
123
+ > src/r4py/r-runtime/dependency-sources.json
124
+ CELLAR=$(brew --cellar)
125
+ (cd "$CELLAR" && find . -type f \
126
+ \( -iname 'license*' -o -iname 'copying*' -o -iname 'copyright*' \) \
127
+ -print0) | tar -C "$CELLAR" --null -T - \
128
+ -cf src/r4py/r-runtime/dependency-licenses.tar
129
+ - name: Build wheel
130
+ run: python -m build --wheel
131
+ - name: Repair macOS wheel
132
+ if: runner.os == 'macOS'
133
+ run: |
134
+ python -m pip install delocate
135
+ DYLD_LIBRARY_PATH="$PWD/src/r4py/r-runtime/lib" python - <<'PY'
136
+ import os
137
+ import platform
138
+ from pathlib import Path
139
+ from delocate.delocating import delocate_wheel
140
+ from packaging.version import Version
141
+
142
+ output = Path("wheelhouse")
143
+ output.mkdir(exist_ok=True)
144
+ for wheel in Path("dist").glob("*.whl"):
145
+ delocate_wheel(
146
+ str(wheel),
147
+ str(output / wheel.name),
148
+ lib_filt_func=lambda path: not path.endswith(".class"),
149
+ require_archs=[platform.machine()],
150
+ require_target_macos_version=Version(os.environ["MACOSX_DEPLOYMENT_TARGET"]),
151
+ )
152
+ PY
153
+ - name: Stage Windows wheel
154
+ if: runner.os == 'Windows'
155
+ run: mkdir -p wheelhouse && cp dist/*.whl wheelhouse/
156
+ - name: Test installed wheel
157
+ run: python tests/smoke_wheel.py wheelhouse/*.whl
158
+ - uses: actions/upload-artifact@v4
159
+ with:
160
+ name: wheels-${{ matrix.runner }}
161
+ path: wheelhouse/*.whl
162
+
163
+ publish:
164
+ if: github.event_name == 'workflow_dispatch' && inputs.publish && startsWith(github.ref, 'refs/tags/v')
165
+ needs: [source, linux, native]
166
+ runs-on: ubuntu-latest
167
+ environment: pypi
168
+ permissions:
169
+ id-token: write
170
+ steps:
171
+ - uses: actions/download-artifact@v4
172
+ with:
173
+ name: source
174
+ path: dist
175
+ - uses: actions/download-artifact@v4
176
+ with:
177
+ pattern: wheels-*
178
+ merge-multiple: true
179
+ path: dist
180
+ - uses: pypa/gh-action-pypi-publish@release/v1
181
+
@@ -0,0 +1,14 @@
1
+ .venv/
2
+ .build/
3
+ dist/
4
+ wheelhouse/
5
+ src/r4py/r-runtime/
6
+ __pycache__/
7
+ *.py[cod]
8
+ *.egg-info/
9
+ .pytest_cache/
10
+ .ruff_cache/
11
+ .Rhistory
12
+ .RData
13
+ Rplots.pdf
14
+
r4py-4.6.2.1/LICENSE ADDED
@@ -0,0 +1,26 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 r4py contributors
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
22
+
23
+ This license covers r4py's Python code and build tooling, not bundled R or its
24
+ dependencies. R is licensed under GPL-2.0-or-later; its distribution includes
25
+ COPYING and individual package licenses.
26
+
r4py-4.6.2.1/PKG-INFO ADDED
@@ -0,0 +1,175 @@
1
+ Metadata-Version: 2.5
2
+ Name: r4py
3
+ Version: 4.6.2.1
4
+ Summary: R, ready to roll. A complete R runtime in a Python wheel.
5
+ License-Expression: MIT AND GPL-2.0-or-later
6
+ License-File: LICENSE
7
+ Keywords: R,bundled,cross-platform,r-runtime,runtime,statistics
8
+ Classifier: Operating System :: MacOS
9
+ Classifier: Operating System :: Microsoft :: Windows
10
+ Classifier: Operating System :: POSIX :: Linux
11
+ Classifier: Programming Language :: Python :: 3
12
+ Classifier: Typing :: Typed
13
+ Requires-Python: >=3.10
14
+ Description-Content-Type: text/markdown
15
+
16
+ <div align="center">
17
+
18
+ <h1><img src="logo.svg" alt="Python snakes combined with the R logo" width="200" /></h1>
19
+
20
+ **R, ready to roll.**
21
+
22
+ A complete R runtime in a Python wheel.
23
+
24
+ [![PyPI](https://img.shields.io/pypi/v/r4py?style=flat-square&logo=pypi&logoColor=white)](https://pypi.org/project/r4py/)
25
+ [![Python 3.10+](https://img.shields.io/badge/Python-3.10%2B-3776AB?style=flat-square&logo=python&logoColor=white)](https://www.python.org/)
26
+ [![R 4.6.2](https://img.shields.io/badge/R-4.6.2-276DC3?style=flat-square&logo=r&logoColor=white)](https://www.r-project.org/)
27
+ [![Wheels](https://github.com/JGalego/r4py/actions/workflows/wheels.yml/badge.svg)](https://github.com/JGalego/r4py/actions/workflows/wheels.yml)
28
+ [![Platforms](https://img.shields.io/badge/platforms-Linux%20%7C%20macOS%20%7C%20Windows-475569?style=flat-square)](#install)
29
+ [![Licenses: MIT and GPL-2.0-or-later](https://img.shields.io/badge/license-MIT%20%26%20GPL--2.0%2B-475569?style=flat-square)](#licensing)
30
+
31
+ </div>
32
+
33
+ No system R installation. No runtime dependencies on Python packages. No downloads on import. No changes to your process environment.
34
+
35
+ ## Install
36
+
37
+ ```sh
38
+ pip install r4py
39
+ ```
40
+
41
+ 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.1` means R `4.6.2`, packaging revision `1`.
42
+
43
+ The release workflow targets:
44
+
45
+ | Platform | Architectures |
46
+ | --- | --- |
47
+ | Linux, glibc 2.28+ | x86-64, ARM64 |
48
+ | macOS 15+ | Intel, Apple Silicon |
49
+ | Windows 10+ | x86-64 |
50
+
51
+ Linux wheels are repaired with auditwheel; macOS wheels with delocate. Alpine/musl and Windows ARM64 are not supported. Python 3.10+ is required.
52
+
53
+ ## Python
54
+
55
+ ```python
56
+ from subprocess import run
57
+ from r4py import R, R_HOME, R_VERSION, RSCRIPT
58
+
59
+ print(R_HOME) # pathlib.Path to the bundled R installation
60
+ print(R_VERSION) # (4, 6, 2)
61
+
62
+ run([RSCRIPT, "--vanilla", "-e", "cat(mean(1:10))"], check=True)
63
+ run([RSCRIPT, "analysis.R", "input.csv"], check=True)
64
+ run([R, "CMD", "config", "CC"], check=True)
65
+ ```
66
+
67
+ The executables locate their own runtime, even if the environment is moved. To override a system R environment or configure a child process:
68
+
69
+ ```python
70
+ from r4py import get_env
71
+
72
+ run(
73
+ [RSCRIPT, "--vanilla", "-e", "cat(R.home())"],
74
+ env=get_env({"R_LIBS_USER": "/path/to/my/R/library"}),
75
+ check=True,
76
+ capture_output=True,
77
+ text=True,
78
+ )
79
+ ```
80
+
81
+ `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`.
82
+
83
+ This is a runtime distribution, not a Python-to-R object bridge. Use subprocesses, files, or an independently installed bridge such as rpy2.
84
+
85
+ ## Command line
86
+
87
+ ```sh
88
+ r4py --vanilla -e 'cat(mean(1:10))'
89
+ r4py analysis.R input.csv
90
+ python -m r4py --vanilla -e 'cat(R.version.string)'
91
+ r4py-r # interactive R
92
+ r4py-r CMD config CC
93
+ ```
94
+
95
+ `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.
96
+
97
+ ## R packages
98
+
99
+ Recommended packages, including Matrix, MASS, survival, and lattice, are already included. Install additional packages into a **writable library outside the wheel**:
100
+
101
+ ```sh
102
+ 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")'
103
+ ```
104
+
105
+ 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.
106
+
107
+ ## Build and test
108
+
109
+ ```sh
110
+ uv sync --no-install-project
111
+ uv run --no-sync ruff check .
112
+ uv run --no-sync pyright
113
+ uv run --no-sync pytest -m 'not runtime'
114
+ uv run --no-sync python build_r_runtime.py
115
+ uv build --wheel
116
+ ```
117
+
118
+ 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](.github/workflows/wheels.yml). `--jobs N` controls compilation parallelism. `--source-archive PATH` uses a local tarball with the same pinned SHA-256 verification.
119
+
120
+ On Windows, or to reuse a native R installation:
121
+
122
+ ```sh
123
+ uv run --no-sync python build_r_runtime.py --runtime /path/to/R/home
124
+ ```
125
+
126
+ 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.
127
+
128
+ 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:
129
+
130
+ ```sh
131
+ AUDITWHEEL_LD_LIBRARY_PATH="$PWD/src/r4py/r-runtime/lib" \
132
+ uvx --from auditwheel --with patchelf auditwheel repair --strip \
133
+ -w wheelhouse dist/r4py-*.whl
134
+ ```
135
+
136
+ ```sh
137
+ uv run --no-sync pytest
138
+ R4PY_REQUIRE_RUNTIME=1 uv run --no-sync pytest -m runtime
139
+ uv run --no-sync python tests/smoke_wheel.py wheelhouse/r4py-*.whl
140
+ ```
141
+
142
+ 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.
143
+
144
+ ## Licensing
145
+
146
+ 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.
147
+
148
+ R source: [R-4.6.2.tar.gz](https://cran.r-project.org/src/base/R-4/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.
149
+
150
+ The [logo](logo.svg) combines the [Python two-snakes device](https://www.python.org/community/logos/), a trademark of the Python Software Foundation, with the [R logo](https://www.r-project.org/logo/), copyright 2016 The R Foundation. The R artwork and composite arrangement are [CC BY-SA 4.0](https://creativecommons.org/licenses/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](https://www.python.org/psf/trademarks/). Neither foundation's endorsement is implied.
151
+
152
+ ## Releases and PyPI
153
+
154
+ Release each supported stable R version separately: r4py `4.6.2.1` and tag `v4.6.2.1` bundle R `4.6.2`, with packaging revision `1`. Packaging-only fixes increment the fourth component. Keep previous releases available so users can pin their R runtime.
155
+
156
+ For the first PyPI upload, add a pending publisher at [PyPI account publishing](https://pypi.org/manage/account/publishing/):
157
+
158
+ | Field | Value |
159
+ | --- | --- |
160
+ | PyPI project name | `r4py` |
161
+ | Repository owner | `JGalego` |
162
+ | Repository name | `r4py` |
163
+ | Workflow filename | `wheels.yml` |
164
+ | Environment name | `pypi` |
165
+
166
+ 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.
167
+
168
+ 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:
169
+
170
+ ```sh
171
+ gh workflow run wheels.yml --ref v4.6.2.1 -f publish=true
172
+ ```
173
+
174
+ 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.
175
+
r4py-4.6.2.1/README.md ADDED
@@ -0,0 +1,160 @@
1
+ <div align="center">
2
+
3
+ <h1><img src="logo.svg" alt="Python snakes combined with the R logo" width="200" /></h1>
4
+
5
+ **R, ready to roll.**
6
+
7
+ A complete R runtime in a Python wheel.
8
+
9
+ [![PyPI](https://img.shields.io/pypi/v/r4py?style=flat-square&logo=pypi&logoColor=white)](https://pypi.org/project/r4py/)
10
+ [![Python 3.10+](https://img.shields.io/badge/Python-3.10%2B-3776AB?style=flat-square&logo=python&logoColor=white)](https://www.python.org/)
11
+ [![R 4.6.2](https://img.shields.io/badge/R-4.6.2-276DC3?style=flat-square&logo=r&logoColor=white)](https://www.r-project.org/)
12
+ [![Wheels](https://github.com/JGalego/r4py/actions/workflows/wheels.yml/badge.svg)](https://github.com/JGalego/r4py/actions/workflows/wheels.yml)
13
+ [![Platforms](https://img.shields.io/badge/platforms-Linux%20%7C%20macOS%20%7C%20Windows-475569?style=flat-square)](#install)
14
+ [![Licenses: MIT and GPL-2.0-or-later](https://img.shields.io/badge/license-MIT%20%26%20GPL--2.0%2B-475569?style=flat-square)](#licensing)
15
+
16
+ </div>
17
+
18
+ No system R installation. No runtime dependencies on Python packages. No downloads on import. No changes to your process environment.
19
+
20
+ ## Install
21
+
22
+ ```sh
23
+ pip install r4py
24
+ ```
25
+
26
+ 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.1` means R `4.6.2`, packaging revision `1`.
27
+
28
+ The release workflow targets:
29
+
30
+ | Platform | Architectures |
31
+ | --- | --- |
32
+ | Linux, glibc 2.28+ | x86-64, ARM64 |
33
+ | macOS 15+ | Intel, Apple Silicon |
34
+ | Windows 10+ | x86-64 |
35
+
36
+ Linux wheels are repaired with auditwheel; macOS wheels with delocate. Alpine/musl and Windows ARM64 are not supported. Python 3.10+ is required.
37
+
38
+ ## Python
39
+
40
+ ```python
41
+ from subprocess import run
42
+ from r4py import R, R_HOME, R_VERSION, RSCRIPT
43
+
44
+ print(R_HOME) # pathlib.Path to the bundled R installation
45
+ print(R_VERSION) # (4, 6, 2)
46
+
47
+ run([RSCRIPT, "--vanilla", "-e", "cat(mean(1:10))"], check=True)
48
+ run([RSCRIPT, "analysis.R", "input.csv"], check=True)
49
+ run([R, "CMD", "config", "CC"], check=True)
50
+ ```
51
+
52
+ The executables locate their own runtime, even if the environment is moved. To override a system R environment or configure a child process:
53
+
54
+ ```python
55
+ from r4py import get_env
56
+
57
+ run(
58
+ [RSCRIPT, "--vanilla", "-e", "cat(R.home())"],
59
+ env=get_env({"R_LIBS_USER": "/path/to/my/R/library"}),
60
+ check=True,
61
+ capture_output=True,
62
+ text=True,
63
+ )
64
+ ```
65
+
66
+ `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`.
67
+
68
+ This is a runtime distribution, not a Python-to-R object bridge. Use subprocesses, files, or an independently installed bridge such as rpy2.
69
+
70
+ ## Command line
71
+
72
+ ```sh
73
+ r4py --vanilla -e 'cat(mean(1:10))'
74
+ r4py analysis.R input.csv
75
+ python -m r4py --vanilla -e 'cat(R.version.string)'
76
+ r4py-r # interactive R
77
+ r4py-r CMD config CC
78
+ ```
79
+
80
+ `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.
81
+
82
+ ## R packages
83
+
84
+ Recommended packages, including Matrix, MASS, survival, and lattice, are already included. Install additional packages into a **writable library outside the wheel**:
85
+
86
+ ```sh
87
+ 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")'
88
+ ```
89
+
90
+ 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.
91
+
92
+ ## Build and test
93
+
94
+ ```sh
95
+ uv sync --no-install-project
96
+ uv run --no-sync ruff check .
97
+ uv run --no-sync pyright
98
+ uv run --no-sync pytest -m 'not runtime'
99
+ uv run --no-sync python build_r_runtime.py
100
+ uv build --wheel
101
+ ```
102
+
103
+ 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](.github/workflows/wheels.yml). `--jobs N` controls compilation parallelism. `--source-archive PATH` uses a local tarball with the same pinned SHA-256 verification.
104
+
105
+ On Windows, or to reuse a native R installation:
106
+
107
+ ```sh
108
+ uv run --no-sync python build_r_runtime.py --runtime /path/to/R/home
109
+ ```
110
+
111
+ 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.
112
+
113
+ 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:
114
+
115
+ ```sh
116
+ AUDITWHEEL_LD_LIBRARY_PATH="$PWD/src/r4py/r-runtime/lib" \
117
+ uvx --from auditwheel --with patchelf auditwheel repair --strip \
118
+ -w wheelhouse dist/r4py-*.whl
119
+ ```
120
+
121
+ ```sh
122
+ uv run --no-sync pytest
123
+ R4PY_REQUIRE_RUNTIME=1 uv run --no-sync pytest -m runtime
124
+ uv run --no-sync python tests/smoke_wheel.py wheelhouse/r4py-*.whl
125
+ ```
126
+
127
+ 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.
128
+
129
+ ## Licensing
130
+
131
+ 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.
132
+
133
+ R source: [R-4.6.2.tar.gz](https://cran.r-project.org/src/base/R-4/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.
134
+
135
+ The [logo](logo.svg) combines the [Python two-snakes device](https://www.python.org/community/logos/), a trademark of the Python Software Foundation, with the [R logo](https://www.r-project.org/logo/), copyright 2016 The R Foundation. The R artwork and composite arrangement are [CC BY-SA 4.0](https://creativecommons.org/licenses/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](https://www.python.org/psf/trademarks/). Neither foundation's endorsement is implied.
136
+
137
+ ## Releases and PyPI
138
+
139
+ Release each supported stable R version separately: r4py `4.6.2.1` and tag `v4.6.2.1` bundle R `4.6.2`, with packaging revision `1`. Packaging-only fixes increment the fourth component. Keep previous releases available so users can pin their R runtime.
140
+
141
+ For the first PyPI upload, add a pending publisher at [PyPI account publishing](https://pypi.org/manage/account/publishing/):
142
+
143
+ | Field | Value |
144
+ | --- | --- |
145
+ | PyPI project name | `r4py` |
146
+ | Repository owner | `JGalego` |
147
+ | Repository name | `r4py` |
148
+ | Workflow filename | `wheels.yml` |
149
+ | Environment name | `pypi` |
150
+
151
+ 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.
152
+
153
+ 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:
154
+
155
+ ```sh
156
+ gh workflow run wheels.yml --ref v4.6.2.1 -f publish=true
157
+ ```
158
+
159
+ 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.
160
+