diff --git a/conda_build/build.py b/conda_build/build.py index 450c8e2001..c8b86946f0 100644 --- a/conda_build/build.py +++ b/conda_build/build.py @@ -486,7 +486,7 @@ def detect_and_record_prefix_files(m, files, prefix): def sanitize_channel(channel): - return re.sub('\/t\/[a-zA-Z0-9\-]*\/', '/t//', channel) + return re.sub(r'\/t\/[a-zA-Z0-9\-]*\/', '/t//', channel) def write_info_files_file(m, files): @@ -1263,7 +1263,7 @@ def build(m, stats, post=None, need_source_download=True, need_reparse_in_env=Fa output_excludes = set(name for (name, variant) in m.other_outputs.keys()) if excludes or output_excludes: - exclude_pattern = re.compile('|'.join('(?:^{}(?:\s|$|\Z))'.format(exc) + exclude_pattern = re.compile(r'|'.join(r'(?:^{}(?:\s|$|\Z))'.format(exc) for exc in excludes | output_excludes)) # this metadata object may not be finalized - the outputs are, but this is the diff --git a/conda_build/convert.py b/conda_build/convert.py index 50255eeacb..30b23e272d 100644 --- a/conda_build/convert.py +++ b/conda_build/convert.py @@ -230,7 +230,7 @@ def update_lib_path(path, target_platform, temp_dir=None): elif target_platform == 'unix': python_version = retrieve_python_version(temp_dir) - renamed_lib_path = re.sub('\ALib', os.path.join('lib', python_version), path) + renamed_lib_path = re.sub('\ALib', os.path.join('lib', python_version), path.replace('\\', '\\\\')) return os.path.normpath(renamed_lib_path) diff --git a/conda_build/index.py b/conda_build/index.py index d72ddbbdb2..10bf487b56 100644 --- a/conda_build/index.py +++ b/conda_build/index.py @@ -143,7 +143,8 @@ def submit(self, fn, *args, **kwargs): "noarch", ) -os.environ['CONDA_ADD_ANACONDA_TOKEN'] = "false" +# TODO: this is to make sure that the index doesn't leak tokens. It breaks use of private channels, though. +# os.environ['CONDA_ADD_ANACONDA_TOKEN'] = "false" try: @@ -502,7 +503,7 @@ def _add_namespace_to_spec(fn, info, dep_str, namemap, missing_dependencies, sub return dep_str spec = MatchSpec(dep_str) - if spec.namespace: + if hasattr(spec, 'namespace') and spec.namespace: # this spec is fine return dep_str else: diff --git a/conda_build/os_utils/pyldd.py b/conda_build/os_utils/pyldd.py index 5256626378..f48bbe7c60 100644 --- a/conda_build/os_utils/pyldd.py +++ b/conda_build/os_utils/pyldd.py @@ -1104,7 +1104,7 @@ def inspect_linkages_otool(filename, arch='native'): args.extend(['-arch', os.uname()[4]]) args.extend(['-L', filename]) result = check_output(args).decode(encoding='ascii') - groups = re.findall('^\t(.*) \(compatibility', result, re.MULTILINE) + groups = re.findall(r'^\t(.*) \(compatibility', result, re.MULTILINE) return groups @@ -1115,7 +1115,7 @@ def inspect_linkages_ldd(filename): result, err = process.communicate() result = result.decode(encoding='ascii') err = err.decode(encoding='ascii') - groups = re.findall('^\t(?!linux-gate\.so\.1.*$)[^ ]+ => (.*) \([0-9a-fx]+\)', + groups = re.findall(r'^\t(?!linux-gate\.so\.1.*$)[^ ]+ => (.*) \([0-9a-fx]+\)', result, re.MULTILINE) return groups @@ -1171,9 +1171,9 @@ def ldd(*args): def main(argv): for idx, progname in enumerate(argv[0:2][::-1]): - if re.match('.*ldd(?:$|\.exe|\.py)', progname): + if re.match(r'.*ldd(?:$|\.exe|\.py)', progname): return ldd(*argv[2 - idx:]) - elif re.match('.*otool(?:$|\.exe|\.py)', progname): + elif re.match(r'.*otool(?:$|\.exe|\.py)', progname): return otool(*argv[2 - idx:]) elif os.path.isfile(progname): klass = codefile_class(progname) diff --git a/conda_build/render.py b/conda_build/render.py index aaa3e8a6f6..558cf8159f 100644 --- a/conda_build/render.py +++ b/conda_build/render.py @@ -446,7 +446,7 @@ def finalize_metadata(m, permit_unsatisfiable_variants=False): output_excludes = set(name for (name, variant) in m.other_outputs.keys()) if excludes or output_excludes: - exclude_pattern = re.compile('|'.join('(?:^{}(?:\s|$|\Z))'.format(exc) + exclude_pattern = re.compile(r'|'.join(r'(?:^{}(?:\s|$|\Z))'.format(exc) for exc in excludes | output_excludes)) parent_recipe = m.meta.get('extra', {}).get('parent_recipe', {}) @@ -484,7 +484,7 @@ def finalize_metadata(m, permit_unsatisfiable_variants=False): # on the keys in the 'pin_run_as_build' key in the variant, which is a list of package # names to have this behavior. if output_excludes: - exclude_pattern = re.compile('|'.join('(?:^{}(?:\s|$|\Z))'.format(exc) + exclude_pattern = re.compile(r'|'.join(r'(?:^{}(?:\s|$|\Z))'.format(exc) for exc in output_excludes)) pinning_env = 'host' if rendered_metadata.is_cross else 'build' diff --git a/conda_build/skeletons/pypi.py b/conda_build/skeletons/pypi.py index 51c1afa3fb..d8c72f0ab9 100644 --- a/conda_build/skeletons/pypi.py +++ b/conda_build/skeletons/pypi.py @@ -383,7 +383,7 @@ def skeletonize(packages, output_dir=".", version=None, recursive=False, # Fix the indents recipe_lines = [] for line in rendered_recipe.splitlines(): - match = re.search('^\s+(-) ', line, + match = re.search(r'^\s+(-) ', line, flags=re.MULTILINE) if match: pre, sep, post = line.partition('-') @@ -639,11 +639,11 @@ def convert_version(version): MARKER_RE = re.compile(r"(?P^[^=<>!\s]+)" - "\s*" - "(?P[=!><]=?\s*[^\s;]+)?" - "(?:\s+;\s+)?(?P[^=<>!\s;]+)?" - "\s*" - "(?P[=<>!\s]+[^=<>!\s]+)?" + r"\s*" + r"(?P[=!><]=?\s*[^\s;]+)?" + r"(?:\s+;\s+)?(?P[^=<>!\s;]+)?" + r"\s*" + r"(?P[=<>!\s]+[^=<>!\s]+)?" ) @@ -857,7 +857,7 @@ def get_package_metadata(package, d, data, output_dir, python_version, all_extra else: license_name = ' or '.join(licenses) # remove the word license from the license - clean_license_name = re.subn('(.*)\s+license', r'\1', license_name, flags=re.IGNORECASE)[0] + clean_license_name = re.subn(r'(.*)\s+license', r'\1', license_name, flags=re.IGNORECASE)[0] d['license'] = clean_license_name d['license_family'] = guess_license_family(license_name, allowed_license_families) if 'new_hash_value' in pkginfo: diff --git a/conda_build/source.py b/conda_build/source.py index de9d0b11b6..8065100f01 100644 --- a/conda_build/source.py +++ b/conda_build/source.py @@ -526,14 +526,14 @@ def _guess_patch_strip_level(filesstr, src_dir): def _get_patch_file_details(path): - re_files = re.compile('^(?:---|\+\+\+) ([^\n\t]+)') + re_files = re.compile(r'^(?:---|\+\+\+) ([^\n\t]+)') files = set() with io.open(path, errors='ignore') as f: files = [] first_line = True is_git_format = True for l in f.readlines(): - if first_line and not re.match('From [0-9a-f]{40}', l): + if first_line and not re.match(r'From [0-9a-f]{40}', l): is_git_format = False first_line = False m = re_files.search(l) diff --git a/tests/test-recipes/metadata/_numpy_xx/run_test.bat b/tests/test-recipes/metadata/_numpy_xx/run_test.bat index cf200831a2..d8f9b23383 100644 --- a/tests/test-recipes/metadata/_numpy_xx/run_test.bat +++ b/tests/test-recipes/metadata/_numpy_xx/run_test.bat @@ -1,5 +1,5 @@ @echo on conda list -p "%PREFIX%" --canonical if errorlevel 1 exit 1 -conda list -p "%PREFIX%" --canonical | grep "conda-build-test-numpy-build-run-1\.0-np112py.._0" +conda list -p "%PREFIX%" --canonical | grep "conda-build-test-numpy-build-run-1\.0-np115py.._0" if errorlevel 1 exit 1 diff --git a/tests/test-recipes/metadata/_numpy_xx/run_test.py b/tests/test-recipes/metadata/_numpy_xx/run_test.py index f7e879da49..9dc97bf96d 100644 --- a/tests/test-recipes/metadata/_numpy_xx/run_test.py +++ b/tests/test-recipes/metadata/_numpy_xx/run_test.py @@ -7,7 +7,7 @@ def main(): prefix = os.environ['PREFIX'] info_files = glob.glob(os.path.join(prefix, 'conda-meta', - 'conda-build-test-numpy-build-run-1.0-np112py*0.json')) + 'conda-build-test-numpy-build-run-1.0-np115py*0.json')) assert len(info_files) == 1 info_file = info_files[0] with open(info_file, 'r') as fh: @@ -21,7 +21,7 @@ def main(): assert depends[1].startswith('python ') import numpy - assert numpy.__version__[:4] == '1.12' + assert numpy.__version__[:4] == '1.15' if __name__ == '__main__': diff --git a/tests/test-recipes/metadata/_numpy_xx/run_test.sh b/tests/test-recipes/metadata/_numpy_xx/run_test.sh index 5183c4fceb..1e4bc63642 100644 --- a/tests/test-recipes/metadata/_numpy_xx/run_test.sh +++ b/tests/test-recipes/metadata/_numpy_xx/run_test.sh @@ -1,3 +1,3 @@ conda list -p $PREFIX --canonical # Test the build string. Should contain NumPy, but not the version -conda list -p $PREFIX --canonical | grep "conda-build-test-numpy-build-run-1\.0-np112py.._0" +conda list -p $PREFIX --canonical | grep "conda-build-test-numpy-build-run-1\.0-np115py.._0" diff --git a/tests/test-recipes/metadata/_numpy_xx_host/run_test.bat b/tests/test-recipes/metadata/_numpy_xx_host/run_test.bat index cf200831a2..d8f9b23383 100644 --- a/tests/test-recipes/metadata/_numpy_xx_host/run_test.bat +++ b/tests/test-recipes/metadata/_numpy_xx_host/run_test.bat @@ -1,5 +1,5 @@ @echo on conda list -p "%PREFIX%" --canonical if errorlevel 1 exit 1 -conda list -p "%PREFIX%" --canonical | grep "conda-build-test-numpy-build-run-1\.0-np112py.._0" +conda list -p "%PREFIX%" --canonical | grep "conda-build-test-numpy-build-run-1\.0-np115py.._0" if errorlevel 1 exit 1 diff --git a/tests/test-recipes/metadata/_numpy_xx_host/run_test.py b/tests/test-recipes/metadata/_numpy_xx_host/run_test.py index f7e879da49..9dc97bf96d 100644 --- a/tests/test-recipes/metadata/_numpy_xx_host/run_test.py +++ b/tests/test-recipes/metadata/_numpy_xx_host/run_test.py @@ -7,7 +7,7 @@ def main(): prefix = os.environ['PREFIX'] info_files = glob.glob(os.path.join(prefix, 'conda-meta', - 'conda-build-test-numpy-build-run-1.0-np112py*0.json')) + 'conda-build-test-numpy-build-run-1.0-np115py*0.json')) assert len(info_files) == 1 info_file = info_files[0] with open(info_file, 'r') as fh: @@ -21,7 +21,7 @@ def main(): assert depends[1].startswith('python ') import numpy - assert numpy.__version__[:4] == '1.12' + assert numpy.__version__[:4] == '1.15' if __name__ == '__main__': diff --git a/tests/test-recipes/metadata/_numpy_xx_host/run_test.sh b/tests/test-recipes/metadata/_numpy_xx_host/run_test.sh index 5183c4fceb..1e4bc63642 100644 --- a/tests/test-recipes/metadata/_numpy_xx_host/run_test.sh +++ b/tests/test-recipes/metadata/_numpy_xx_host/run_test.sh @@ -1,3 +1,3 @@ conda list -p $PREFIX --canonical # Test the build string. Should contain NumPy, but not the version -conda list -p $PREFIX --canonical | grep "conda-build-test-numpy-build-run-1\.0-np112py.._0" +conda list -p $PREFIX --canonical | grep "conda-build-test-numpy-build-run-1\.0-np115py.._0" diff --git a/tests/test_api_build.py b/tests/test_api_build.py index dc6b072338..7004788e5f 100644 --- a/tests/test_api_build.py +++ b/tests/test_api_build.py @@ -1109,12 +1109,12 @@ def test_setup_py_data_in_env(testing_config): def test_numpy_xx(testing_config): recipe = os.path.join(metadata_dir, '_numpy_xx') - api.build(recipe, config=testing_config, numpy='1.12') + api.build(recipe, config=testing_config, numpy='1.15', python="3.6") def test_numpy_xx_host(testing_config): recipe = os.path.join(metadata_dir, '_numpy_xx_host') - api.build(recipe, config=testing_config, numpy='1.12') + api.build(recipe, config=testing_config, numpy='1.15', python="3.6") def test_python_xx(testing_config): diff --git a/tests/test_api_skeleton.py b/tests/test_api_skeleton.py index 4f9dc5fcb5..6d55518966 100644 --- a/tests/test_api_skeleton.py +++ b/tests/test_api_skeleton.py @@ -110,7 +110,7 @@ def test_pypi_with_version_arg(testing_workdir): def test_pypi_with_extra_specs(testing_workdir): # regression test for https://github.com/conda/conda-build/issues/1697 - api.skeletonize('bigfile', 'pypi', extra_specs=["cython", "mpi4py"], version='0.1.24') + api.skeletonize('bigfile', 'pypi', extra_specs=["cython", "mpi4py"], version='0.1.24', python="3.6") m = api.render('bigfile')[0][0] assert parse_version(m.version()) == parse_version("0.1.24") assert any('cython' in req for req in m.meta['requirements']['host']) @@ -119,7 +119,7 @@ def test_pypi_with_extra_specs(testing_workdir): def test_pypi_with_version_inconsistency(testing_workdir): # regression test for https://github.com/conda/conda-build/issues/189 - api.skeletonize('mpi4py_test', 'pypi', extra_specs=["mpi4py"], version='0.0.10') + api.skeletonize('mpi4py_test', 'pypi', extra_specs=["mpi4py"], version='0.0.10', python="3.6") m = api.render('mpi4py_test')[0][0] assert parse_version(m.version()) == parse_version("0.0.10")