File: Installation.rst

package info (click to toggle)
python-pytooling 8.6.0-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 3,564 kB
  • sloc: python: 23,883; makefile: 13
file content (592 lines) | stat: -rw-r--r-- 15,977 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
.. |PackageName| replace:: pyTooling

.. _INSTALL:

Installation/Updates
####################

See the following instructions on how to install or update the package from common sources like PyPI. Developers can
also install the packages with development dependencies. In case of local development, see the additional sections on
how to run unit tests, type checks or how to build the documentation to create all the build artifacts.

See the list of :ref:`necessary dependencies <DEP>`.


.. _INSTALL/pip:

Using PIP to Install from PyPI
******************************

The following instruction are using PIP (Package Installer for Python) as a package manager and PyPI (Python Package
Index) as a source of Python packages.

PIP might download further packages as listed in :ref:`package dependencies <DEP/package>`.


.. _INSTALL/pip/install:

Installing a Wheel Package from PyPI using PIP
==============================================

Users can install the |PackageName| package as a minimal installation or the package with extensions (``packaging``,
``terminal``, ``yaml``) installing further dependencies. In case the provided extensions are not needed, it keeps the
list of dependencies low - especially the minimal installation is still dependency free.

See :ref:`DEP/package` for more details.

.. tab-set::

   .. tab-item:: Linux/macOS
      :sync: Linux

      .. tab-set::

         .. tab-item:: Minimal installation
            :sync: Minimal

            .. code-block:: bash

               # Basic pyTooling package
               pip3 install pyTooling

               # Alternatively
               python3 -m pip install pyTooling

         .. tab-item:: With Packaging Support
            :sync: Packaging

            .. code-block:: bash

               # With setuptools support for pyTooling.Packaging
               pip3 install pyTooling[packaging]

               # Alternatively
               python3 -m pip install pyTooling[packaging]

         .. tab-item:: With Colored Console/Terminal Support
            :sync: Terminal

            .. code-block:: bash

               # With color support for pyTooling.TerminalUI
               pip3 install pyTooling[terminal]

               # Alternatively
               python3 -m pip install pyTooling[terminal]

         .. tab-item:: With YAML Support for Configuration Files
            :sync: YAML

            .. code-block:: bash

               # With YAML support for pyTooling.Configuration.YAML
               pip3 install pyTooling[yaml]

               # Alternatively
               python3 -m pip install pyTooling[yaml]

   .. tab-item:: Windows
      :sync: Windows

      .. tab-set::

         .. tab-item:: Minimal installation
            :sync: Minimal

            .. code-block:: powershell

               # Basic pyTooling package
               pip install pyTooling

               # Alternatively
               py -m pip install pyTooling

         .. tab-item:: With Packaging Support
            :sync: Packaging

            .. code-block:: powershell

               # With setuptools support for pyTooling.Packaging
               pip install pyTooling[packaging]

               # Alternatively
               py -m pip install pyTooling[packaging]

         .. tab-item:: With Colored Console/Terminal Support
            :sync: Terminal

            .. code-block:: powershell

               # With color support for pyTooling.TerminalUI
               pip install pyTooling[terminal]

               # Alternatively
               py -m pip install pyTooling[terminal]

         .. tab-item:: With YAML Support for Configuration Files
            :sync: YAML

            .. code-block:: powershell

               # With YAML support for pyTooling.Configuration.YAML
               pip install pyTooling[yaml]

               # Alternatively
               py -m pip install pyTooling[yaml]

Developers can install the |PackageName| package itself or the package with further dependencies for documentation
generation (``doc``), running unit tests (``test``) or just all (``all``) dependencies.

See :ref:`DEP` for more details.

.. tab-set::

   .. tab-item:: Linux/macOS
      :sync: Linux

      .. tab-set::

         .. tab-item:: Minimal installation
            :sync: Minimal

            .. code-block:: bash

               # Basic pyTooling package
               pip3 install pyTooling

               # Alternatively
               python3 -m pip install pyTooling

         .. tab-item:: With Documentation Dependencies
            :sync: Doc

            .. code-block:: bash

               # Install with dependencies to generate documentation
               pip3 install pyTooling[doc]

               # Alternatively
               python3 -m pip install pyTooling[doc]

         .. tab-item:: With Unit Testing Dependencies
            :sync: Unit

            .. code-block:: bash

               # Install with dependencies to run unit tests
               pip3 install pyTooling[test]

               # Alternatively
               python3 -m pip install pyTooling[test]

         .. tab-item:: All Developer Dependencies
            :sync: All

            .. code-block:: bash

               # Install with all developer dependencies
               pip3 install pyTooling[all]

               # Alternatively
               python3 -m pip install pyTooling[all]

   .. tab-item:: Windows
      :sync: Windows

      .. tab-set::

         .. tab-item:: Minimal installation
            :sync: Minimal

            .. code-block:: powershell

               # Basic pyTooling package
               pip install pyTooling

               # Alternatively
               py -m pip install pyTooling

         .. tab-item:: With Documentation Dependencies
            :sync: Doc

            .. code-block:: powershell

               # Install with dependencies to generate documentation
               pip install pyTooling[doc]

               # Alternatively
               py -m pip install pyTooling[doc]

         .. tab-item:: With Unit Testing Dependencies
            :sync: Unit

            .. code-block:: powershell

               # Install with dependencies to run unit tests
               pip install pyTooling[test]

               # Alternatively
               py -m pip install pyTooling[test]

         .. tab-item:: All Developer Dependencies
            :sync: All

            .. code-block:: powershell

               # Install with all developer dependencies
               pip install pyTooling[all]

               # Alternatively
               py -m pip install pyTooling[all]


