8000 Merge remote-tracking branch 'origin/master' · mindsocket/python-guide@bc110a2 · GitHub
[go: up one dir, main page]

Skip to content
8000

Commit bc110a2

Browse files
author
Kenneth Reitz
committed
Merge remote-tracking branch 'origin/master'
2 parents ccea69f + dc3af98 commit bc110a2

File tree

4 files changed

+98
-21
lines changed

4 files changed

+98
-21
lines changed

Makefile

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,7 @@
1-
build:
2-
cd docs && make html
1+
.PHONY: build
2+
build: html
3+
4+
# this pattern rule lets you run "make build" (or any other target
5+
# in docs/Makefile) in this directory as though you were in docs/
6+
%:
7+
cd docs && make $@

docs/scenarios/imaging.rst

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,22 @@ Ubuntu 11.04
3535
Installing on Mac OS X
3636
~~~~~~~~~~~~~~~~~~~~~~
3737

38-
.. todo::
39-
Notes on installing on Mac OS X
38+
PIP doesn't know about the Mac OS X Freetype paths. To rectify that:
39+
40+
.. code-block:: bash
41+
42+
$ ln -s /usr/X11/include/freetype2 /usr/local/include/
43+
$ ln -s /usr/X11/include/ft2build.h /usr/local/include/
44+
$ ln -s /usr/X11/lib/libfreetype.6.dylib /usr/local/lib/
45+
$ ln -s /usr/X11/lib/libfreetype.6.dylib /usr/local/lib/libfreetype.dylib
46+
47+
then:
48+
49+
.. code-block:: bash
50+
51+
$ brew install libjpeg
52+
$ pip install PIL
53+
4054
4155
Installing on Windows
4256
~~~~~~~~~~~~~~~~~~~~~

docs/shipping/freezing.rst

Lines changed: 70 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -8,42 +8,100 @@ Many applications you use every day do this:
88

99
- Dropbox
1010
- BitTorrent
11-
-
12-
11+
- ...
1312

1413
.. todo:: Fill in "Freezing Your Code" stub
1514

15+
16+
17+
Comparison
18+
----------
19+
20+
Solutions and platforms/features supported:
21+
22+
=========== ======= ===== ==== ======== ======= ============= ============== ==== =====================
23+
Solution Windows Linux OS X Python 3 Licence One-file mode Zipfile import Eggs pkg_resources support
24+
=========== ======= ===== ==== ======== ======= ============= ============== ==== =====================
25+
bbFreeze yes yes yes no MIT no yes yes yes
26+
py2exe yes no no no MIT yes yes no no
27+
pyInstaller yes yes yes no GPL yes no yes no
28+
cx_Freeze yes yes yes yes PSF no yes yes no
29+
=========== ======= ===== ==== ======== ======= ============= ============== ==== =====================
30+
31+
.. todo:: Add other solutions: py2app
32+
33+
.. note::
34+
Freezing Python code on Linux into a Windows executable was only once
35+
supported in PyInstaller, `but later dropped
36+
<http://stackoverflow.com/questions/2950971/cross-compiling-a-python-script-on-linux-into-a-windows-executable#comment11890276_2951046>`_.
37+
38+
.. note::
39+
All solutions need MS Visual C++ dll to be installed on target machine.
40+
Only Pyinstaller makes self-executable exe that bundles the dll when
41+
passing ``--onefile`` to `Configure.py`.
42+
1643
Windows
17-
:::::::
44+
-------
45+
46+
bbFreeze
47+
~~~~~~~~
48+
49+
Prerequisite is to install :ref:`Python, Distribute and pywin32 dependency on Windows <install-windows>`.
1850

51+
.. todo:: Write steps for most basic .exe
1952

2053
py2exe
21-
------
54+
~~~~~~
2255

56+
Prerequisite is to install :ref:`Python on Windows <install-windows>`.
2357

58+
1. Download and install http://sourceforge.net/projects/py2exe/files/py2exe/
2459

