Skip to content

Commit

Permalink
Merge pull request #176 from jezdez/22.9.0_he4310d
Browse files Browse the repository at this point in the history
conda v22.9.0 #2
  • Loading branch information
beckermr authored Sep 27, 2022
2 parents c6f96fe + 6cf31c8 commit 8d756ad
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 80 deletions.
34 changes: 0 additions & 34 deletions .ci_support/migrations/python310.yaml

This file was deleted.

23 changes: 0 additions & 23 deletions recipe/gh11734.patch

This file was deleted.

64 changes: 44 additions & 20 deletions recipe/gh9946_utf_16_replacement.patch
Original file line number Diff line number Diff line change
@@ -1,43 +1,68 @@
diff --color -Naur conda-4.10.3.orig/conda/core/portability.py conda-4.10.3/conda/core/portability.py
--- conda-4.10.3.orig/conda/core/portability.py 2021-06-29 23:30:51.000000000 -0300
+++ conda-4.10.3/conda/core/portability.py 2021-09-09 16:15:55.872345749 -0300
@@ -3,6 +3,10 @@
diff --color -Naur conda-22.9.0.orig/conda/core/portability.py conda-22.9.0/conda/core/portability.py
--- conda-22.9.0.orig/conda/core/portability.py 2022-06-29 23:30:51.000000000 -0300
+++ conda-22.9.0/conda/core/portability.py 2022-09-09 16:15:55.872345749 -0300
@@ -3,6 +3,9 @@
# SPDX-License-Identifier: BSD-3-Clause
from __future__ import absolute_import, division, print_function, unicode_literals

+# force encodings to be available when updating python.
+# xref.: https://github.com/conda-forge/conda-feedstock/pull/135
+from encodings import utf_8, utf_16, utf_16_le, utf_16_be, utf_32, utf_32_le, utf_32_be
+
from logging import getLogger
from os.path import realpath
import re
@@ -68,21 +72,40 @@
@@ -77,34 +80,52 @@ def update_prefix(


def replace_prefix(mode, data, placeholder, new_prefix):
- if mode == FileMode.text:
- if not on_win:
- # if new_prefix contains spaces, it might break the shebang!
- # handle this by escaping the spaces early, which will trigger a
- # /usr/bin/env replacement later on
- newline_pos = data.find(b"\n")
- if newline_pos > -1:
- shebang_line, rest_of_data = data[:newline_pos], data[newline_pos:]
- shebang_placeholder = f"#!{placeholder}".encode('utf-8')
- if shebang_placeholder in shebang_line:
- escaped_shebang = f"#!{new_prefix}".replace(" ", "\\ ").encode('utf-8')
- shebang_line = shebang_line.replace(shebang_placeholder, escaped_shebang)
- data = shebang_line + rest_of_data
- # the rest of the file can be replaced normally
- data = data.replace(placeholder.encode('utf-8'), new_prefix.encode('utf-8'))
- elif mode == FileMode.binary:
- data = binary_replace(data, placeholder.encode('utf-8'), new_prefix.encode('utf-8'))
- else:
- raise CondaIOError("Invalid mode: %r" % mode)
+ popular_encodings = [
+ 'utf-8',
+ "utf-8",
+ # Make sure to specify -le and -be so that the UTF endian prefix
+ # doesn't show up in the string
+ 'utf-16-le', 'utf-16-be',
+ 'utf-32-le', 'utf-32-be'
+ "utf-16-le",
+ "utf-16-be",
+ "utf-32-le",
+ "utf-32-be",
+ ]
+ for encoding in popular_encodings:
+ if mode == FileMode.text:
+ data = data.replace(placeholder.encode(encoding),
+ new_prefix.encode(encoding))
+ if not on_win:
+ # if new_prefix contains spaces, it might break the shebang!
+ # handle this by escaping the spaces early, which will trigger a
+ # /usr/bin/env replacement later on
+ newline_pos = data.find(b"\n")
+ if newline_pos > -1:
+ shebang_line, rest_of_data = data[:newline_pos], data[newline_pos:]
+ shebang_placeholder = f"#!{placeholder}".encode(encoding)
+ if shebang_placeholder in shebang_line:
+ escaped_shebang = f"#!{new_prefix}".replace(" ", "\\ ").encode(encoding)
+ shebang_line = shebang_line.replace(shebang_placeholder, escaped_shebang)
+ data = shebang_line + rest_of_data
+ # the rest of the file can be replaced normally
+ data = data.replace(placeholder.encode(encoding), new_prefix.encode(encoding))
+ elif mode == FileMode.binary:
+ data = binary_replace(data,
+ placeholder.encode(encoding),
+ new_prefix.encode(encoding),
+ encoding=encoding)
+ data = binary_replace(
+ data, placeholder.encode(encoding), new_prefix.encode(encoding), encoding=encoding
+ )
+ else:
+ raise CondaIOError("Invalid mode: %r" % mode)
return data
Expand All @@ -50,7 +75,6 @@ diff --color -Naur conda-4.10.3.orig/conda/core/portability.py conda-4.10.3/cond
replaced with `b` and the remaining string is padded with null characters.
All input arguments are expected to be bytes objects.
+
+
+ Parameters
+ ----------
+ encoding: str
Expand All @@ -60,7 +84,7 @@ diff --color -Naur conda-4.10.3.orig/conda/core/portability.py conda-4.10.3/cond
if on_win:
# on Windows for binary files, we currently only replace a pyzzer-type entry point
# we skip all other prefix replacement
@@ -99,7 +122,10 @@
@@ -121,7 +142,10 @@ def binary_replace(data, a, b):
return match.group().replace(a, b) + b'\0' * padding

original_data_len = len(data)
Expand All @@ -72,9 +96,9 @@ diff --color -Naur conda-4.10.3.orig/conda/core/portability.py conda-4.10.3/cond
data = pat.sub(replace, data)
assert len(data) == original_data_len

diff --color -Naur conda-4.10.3.orig/tests/test_install.py conda-4.10.3/tests/test_install.py
--- conda-4.10.3.orig/tests/test_install.py 2021-06-29 23:30:51.000000000 -0300
+++ conda-4.10.3/tests/test_install.py 2021-09-09 16:16:53.941678976 -0300
diff --color -Naur conda-22.9.0.orig/tests/test_install.py conda-22.9.0/tests/test_install.py
--- conda-22.9.0.orig/tests/test_install.py 2022-06-29 23:30:51.000000000 -0300
+++ conda-22.9.0/tests/test_install.py 2022-09-09 16:16:53.941678976 -0300
@@ -34,9 +34,14 @@

@pytest.mark.xfail(on_win, reason="binary replacement on windows skipped", strict=True)
Expand Down
5 changes: 2 additions & 3 deletions recipe/meta.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{% set on_win = SUBDIR in ('win-64', 'win-32') %}
{% set version = "4.14.0" %}
{% set version = "22.9.0" %}
# Running pytest requires the inclusion of test files which baloons
# the size of the package; values can be "yes" or "no"
{% set run_pytest = "no" %}
Expand All @@ -11,10 +11,9 @@ package:
source:
fn: conda-{{ version }}.tar.gz
url: https://github.com/conda/conda/archive/{{ version }}.tar.gz
sha256: 9b9fa3e20a2bcdd30496fc886bdd28b102e3a87eb3cdb4659b0a7e4e9edd52a8
sha256: 35c924fab82e1be7a3359494ff02eab2b2d9b04004cc689e41f84edc1fb853c0
patches:
- gh9946_utf_16_replacement.patch
- gh11734.patch

build:
number: 0
Expand Down

0 comments on commit 8d756ad

Please sign in to comment.