Skip to content

Commit

Permalink
Get rid of requirements.txt
Browse files Browse the repository at this point in the history
  • Loading branch information
Akuli committed Feb 7, 2024
1 parent 859404d commit a2231b9
Show file tree
Hide file tree
Showing 7 changed files with 36 additions and 45 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/autofix.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ jobs:
import tomli
with open("pr/pyproject.toml", "rb") as f:
content = tomli.load(f)
for dep in content["project"]["dependencies"]:
print(dep)
for dep in content["project"]["optional-dependencies"]["dev"]:
print(dep)
' >> pr/requirements-dev.txt
Expand Down
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
17 changes: 16 additions & 1 deletion requirements-dev.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,19 @@
# 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 a2231b9

Please sign in to comment.