Skip to content

Commit

Permalink
Get rid of requirements.txt (#1435)
Browse files Browse the repository at this point in the history
  • Loading branch information
Akuli authored Feb 7, 2024
1 parent 5d1c053 commit d6de58e
Show file tree
Hide file tree
Showing 6 changed files with 34 additions and 44 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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

Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/release-builds.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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/[email protected]
Expand Down
1 change: 0 additions & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
16 changes: 16 additions & 0 deletions requirements-dev.txt
Original file line number Diff line number Diff line change
@@ -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
Expand Down
20 changes: 0 additions & 20 deletions requirements.txt

This file was deleted.

31 changes: 13 additions & 18 deletions tests/test_porcupine_files.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
)

0 comments on commit d6de58e

Please sign in to comment.