Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 49 additions & 0 deletions edx_repo_tools/resolve-common-constraints.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
# Fetching latest copy of common constraints from edx-lint repo
wget -O "requirements/common_constraints.txt" https://raw.githubusercontent.com/edx/edx-lint/master/edx_lint/files/common_constraints.txt || touch "requirements/common_constraints.txt"

common_constraints=()
local_constraints=()
updated_common_constraints=()

while IFS= read -r line; do
if [ -n "$line" ] && [ "${line:0:1}" != "#" ];
then
# Read common constraints from common constraints file
common_constraints+=("$line")
fi
done < requirements/common_constraints.txt

while IFS= read -r line; do
if [ -n "$line" ] && [ "${line:0:1}" != "#" ] && [ "${line:0:1}" != "-" ];
then
# Read local constraints from constraints file for comparison
local_constraints+=("$line")
fi
done < requirements/constraints.txt


for common in "${common_constraints[@]}"
do
# Extract package name from constraint
common_package=$(echo "$common" | sed 's/\([a-zA-Z0-9-]*\).*/\1/')
found=false
for local in "${local_constraints[@]}"
do
# Extract package name from constraint
local_package=$(echo "$local" | sed 's/\([a-zA-Z0-9-]*\).*/\1/')
if [ "$common_package" = "$local_package" ];
then
# Update the flag if local pin is found on same package
found=true
break
fi
done
if [ "$found" = false ];
then
updated_common_constraints+=("$common")
fi
done

# Adding filtered common constraints into a file before running pip-compile and add reference of this file in constraints file.
printf "%s\n" "${updated_common_constraints[@]}" > requirements/common_constraints.txt
echo "-c common_constraints.txt" >> requirements/constraints.txt
3 changes: 2 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

setup(
name='edx-repo-tools',
version='0.3.2',
version='0.3.3',
description="This repo contains a number of tools Open edX uses for working with GitHub repositories.",
long_description=long_description,
license='Apache',
Expand Down Expand Up @@ -52,6 +52,7 @@
'conventional_commits = edx_repo_tools.conventional_commits.commitstats:main',
'replace_render_to_response = edx_repo_tools.codemods.django3.replace_render_to_response:main',
'add_django32_settings = edx_repo_tools.codemods.django3.add_new_django32_settings:main',
'resolve_common_constraints = edx_repo_tools.resolve_common_constraints',
],
},
package_data={
Expand Down