Skip to content

Commit e810088

Browse files
committed
Add Pipenv support and updates to READMEs
1 parent a13aee6 commit e810088

File tree

4 files changed

+50
-7
lines changed

4 files changed

+50
-7
lines changed

.gitignore

+4
Original file line numberDiff line numberDiff line change
@@ -93,3 +93,7 @@ ENV/
9393

9494
# IntelliJ IDEs such as PyCharm
9595
.idea
96+
97+
# Pipenv
98+
Pipfile.lock
99+
.venv

Pipfile

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
[[source]]
2+
name = "pypi"
3+
url = "https://pypi.org/simple"
4+
verify_ssl = true
5+
6+
[dev-packages]
7+
ipython = "*"
8+
9+
[packages]
10+
cffi = "*"
11+
cython = "*"
12+
pybind11 = "*"

Prerequisites.md

+23-5
Original file line numberDiff line numberDiff line change
@@ -47,29 +47,47 @@ We recommend using
4747

4848

4949
## Python and Other Tools
50-
By far the easiest way to get all of the tools installed and setup is by using the Anaconda Python
50+
51+
### Pipenv
52+
[Pipenv](https://github.com/pypa/pipenv) is an easy way to install compatible versions of `cffi`, `cython`, and
53+
`pybind11`. Once `pipenv` in installed, these other packages can be installed in a virtual environment using:
54+
```shell script
55+
pipenv install
56+
```
57+
58+
Then this Python virtual environment can be entered using:
59+
```shell script
60+
pipenv shell
61+
```
62+
63+
### Anaconda Python
64+
Another easy way to get all of the tools installed and setup is by using the Anaconda Python
5165
distribution. This is a free distribution of Python available for Windows, Mac OS X, and Linux which
5266
comes with a couple hundred of the most common and useful Python modules pre-installed including Cython
5367
and CFFI. It also comes with the ``conda`` package manager which can be used to install additional
5468
tools such as SWIG.
5569

56-
## Anaconda Python
57-
Download the latest version of [Anaconda](https://www.continuum.io/downloads). Either the Python 3.6 or
58-
Python 2.7 version should be fine, but we recommend the Python 3.6 version.
70+
Download the latest version of [Anaconda](https://www.continuum.io/downloads). We recommend Python 3.6 or newer.
5971

6072
Install Anaconda per the instructions and let it modify your .bashrc, .bash_profile, or path accordingly.
6173
NOTE: Do not use ``sudo`` to install Anaconda, just install it as a normal user.
6274

6375
This also installs Cython and CFFI.
6476

6577
## SWIG
66-
Now that Anaconda is installed, you can use the included **conda** package manager to install SWIG. Do
78+
If Anaconda is installed, you can use the included **conda** package manager to install SWIG. Do
6779
the following in a command-line terminal:
6880

6981
```bash
7082
conda install swig
7183
```
7284

85+
Alternatively, on macOS you can use the Homebrew package manager to install SWIG:
86+
87+
```shell script
88+
brew install swig
89+
```
90+
7391
## PyPy
7492
PyPy is best installed with a package manager such as *brew* on Mac OS X or *apt-get** on many Linux distros.
7593

README.md

+11-2
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,10 @@ means that code ran twice as fast as the pure Python version.
3030
| CFFI | 6 |
3131
| Python | 1 |
3232

33-
NOTE: These numbers were measured on a 2013 15" Mac Book Pro using Python 3.6 via Anaconda distro
34-
with the latest versions of all tools installed using the conda package manager.
33+
NOTE: These numbers were originally measured on a 2013 15" Mac Book Pro using Python 3.6 via Anaconda distro
34+
with the latest versions of all tools installed using the conda package manager. I have more recently measured
35+
using a Python 3.7 virtual environment via [Pipenv](https://github.com/pypa/pipenv) and confirmed that they
36+
stayed approximately the same and relative rankings in terms of performance are identical.
3537

3638
The Fibonacci example presented here is pretty trivial. Your mileage may vary depending on your
3739
application. But overall these performance measurements are fairly representative of what you
@@ -155,6 +157,13 @@ pybind11 struggles with easy cross-platform compatibility and its performance is
155157
pain to use than SWIG. So I'd recommend staying away from it for now unless you are looking to embed Python code within
156158
a C++ project on Windows.
157159

160+
## Updates for 2019
161+
Recent re-evaluation of all these options firmly confirms my original conclusions. `Cython` and `SWIG` are both awesome
162+
with distinct tradeoffs. The combination of `PyPy` + `CFFI` is attractive and shows a lot of potential. While the
163+
cross-platform compatibility issues previously seen with `pybind11` appear to have been resolved, I still can't see a
164+
use case for which it would be superior to one of the other options; but it has a ton of stars on GitHub so perhaps I
165+
am missing something?
166+
158167
# Running Example Code Yourself
159168
For information on getting all of the necessary prerequisites installed, see
160169
[Prerequisites for Running Example Code](https://github.com/tleonhardt/Python_Interface_Cpp/blob/master/Prerequisites.md).

0 commit comments

Comments
 (0)