Skip to content
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

Fix channels_remap and add regression test for percent-encoded packages #909

Merged
merged 11 commits into from
Dec 5, 2024
Merged
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
20 changes: 8 additions & 12 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,6 @@ jobs:
matrix:
include:
# UBUNTU
- os: ubuntu-latest
python-version: "3.8"
conda-standalone: conda-standalone
check-docs: true
- os: ubuntu-latest
python-version: "3.9"
conda-standalone: conda-standalone
Expand All @@ -58,12 +54,9 @@ jobs:
conda-standalone: conda-standalone
# MACOS
- os: macos-13
python-version: "3.8"
python-version: "3.9"
conda-standalone: conda-standalone-nightly
# Not running for 3.9, 3.10 to save some CI resources
# - os: macos
# python-version: "3.9"
# conda-standalone: conda-standalone
# Not running for 3.10 to save some CI resources
# - os: macos-13
# python-version: "3.10"
# conda-standalone: micromamba
Expand All @@ -74,9 +67,6 @@ jobs:
python-version: "3.12"
conda-standalone: micromamba
# WINDOWS
- os: windows-latest
python-version: "3.8"
conda-standalone: conda-standalone
- os: windows-latest
python-version: "3.9"
conda-standalone: conda-standalone-nightly
Expand Down Expand Up @@ -132,6 +122,12 @@ jobs:
conda activate constructor-dev
echo "CONSTRUCTOR_CONDA_EXE=$CONDA_PREFIX/standalone_conda/conda.exe" >> $GITHUB_ENV
fi
- name: conda info
run: conda info
- name: conda list
run: conda list
- name: conda config
run: conda config --show-sources
- name: Run unit tests
run: |
pytest -vv --cov=constructor --cov-branch tests/ -m "not examples"
Expand Down
25 changes: 23 additions & 2 deletions constructor/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -178,14 +178,35 @@ def ensure_transmuted_ext(info, url):

def get_final_url(info, url):
mapping = info.get('channels_remap', [])
if not url.lower().endswith((".tar.bz2", ".conda", "/")):
url += "/"
added_slash = True
else:
added_slash = False
for entry in mapping:
src = entry['src']
dst = entry['dest']
if url.startswith(src):
new_url = url.replace(src, dst)
# Treat http:// and https:// as equivalent
if src.startswith("http"):
srcs = tuple(
dict.fromkeys(
[
src.replace("http://", "https://"),
src.replace("https://", "http://")
]
)
)
else:
srcs = (src,)
if url.startswith(srcs):
new_url = url
for src in srcs:
new_url = new_url.replace(src, dst)
if url.endswith(".tar.bz2"):
logger.warning("You need to make the package %s available "
"at %s", url.rsplit('/', 1)[1], new_url)
if added_slash:
new_url = new_url[:-1]
return new_url
return url

Expand Down
17 changes: 17 additions & 0 deletions examples/regressions/construct.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
name: regressions

version: 0.0.1

keep_pkgs: True

channels:
- conda-forge

specs:
- x264 # check https://github.com/conda/constructor/issues/908

initialize_by_default: false
register_python: false
check_path_spaces: false
check_path_length: false
installer_type: all
20 changes: 20 additions & 0 deletions news/909-cls-compat
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
### Enhancements

* <news item>

### Bug fixes

* `channels_remap` is now insensitive to `http` vs `https`, and trailing slashes. (#909)
* Add a regression test for packages including percent-encodable characters in their filenames. (#908 via #909)

### Deprecations

* <news item>

### Docs

* <news item>

### Other

* Do not run CI against Python 3.8. (#909)
1 change: 1 addition & 0 deletions recipe/meta.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ requirements:
- nsis >=3.08 # [win]
run_constrained: # [unix]
- nsis >=3.08 # [unix]
- conda-libmamba-solver !=24.11.0

test:
source_files:
Expand Down
13 changes: 13 additions & 0 deletions tests/test_examples.py
Original file line number Diff line number Diff line change
Expand Up @@ -911,3 +911,16 @@ def test_ignore_condarc_files(tmp_path, monkeypatch, request):
# the bogus .condarc file.
# pkg installers unfortunately do not output any errors into the log.
assert proc.stderr.count("Bad conversion of configurable") == 4


def test_regressions(tmp_path, request):
input_path = _example_path("regressions")
for installer, install_dir in create_installer(input_path, tmp_path):
_run_installer(
input_path,
installer,
install_dir,
request=request,
check_subprocess=True,
uninstall=True,
)
Loading