diff --git a/.github/workflows/ci-windows-powershell.yml b/.github/workflows/ci-windows-powershell.yml index f8aeef5b4..de493e02b 100644 --- a/.github/workflows/ci-windows-powershell.yml +++ b/.github/workflows/ci-windows-powershell.yml @@ -38,7 +38,7 @@ jobs: - name: "Windows specific: Install StrictDoc's dependencies" run: | - python developer/pip_install_strictdoc_deps.py + pip install . - name: "Windows specific: Install Check dependencies (everything for lint + test)" run: | diff --git a/.github/workflows/ci-windows.yml b/.github/workflows/ci-windows.yml index ab86f5ea6..0f8a4a1f1 100644 --- a/.github/workflows/ci-windows.yml +++ b/.github/workflows/ci-windows.yml @@ -38,7 +38,7 @@ jobs: - name: "Windows specific: Install StrictDoc's dependencies" run: | - python developer/pip_install_strictdoc_deps.py + pip install . - name: "Windows specific: Install Check dependencies (everything for lint + test)" run: | diff --git a/.github/workflows/end2end-tests.yml b/.github/workflows/end2end-tests.yml index 4ecd3a075..f038bcd6e 100644 --- a/.github/workflows/end2end-tests.yml +++ b/.github/workflows/end2end-tests.yml @@ -100,7 +100,7 @@ jobs: - name: "Windows specific: Install StrictDoc's dependencies" run: | - python developer/pip_install_strictdoc_deps.py + pip install . - name: "Windows specific: Install Check dependencies (everything for test)" run: | diff --git a/developer/pip_install_strictdoc_deps.py b/developer/pip_install_strictdoc_deps.py deleted file mode 100644 index d4ca0a30f..000000000 --- a/developer/pip_install_strictdoc_deps.py +++ /dev/null @@ -1,101 +0,0 @@ -import importlib.metadata as importlib_metadata -import os -import subprocess -import sys -import tempfile - -import toml -from packaging.requirements import Requirement - - -class PackageNotFound(Exception): - pass - - -class PackageVersionConflict(Exception): - pass - - -# A simplified version inspired by: -# https://github.com/HansBug/hbutils/blob/37879186c489bced2791309c43d131f1703b7bd4/hbutils/system/python/package.py#L171 -def check_if_package_installed(package_name: str): - requirement: Requirement = Requirement(package_name) - try: - version = importlib_metadata.distribution(requirement.name).version - except importlib_metadata.PackageNotFoundError: - raise PackageNotFound(requirement) from None - if not requirement.specifier.contains(version): - raise PackageVersionConflict(version) - - -print( # noqa: T201 - "pip_install_strictdoc_deps.py: " - "checking if the current Python environment has all packages installed" - ".", - flush=True, -) - -pyproject_content = toml.load("pyproject.toml") - - -# The development dependencies are ignored, because they are managed in tox.ini. -dependencies = pyproject_content["project"]["dependencies"] - -needs_installation = False - -for dependency in dependencies: - try: - check_if_package_installed(dependency) - except PackageNotFound: - print( # noqa: T201 - f"pip_install_strictdoc_deps.py: " - f"Package is not installed: '{dependency}'.", - flush=True, - ) - needs_installation = True - break - except PackageVersionConflict as exception_: - print( # noqa: T201 - ( - f"pip_install_strictdoc_deps.py: version conflict between " - f"StrictDoc's requirement '{dependency}' " - f"and the already installed package: " - f"{exception_.args[0]}." - ), - flush=True, - ) - needs_installation = True - break - -if not needs_installation: - print( # noqa: T201 - "pip_install_strictdoc_deps.py: all packages seem to be installed.", - flush=True, - ) - sys.exit(0) - -print( # noqa: T201 - "pip_install_strictdoc_deps.py: will install packages.", flush=True -) - -all_packages = "\n".join(dependencies) + "\n" - -with tempfile.TemporaryDirectory() as tmp_dir: - with open( - os.path.join(tmp_dir, "requirements.txt"), "w", encoding="utf8" - ) as tmp_requirements_txt_file: - tmp_requirements_txt_file.write(all_packages) - - command = [ - sys.executable, - "-m", - "pip", - "install", - "-r", - tmp_requirements_txt_file.name, - ] - - result = subprocess.run(command, check=True, encoding="utf8") - print( # noqa: T201 - f"'pip install' command exited with: {result.returncode}", flush=True - ) diff --git a/docs/sphinx/source/strictdoc_11_developer_guide.rst b/docs/sphinx/source/strictdoc_11_developer_guide.rst index 030f650ef..b0268d993 100644 --- a/docs/sphinx/source/strictdoc_11_developer_guide.rst +++ b/docs/sphinx/source/strictdoc_11_developer_guide.rst @@ -81,7 +81,7 @@ in StrictDoc's source code. Otherwise, install StrictDoc as a normal Pip package .. code-block:: git clone https://github.com/strictdoc-project/strictdoc.git && cd strictdoc - python developer/pip_install_strictdoc_deps.py + pip install . python3 strictdoc/cli/main.py The ``pip_install_strictdoc_deps.py`` installs all dependencies of StrictDoc, but not StrictDoc itself. diff --git a/docs/strictdoc_11_developer_guide.sdoc b/docs/strictdoc_11_developer_guide.sdoc index 9c3cdc472..1007fd6bc 100644 --- a/docs/strictdoc_11_developer_guide.sdoc +++ b/docs/strictdoc_11_developer_guide.sdoc @@ -55,12 +55,6 @@ On Linux Ubuntu: .. code:: bash sudo apt install tidy - -From the core Python packages, StrictDoc needs Invoke, Tox and TOML: - -.. code:: bash - - pip install invoke tox toml <<< [SECTION] @@ -89,13 +83,28 @@ STATEMENT: >>> **Note:** Use this way of installing StrictDoc only if you want to make changes in StrictDoc's source code. Otherwise, install StrictDoc as a normal Pip package by running ``pip install strictdoc``. -.. code-block:: +1. Clone the project. +2. Create a virtual environment. +3. Install dependencies. +4. Run the StrictDoc CLI. + +.. code:: bash git clone https://github.com/strictdoc-project/strictdoc.git && cd strictdoc - python developer/pip_install_strictdoc_deps.py + python3 -m venv .venv + . ./.venv/bin/activate + pip install . python3 strictdoc/cli/main.py -The ``pip_install_strictdoc_deps.py`` installs all dependencies of StrictDoc, but not StrictDoc itself. +**Note:** Windows users, substitute: ``.\.venv\Scripts\activate`` + +This installs all dependencies of StrictDoc, but not StrictDoc itself. + +To also install the dev dependencies specified in ``pyproject.toml``: + +.. code:: bash + + pip install ".[development]" <<< [/SECTION] diff --git a/tox.ini b/tox.ini index b62942667..a09d44bc5 100644 --- a/tox.ini +++ b/tox.ini @@ -18,7 +18,7 @@ deps = # Reload files when changed (used by 'invoke watch') watchdog>=2.1.7 commands = - python developer/pip_install_strictdoc_deps.py + pip install . {posargs} [testenv:{py37,py38,py39,py310,py311,py312}-check] @@ -31,7 +31,7 @@ pass_env= CHROMEWEBDRIVER STRICTDOC_CACHE_DIR commands = - python developer/pip_install_strictdoc_deps.py + pip install . {posargs} [testenv:{py37,py38,py39,py310,py311,py312}-documentation] @@ -48,7 +48,7 @@ deps = sphinx>=3.2.1 guzzle_sphinx_theme~=0.7.11 commands = - python developer/pip_install_strictdoc_deps.py + pip install . {posargs} [testenv:{py37,py38,py39,py310,py311,py312}-release] @@ -74,7 +74,7 @@ deps = twine {[testenv:py37-check]deps} commands = - python developer/pip_install_strictdoc_deps.py + pip install . {posargs} [testenv:{py37,py38,py39,py310,py311,py312}-pyinstaller] @@ -84,5 +84,5 @@ deps = -rrequirements.bootstrap.txt pyinstaller commands = - python developer/pip_install_strictdoc_deps.py + pip install . {posargs}