Skip to content

Commit b8efdae

Browse files
committed
Update setup.py with the new README and version number
1 parent 69e53b8 commit b8efdae

File tree

1 file changed

+94
-88
lines changed

1 file changed

+94
-88
lines changed

setup.py

+94-88
Original file line numberDiff line numberDiff line change
@@ -2,155 +2,161 @@
22
PyLaTeX
33
-------
44
5-
PyLaTeX is a Python library for creating LaTeX files. The goal of this library
6-
is being an easy, but extensible interface between Python and LaTeX.
5+
PyLaTeX is a Python library for creating and compiling LaTeX files. The goal of
6+
this library is being an easy, but extensible interface between Python and
7+
LaTeX.
78
89
910
Features
10-
~~~~~~~~
11-
12-
The library contains some basic features I have had the need for so far.
13-
Currently those are:
11+
--------
1412
1513
- Document generation and compilation
16-
- Section, table, math and package classes
14+
- Section, table, math, figure and package classes
1715
- A matrix class that can compile NumPy ndarrays and matrices to LaTeX
18-
- An escape function
19-
- Bold and italic functions
20-
- Every class has a dump method, which writes the output to a filepointer
16+
- Very exstensible base classes that you can use to easily add new features
17+
- Contextmanager style class hierarchy
18+
- Functionality to escape special LaTeX characters
19+
- Bold, italic and verbatim functions
20+
- Every class has a dump method, which writes the output to a filepointer this way you can use snippets in in normal LaTeX files using \\input
2121
2222
Everything else you want you can still add to the document by adding LaTeX
23-
formatted strings instead of classes or regular strings.
23+
formatted strings to the container class you want it to be in.
2424
2525
2626
Dependencies
27-
~~~~~~~~~~~~
27+
------------
2828
2929
- Python 3.x or Python 2.7
30+
- ordered-set
31+
32+
Optional dependencies
33+
~~~~~~~~~~~~~~~~~~~~~
34+
3035
- pdflatex (only if you want to compile the tex file)
3136
- NumPy (only if you want to convert it's matrixes)
32-
- ordered-set
37+
- awkwardduet (only if you want to compile to python 2 source code yourself)
3338
3439
3540
Installation
36-
~~~~~~~~~~~~
41+
------------
3742
3843
::
3944
4045
pip install pylatex
4146
4247
4348
Example
44-
~~~~~~~
49+
-------
50+
51+
This is generated by the code below:
52+
53+
.. image:: https://raw.github.com/JelteF/PyLaTeX/master/docs/static/screenshot.png
54+
4555
4656
.. code:: python
4757
4858
import numpy as np
4959
50-
from pylatex import Document, Section, Subsection, Table, Math, TikZ, Axis, \
51-
Plot
60+
from pylatex import Document, Section, Subsection, Table, Math, TikZ, Axis, \\
61+
Plot, Figure, Package
5262
from pylatex.numpy import Matrix
53-
from pylatex.utils import italic
63+
from pylatex.utils import italic, escape_latex
5464
5565
doc = Document()
56-
section = Section('Yaay the first section, it can even be ' + italic('italic'))
57-
58-
section.append('Some regular text')
59-
60-
math = Subsection('Math that is incorrect', data=[Math(data=['2*3', '=', 9])])
61-
62-
section.append(math)
63-
table = Table('rc|cl')
64-
table.add_hline()
65-
table.add_row((1, 2, 3, 4))
66-
table.add_hline(1, 2)
67-
table.add_empty_row()
68-
table.add_row((4, 5, 6, 7))
69-
70-
table = Subsection('Table of something', data=[table])
71-
72-
section.append(table)
66+
doc.packages.append(Package('geometry', options=['tmargin=1cm',
67+
'lmargin=10cm']))
68+
69+
with doc.create(Section('The simple stuff')):
70+
doc.append('Some regular text and some ' + italic('italic text. '))
71+
doc.append(escape_latex('\\nAlso some crazy characters: $&#{}'))
72+
with doc.create(Subsection('Math that is incorrect')) as math:
73+
doc.append(Math(data=['2*3', '=', 9]))
74+
75+
with doc.create(Subsection('Table of something')):
76+
with doc.create(Table('rc|cl')) as table:
77+
table.add_hline()
78+
table.add_row((1, 2, 3, 4))
79+
table.add_hline(1, 2)
80+
table.add_empty_row()
81+
table.add_row((4, 5, 6, 7))
7382
7483
a = np.array([[100, 10, 20]]).T
7584
M = np.matrix([[2, 3, 4],
7685
[0, 0, 1],
7786
[0, 0, 2]])
7887
79-
math = Math(data=[Matrix(M), Matrix(a), '=', Matrix(M*a)])
80-
equation = Subsection('Matrix equation', data=[math])
81-
82-
section.append(equation)
83-
84-
tikz = TikZ()
85-
86-
axis = Axis(options='height=6cm, width=6cm, grid=major')
87-
88-
plot1 = Plot(name='model', func='-x^5 - 242')
89-
coordinates = [
90-
(-4.77778, 2027.60977),
91-
(-3.55556, 347.84069),
92-
(-2.33333, 22.58953),
93-
(-1.11111, -493.50066),
94-
(0.11111, 46.66082),
95-
(1.33333, -205.56286),
96-
(2.55556, -341.40638),
97-
(3.77778, -1169.24780),
98-
(5.00000, -3269.56775),
99-
]
100-
101-
plot2 = Plot(name='estimate', coordinates=coordinates)
102-
103-
axis.append(plot1)
104-
axis.append(plot2)
105-
106-
tikz.append(axis)
107-
108-
plot_section = Subsection('Random graph', data=[tikz])
109-
110-
section.append(plot_section)
111-
112-
doc.append(section)
88+
with doc.create(Section('The fancy stuff')):
89+
with doc.create(Subsection('Correct matrix equations')):
90+
doc.append(Math(data=[Matrix(M), Matrix(a), '=', Matrix(M*a)]))
91+
92+
with doc.create(Subsection('Beautiful graphs')):
93+
with doc.create(TikZ()):
94+
plot_options = 'height=6cm, width=6cm, grid=major'
95+
with doc.create(Axis(options=plot_options)) as plot:
96+
plot.append(Plot(name='model', func='-x^5 - 242'))
97+
98+
coordinates = [
99+
(-4.77778, 2027.60977),
100+
(-3.55556, 347.84069),
101+
(-2.33333, 22.58953),
102+
(-1.11111, -493.50066),
103+
(0.11111, 46.66082),
104+
(1.33333, -205.56286),
105+
(2.55556, -341.40638),
106+
(3.77778, -1169.24780),
107+
(5.00000, -3269.56775),
108+
]
109+
110+
plot.append(Plot(name='estimate', coordinates=coordinates))
111+
112+
with doc.create(Subsection('Cute kitten pictures')):
113+
with doc.create(Figure(position='h!')) as kitten_pic:
114+
kitten_pic.add_image('docs/static/kitten.jpg', width='120px')
115+
kitten_pic.add_caption('Look it\\'s on its back')
113116
114117
doc.generate_pdf()
115118
116-
This code will generate this:
117-
118-
.. image:: https://raw.github.com/JelteF/PyLaTeX/master/docs/static/screenshot.png
119-
120119
121120
Future development
122-
~~~~~~~~~~~~~~~~~~
121+
------------------
123122
124-
I will keep adding functionality I need to this library, an interface for
125-
graphics and math will probably be added in a future version.
123+
I will keep adding functionality I need to this library.
126124
127-
If you add a feature yourself, or fix a bug, please send a pull request.
125+
If you add a feature yourself, or fix a bug, please send a pull request. The
126+
code is not very difficult and mostly speaks for itself. If you have a question
127+
just let me know.
128128
129-
You can submit issues, but it will not be my priority to fix them. My job and
130-
education are a bit higher on the priority list.
129+
You can submit issues and I will probably respond quite quick. However, it might
130+
take a lot more time for me to fix something. I also have a job, education and a
131+
personal life to worry about. If you want something done try to fix it yourself
132+
as well. Accepting pull requests costs way less time.
131133
132134
133135
Support
134-
~~~~~~~
136+
-------
135137
136138
This library is being developed in and for Python 3. Because of a conversion
137-
script the current version also works in Python 2.7. For futere versions, no
138-
such promise will be made. Uncompatible Python 3 features will not be headed to
139-
keep supporting Python 2.7.
139+
script the current version also works in Python 2.7. For future versions, no
140+
such promise will be made. Python 3 features that are useful but incompatible
141+
with Python 2 will be used. If you find a bug for Python 2 and it is fixable
142+
without ugly hacks feel free to send a pull request.
140143
141144
The platform this library is developed for is Linux. I have no intention to
142-
write fixes or test for platform specific bugs. Pull requests that fix those
143-
are always welcome though.
145+
write fixes or test for platform specific bugs with every update. Pull requests
146+
that fix those issues are always welcome though.
144147
145148
Copyright and License
146-
~~~~~~~~~~~~~~~~~~~~~
149+
---------------------
147150
148151
Copyright 2014 Jelte Fennema, under `the MIT license
149152
<https://github.com/JelteF/PyLaTeX/blob/master/LICENSE>`_.
150153
151154
"""
152155

153-
from distutils.core import setup
156+
try:
157+
from setuptools import setup
158+
except ImportError:
159+
from distutils.core import setup
154160
import sys
155161

156162

@@ -167,7 +173,7 @@
167173
source_dir = 'python2_source'
168174

169175
setup(name='PyLaTeX',
170-
version='0.5',
176+
version='0.6',
171177
author='Jelte Fennema',
172178
author_email='pylatex@jeltef.nl',
173179
description='A Python library for creating LaTeX files',

0 commit comments

Comments
 (0)