.. |PackageName| replace:: pyVersioning .. _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 `. .. _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 `. .. _INSTALL/pip/install: Installing a Wheel Package from PyPI using PIP ============================================== 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 pyVersioning package pip3 install pyVersioning # Alternatively python3 -m pip install pyVersioning .. tab-item:: With Documentation Dependencies :sync: Doc .. code-block:: bash # Install with dependencies to generate documentation pip3 install pyVersioning[doc] # Alternatively python3 -m pip install pyVersioning[doc] .. tab-item:: With Unit Testing Dependencies :sync: Unit .. code-block:: bash # Install with dependencies to run unit tests pip3 install pyVersioning[test] # Alternatively python3 -m pip install pyVersioning[test] .. tab-item:: All Developer Dependencies :sync: All .. code-block:: bash # Install with all developer dependencies pip3 install pyVersioning[all] # Alternatively python3 -m pip install pyVersioning[all] .. tab-item:: Windows :sync: Windows .. tab-set:: .. tab-item:: Minimal installation :sync: Minimal .. code-block:: powershell # Basic pyVersioning package pip install pyVersioning # Alternatively py -m pip install pyVersioning .. tab-item:: With Documentation Dependencies :sync: Doc .. code-block:: powershell # Install with dependencies to generate documentation pip install pyVersioning[doc] # Alternatively py -m pip install pyVersioning[doc] .. tab-item:: With Unit Testing Dependencies :sync: Unit .. code-block:: powershell # Install with dependencies to run unit tests pip install pyVersioning[test] # Alternatively py -m pip install pyVersioning[test] .. tab-item:: All Developer Dependencies :sync: All .. code-block:: powershell # Install with all developer dependencies pip install pyVersioning[all] # Alternatively py -m pip install pyVersioning[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 pyVersioning ~= 0.15.0 .. _INSTALL/pip/update: Updating from PyPI using PIP ============================ .. tab-set:: .. tab-item:: Linux/macOS :sync: Linux .. code-block:: bash # Update pyVersioning pip3 install -U pyVersioning # Alternatively python3 -m pip install -U pyVersioning .. tab-item:: Windows :sync: Windows .. code-block:: powershell # Update pyVersioning pip install -U pyVersioning # Alternatively py -m pip install -U pyVersioning .. _INSTALL/pip/uninstall: Uninstallation using PIP ======================== .. tab-set:: .. tab-item:: Linux/macOS :sync: Linux .. code-block:: bash # Uninstall pyVersioning pip3 uninstall pyVersioning # Alternatively python3 -m pip uninstall pyVersioning .. tab-item:: Windows :sync: Windows .. code-block:: powershell # Uninstall pyVersioning pip uninstall pyVersioning # Alternatively py -m pip uninstall pyVersioning .. _INSTALL/testing: Running unit tests ****************** This package is provided with unit tests for `pytest `__. 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 `__. All steps provide appropriate artifacts as XML or HTML reports. The artifact output directories are specified in ``pyproject.toml``. Ensure :ref:`unit testing requirements ` are installed. .. tab-set:: .. tab-item:: Linux/macOS :sync: Linux .. tab-set:: .. tab-item:: Unit Testing :sync: UnitTesting .. code-block:: bash cd # 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 # 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 # 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 # 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 # 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 # 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 `__. The artifact output directory is specified in ``pyproject.toml``. Ensure :ref:`unit testing requirements ` are installed. .. tab-set:: .. tab-item:: Linux/macOS :sync: Linux .. code-block:: bash cd # Running type checking using mypy export MYPY_FORCE_COLOR=1 mypy -p pyversioning .. tab-item:: Windows :sync: Windows .. code-block:: powershell cd # Running type checking using mypy $env:MYPY_FORCE_COLOR = 1 mypy -p pyversioning .. _INSTALL/documentation: Building documentation ********************** The documentation can be build locally using `Sphinx `__. 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 `__. Ensure :ref:`documentation requirements ` are installed. .. tab-set:: .. tab-item:: Linux/macOS :sync: Linux .. tab-set:: .. tab-item:: Generating HTML :sync: HTML .. code-block:: bash cd # 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 # 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 `__ is required. .. tab-item:: Windows :sync: Windows .. tab-set:: .. tab-item:: Generating HTML :sync: HTML .. code-block:: powershell cd # Building documentation using Sphinx .\doc\make.bat html --verbose .. tab-item:: Generating LaTeX :sync: LaTeX .. code-block:: powershell cd # 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 `__ 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 ` are installed. .. tab-set:: .. tab-item:: Linux/macOS :sync: Linux .. code-block:: bash cd # Package the code in a wheel (*.whl) python3 -m build --wheel # Uninstall the old package python3 -m pip uninstall -y pyVersioning # Install from wheel python3 -m pip install ./dist/pyVersioning-0.15.0-py3-none-any.whl .. tab-item:: Windows :sync: Windows .. code-block:: powershell cd # Package the code in a wheel (*.whl) py -m build --wheel # Uninstall the old package py -m pip uninstall -y pyVersioning # Install from wheel py -m pip install .\dist\pyVersioning-0.15.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.