-
Notifications
You must be signed in to change notification settings - Fork 436
Make create-env-files.sh respect min python version supported
#1446
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -16,36 +16,56 @@ | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| set -o errexit | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| set -o nounset | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| declare -r usage="Usage: ${0} [-h] [UV_OPTIONS] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| # Go to the top of the local TFQ git tree. Do it early in case this fails. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| script_dir=$(CDPATH="" cd -- "$(dirname -- "${0}")" && pwd -P) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| repo_dir=$(git -C "${script_dir}" rev-parse --show-toplevel 2>/dev/null) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| cd "${repo_dir}" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+20
to
+22
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If the script is run outside of a git repository (for example, from a source archive/tarball) or if
Suggested change
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| default_min_python=$(python3 -c 'import re | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is way too complicated and as is it extracts the and bump it up when the minimum required version goes up. Add: not needed at all per #1446 (comment)
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Setup.py is going away in another PR, which is why this doesn't look in setup.py |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| s = open("pyproject.toml").read() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| m = re.search(r"requires-python.*?>=?(\d+\.\d+)", s) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if not m: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| m = re.search(r"target-version.*?py(\d)(\d+)", s) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| print(m.group(1) if "requires-python" in m.re.pattern else m.expand(r"\1.\2")) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ' 2>/dev/null || echo "3.10") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+24
to
+30
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If
Suggested change
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Slop and Bloat Gemini, Yuck! |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| declare -r usage="Usage: ${0} [-h] [-p X.Y] [UV_OPTIONS] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Generate environment files for OpenFermion development using uv's | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 'universal' option, making the result compatible with multiple | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Python versions. The output is written to subdirectories under | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| dev_tools/requirements/. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Options: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| -h Show this help message and exit | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| -h Show this help message and exit | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| -p X.Y Minimum Python version to support (default: ${default_min_python}) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| All other options on the command line will be passed directly to | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 'uv pip compile'. Run 'uv pip compile --help' to learn about the | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| options available." | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| min_python=("--python-version" "${default_min_python}") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| while [[ $# -gt 0 ]]; do | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| case "${1}" in | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| -h|--help) echo "${usage}"; exit 0 ;; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| -p|--min-python|--python-version) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is shadowing the uv-pip I recommend to add the diff --git a/pyproject.toml b/pyproject.toml
index 72ba61d..b8de85d 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -73,4 +73,5 @@ follow_untyped_imports = true
[tool.uv.pip]
universal = true
generate-hashes = true
custom-compile-command = "dev_tools/requirements/create-env-files.sh"
+python-version = "3.10"
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if [[ $# -lt 2 || -z "${2:-}" ]]; then | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| echo "Error: option '${1}' requires an argument" >&2 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| echo "${usage}" >&2 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| exit 1 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| fi | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| min_python=("--python-version" "${2}") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| shift 2 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ;; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| *) break ;; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| esac | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| done | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
48
to
62
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The current argument parsing loop terminates on the first unrecognized option (using We can fix this by collecting unrecognized options into an array and resetting the positional parameters (
Suggested change
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| # Go to the top of the local TFQ git tree. Do it early in case this fails. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| script_dir=$(CDPATH="" cd -- "$(dirname -- "${0}")" && pwd -P) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| repo_dir=$(git -C "${script_dir}" rev-parse --show-toplevel 2>/dev/null) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| cd "${repo_dir}" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| mkdir -p dev_tools/requirements/envs dev_tools/requirements/max_compat | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| # ~~~~ Generate basic requirements files ~~~~ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| uv pip compile "$@" \ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| uv pip compile "${min_python[@]}" "$@" \ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This and below can be reverted after setting python-version in pyproject.toml. |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| -o dev_tools/requirements/envs/dev.env.txt \ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| dev_tools/requirements/deps/format.txt \ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| dev_tools/requirements/deps/mypy.txt \ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -56,45 +76,45 @@ uv pip compile "$@" \ | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| dev_tools/requirements/deps/runtime.txt \ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| dev_tools/requirements/deps/shellcheck.txt | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| uv pip compile "$@" \ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| uv pip compile "${min_python[@]}" "$@" \ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| -o dev_tools/requirements/envs/format.env.txt \ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| -c dev_tools/requirements/envs/dev.env.txt \ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| dev_tools/requirements/deps/format.txt \ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| dev_tools/requirements/deps/runtime.txt | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| uv pip compile "$@" \ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| uv pip compile "${min_python[@]}" "$@" \ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| -o dev_tools/requirements/envs/pylint.env.txt \ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| -c dev_tools/requirements/envs/dev.env.txt \ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| dev_tools/requirements/deps/pylint.txt \ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| dev_tools/requirements/deps/runtime.txt | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| uv pip compile "$@" \ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| uv pip compile "${min_python[@]}" "$@" \ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| -o dev_tools/requirements/envs/pytest.env.txt \ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| -c dev_tools/requirements/envs/dev.env.txt \ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| dev_tools/requirements/deps/pytest.txt \ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| dev_tools/requirements/deps/runtime.txt | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| uv pip compile "$@" \ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| uv pip compile "${min_python[@]}" "$@" \ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| -o dev_tools/requirements/envs/pytest-extra.env.txt \ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| -c dev_tools/requirements/envs/dev.env.txt \ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| dev_tools/requirements/deps/pytest.txt \ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| dev_tools/requirements/deps/resource_estimates_runtime.txt \ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| dev_tools/requirements/deps/runtime.txt | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| uv pip compile "$@" \ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| uv pip compile "${min_python[@]}" "$@" \ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| -o dev_tools/requirements/envs/mypy.env.txt \ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| -c dev_tools/requirements/envs/dev.env.txt \ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| dev_tools/requirements/deps/mypy.txt \ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| dev_tools/requirements/deps/runtime.txt | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| uv pip compile "$@" \ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| uv pip compile "${min_python[@]}" "$@" \ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| -o dev_tools/requirements/envs/shellcheck.env.txt \ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| -c dev_tools/requirements/envs/dev.env.txt \ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| dev_tools/requirements/deps/shellcheck.txt | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| # ~~~~ Generate max_compat files ~~~~ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| uv pip compile "$@" \ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| uv pip compile "${min_python[@]}" "$@" \ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| -o dev_tools/requirements/max_compat/pytest-max-compat.env.txt \ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| -c dev_tools/requirements/deps/oldest-versions.txt \ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| dev_tools/requirements/deps/pytest.txt \ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should keep the stderr message so user gets a clue what is going on if the script exits here on git-rev-parse failure.