From d6de58ee10e40d3e920e94c75816ce2a38e0ffd5 Mon Sep 17 00:00:00 2001 From: Akuli Date: Wed, 7 Feb 2024 12:15:26 +0200 Subject: [PATCH] Get rid of requirements.txt (#1435) --- .github/workflows/check.yml | 6 +++--- .github/workflows/release-builds.yml | 4 ++-- CONTRIBUTING.md | 1 - requirements-dev.txt | 16 ++++++++++++++ requirements.txt | 20 ------------------ tests/test_porcupine_files.py | 31 ++++++++++++---------------- 6 files changed, 34 insertions(+), 44 deletions(-) delete mode 100644 requirements.txt diff --git a/.github/workflows/check.yml b/.github/workflows/check.yml index 6e1bc2f26..5257015e4 100644 --- a/.github/workflows/check.yml +++ b/.github/workflows/check.yml @@ -15,7 +15,7 @@ jobs: python-version: "3.11" cache: pip - run: pip install wheel - - run: pip install -r requirements.txt -r requirements-dev.txt + - run: pip install -r requirements-dev.txt - run: | time mypy --platform linux --python-version 3.8 porcupine docs/extensions.py time mypy --platform linux --python-version 3.9 porcupine docs/extensions.py @@ -42,7 +42,7 @@ jobs: python-version: ${{ matrix.python-version }} cache: pip - run: pip install wheel - - run: pip install -r requirements.txt -r requirements-dev.txt + - run: pip install -r requirements-dev.txt - if: matrix.os == 'ubuntu-latest' # Make sure that it doesn't crash with Noto Color Emoji installed run: sudo apt install --no-install-recommends fonts-noto-color-emoji tkdnd @@ -73,7 +73,7 @@ jobs: - if: matrix.python-version != '3.8' run: brew install python-tk@${{ matrix.python-version }} - run: $PYTHON --version - - run: $PYTHON -m pip install -r requirements.txt -r requirements-dev.txt + - run: $PYTHON -m pip install -r requirements-dev.txt - run: $PYTHON scripts/download-tkdnd.py - run: $PYTHON -m pytest --durations=10 diff --git a/.github/workflows/release-builds.yml b/.github/workflows/release-builds.yml index 177f405a2..880c5b6d1 100644 --- a/.github/workflows/release-builds.yml +++ b/.github/workflows/release-builds.yml @@ -14,7 +14,7 @@ jobs: python-version: "3.8" # last version supporting windows 7 cache: pip - run: pip install wheel - - run: pip install -r requirements.txt -r requirements-dev.txt + - run: pip install -r requirements-dev.txt - uses: egor-tensin/setup-clang@v1 with: platform: x64 @@ -34,7 +34,7 @@ jobs: python-version: "3.11" cache: pip - run: pip install wheel - - run: pip install -r requirements.txt -r requirements-dev.txt + - run: pip install -r requirements-dev.txt - run: python3 -m sphinx ./docs ./build - if: startsWith(github.ref, 'refs/tags/v') uses: JamesIves/github-pages-deploy-action@4.1.3 diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index b3f575156..bdef863dd 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -27,7 +27,6 @@ Then install Python 3.8 or newer and [git](https://git-scm.com/), and run these cd porcupine python3 -m venv env source env/bin/activate - pip install -r requirements.txt pip install -r requirements-dev.txt python3 -m porcupine diff --git a/requirements-dev.txt b/requirements-dev.txt index 8f79a8f11..d50e40434 100644 --- a/requirements-dev.txt +++ b/requirements-dev.txt @@ -1,4 +1,20 @@ # Auto-generated in GitHub Actions. See autofix.yml. +platformdirs>=3.0.0,<4.0.0 +Pygments==2.12.0 +toposort>=1.5 +colorama>=0.2.5 +sansio-lsp-client>=0.10.0,<0.11.0 +python-language-server[rope,pyflakes]>=0.36.2,<1.0.0 +black>=21.5b2 +isort>=5.10 +typing_extensions +dacite>=1.5.1,<2.0.0 +tomli==2.0.1 +send2trash>=1.8.0,<2.0.0 +psutil>=5.8.0,<6.0.0 +PyYAML==6.0 +tree-sitter-builds==2023.3.12 +sv-ttk>=2.5.5 pytest==6.2.5 pytest-cov==4.0.0 pytest-mock==3.10.0 diff --git a/requirements.txt b/requirements.txt deleted file mode 100644 index 8f6b8b290..000000000 --- a/requirements.txt +++ /dev/null @@ -1,20 +0,0 @@ -platformdirs>=3.0.0,<4.0.0 -# pygments version fixed because haxx in highlight plugin -Pygments==2.12.0 -toposort>=1.5 -colorama>=0.2.5 -sansio-lsp-client>=0.10.0,<0.11.0 -python-language-server[rope,pyflakes]>=0.36.2,<1.0.0 -# black and isort minimum versions should be something old and kinda reasonable. -# For developing Porcupine, newer versions can be set in requirements-dev. -black>=21.5b2 -isort>=5.10 -# typing.Literal is new in python 3.8 -typing_extensions -dacite>=1.5.1,<2.0.0 -tomli==2.0.1 -send2trash>=1.8.0,<2.0.0 -psutil>=5.8.0,<6.0.0 -PyYAML==6.0 -tree-sitter-builds==2023.3.12 -sv-ttk>=2.5.5 diff --git a/tests/test_porcupine_files.py b/tests/test_porcupine_files.py index 6978ed6d1..8d4ff3d53 100644 --- a/tests/test_porcupine_files.py +++ b/tests/test_porcupine_files.py @@ -17,27 +17,22 @@ def test_copyright(): assert str(datetime.datetime.now().year) in porcupine.__copyright__ -# The intended way to store dependency info is that setup.py or pyproject.toml contains version -# ranges, and requirements.txt contains specific versions in those ranges so that each deployment -# gets the same dependencies from there. -# -# A downside is that if your deployment also gets dependencies from other places, they could specify -# conflicting versions. This could be a problem for Porcupine: even though users usually install -# Porcupine into a virtualenv that doesn't contain anything else, I don't want to assume that they -# do. -# -# Another downside with pinning for Porcupine would be dependencies getting outdated easily. -# -# Solution: pin only the packages where updating will likely break things, and keep the same -# dependencies in requirements.txt (for easy "pip install -r requirements.txt" during development) -# and in pyproject.toml (for installing released versions). +# Porcupine dependencies are specified in pyproject.toml, but also kept in +# requirements-dev.txt for a convenient and familiar workflow. You just +# "pip install -r requirements-dev.txt" when you start developing Porcupine. def test_requirements_and_pyproject_toml_in_sync(): - requirements = [] - with open("requirements.txt") as file: + reqs_dev_content = [] + with open("requirements-dev.txt") as file: for line in file: requirement = line.split("#")[0].strip() if requirement: - requirements.append(requirement) + reqs_dev_content.append(requirement) with open("pyproject.toml", "rb") as file: - assert tomli.load(file)["project"]["dependencies"] == requirements + toml_content = tomli.load(file) + + assert ( + toml_content["project"]["dependencies"] + + toml_content["project"]["optional-dependencies"]["dev"] + == reqs_dev_content + )