Skip to content

Commit

Permalink
Merge branch 'dev' into node-deps
Browse files Browse the repository at this point in the history
  • Loading branch information
philippemilink authored Jan 13, 2024
2 parents 05c6829 + 0f79e79 commit 26048eb
Show file tree
Hide file tree
Showing 7 changed files with 93 additions and 25 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ env:
PYTHON_VERSION: "3.9"
MARIADB_VERSION: "10.4.10"
COVERALLS_VERSION: "3.3.1" # check if Coverage needs to be also updated in requirements-ci.txt
GECKODRIVER_VERSION: "0.33.0"
GECKODRIVER_VERSION: "0.34.0"

# As GitHub Action does not allow environment variables
# to be used in services definitions, these are only for
Expand Down
6 changes: 3 additions & 3 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
repos:
- repo: https://github.com/asottile/pyupgrade
rev: v3.13.0
rev: v3.15.0
hooks:
- id: pyupgrade
args: [--py39-plus]
- repo: https://github.com/psf/black-pre-commit-mirror
rev: 23.9.1 # needs to be also updated in requirements-dev.txt
rev: 23.12.1 # needs to be also updated in requirements-dev.txt
hooks:
- id: black
language_version: python3
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.4.0
rev: v4.5.0
hooks:
- id: trailing-whitespace
exclude_types: ["svg"]
Expand Down
5 changes: 1 addition & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,7 @@ clean-back: ## Remove Python bytecode files (*.pyc)
find . -name '*.pyc' -exec rm {} \;

list-outdated-back: ## List outdated Python packages
@echo 'Info: You need to check `easy-thumbnails` version manually!'
@echo "Package Version Latest Type"
@echo "----------------------- --------- --------- -----"
@pip list --outdated | grep "`awk -F== '{ print $$1 }' requirements*.txt | tr -s '\n' '\n' | sort`"
python scripts/check_requirements_versions.py requirements*.txt

##
## ~ Frontend
Expand Down
12 changes: 6 additions & 6 deletions requirements-dev.txt
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
-r requirements.txt

black==23.9.1 # needs to be also updated in .pre-commit-config.yaml
colorlog==6.7.0
django-debug-toolbar==3.8.1
black==23.12.1 # needs to be also updated in .pre-commit-config.yaml
colorlog==6.8.0
django-debug-toolbar==4.2.0
django-extensions==3.2.3
Faker==19.6.2
pre-commit==3.4.0
Faker==22.2.0
pre-commit==3.6.0
PyYAML==6.0.1
selenium==4.9.1
Sphinx==7.2.6
sphinx-rtd-theme==1.3.0
sphinx-rtd-theme==2.0.0
8 changes: 4 additions & 4 deletions requirements-prod.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
-r requirements.txt

gunicorn==20.1.0
mysqlclient==2.1.1
sentry-sdk==1.10.1
ujson==5.4.0
gunicorn==21.2.0
mysqlclient==2.2.1
sentry-sdk==1.39.2
ujson==5.9.0
14 changes: 7 additions & 7 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,20 +9,20 @@ django-crispy-forms==1.14.0
django-model-utils==4.3.1
django-munin==0.2.1
django-recaptcha==3.0.0
Django==3.2.21
Django==3.2.23
easy-thumbnails[svg]==2.8.5
factory-boy==3.3.0
geoip2==4.7.0
GitPython==3.1.37
geoip2==4.8.0
GitPython==3.1.41
homoglyphs==2.0.4
lxml==4.9.3
Pillow==10.0.1
lxml==5.1.0
Pillow==10.2.0
pymemcache==4.0.0
requests==2.31.0

# Api dependencies
django-cors-headers==4.2.0
django-filter==23.3
django-cors-headers==4.3.1
django-filter==23.5
django-oauth-toolkit==1.7.0
djangorestframework==3.14.0
drf-extensions==0.7.1
Expand Down
71 changes: 71 additions & 0 deletions scripts/check_requirements_versions.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
import re
import requests
from packaging import version
from pathlib import Path

print_red = lambda x: print("\33[91m", x, "\33[0m")
print_green = lambda x: print("\33[92m", x, "\33[0m")
print_yellow = lambda x: print("\33[93m", x, "\33[0m")

# Regex matching some_weird_package2[full]==4.3.2abcd
regex = re.compile(r"^[a-zA-Z0-9_\-\[\]]+==[a-zA-Z0-9.]+")


def check_requirements_versions(requirements_files):
for requirements_file in requirements_files:
requirements_path = Path(requirements_file)

if not requirements_path.exists():
print(f"{requirements_path.name} does not exists.")
print()
continue

with open(requirements_path) as f:
requirements = f.readlines()

print(f" #### {requirements_path.name}")
print()
print(" Package Version Latest ")
print(" ----------------------------- -------------- ---------------")

for line in requirements:
match = regex.match(line)
if not match:
continue

# Extract package and version from regex match (e.g. some_weird_package2[full] and 4.3.2abcd)
# and remove the extras requirements if present (e.g. remove [full] leaving only some_weird_package2)
package, requirements_version = match.group().split("==")
if "[" in package:
package = package[: package.index("[")]

# Retrieve package info from Pypi and extract latest version
response = requests.get(f"https://pypi.org/pypi/{package}/json")
latest_version = response.json().get("info").get("version")

# Print with colors:
# - green if versions are exactly equal (no update available)
# - yellow if major versions are equal (minor or patch update available)
# - red otherwise (major update available or another issue)
print_with_colors = print_red
if version.parse(latest_version) == version.parse(requirements_version):
print_with_colors = print_green
elif version.parse(latest_version).major == version.parse(requirements_version).major:
print_with_colors = print_yellow

print_with_colors(f"{package:30}{requirements_version:15}{latest_version:15}")

print()


if __name__ == "__main__":
import argparse

parser = argparse.ArgumentParser()
parser.add_argument("requirements_file", nargs="+", help="requirements file")
args = parser.parse_args()

try:
check_requirements_versions(args.requirements_file)
except KeyboardInterrupt:
pass

0 comments on commit 26048eb

Please sign in to comment.