generated from ansys/template
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
48 - Add dependency version constraints (#53)
* Add minimum versions for runtime dependencies, also update gitignore * Fix minimum version * Add generate_requirements.py script and remove manually added files * Add commit hook to the repo, add usage instructions and update docs * Add newlines to generated requiremetns * Remove blank requirements.txt * Review comments - Run black on generate_requirements.py - Add to lint targets - Roll back requests-negotiate-sspi to pypi latest release - Make hook somewhat tolerant to differences in python installation names
- Loading branch information
Showing
11 changed files
with
126 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
#!/bin/bash | ||
# | ||
# A pre-commit hook to automatically generate requirements files | ||
# from the install_requires and extra_requires entries in the | ||
# setup.cfg file. | ||
# These are only present to allow github's dependabot tool to actually | ||
# monitor our packages | ||
|
||
# Redirect output to stderr. | ||
exec 1>&2 | ||
|
||
pythonAliases=("python3" "py" "python") | ||
hasPython=0 | ||
|
||
for alias in "${pythonAliases[@]}"; do | ||
if command -v "$alias"; then | ||
pythonAlias="$alias" | ||
hasPython=1 | ||
break | ||
fi | ||
done | ||
|
||
if [ -z "$hasPython" ]; then | ||
echo "No python was detected, ensure it is available on your path as one of:" | ||
echo "${pythonAliases[*]}" | ||
exit 1 | ||
fi | ||
|
||
ROOT_DIR=$(git rev-parse --show-toplevel) | ||
pushd "$ROOT_DIR/requires" || exit 1 | ||
"$pythonAlias" ./generate_requirements.py | ||
if test -f "./.updated"; then | ||
rm ./.updated | ||
git add ./*_requirements.txt | ||
fi | ||
popd || exit 0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
import os | ||
import shutil | ||
import sys | ||
|
||
from setuptools.config import read_configuration | ||
|
||
|
||
def item_generator(things): | ||
for item in things: | ||
yield item | ||
yield "\n" | ||
|
||
|
||
setup_info = read_configuration("../setup.cfg") | ||
|
||
install_requires = [] | ||
extras_require = {} | ||
|
||
if "options" in setup_info: | ||
info_options = setup_info["options"] | ||
if "install_requires" in info_options: | ||
install_requires = info_options["install_requires"] | ||
if "extras_require" in info_options: | ||
extras_require = info_options["extras_require"] | ||
|
||
# Copy all existing requirements.txt files to allow us to roll-back if something goes wrong | ||
for file in os.listdir("./"): | ||
if file.endswith("requirements.txt"): | ||
shutil.move(file, f"./{file}.orig") | ||
|
||
try: | ||
with open("./package_requirements.txt", "w", encoding="utf8") as fp: | ||
print("Writing package requirements to package_requirements.txt") | ||
fp.writelines(item_generator(install_requires)) | ||
|
||
for extra, requirements in extras_require.items(): | ||
file_name = f"{extra}_requirements.txt" | ||
print(f"Writing extra requirements for {extra} to {file_name}") | ||
with open(file_name, "w", encoding="utf8") as fp: | ||
fp.writelines(item_generator(requirements)) | ||
|
||
with open("./.updated", "w") as fp: | ||
fp.write("updated") | ||
|
||
for file in os.listdir("./"): | ||
if file.endswith(".orig"): | ||
os.remove(file) | ||
|
||
except (IOError, OSError) as excinfo: | ||
print("An error occurred:") | ||
print(excinfo) | ||
|
||
for file in os.listdir("./"): | ||
if file.endswith(".orig"): | ||
shutil.move(file, file[:-5]) | ||
|
||
print("Rolled back to original state, aborting") | ||
sys.exit(1) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
requests-kerberos >= 0.13.0; sys_platform == "linux" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
requests_oauthlib >= 1.2 | ||
keyring >= 22.0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
requests >= 2.26 | ||
requests-negotiate-sspi >= 0.5.2; sys_platform == "win32" | ||
requests-ntlm >= 1.1.0 | ||
pyparsing >= 3.0 | ||
python-dateutil >= 2.6.1 | ||
typing-extensions >= 3.7; python_version < '3.8' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters