-
Notifications
You must be signed in to change notification settings - Fork 167
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
Add support for virtual_specs
checks before installation
#809
Changes from 31 commits
46c8f19
65ddaba
39b61cd
75dfbfa
b6c4233
d9f7133
a017d7d
220f762
2960219
b36495f
26ccbe4
39f689d
3154b02
247bd45
fd55c51
5399871
ec575b6
df02fbd
8600666
adcbab9
263bd0e
b17085e
ab60642
8b9146c
553b41a
86b958d
6576d53
28f74d5
a59d2c5
858586d
4f46d6c
3930766
4c6664f
471bad4
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 |
---|---|---|
|
@@ -21,6 +21,32 @@ if ! echo "$0" | grep '\.sh$' > /dev/null; then | |
return 1 | ||
fi | ||
|
||
#if osx and min_osx_version | ||
min_osx_version="__MIN_OSX_VERSION__" | ||
system_osx_version=$(SYSTEM_VERSION_COMPAT=0 sw_vers -productVersion) | ||
# shellcheck disable=SC2183 disable=SC2046 | ||
int_min_osx_version="$(printf "%02d%02d%02d" $(echo "$min_osx_version" | sed 's/\./ /g'))" | ||
# shellcheck disable=SC2183 disable=SC2046 | ||
int_system_osx_version="$(printf "%02d%02d%02d" $(echo "$system_osx_version" | sed 's/\./ /g'))" | ||
if [ "$int_system_osx_version" -lt "$int_min_osx_version" ]; then | ||
echo "Installer requires macOS >=${min_osx_version}, but system has ${system_osx_version}." | ||
exit 1 | ||
fi | ||
#endif | ||
#if linux and min_glibc_version | ||
min_glibc_version="__MIN_GLIBC_VERSION__" | ||
# ldd reports glibc in the last field of the first line | ||
system_glibc_version=$(ldd --version | awk 'NR==1{print $NF}') | ||
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.
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. You can use https://github.com/Docker-Hub-frolvlad/docker-alpine-glibc if you want to test. 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. Thanks Isuru! Added a workaround for musl systems. Invoking ld.so directly in CentOS does not work so I'll leave it with those two branches for now. |
||
# shellcheck disable=SC2183 disable=SC2046 | ||
int_min_glibc_version="$(printf "%02d%02d%02d" $(echo "$min_glibc_version" | sed 's/\./ /g'))" | ||
# shellcheck disable=SC2183 disable=SC2046 | ||
int_system_glibc_version="$(printf "%02d%02d%02d" $(echo "$system_glibc_version" | sed 's/\./ /g'))" | ||
if [ "$int_system_glibc_version" -lt "$int_min_glibc_version" ]; then | ||
echo "Installer requires GLIBC >=${min_glibc_version}, but system has ${system_glibc_version}." | ||
exit 1 | ||
fi | ||
#endif | ||
|
||
# Export variables to make installer metadata available to pre/post install scripts | ||
# NOTE: If more vars are added, make sure to update the examples/scripts tests too | ||
|
||
|
@@ -423,6 +449,17 @@ export TMP_BACKUP="${TMP:-}" | |
export TMP="$PREFIX/install_tmp" | ||
mkdir -p "$TMP" | ||
|
||
# Check whether the virtual specs can be satisfied | ||
# We need to specify CONDA_SOLVER=classic for conda-standalone | ||
# to work around this bug in conda-libmamba-solver: | ||
# https://github.com/conda/conda-libmamba-solver/issues/480 | ||
# shellcheck disable=SC2050 | ||
if [ "__VIRTUAL_SPECS__" != "" ]; then | ||
CONDA_QUIET="$BATCH" \ | ||
CONDA_SOLVER="classic" \ | ||
marcoesters marked this conversation as resolved.
Show resolved
Hide resolved
|
||
"$CONDA_EXEC" create --dry-run --prefix "$PREFIX" --offline __VIRTUAL_SPECS__ | ||
fi | ||
|
||
# Create $PREFIX/.nonadmin if the installation didn't require superuser permissions | ||
if [ "$(id -u)" -ne 0 ]; then | ||
touch "$PREFIX/.nonadmin" | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -282,3 +282,30 @@ def check_required_env_vars(env_vars): | |
raise RuntimeError( | ||
f"Missing required environment variables {', '.join(missing_vars)}." | ||
) | ||
|
||
|
||
def parse_virtual_specs(info) -> dict: | ||
from .conda_interface import MatchSpec # prevent circular import | ||
|
||
specs = {"__osx": {}, "__glibc": {}} | ||
for spec in info.get("virtual_specs", ()): | ||
spec = MatchSpec(spec) | ||
if spec.name not in ("__osx", "__glibc"): | ||
continue | ||
if not spec.version: | ||
continue | ||
if "|" in spec.version.spec_str: | ||
raise ValueError("Can't process `|`-joined versions. Only `,` is allowed.") | ||
versions = spec.version.tup if "," in spec.version.spec_str else (spec.version,) | ||
for version in versions: | ||
operator = version.operator_func.__name__ | ||
if operator == "ge": | ||
specs[spec.name]["min"] = str(version.matcher_vo) | ||
elif operator == "lt" and spec.name == "__osx": | ||
specs[spec.name]["before"] = str(version.matcher_vo) | ||
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. Maybe I'm still jet lagged, but is this used anywhere? 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. Yes, at https://github.com/conda/constructor/pull/809/files#diff-620cc606622328c2ee309e832c215dbf23da87df82a5b10bd09ced66c2f9b503R200 ('before' it's part of the XML attributes that key accepts) |
||
else: | ||
raise ValueError( | ||
f"Invalid version operator for {spec}. " | ||
"__osx only supports `<` or `>=`; __glibc only supports `>=`." | ||
) | ||
return specs |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
name: virtual_specs | ||
|
||
version: 0.0.1 | ||
|
||
keep_pkgs: True | ||
|
||
channels: | ||
- conda-forge | ||
|
||
specs: | ||
- ca-certificates | ||
|
||
virtual_specs: | ||
- __osx>=30,<31 # [osx] | ||
- __glibc>=20 # [linux] | ||
- __win<0 # [win] | ||
|
||
initialize_by_default: false | ||
register_python: false | ||
check_path_spaces: false | ||
check_path_length: false | ||
installer_type: all |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
### Enhancements | ||
|
||
* A new setting `virtual_specs` allows the installer to run some solver checks before the installation proceeds. Useful for checking whether certain virtual package versions can be satisfied. (#809) | ||
|
||
### Bug fixes | ||
|
||
* <news item> | ||
|
||
### Deprecations | ||
|
||
* <news item> | ||
|
||
### Docs | ||
|
||
* <news item> | ||
|
||
### Other | ||
|
||
* <news item> |
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.
Is the condo exe compatible with a much lower bound than one would otherwise expect. Say 2.12 on Linux.
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.
Is seems that on Linux you use ldd but that on osx you use a dry run.
any way to also use shell commands on osx? I feel like that would be more robust to increases in minimum requirements in osx
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.
It's there:
https://github.com/conda/constructor/pull/809/files#diff-d5126ee7f99e6583ba9574579ff73994eaf0eebcfdc792a6deb00a0dc2158f6eR24-R35
And also for PKG:
https://github.com/conda/constructor/pull/809/files#diff-620cc606622328c2ee309e832c215dbf23da87df82a5b10bd09ced66c2f9b503R193-R203
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.
amazing, thanks!