Source code for deepctr.utils

# -*- coding:utf-8 -*-

    Weichen Shen,


import json
import logging
from threading import Thread

import requests

    from packaging.version import parse
except ImportError:
    from pip._vendor.packaging.version import parse

[docs]def check_version(version): """Return version of package on using json.""" def check(version): try: url_pattern = '' req = requests.get(url_pattern) latest_version = parse('0') version = parse(version) if req.status_code == j = json.loads(req.text.encode('utf-8')) releases = j.get('releases', []) for release in releases: ver = parse(release) if ver.is_prerelease or ver.is_postrelease: continue latest_version = max(latest_version, ver) if latest_version > version: logging.warning( '\nDeepCTR version {0} detected. Your version is {1}.\nUse `pip install -U deepctr` to upgrade.Changelog:{0}'.format( latest_version, version)) except: print("Please check the latest version manually on") return Thread(target=check, args=(version,)).start()