Skip to content

Commit c48a069

Browse files
author
Lennart Regebro
committed
Supporting Python 3
0 parents  commit c48a069

File tree

266 files changed

+10767
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

266 files changed

+10767
-0
lines changed

CLA.txt

+82
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
Contributor License Agreement
2+
=============================
3+
4+
You accept and agree to the following terms and conditions for Your present
5+
and future Contributions to the Work. Except for the license granted herein
6+
to Lennart Regebro, You reserve all right, title, and interest in and to Your
7+
Contributions.
8+
9+
1. Definitions.
10+
11+
"You" (or "Your") shall mean the copyright owner or legal entity
12+
authorized by the copyright owner that is making this Agreement with
13+
Lennart Regebro. For legal entities, the entity making a Contribution and
14+
all other entities that control, are controlled by, or are under common
15+
control with that entity are considered to be a single Contributor. For
16+
the purposes of this definition, "control" means (i) the power, direct or
17+
indirect, to cause the direction or management of such entity, whether by
18+
contract or otherwise, or (ii) ownership of fifty percent (50%) or more of
19+
the outstanding shares, or (iii) beneficial ownership of such entity.
20+
21+
"Contribution" shall mean any original work of authorship, including any
22+
modifications or additions to an existing work, that is intentionally
23+
submitted by You to Lennart Regebro for inclusion in, or documentation of,
24+
the Work. For the purposes of this definition, "submitted" means any form
25+
of electronic, verbal, or written communication sent to Lennart Regebro,
26+
including but not limited to communication on electronic mailing lists,
27+
source code control systems, and issue tracking systems for the purpose of
28+
discussing and improving the Work, but excluding communication that is
29+
conspicuously marked or otherwise designated in writing by You as "Not a
30+
Contribution."
31+
32+
"The Work" shall mean the book "Supporting Python 3" and it's code and
33+
documentation.
34+
35+
2. Grant of Copyright License. Subject to the terms and conditions of this
36+
Agreement, You hereby grant to Lennart Regebro a perpetual, worldwide,
37+
non-exclusive, no-charge, royalty-free, irrevocable copyright license to
38+
reproduce, prepare derivative works of, publish, publicly display,
39+
sublicense, and distribute Your Contributions and such derivative works.
40+
41+
3. Grant of Patent License. Subject to the terms and conditions of this
42+
Agreement, You hereby grant to Lennart Regebro and to recipients of
43+
software distributed by Lennart Regebro a perpetual, worldwide,
44+
non-exclusive, no-charge, royalty-free, irrevocable (except as stated in
45+
this section) patent license to make, have made, use, offer to sell, sell,
46+
import, and otherwise transfer the Work, where such license applies only
47+
to those patent claims licensable by You that are necessarily infringed by
48+
Your Contribution(s) alone or by combination of Your Contribution(s) with
49+
the Work to which such Contribution(s) was submitted. If any entity
50+
institutes patent litigation against You or any other entity (including a
51+
cross-claim or counterclaim in a lawsuit) alleging that your Contribution,
52+
or the Work to which you have contributed, constitutes direct or
53+
contributory patent infringement, then any patent licenses granted to that
54+
entity under this Agreement for that Contribution or Work shall terminate
55+
as of the date such litigation is filed.
56+
57+
4. You represent that you are legally entitled to grant the above license. If
58+
your employer(s) has rights to intellectual property that you create that
59+
includes your Contributions, you represent that you have received
60+
permission to make Contributions on behalf of that employer, that your
61+
employer has waived such rights for your Contributions to Lennart Regebro,
62+
or that your employer has executed a separate Corporate CLA with Lennart
63+
Regebro.
64+
65+
5. You represent that each of Your Contributions is Your original creation
66+
(see section 7 for submissions on behalf of others). You represent that
67+
Your Contribution submissions include complete details of any third-party
68+
license or other restriction (including, but not limited to, related
69+
patents and trademarks) of which you are personally aware and which are
70+
associated with any part of Your Contributions.
71+
72+
6. You are not expected to provide support for Your Contributions, except to
73+
the extent You desire to provide support. You may provide support for
74+
free, for a fee, or not at all. Unless required by applicable law or
75+
agreed to in writing, You provide Your Contributions on an "AS IS" BASIS,
76+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied,
77+
including, without limitation, any warranties or conditions of TITLE, NON-
78+
INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE.
79+
80+
7. You agree to notify Lennart Regebro of any facts or circumstances of
81+
which you become aware that would make these representations
82+
inaccurate in any respect.

INSTALL.txt

