Skip to content

Commit c49e927

Browse files
jaimergpisuruf
andcommitted
add blog/2020-03-10-pypy.md
Co-authored-by: isuruf <[email protected]>
1 parent ec98499 commit c49e927

File tree

1 file changed

+121
-0
lines changed

1 file changed

+121
-0
lines changed

blog/2020-03-10-pypy.md

Lines changed: 121 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,121 @@
1+
---
2+
authors:
3+
- isuruf
4+
tags: [infrastructure]
5+
---
6+
7+
# PyPy builds on conda-forge
8+
9+
conda-forge now supports PyPy3.6 as the python interpreter in a conda
10+
environment
11+
12+
Supported platforms are,
13+
14+
> - Linux-x86_64 (glibc 2.12 or newer)
15+
> - OSX-x86_64 (OSX 10.9 or newer)
16+
> - Linux-aarch64 (glibc 2.17 or newer)
17+
> - Linux-ppc64le (glibc 2.17 or newer)
18+
19+
<!--truncate-->
20+
21+
## How to use PyPy
22+
23+
To use the PyPy builds you can do the following,
24+
25+
```bash
26+
conda config --set channel_priority strict
27+
conda create -n pypy pypy
28+
conda activate pypy
29+
```
30+
31+
If you don't have a conda installation already, you can use
32+
[miniforge-pypy3](https://github.com/conda-forge/miniforge#miniforge-pypy3)
33+
which gives you a conda installation powered by pypy itself.
34+
35+
However as of the writing of this post, not many conda packages can be
36+
installed into this environment, but noarch packages which do not depend
37+
on the python version nor the interpreter can be installed. For eg,
38+
mpmath is a noarch package without any dependencies.
39+
40+
```bash
41+
conda install mpmath # succeeds
42+
conda install numpy # fails as of March 10, 2020
43+
```
44+
45+
**UPDATE**: numpy and scipy builds are working as of April 10, 2020.
46+
47+
All python C extensions needs to be rebuilt for the PyPy ABI. This is
48+
currently on the way and can be tracked at the [status
49+
page](https://conda-forge.org/status).
50+
51+
## python_abi Package
52+
53+
As part of adding support for PyPy and to keep the older python builds
54+
working, a python_abi package was added. This defines the abi for the
55+
python package and any non-noarch python packages will have a dependency
56+
on this package. Older python downstream packages like numpy had their
57+
metadata patched to add a CPython ABI. You can ask for a specific python
58+
ABI.
59+
60+
```bash
61+
conda install "python_abi=*=*_cp27mu"
62+
```
63+
64+
If you are using python packages from packages other than defaults, you
65+
will be able to install python extensions built with CPython ABI into
66+
PyPy builds as their metadata have not been patched. Solution in this
67+
case is to hotfix the metadata which is available to only high volume
68+
conda channel or to rebuild those packages with the new python packages
69+
and mark the older ones as broken.
70+
71+
Using the newer packages will rerender the following requirement to add
72+
a dependency on python_abi. For eg,
73+
74+
```yaml
75+
requirements:
76+
host:
77+
- python 3.6
78+
run:
79+
- python
80+
```
81+
82+
is rendered as,
83+
84+
```yaml
85+
requirements:
86+
host:
87+
- python 3.6.10 h9d8adfe_1009_cpython
88+
run:
89+
- python >=3.6,<3.7.0a0
90+
- python_abi 3.6 *_cp36m
91+
```
92+
93+
whereas,
94+
95+
```yaml
96+
requirements:
97+
host:
98+
- python 3.6 *_73_pypy
99+
run:
100+
- python
101+
```
102+
103+
is rendered as,
104+
105+
```yaml
106+
requirements:
107+
host:
108+
- python 3.6.9 0_73_pypy
109+
run:
110+
- python >=3.6,<3.7.0a0
111+
- python_abi 3.6 *_pypy36_pp73
112+
```
113+
114+
Note that the PyPy ABI tag has `pp73` at the end which
115+
indicates that the ABI is stable only for PyPy3.6 7.3.x series.
116+
117+
This opens up the possibility of adding debug builds of python and
118+
building extension packages using the Python Debug ABI.
119+
120+
Discussion on the PyPy builds can be found in the issue
121+
[conda-forge/conda-forge.github.io#867](https://github.com/conda-forge/conda-forge.github.io/issues/867).

0 commit comments

Comments
 (0)