.. _INSTALL/pip/requirements:

Referencing the package in ``requirements.txt``
===============================================

When |PackageName| is used by another Python package, it's recommended to list the dependency to the |PackageName|
package in a ``requirements.txt`` file.

.. admonition:: ``requirements.txt``

   .. code-block:: text

      pyTooling ~= 8.5


.. _INSTALL/pip/update:

Updating from PyPI using PIP
============================

.. tab-set::

   .. tab-item:: Linux/macOS
      :sync: Linux

      .. code-block:: bash

         # Update pyTooling
         pip3 install -U pyTooling

         # Alternatively
         python3 -m pip install -U pyTooling

   .. tab-item:: Windows
      :sync: Windows

      .. code-block:: powershell

         # Update pyTooling
         pip install -U pyTooling

         # Alternatively
         py -m pip install -U pyTooling


.. _INSTALL/pip/uninstall:

Uninstallation using PIP
========================

.. tab-set::

   .. tab-item:: Linux/macOS
      :sync: Linux

      .. code-block:: bash

         # Uninstall pyTooling
         pip3 uninstall pyTooling

         # Alternatively
         python3 -m pip uninstall pyTooling

   .. tab-item:: Windows
      :sync: Windows

      .. code-block:: powershell

         # Uninstall pyTooling
         pip uninstall pyTooling

         # Alternatively
         py -m pip uninstall pyTooling


.. _INSTALL/testing:

Running unit tests
******************

This package is provided with unit tests for `pytest <https://docs.pytest.org/>`__. The provided testcases can be
executed locally for testing or development purposes. In addition, code coverage including branch coverage can be
collected using `Coverage.py <https://coverage.readthedocs.io/>`__. All steps provide appropriate artifacts as XML or
HTML reports. The artifact output directories are specified in ``pyproject.toml``.

Ensure :ref:`unit testing requirements <DEP/testing>` are installed.

.. tab-set::

   .. tab-item:: Linux/macOS
      :sync: Linux

      .. tab-set::

         .. tab-item:: Unit Testing
            :sync: UnitTesting

            .. code-block:: bash

               cd <pyTooling>

               # Running unit tests using pytest
               pytest -raP --color=yes tests/unit

         .. tab-item:: Unit Testing with Ant/JUnit XML Reports
            :sync: UnitTestingXML

            .. code-block:: bash

               cd <pyTooling>

               # Running unit tests using pytest
               pytest -raP --color=yes --junitxml=report/unit/unittest.xml --template=html1/index.html --report=report/unit/html/index.html --split-report tests/unit

         .. tab-item:: Unit Testing with Code Coverage
            :sync: Coverage

            .. code-block:: bash

               cd <pyTooling>

               # Running unit tests with code coverage using Coverage.py
               coverage run --data-file=.coverage --rcfile=pyproject.toml -m pytest -ra --tb=line --color=yes tests/unit

               # Write coverage report to console"
               coverage report

               # Convert coverage report to HTML
               coverage html

               # Convert coverage report to XML (Cobertura)
               coverage xml

   .. tab-item:: Windows
      :sync: Windows

      .. tab-set::

         .. tab-item:: Unit Testing
            :sync: UnitTesting

            .. code-block:: powershell

               cd <pyTooling>

               # Running unit tests using pytest
               pytest -raP --color=yes tests\unit

         .. tab-item:: Unit Testing with Ant/JUnit XML Reports
            :sync: UnitTestingXML

            .. code-block:: powershell

               cd <pyTooling>

               # Running unit tests using pytest
               pytest -raP --color=yes --junitxml=report\unit\unittest.xml --template=html1\index.html --report=report\unit\html\index.html --split-report tests\unit

         .. tab-item:: Unit Testing with Code Coverage
            :sync: Coverage

            .. code-block:: powershell

               cd <pyTooling>

               # Running unit tests with code coverage using Coverage.py
               coverage run --data-file=.coverage --rcfile=pyproject.toml -m pytest -ra --tb=line --color=yes tests\unit

               # Write coverage report to console"
               coverage report

               # Convert coverage report to HTML
               coverage html

               # Convert coverage report to XML (Cobertura)
               coverage xml