+49
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
Installation
2+
============
3+
4+
You need a Python with Sphinx installed. It's tested with Python 3.4, but
5+
any Python with Sphinx is likely to work.
6+
7+
To run make spell you need aspell and american english dictionaries.
8+
9+
* Debian-based: ``apt-get install aspell-en``
10+
* Red Hats: ``yum install aspell-en``
11+
12+
To make pdf's you need Texlive 2013:
13+
14+
* Debian-based: ``apt-get install texlive-full``
15+
* Red Hats: ``yum install texlive*``
16+
* Other systems: http://www.tug.org/texlive/quickinstall.html
17+
18+
You also need the following fonts:
19+
20+
* Flux Bold (FLUXB___.ttf)
21+
This is a commercial font, so you need to buy it if you want to generate PDF's.
22+
* DejaVu Sans Mono
23+
It's included in many Linux distro's by default.
24+
* TeX Gyre Schola
25+
http://www.gust.org.pl/projects/e-foundry/tex-gyre/schola
26+
Installable as ``texlive-tex-gyre`` on RPM based linuces and
27+
``fonts-texgyre`` on DEB based linuces.
28+
29+
30+
Testing setup
31+
=============
32+
33+
(This is all stupid and needs to change. We should probably use Spiny.
34+
We can't use Tox, because it doesn't support old Python versions.)
35+
36+
Python 2.3, 2.4 and 2.5 must be installed in ``/opt/python23`` etc (or paths
37+
changed in runtest.sh)
38+
39+
Python 2.6, 2.7, 3.1, 3.1 and 3.3 must be installed in ``./python26``,
40+
``./python27``, etc (virtualenvs are fine).
41+
42+
In Python 2.6 and above also do this::
43+
44+
pip install zope.interface setuptools==11.2
45+
46+
Run the tests with ``make test``. Some tests may fail on the first time, with
47+
warnings like ``warning: no previously-included files matching '*.pyc' found
48+
anywhere in distribution``. Re-running them solves that.
49+

Makefile

