Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a note about pyenv in README and the guide #763

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 20 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@

[Rust](http://www.rust-lang.org/) bindings for [Python](https://www.python.org/). This includes running and interacting with Python code from a Rust binary, as well as writing native Python modules.

You can either write a native Python module in Rust, or use Python from a Rust binary.

* User Guide: [stable](https://pyo3.rs) | [master](https://pyo3.rs/master)

* API Documentation: [stable](https://docs.rs/pyo3/) | [master](https://pyo3.rs/master/doc)
Expand All @@ -22,16 +24,29 @@ If you have never used nightly Rust, the official guide has
[a great section](https://doc.rust-lang.org/book/appendix-07-nightly-rust.html#rustup-and-the-role-of-rust-nightly)
about installing it.

PyPy is also supported (via cpyext) for Python 3.5 only, targeted PyPy version is 7.0.0.
Please refer to the guide for installation instruction against PyPy.
### OS dependent packages
Basically, `Python` is only what you need.
kngwyu marked this conversation as resolved.
Show resolved Hide resolved
However, on some OSs, you need to install some additional packages including Python header files.

You can either write a native Python module in Rust, or use Python from a Rust binary.
E.g. if you are on *Ubuntu 18.04*, please run

```bash
sudo apt install python3-dev
```

However, on some OSs, you need some additional packages. E.g. if you are on *Ubuntu 18.04*, please run
### pyenv
[pyenv](https://github.com/pyenv/pyenv) is a major Python version manager.

To use PyO3 with pyenv, please set `--enable--shared` when builiding CPython.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this necessary on all platforms or only on mac? I'm using pyenv on ubuntu and I do not remember setting that option.

Copy link
Member Author

@kngwyu kngwyu Feb 13, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't have a macOS machine, but weirdly, Ubuntu 18.04 + Python 3.7.6(from pyenv) works but Arch Linux + Python 3.7.6 doesn't work.
There's certainly some OS-specific issue, but I still haven't detect it 😰

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess in this it's best to just document this as "you might --enable--shared on some linux distributions"

```bash
sudo apt install python3-dev python-dev
$ env PYTHON_CONFIGURE_OPTS="--enable-shared" pyenv install 3.7.5
```
You can also refer to [pyenv wiki](https://github.com/pyenv/pyenv/wiki#how-to-build-cpython-with---enable-shared).

### PyPy

PyPy is also supported (via cpyext) for Python 3.5 only, targeted PyPy version is 7.0.0.
Please refer to the guide for installation instruction against PyPy.

## Using Rust from Python

Expand Down
25 changes: 20 additions & 5 deletions guide/src/get_started.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

[Rust](http://www.rust-lang.org/) bindings for [Python](https://www.python.org/). This includes running and interacting with Python code from a Rust binary, as well as writing native Python modules.

You can either write a native Python module in Rust, or use Python from a Rust binary.

* User Guide: [stable](https://pyo3.rs) | [master](https://pyo3.rs/master)

* API Documentation: [master](https://pyo3.rs/master/doc)
Expand All @@ -16,16 +18,29 @@ If you have never used nightly Rust, the official guide has
[a great section](https://doc.rust-lang.org/book/appendix-07-nightly-rust.html#rustup-and-the-role-of-rust-nightly)
about installing it.

PyPy is also supported (via cpyext) for Python 3.5 only, targeted PyPy version is 7.0.0.
Please refer to the [pypy section](https://pyo3.rs/master/pypy.html).
### OS dependent packages
Basically, `Python` is only what you need.
kngwyu marked this conversation as resolved.
Show resolved Hide resolved
However, on some OSs, you need to install some additional packages including Python header files.

You can either write a native Python module in Rust, or use Python from a Rust binary.
E.g. if you are on *Ubuntu 18.04*, please run

```bash
sudo apt install python3-dev
```

However, on some OSs, you need some additional packages. E.g. if you are on *Ubuntu 18.04*, please run
### pyenv
[pyenv](https://github.com/pyenv/pyenv) is a major Python version manager.

To use PyO3 with pyenv, please set `--enable--shared` when builiding CPython.
```bash
sudo apt install python3-dev python-dev
$ env PYTHON_CONFIGURE_OPTS="--enable-shared" pyenv install 3.7.5
```
You can also refer to [pyenv wiki](https://github.com/pyenv/pyenv/wiki#how-to-build-cpython-with---enable-shared).

### PyPy

PyPy is also supported (via cpyext) for Python 3.5 only, targeted PyPy version is 7.0.0.
Please refer to the guide for installation instruction against PyPy.

## Using Rust from Python

Expand Down