.. _INSTALL/typechecking:

Running type checks
*******************

This package is provided with type checks. These can be executed locally for testing or development purposes using
`mypy <https://mypy-lang.org/>`__. The artifact output directory is specified in ``pyproject.toml``.

Ensure :ref:`unit testing requirements <DEP/testing>` are installed.

.. tab-set::

   .. tab-item:: Linux/macOS
      :sync: Linux

      .. code-block:: bash

         cd <pyTooling>

         # Running type checking using mypy
         export MYPY_FORCE_COLOR=1
         mypy -p pyTooling

   .. tab-item:: Windows
      :sync: Windows

      .. code-block:: powershell

         cd <pyTooling>

         # Running type checking using mypy
         $env:MYPY_FORCE_COLOR = 1
         mypy -p pyTooling


.. _INSTALL/documentation:

Building documentation
**********************

The documentation can be build locally using `Sphinx <https://www.sphinx-doc.org/>`__. It can generate HTML and LaTeX
outputs. In an additional step, the LaTeX output can be translated to a PDF file using a LaTeX environment like
`MiKTeX <https://miktex.org/>`__.

Ensure :ref:`documentation requirements <DEP/documentation>` are installed.

.. tab-set::

   .. tab-item:: Linux/macOS
      :sync: Linux

      .. tab-set::

         .. tab-item:: Generating HTML
            :sync: HTML

            .. code-block:: bash

               cd <pyTooling>

               # Adding package root to PYTHONPATH
               export PYTHONPATH=$(pwd)
               cd doc

               # Building documentation using Sphinx
               sphinx-build -v -n -b html -d _build/doctrees -j $(nproc) -w _build/html.log . _build/html

         .. tab-item:: Generating LaTeX
            :sync: LaTeX

            .. code-block:: bash

               cd <pyTooling>

               # Adding package root to PYTHONPATH
               export PYTHONPATH=$(pwd)
               cd doc

               # Building documentation using Sphinx
               sphinx-build -v -n -b latex -d _build/doctrees -j $(nproc) -w _build/latex.log . _build/latex

         .. tab-item:: Generating PDF (from LaTeX)
            :sync: PDF

            .. todo:: Describe LaTeX to PDF conversion on Linux using Miktex.

            .. hint:: A `Miktex installation <https://miktex.org/>`__ is required.

   .. tab-item:: Windows
      :sync: Windows

      .. tab-set::

         .. tab-item:: Generating HTML
            :sync: HTML

            .. code-block:: powershell

               cd <pyTooling>

               # Building documentation using Sphinx
               .\doc\make.bat html --verbose

         .. tab-item:: Generating LaTeX
            :sync: LaTeX

            .. code-block:: powershell

               cd <pyTooling>

               # Building documentation using Sphinx
               .\doc\make.bat latex --verbose

         .. tab-item:: Generating PDF (from LaTeX)
            :sync: PDF

            .. todo:: Describe LaTeX to PDF conversion on Windows using Miktex.

            .. hint:: A `Miktex installation <https://miktex.org/>`__ is required.


.. _INSTALL/building:

Local Packaging and Installation via PIP
****************************************

For development and bug fixing it might be handy to create a local wheel package and also install it locally on the
development machine. The following instructions will create a local wheel package (``*.whl``) and then use PIP to
install it. As a user might have a |PackageName| installation from PyPI, it's recommended to uninstall any previous
|PackageName| packages. (This step is also needed if installing an updated local wheel file with same version number.
PIP will not detect a new version and thus not overwrite/reinstall the updated package contents.)

Ensure :ref:`packaging requirements <DEP/packaging>` are installed.

.. tab-set::

   .. tab-item:: Linux/macOS
      :sync: Linux

      .. code-block:: bash

         cd <pyTooling>

         # Package the code in a wheel (*.whl)
         python3 -m build --wheel

         # Uninstall the old package
         python3 -m pip uninstall -y pyTooling

         # Install from wheel
         python3 -m pip install ./dist/pyTooling-8.5.0-py3-none-any.whl

   .. tab-item:: Windows
      :sync: Windows

      .. code-block:: powershell

         cd <pyTooling>

         # Package the code in a wheel (*.whl)
         py -m build --wheel

         # Uninstall the old package
         py -m pip uninstall -y pyTooling

         # Install from wheel
         py -m pip install .\dist\pyTooling-8.5.0-py3-none-any.whl

.. note::

   The legacy ways of building a package using ``setup.py bdist_wheel`` and installation using ``setup.py install`` is
   not recommended anymore.