+96
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
# Makefile for Sphinx documentation
2+
#
3+
4+
export PYTHONPATH = $(shell echo "$$PYTHONPATH"):.
5+
6+
# You can set these variables from the command line.
7+
SPHINXOPTS =
8+
SPHINXBUILD = ./bin/sphinx-build
9+
PAPER =
10+
BUILDDIR = build
11+
12+
# Internal variables.
13+
ALLSPHINXOPTS = -d $(BUILDDIR)/doctrees $(SPHINXOPTS) source
14+
15+
LATEXPATH = $${PATH}
16+
LATEXEXE = xelatex
17+
LATEXOPTS =
18+
19+
OUTPUTNAME=SupportingPython3
20+
21+
SPELL = aspell -l en_US
22+
23+
.PHONY: help clean html dirhtml pickle json htmlhelp qthelp latex changes linkcheck doctest
24+
25+
help:
26+
@echo "Please use \`make <target>' where <target> is one of"
27+
@echo " html to make standalone HTML files"
28+
@echo " dirhtml to make HTML files named index.html in directories"
29+
@echo " latex to make LaTeX files, you can set PAPER=a4 or PAPER=letter"
30+
@echo " pdf to make a PDF"
31+
@echo " epub to make an ePUB book"
32+
@echo " changes to make an overview of all changed/added/deprecated items"
33+
@echo " linkcheck to check all external links for integrity"
34+
35+
clean:
36+
-rm -rf $(BUILDDIR)/*
37+
38+
html:
39+
$(SPHINXBUILD) -b html $(ALLSPHINXOPTS) $(BUILDDIR)/html
40+
@echo
41+
@echo "Build finished. The HTML pages are in $(BUILDDIR)/html."
42+
43+
epub:
44+
$(SPHINXBUILD) -b epub $(ALLSPHINXOPTS) $(BUILDDIR)/epub
45+
@echo
46+
@echo "Build finished. The epub pages are in $(BUILDDIR)/epub."
47+
48+
dirhtml:
49+
$(SPHINXBUILD) -b dirhtml $(ALLSPHINXOPTS) $(BUILDDIR)/dirhtml
50+
@echo
51+
@echo "Build finished. The HTML pages are in $(BUILDDIR)/dirhtml."
52+
53+
latex:
54+
$(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex
55+
@echo
56+
@echo "Build finished; the LaTeX files are in $(BUILDDIR)/latex."
57+
@echo "Run \`make all-pdf' or \`make all-ps' in that directory to" \
58+
"run these through (pdf)latex."
59+
60+
changes:
61+
$(SPHINXBUILD) -b changes $(ALLSPHINXOPTS) $(BUILDDIR)/changes
62+
@echo
63+
@echo "The overview file is in $(BUILDDIR)/changes."
64+
65+
linkcheck:
66+
$(SPHINXBUILD) -b linkcheck $(ALLSPHINXOPTS) $(BUILDDIR)/linkcheck
67+
@echo
68+
@echo "Link check complete; look for any errors in the above output " \
69+
"or in $(BUILDDIR)/linkcheck/output.txt."
70+
71+
pdf: latex
72+
# Copy in some custom files
73+
cp source/_templates/sphinxcustom.cls $(BUILDDIR)/latex/sphinxcustom.cls
74+
cp source/_templates/sphinx.sty $(BUILDDIR)/latex/sphinx.sty
75+
cp source/_static/by-nc-sa.pdf $(BUILDDIR)/latex/by-nc-sa.pdf
76+
# Run LaTeX three times, the first time generates the text:
77+
cd $(BUILDDIR)/latex; PATH=$(LATEXPATH) $(LATEXEXE) $(LATEXOPTS) $(OUTPUTNAME).tex
78+
# Create the indexes
79+
-cd $(BUILDDIR)/latex; PATH=$(LATEXPATH) makeindex -s python.ist $(OUTPUTNAME).idx
80+
# Re run LaTex with indexes. Now we get a content listing and an index.
81+
cd $(BUILDDIR)/latex; PATH=$(LATEXPATH) $(LATEXEXE) $(LATEXOPTS) $(OUTPUTNAME).tex
82+
# Recreate the index since all the page numbers changed when the content listing appeared.
83+
-cd $(BUILDDIR)/latex; PATH=$(LATEXPATH) makeindex -s python.ist $(OUTPUTNAME).idx
84+
# And run LaTex again, this time with correct page numbers
85+
cd $(BUILDDIR)/latex; PATH=$(LATEXPATH) $(LATEXEXE) $(LATEXOPTS) $(OUTPUTNAME).tex
86+
87+
spell:
88+
for f in source/*.rst; do $(SPELL) -c $$f; done
89+
90+
stats:
91+
wc source/*.rst
92+
93+
test:
94+
./runtests.sh
95+
96+
check: spell test stats

README.txt

+77
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
Supporting Python 3
2+
===================
3+
4+
This is a free book about how to make your code support Python 3.
5+
6+
It costs nothing, and you can both publish it and contribute to it!
7+
8+
9+
Reading this book
10+
-----------------
11+
12+
Supporting Python 3 is available for free on http://python3porting.com/ . You
13+
can also download a PDF version from https://gumroad.com/l/python3 for any
14+
price you like, and you can buy a paper version from
15+
https://www.createspace.com/4312357 for $4.45, which is the printing cost of
16+
the book, and hence as close to free as you can possibly come.
17+
18+
As of today, the name of the book in all these places are "Porting to Python
19+
3", which is the old name of the book before I made it into a community
20+
effort. This will change sometime during 2015, and the above links will also
21+
change as a result.
22+
23+
24+
Contributing to this book
25+
-------------------------
26+
27+
To contribute to this book, fork it on
28+
`GitHub https://github.com/regebro/supporting-python-3`_.
29+
30+
Follow the instructions in INSTALL.txt on how to install it, and
31+
make the changes you like, and create a pull request.
32+
33+
It's probably a good idea to talk to Lennart Regebro before making major
34+
changes or additions.
35+
36+
37+
License
38+
-------
39+
40+
This book is (c) Lennart Regebro 2011-2015, and is licensed under a Creative
41+
Commons Attribution-NonCommercial-ShareAlike 3.0 Unported License.
42+
43+
See http://creativecommons.org/licenses/by-nc-sa/3.0/
44+
45+
This means you can publish this book or parts of it, but not in such a way
46+
that you make money from it. Should you want to use this book in a commercial
47+
setting, please contact Lennart Regebro, [email protected].
48+
49+
The book in it's current form uses Flux Bold, which is a commercial font.
50+
If you want to publish this book in any form, you need either to replace
51+
this font, or buy a license for the usage that you intend.
52+
53+
Generating the PDFs
54+
-------------------
55+
56+
Making a PDF is not just a matter of doing ``make pdf``. Doing so will indeed
57+
create a PDF, but you need to create four PDF's when releasing the book.
58+
59+
You need::
60+
61+
* A print PDF, 6" x 9", black only.
62+
* A screen PDF, 8.27" x 11", with syntax highlighting.
63+
* A tablet PDF, 7" x 9", with syntax highlighting.
64+
* A phone PDF, 4.8" x 7.2", with syntax highlighting.
65+
66+
You do this by changing the conf.py. For the print PDF, the ``pygments_style``
67+
should be ``"none"`` otherwise it should be ``"sphinx"``.
68+
69+
To select the paper size, change the used variable in ``print_latex_elements``
70+
between ``print_form``, ``screen_form``, ``tablets_form`` or ``phone_form``.
71+
72+
You don't need to do anything more for the Print PDF, it's done, but the
73+
other PDF's should have the front and back covers merged. This can be done
74+
with tools like pdfunite::
75+
76+
$ pdfunite covers/PhoneFront.pdf build/latex/SupportingPython3.pdf \
77+
covers/PhoneBack.pdf SupportingPython3-phone-1.0-dev.pdf

UTF-8.txt

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
It wörks

covers/802764156_859a8f6969_o.jpg

464 KB
Loading

covers/Cover.xcf

10.4 MB
Binary file not shown.

covers/PhoneBack.pdf

248 KB
Binary file not shown.

covers/PhoneFront.pdf

361 KB
Binary file not shown.

covers/Print Cover.pdf

7.67 MB
Binary file not shown.

covers/README.txt

+83
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
How to make covers
2+
==================
3+
4+
The cover is in the Covers.xcf file. That's a GIMP file, so you need to use
5+
GIMP to open it for editing and PDF generation. And you need to create a lot
6+
of PDF's. You will also need GhostScript installed.
7+
8+
The Covers.xcf is designed for use with Createspace self publishing.
9+
For more information on the PDF requirements, check with createspace.
10+
11+
The Spine of the book is the number of interior pages * 0.002252 inches.
12+
If a significant amount of pages is added to the book, you may need to
13+
adjust the design.
14+
15+
The two top layers are:
16+
17+
* BookCover6X9_BW_140. This is an import of the Createspace cover template.
18+
It's for 140 pages, and the book is currently 151, but that's not enough
19+
to create a problem.
20+
21+
* Preview Mask. This is a gray mask that will allow you to see approximately
22+
the area that the printed cover will be.
23+
24+
Both these layers must be invisible when printing the cover.
25+
26+
27+
Custom paper sizes
28+
------------------
29+
30+
The PDF's come in three formats: Print, Phone, Tablet and Screen. OK, fine,
31+
phones and tablets are also screens, but they are also computers, and "PC"
32+
kinda implies it's not a Mac, so I choose "screen" as a name.
33+
34+
To create the cover PDFs them you need to create several custom paper sizes.
35+
There should be creates with 0 page margins, and the following sizes
36+
(width x height):
37+
38+
* Print size: 17" x 11"
39+
* Phone size: 4.8" x 7.2"
40+
* Tablet size: 6" x 9"
41+
* Screen size: 7.32" x 11"
42+
(This fits both in A4 and Letter and hence you can also print it.)
43+
44+
45+
The print cover PDF
46+
-------------------
47+
48+
To create the cover for printing, select the custom paper size that is 17" wide
49+
by 11" high. Go to the Image Settings tab in the print dialog, select "Ignore
50+
page margins" and then scale the image to as big as possible.
51+
52+
Print to a file in portrait mode. Yes, that portrait mode will be wider than
53+
high, but that's not a problem. The default output for printing is typically a
54+
file called ``output.pdf`` in your home directory.
55+
56+
The resulting PDF will be sent to the printing company to make the cover, and
57+
the PDF created by Sphinx is the inside pages. The printing companies I have
58+
used for the big conference print runs have both accepted this PDF, and it's
59+
designed for use with Createspace. Other online self-publishing companies may
60+
have other requirements.
61+
62+
63+
The PDF covers
64+
--------------
65+
66+
The PDF issues should also have covers, but unlike the print cover they
67+
should contain only the printed area. Therefore you must crop the image
68+
before printing. Turn on the preview mask, make sure that Snap to guides
69+
is enabled and crop away the gray area and the spine. The resulting image
70+
should be approximately 6" x 9".
71+
72+
This image you then print to the Phone, Tablet and Screen papers, again
73+
while ignoring page margins and scaling the image to be as big as possible.
74+
The resulting images will be too heavy, with front covers being around 6MB.
75+
76+
Therefore you need to optimize each PDF with Ghostscript. The command to
77+
optimize the front PDF for the Phone size would be this::
78+
79+
gs -dNOPAUSE -dBATCH -sDEVICE=pdfwrite -dCompatibilityLevel=1.4 -sOutputFile=PhoneFront.pdf ~/output.pdf
80+
81+
Repeat for each of the sizes, and then do the same for the back cover.
82+
83+
Done!

covers/ScreenBack.pdf

248 KB
Binary file not shown.

covers/ScreenFront.pdf

361 KB
Binary file not shown.

covers/TabletBack.pdf

248 KB
Binary file not shown.

covers/TabletFront.pdf

361 KB
Binary file not shown.

maybe_a.gif

24.7 KB
Loading

0 commit comments

Comments
 (0)