Skip to content

Commit 210dac4

Browse files
committed
Updated mac doc: using virtualenv
1 parent 81d3cbe commit 210dac4

File tree

1 file changed

+30
-16
lines changed

1 file changed

+30
-16
lines changed

doc/development/darwin.md

Lines changed: 30 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -30,12 +30,26 @@ Install non-system, framework-based, universal [Python](http://www.python.org/ft
3030

3131
#### Python tools
3232
```bash
33-
pip install -U pip setuptools
33+
pip install -U pip setuptools virtualenv
3434
```
3535

3636
### Dependencies
3737

38-
Following dependencies are included in dmg package, but if you want to install it manually, they are:
38+
First you need to configure a virtualenv
39+
40+
```bash
41+
virtualenv $HOME/venv
42+
```
43+
44+
In order to use wxPython from the virtualenv this hack is needed
45+
46+
```bash
47+
cp `which python` $HOME/venv/bin/python;
48+
echo 'export PYTHONHOME=$HOME/venv' >> $HOME/venv/bin/activate;
49+
source $HOME/venv/bin/activate
50+
```
51+
52+
Then, you can install the python dependencies into the virtualenv
3953

4054
#### OpenCV
4155
```bash
@@ -45,8 +59,8 @@ brew install opencv
4559
```
4660

4761
```bash
48-
sudo ln -s /usr/local/Cellar/opencv/2.4.12_2/lib/python2.7/site-packages/cv.py /Library/Python/2.7/site-packages/cv.py
49-
sudo ln -s /usr/local/Cellar/opencv/2.4.12_2/lib/python2.7/site-packages/cv2.so /Library/Python/2.7/site-packages/cv2.so
62+
ln -s /usr/local/Cellar/opencv/2.4.12_2/lib/python2.7/site-packages/cv.py $HOME/venv/lib/python2.7/site-packages;
63+
ln -s /usr/local/Cellar/opencv/2.4.12_2/lib/python2.7/site-packages/cv2.so $HOME/venv/lib/python2.7/site-packages
5064
```
5165

5266
#### wxPython
@@ -55,7 +69,7 @@ brew install wxpython
5569
```
5670

5771
```bash
58-
sudo ln -s /usr/local/Cellar/wxpython/3.0.2.0/lib/python2.7/site-packages/wx-3.0-osx_cocoa/wx /Library/Python/2.7/site-packages/wx
72+
ln -s /usr/local/Cellar/wxpython/3.0.2.0/lib/python2.7/site-packages/wx* $HOME/venv/lib/python2.7/site-packages
5973
```
6074

6175
#### Python modules
@@ -76,24 +90,24 @@ In order to generate dmg package, some extra dependencies are needed
7690
pip install -U py2app==0.7.2
7791
```
7892

79-
To reduce the package size, "tests" directories must be removed
93+
Also some patches are needed to make py2app work
8094

8195
```bash
82-
cd /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages
83-
sudo find . -name tests -type d -exec rm -r {} +
84-
```
96+
cd $HOME/venv/lib/python2.7/site-packages/py2app/recipes;
8597

86-
Also some patches are needed to make py2app work
98+
sed -i '' 's/scan_code/_scan_code/g' virtualenv.py;
99+
sed -i '' 's/load_module/_load_module/g' virtualenv.py;
87100

88-
```bash
89-
cd /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/py2app/recipes
101+
cd $HOME/venv/lib/python2.7/site-packages/macholib;
90102

91-
sudo sed -i '' 's/scan_code/_scan_code/g' virtualenv.py
92-
sudo sed -i '' 's/load_module/_load_module/g' virtualenv.py
103+
sed -i '' 's/loader=loader.filename/loader_path=loader.filename/g' MachOGraph.py
104+
```
93105

94-
cd /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/macholib
106+
To reduce the package size, "tests" directories must be removed
95107

96-
sudo sed -i '' 's/loader=loader.filename/loader_path=loader.filename/g' MachOGraph.py
108+
```bash
109+
cd $HOME/venv/lib/python2.7/site-packages;
110+
find . -name tests -type d -exec rm -r {} +
97111
```
98112

99113
## 2. Download source code

0 commit comments

Comments
 (0)