diff --git a/conda_build/skeletons/cpan.py b/conda_build/skeletons/cpan.py index 94a1efa5c7..581ee4a194 100644 --- a/conda_build/skeletons/cpan.py +++ b/conda_build/skeletons/cpan.py @@ -7,7 +7,7 @@ import codecs import hashlib -from pkg_resources import parse_version +from packaging.version import Version from glob import glob import gzip import json @@ -231,7 +231,7 @@ def get_build_dependencies_from_src_archive(package_url, sha256, src_cache): def loose_version(ver): - return str(parse_version(str(ver))) + return str(Version(str(ver))) def get_cpan_api_url(url, colons): @@ -438,7 +438,7 @@ def skeletonize(packages, output_dir=".", version=None, release_data = latest_release_data else: release_data = get_release_info(meta_cpan_url, cache_dir, core_modules, package, - parse_version(version)) + Version(version)) # Check if recipe directory already exists dir_path = join(output_dir, packagename, release_data['version']) @@ -566,7 +566,7 @@ def is_core_version(core_version, version): if core_version is None: return False elif core_version is not None and ((version in [None, '']) or - (core_version >= parse_version(version))): + (core_version >= Version(version))): return True else: return False @@ -619,7 +619,7 @@ def latest_pkg_version(pkg): except: pkg_list = None if pkg_list: - pkg_version = parse_version(pkg_list[-1].version) + pkg_version = Version(pkg_list[-1].version) else: pkg_version = None return pkg_version @@ -707,7 +707,7 @@ def deps_for_package(package, release_data, output_dir, cache_dir, # There is a dep version and a pkg_version ... why? if dep_dict['version'] in {'', 'undef'}: dep_dict['version'] = '0' - dep_version = parse_version(dep_dict['version']) + dep_version = Version(dep_dict['version']) # Make sure specified version is valid # TODO def valid_release_info @@ -718,7 +718,7 @@ def deps_for_package(package, release_data, output_dir, cache_dir, 'dependency for %s, %s, is not available on MetaCPAN, ' + 'so we are just assuming the latest version is ' + 'okay.') % (orig_dist, package, str(dep_version))) - dep_version = parse_version('0') + dep_version = Version('0') # Add version number to dependency, if it's newer than latest # we have package for. @@ -991,12 +991,12 @@ def get_release_info(cpan_url, cache_dir, core_modules, package, version): if version is not None: version_str = str(version) rel_version = str(rel_dict['version']) - loose_str = str(parse_version(version_str)) + loose_str = str(Version(version_str)) try: version_mismatch = (version is not None) and ( loose_version('0') != loose_version(version_str) and - parse_version(rel_version) != loose_version(version_str)) + Version(rel_version) != loose_version(version_str)) # print(version_mismatch) except Exception as e: print('We have some strange version mismatches. Please investigate.') diff --git a/conda_build/skeletons/pypi.py b/conda_build/skeletons/pypi.py index 61f5baafb0..19bd48f725 100644 --- a/conda_build/skeletons/pypi.py +++ b/conda_build/skeletons/pypi.py @@ -12,7 +12,7 @@ from os import makedirs, listdir, getcwd, chdir from os.path import join, isdir, exists, isfile, abspath -from pkg_resources import parse_version +from packaging.version import Version import re from shutil import copy2 import subprocess @@ -277,7 +277,7 @@ def skeletonize(packages, output_dir=".", version=None, recursive=False, pypi_data = pypi_resp.json() - versions = sorted(pypi_data["releases"].keys(), key=parse_version) + versions = sorted(pypi_data["releases"].keys(), key=Version) if version_compare: version_compare(versions) diff --git a/conda_build/variants.py b/conda_build/variants.py index 19c1e87a5f..eaeaa71235 100644 --- a/conda_build/variants.py +++ b/conda_build/variants.py @@ -8,7 +8,7 @@ from functools import lru_cache from itertools import product import os.path -from pkg_resources import parse_version +from packaging.version import Version import re import sys @@ -87,9 +87,9 @@ def _get_default_compilers(platform, py_ver): compilers = DEFAULT_COMPILERS[platform].copy() if platform == 'win': - if parse_version(py_ver) >= parse_version('3.5'): + if Version(py_ver) >= Version('3.5'): py_ver = '3.5' - elif parse_version(py_ver) <= parse_version('3.2'): + elif Version(py_ver) <= Version('3.2'): py_ver = '2.7' compilers['c'] = compilers['c'][py_ver] compilers['cxx'] = compilers['cxx'][py_ver] diff --git a/recipe/meta.yaml b/recipe/meta.yaml index afc694561e..4b20a59189 100644 --- a/recipe/meta.yaml +++ b/recipe/meta.yaml @@ -34,6 +34,7 @@ requirements: - filelock - futures # [py<3] - jinja2 + - packaging - patchelf # [linux] - patch >=2.6 # [not win] - m2-patch >=2.6 # [win] @@ -44,7 +45,6 @@ requirements: - pyyaml - requests - scandir # [py<34] - - setuptools - six - glob2 >=0.6 - pytz diff --git a/setup.py b/setup.py index 52802c523a..b5ed898950 100755 --- a/setup.py +++ b/setup.py @@ -26,7 +26,7 @@ "psutil", "six", "libarchive-c", - "setuptools", + "packaging", # "conda-package-handling", # remove comment once released on PyPI "glob2", ] diff --git a/tests/test_api_skeleton.py b/tests/test_api_skeleton.py index 18cb57e6d9..917719c0ae 100644 --- a/tests/test_api_skeleton.py +++ b/tests/test_api_skeleton.py @@ -5,7 +5,7 @@ import subprocess import sys -from pkg_resources import parse_version +from packaging.version import Version import pytest from conda_build.skeletons.pypi import get_package_metadata, \ @@ -342,7 +342,7 @@ def test_pypi_version_sorting(testing_workdir, testing_config): # any effect. api.skeletonize(packages='impyla', repo='pypi', config=testing_config) m = api.render('impyla')[0][0] - assert parse_version(m.version()) >= parse_version("0.13.8") + assert Version(m.version()) >= Version("0.13.8") def test_list_skeletons(): @@ -359,7 +359,7 @@ def test_pypi_with_version_arg(testing_workdir): # regression test for https://github.com/conda/conda-build/issues/1442 api.skeletonize('PrettyTable', 'pypi', version='0.7.2') m = api.render('prettytable')[0][0] - assert parse_version(m.version()) == parse_version("0.7.2") + assert Version(m.version()) == Version("0.7.2") @pytest.mark.slow @@ -373,7 +373,7 @@ def test_pypi_with_extra_specs(testing_workdir, testing_config): api.skeletonize('bigfile', 'pypi', extra_specs=extra_specs, version='0.1.24', python="3.6", config=testing_config) m = api.render('bigfile')[0][0] - assert parse_version(m.version()) == parse_version("0.1.24") + assert Version(m.version()) == Version("0.1.24") assert any('cython' in req for req in m.meta['requirements']['host']) assert any('mpi4py' in req for req in m.meta['requirements']['host']) @@ -389,7 +389,7 @@ def test_pypi_with_version_inconsistency(testing_workdir, testing_config): api.skeletonize('mpi4py_test', 'pypi', extra_specs=extra_specs, version='0.0.10', python="3.6", config=testing_config) m = api.render('mpi4py_test')[0][0] - assert parse_version(m.version()) == parse_version("0.0.10") + assert Version(m.version()) == Version("0.0.10") def test_pypi_with_basic_environment_markers(testing_workdir):