25-
OSX
26-
:::
60+
2. Write setup.p 10000 y (`List of configuration options <http://www.py2exe.org/index.cgi/ListOfOptions>`_)::
2761

62+
from distutils.core import setup
63+
import py2exe
2864

29-
py2app
30-
------
65+
setup(
66+
windows=[{'script': 'foobar.py'}],
67+
)
68+
69+
3. (Optionally) `include icon <http://www.py2exe.org/index.cgi/CustomIcons>`_
3170

71+
4. (Optionally) `one-file mode <http://stackoverflow.com/questions/112698/py2exe-generate-single-executable-file#113014>`_
3272

73+
5. Generate `.exe` into `dist` directory::
3374

75+
$ python setup.py py2exe
76+
77+
6. Provide the Microsoft Visual C runtime DLL. Two options: `globally install dll on target machine <https://www.microsoft.com/en-us/download/details.aspx?id=29>`_ or `distribute dll aloneside with .exe <http://www.py2exe.org/index.cgi/Tutorial#Step52>`_.
3478

3579
PyInstaller
36-
-----------
80+
~~~~~~~~~~~
81+
82+
Prerequisite is to have installed :ref:`Python, Distribute and pywin32 dependency on Windows <install-windows>`.
83+
84+
- `Most basic tutorial <http://bojan-komazec.blogspot.com/2011/08/how-to-create-windows-executable-from.html>`_
85+
- `Manual <http://www.pyinstaller.org/export/d3398dd79b68901ae1edd761f3fe0f4ff19cfb1a/project/doc/Manual.html?format=raw>`_
3786

3887

88+
OSX
89+
---
90+
91+
92+
py2app
93+
~~~~~~
94+
95+
PyInstaller
96+
~~~~~~~~~~~
3997

4098

4199
Linux
42-
:::::
100+
-----
43101

44102

45103
bbFreeze
46-
--------
104+
~~~~~~~~
47105

48106
PyInstaller
49-
-----------
107+
~~~~~~~~~~~

docs/writing/style.rst

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ recognised fact that code is read much more often than it is written.
99
One reason for Python code to be easily read and understood is its relatively
1010
complete set of Code Style guidelines and "Pythonic" idioms.
1111

12-
Moreover, when a veteran Python developer (a Pythonistas) point to some
12+
Moreover, when a veteran Python developer (a Pythonista) point to some
1313
parts of a code and say it is not "Pythonic", it usually means that these lines
1414
of code do not follow the common guidelines and fail to express the intent in
1515
what is considered the best (hear: most readable) way.
@@ -128,7 +128,7 @@ called with each recipient as an argument: ``send('Hello', 'God', 'Mom',
128128
'Cthulhu')``, and in the function body ``args`` will be equal to ``('God',
129129
'Mom', 'Cthulhu')``.
130130

131-
However, this construct has some drawback and should be used with caution. If a
131+
However, this construct has some drawbacks and should be used with caution. If a
132132
function receives a list of arguments of the same nature, it is often more
133133
clear to define it as a function of one argument, that argument being a list or
134134
any sequence. Here, if ``send`` has multiple recipients, it is better to define
@@ -156,7 +156,7 @@ Python functions that are:
156156

157157
* easy to read (the name and arguments need no explanations)
158158

159-
* easy to change (adding a new keyword argument do not break other parts of the
159+
* easy to change (adding a new keyword argument does not break other parts of the
160160
code)
161161

162162
Avoid the magical wand
@@ -178,8 +178,8 @@ possibilities, because it grows the confidence that no hard-wall will be on the
178178
way. However, knowing how to use them and particularly when **not** to use
179179
them is the most important.
180180

181-
Like a Kungfu master, a pythonistas knows how to kill with a single finger, and
182-
never do it.
181+
Like a Kungfu master, a Pythonista knows how to kill with a single finger, and
182+
never to do it.
183183

184184
We are all consenting adults
185185
~~~~~~~~~~~~~~~~~~~~~~~~~~~~

0 commit comments

Comments
 (0)
0