Python distutils.version.StrictVersion() Examples
The following are 30
code examples of distutils.version.StrictVersion().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
distutils.version
, or try the search function
.
Example #1
Source File: redis_storage.py From aiohttp-session with Apache License 2.0 | 7 votes |
def __init__(self, redis_pool, *, cookie_name="AIOHTTP_SESSION", domain=None, max_age=None, path='/', secure=None, httponly=True, key_factory=lambda: uuid.uuid4().hex, encoder=json.dumps, decoder=json.loads): super().__init__(cookie_name=cookie_name, domain=domain, max_age=max_age, path=path, secure=secure, httponly=httponly, encoder=encoder, decoder=decoder) if aioredis is None: raise RuntimeError("Please install aioredis") if StrictVersion(aioredis.__version__).version < (1, 0): raise RuntimeError("aioredis<1.0 is not supported") self._key_factory = key_factory if isinstance(redis_pool, aioredis.pool.ConnectionsPool): warnings.warn( "using a pool created with aioredis.create_pool is deprecated" "please use a pool created with aioredis.create_redis_pool", DeprecationWarning ) redis_pool = aioredis.commands.Redis(redis_pool) elif not isinstance(redis_pool, aioredis.commands.Redis): raise TypeError("Expexted aioredis.commands.Redis got {}".format( type(redis_pool))) self._redis = redis_pool
Example #2
Source File: tensorflow_backend.py From GraphicDesignPatternByPython with MIT License | 6 votes |
def _preprocess_conv3d_input(x, data_format): """Transpose and cast the input before the conv3d. # Arguments x: input tensor. data_format: string, `"channels_last"` or `"channels_first"`. # Returns A tensor. """ # tensorflow doesn't support float64 for conv layer before 1.8.0 if (dtype(x) == 'float64' and StrictVersion(tf.__version__.split('-')[0]) < StrictVersion('1.8.0')): x = tf.cast(x, 'float32') tf_data_format = 'NDHWC' if data_format == 'channels_first': if not _has_nchw_support(): x = tf.transpose(x, (0, 2, 3, 4, 1)) else: tf_data_format = 'NCDHW' return x, tf_data_format
Example #3
Source File: utils.py From hyperledger-py with Apache License 2.0 | 6 votes |
def compare_version(v1, v2): """TODO: Compare hyperledger versions >>> v1 = '1.1' >>> v2 = '1.10' >>> compare_version(v1, v2) 1 >>> compare_version(v2, v1) -1 >>> compare_version(v2, v2) 0 """ s1 = StrictVersion(v1) s2 = StrictVersion(v2) if s1 == s2: return 0 elif s1 > s2: return -1 else: return 1
Example #4
Source File: version.py From pygrametl with BSD 2-Clause "Simplified" License | 6 votes |
def get_package_version(): """Extracts the highest version number of the pygrametl python files""" # The minimum version number is used for the initial value version_number = StrictVersion("0.0") python_files = glob.glob(pygrametl_path + '*.py') for python_file in python_files: # The path of each module is computed and its version extracted module_name = os.path.basename(python_file)[:-3] version = __import__(module_name).__version__ # A alpha / beta version without a number is the first alpha / beta if version.endswith(('a', 'b')): strict_version = StrictVersion(version + '1') else: strict_version = StrictVersion(version) # If a higher version number is found then that it is used if strict_version > version_number: version_number = strict_version return str(version_number)
Example #5
Source File: test_serializer_introspector.py From py2swagger with MIT License | 6 votes |
def test_default_serializer(self): if StrictVersion(VERSION) >= StrictVersion('3.0.0'): return from rest_framework.viewsets import ModelViewSet from django.http import HttpRequest from testapp.models import TestModel class TestViewSet(ModelViewSet): model = TestModel view = TestViewSet() view.request = HttpRequest() si = SerializerIntrospector(view.get_serializer_class()) self.assertEqual(si.name, 'TestModelSerializer')
Example #6
Source File: experiment.py From c2s with MIT License | 6 votes |
def find_class(self, module, name): """ Helps Unpickler to find certain Numpy modules. """ try: numpy_version = StrictVersion(numpy.__version__) if numpy_version >= StrictVersion('1.5.0'): if module == 'numpy.core.defmatrix': module = 'numpy.matrixlib.defmatrix' except ValueError: pass return Unpickler.find_class(self, module, name)
Example #7
Source File: test_librosa_compatibility.py From audio with BSD 2-Clause "Simplified" License | 6 votes |
def test_create_fb(self): self._test_create_fb() self._test_create_fb(n_mels=128, sample_rate=44100) self._test_create_fb(n_mels=128, fmin=2000.0, fmax=5000.0) self._test_create_fb(n_mels=56, fmin=100.0, fmax=9000.0) self._test_create_fb(n_mels=56, fmin=800.0, fmax=900.0) self._test_create_fb(n_mels=56, fmin=1900.0, fmax=900.0) self._test_create_fb(n_mels=10, fmin=1900.0, fmax=900.0) if StrictVersion(librosa.__version__) < StrictVersion("0.7.2"): return self._test_create_fb(n_mels=128, sample_rate=44100, norm="slaney") self._test_create_fb(n_mels=128, fmin=2000.0, fmax=5000.0, norm="slaney") self._test_create_fb(n_mels=56, fmin=100.0, fmax=9000.0, norm="slaney") self._test_create_fb(n_mels=56, fmin=800.0, fmax=900.0, norm="slaney") self._test_create_fb(n_mels=56, fmin=1900.0, fmax=900.0, norm="slaney") self._test_create_fb(n_mels=10, fmin=1900.0, fmax=900.0, norm="slaney")
Example #8
Source File: train_soft_actor_critic_atlas.py From chainerrl with MIT License | 6 votes |
def make_env(args, seed, test): if args.env.startswith('Roboschool'): # Check gym version because roboschool does not work with gym>=0.15.6 from distutils.version import StrictVersion gym_version = StrictVersion(gym.__version__) if gym_version >= StrictVersion('0.15.6'): raise RuntimeError('roboschool does not work with gym>=0.15.6') import roboschool # NOQA env = gym.make(args.env) # Unwrap TimiLimit wrapper assert isinstance(env, gym.wrappers.TimeLimit) env = env.env # Use different random seeds for train and test envs env_seed = 2 ** 32 - 1 - seed if test else seed env.seed(int(env_seed)) # Cast observations to float32 because our model uses float32 env = chainerrl.wrappers.CastObservationToFloat32(env) # Normalize action space to [-1, 1]^n env = chainerrl.wrappers.NormalizeActionSpace(env) if args.monitor: env = chainerrl.wrappers.Monitor( env, args.outdir, force=True, video_callable=lambda _: True) if args.render: env = chainerrl.wrappers.Render(env, mode='human') return env
Example #9
Source File: __init__.py From sjtu-automata with GNU General Public License v3.0 | 6 votes |
def check_update(): """Check for script version. Check latest version on Github page. Returns: bool, True for new version released. """ echoinfo('Checking update...') req = requests.get(__update_url__) if StrictVersion(req.text) > StrictVersion(__version__): echoinfo('Found new version: '+req.text) echowarning( 'New version found! We strongly recommand you to update to the latest version!') echowarning('Use "pip3 install sjtu-automata --upgrade" to upgrade!') return True else: echoinfo('You are up-to-date!') return False
Example #10
Source File: dist.py From lambda-packs with MIT License | 6 votes |
def get_metadata_version(self): mv = getattr(self, 'metadata_version', None) if mv is None: if self.long_description_content_type or self.provides_extras: mv = StrictVersion('2.1') elif (self.maintainer is not None or self.maintainer_email is not None or getattr(self, 'python_requires', None) is not None): mv = StrictVersion('1.2') elif (self.provides or self.requires or self.obsoletes or self.classifiers or self.download_url): mv = StrictVersion('1.1') else: mv = StrictVersion('1.0') self.metadata_version = mv return mv
Example #11
Source File: dist.py From ironpython2 with Apache License 2.0 | 6 votes |
def get_metadata_version(self): mv = getattr(self, 'metadata_version', None) if mv is None: if self.long_description_content_type or self.provides_extras: mv = StrictVersion('2.1') elif (self.maintainer is not None or self.maintainer_email is not None or getattr(self, 'python_requires', None) is not None or self.project_urls): mv = StrictVersion('1.2') elif (self.provides or self.requires or self.obsoletes or self.classifiers or self.download_url): mv = StrictVersion('1.1') else: mv = StrictVersion('1.0') self.metadata_version = mv return mv
Example #12
Source File: dist.py From Mastering-Elasticsearch-7.0 with MIT License | 6 votes |
def get_metadata_version(self): mv = getattr(self, 'metadata_version', None) if mv is None: if self.long_description_content_type or self.provides_extras: mv = StrictVersion('2.1') elif (self.maintainer is not None or self.maintainer_email is not None or getattr(self, 'python_requires', None) is not None): mv = StrictVersion('1.2') elif (self.provides or self.requires or self.obsoletes or self.classifiers or self.download_url): mv = StrictVersion('1.1') else: mv = StrictVersion('1.0') self.metadata_version = mv return mv
Example #13
Source File: dist.py From pex with Apache License 2.0 | 6 votes |
def get_metadata_version(self): mv = getattr(self, 'metadata_version', None) if mv is None: if self.long_description_content_type or self.provides_extras: mv = StrictVersion('2.1') elif (self.maintainer is not None or self.maintainer_email is not None or getattr(self, 'python_requires', None) is not None or self.project_urls): mv = StrictVersion('1.2') elif (self.provides or self.requires or self.obsoletes or self.classifiers or self.download_url): mv = StrictVersion('1.1') else: mv = StrictVersion('1.0') self.metadata_version = mv return mv
Example #14
Source File: test_serializer_introspector.py From py2swagger with MIT License | 6 votes |
def test_default_values(self): field_name = 'custom_integer_field' self.assertEqual(5, self.get_default_value(field_name, True)) self.assertEqual(5, self.get_default_value(field_name)) if StrictVersion(VERSION) >= StrictVersion('3.0.0'): return field_name = 'boolean_field' self.assertEqual(False, self.get_default_value(field_name, True)) self.assertEqual(False, self.get_default_value(field_name)) field_name = 'choices_field' self.assertEqual('a', self.get_default_value(field_name, True)) self.assertEqual('a', self.get_default_value(field_name)) field_name = 'decimal_field' self.assertEqual(100.0, self.get_default_value(field_name, True)) self.assertEqual(100.0, self.get_default_value(field_name)) field_name = 'integer_field' self.assertEqual(0, self.get_default_value(field_name, True)) self.assertEqual(0, self.get_default_value(field_name))
Example #15
Source File: tensorflow_backend.py From GraphicDesignPatternByPython with MIT License | 6 votes |
def _preprocess_conv2d_input(x, data_format, force_transpose=False): """Transpose and cast the input before the conv2d. # Arguments x: input tensor. data_format: string, `"channels_last"` or `"channels_first"`. force_transpose: boolean, whether force to transpose input from NCHW to NHWC if the `data_format` is `"channels_first"`. # Returns A tensor. """ # tensorflow doesn't support float64 for conv layer before 1.8.0 if (dtype(x) == 'float64' and StrictVersion(tf.__version__.split('-')[0]) < StrictVersion('1.8.0')): x = tf.cast(x, 'float32') tf_data_format = 'NHWC' if data_format == 'channels_first': if not _has_nchw_support() or force_transpose: x = tf.transpose(x, (0, 2, 3, 1)) # NCHW -> NHWC else: tf_data_format = 'NCHW' return x, tf_data_format
Example #16
Source File: tensorflow_backend.py From GraphicDesignPatternByPython with MIT License | 6 votes |
def _preprocess_conv1d_input(x, data_format): """Transpose and cast the input before the conv1d. # Arguments x: input tensor. data_format: string, `"channels_last"` or `"channels_first"`. # Returns A tensor. """ # tensorflow doesn't support float64 for conv layer before 1.8.0 if (dtype(x) == 'float64' and StrictVersion(tf.__version__.split('-')[0]) < StrictVersion('1.8.0')): x = tf.cast(x, 'float32') tf_data_format = 'NWC' # to pass TF Conv2dNative operations if data_format == 'channels_first': if not _has_nchw_support(): x = tf.transpose(x, (0, 2, 1)) # NCW -> NWC else: tf_data_format = 'NCW' return x, tf_data_format
Example #17
Source File: music_processor.py From aurora-sdk-mac with Apache License 2.0 | 6 votes |
def check_min_versions(): ret = True # pyaudio vers_required = "0.2.7" vers_current = pyaudio.__version__ if StrictVersion(vers_current) < StrictVersion(vers_required): print("Error: minimum pyaudio vers: {}, current vers {}".format(vers_required, vers_current)) ret = False # librosa vers_required = "0.4.3" vers_current = librosa.__version__ if StrictVersion(vers_current) < StrictVersion(vers_required): print("Error: minimum librosa vers: {}, current vers {}".format(vers_required, vers_current)) ret = False # numpy vers_required = "1.9.0" vers_current = np.__version__ if StrictVersion(vers_current) < StrictVersion(vers_required): print("Error: minimum numpy vers: {}, current vers {}".format(vers_required, vers_current)) ret = False return ret
Example #18
Source File: vmdk.py From cot with MIT License | 6 votes |
def _create_file(cls, path, disk_subformat="streamOptimized", **kwargs): """Worker function for create_file(). Args: path (str): Location to create VMDK file. disk_subformat (str): Defaults to "streamOptimized". **kwargs: See :meth:`DiskRepresentation._create_file` """ if (disk_subformat == "streamOptimized" and helpers['qemu-img'].version < StrictVersion("2.5.1")): # Slightly different warning from the one in from_other_image, # as vmdktool doesn't help us with this case. logger.warning( "QEMU version %s produces 'version 1' VMDK images, which newer" " versions of VMware ESXi will reject with the message '%s'." "\nIn order to generate the preferred 'version 3' images," " please upgrade to QEMU 2.5.1 or later.", str(helpers['qemu-img'].version), "Not a supported disk format (sparse VMDK version too old)") super(VMDK, cls)._create_file(path, disk_subformat=disk_subformat, **kwargs)
Example #19
Source File: test_qemu_img.py From cot with MIT License | 6 votes |
def test_older_version(self, mock_check_output): """Test .version getter logic for older versions.""" mock_check_output.return_value = """ qemu-img version 1.4.2, Copyright (c) 2004-2008 Fabrice Bellard usage: qemu-img command [command options] QEMU disk image utility Command syntax: ...""" self.helper._installed = True version = self.helper.version self.assertSubprocessCalls(mock_check_output, [['qemu-img', '--version']]) self.assertEqual(version, StrictVersion("1.4.2")) # Output should be cached rather than re-invoking qemu-img mock_check_output.reset_mock() version = self.helper.version mock_check_output.assert_not_called() self.assertEqual(version, StrictVersion("1.4.2"))
Example #20
Source File: iptables_raw.py From elixir-deploy-template with MIT License | 6 votes |
def _check_compatibility(self): from distutils.version import StrictVersion cmd = [self.bins['iptables'], '--version'] rc, stdout, stderr = Iptables.module.run_command(cmd, check_rc=False) if rc == 0: result = re.search(r'^ip6tables\s+v(\d+\.\d+)\.\d+$', stdout) if result: version = result.group(1) # CentOS 5 ip6tables (v1.3.x) doesn't support comments, # which means it cannot be used with this module. if StrictVersion(version) < StrictVersion('1.4'): Iptables.module.fail_json(msg="This module isn't compatible with ip6tables versions older than 1.4.x") else: Iptables.module.fail_json(msg="Could not fetch iptables version! Is iptables installed?") # Read rules from the json state file and return a dict.
Example #21
Source File: dockerplugin.py From docker-collectd-plugin with GNU General Public License v2.0 | 6 votes |
def init_callback(self): self.client = docker.Client( base_url=self.docker_url, version=DockerPlugin.MIN_DOCKER_API_VERSION) self.client.timeout = self.timeout # Check API version for stats endpoint support. try: version = self.client.version()['ApiVersion'] if StrictVersion(version) < \ StrictVersion(DockerPlugin.MIN_DOCKER_API_VERSION): raise Exception except: collectd.warning(('Docker daemon at {url} does not ' 'support container statistics!') .format(url=self.docker_url)) return False collectd.register_read(self.read_callback) collectd.info(('Collecting stats about Docker containers from {url} ' '(API version {version}; timeout: {timeout}s).') .format(url=self.docker_url, version=version, timeout=self.timeout)) return True
Example #22
Source File: dist.py From deepWordBug with Apache License 2.0 | 6 votes |
def get_metadata_version(self): mv = getattr(self, 'metadata_version', None) if mv is None: if self.long_description_content_type or self.provides_extras: mv = StrictVersion('2.1') elif (self.maintainer is not None or self.maintainer_email is not None or getattr(self, 'python_requires', None) is not None): mv = StrictVersion('1.2') elif (self.provides or self.requires or self.obsoletes or self.classifiers or self.download_url): mv = StrictVersion('1.1') else: mv = StrictVersion('1.0') self.metadata_version = mv return mv
Example #23
Source File: utils.py From deepWordBug with Apache License 2.0 | 6 votes |
def compare_version(v1, v2): """Compare docker versions >>> v1 = '1.9' >>> v2 = '1.10' >>> compare_version(v1, v2) 1 >>> compare_version(v2, v1) -1 >>> compare_version(v2, v2) 0 """ s1 = StrictVersion(v1) s2 = StrictVersion(v2) if s1 == s2: return 0 elif s1 > s2: return -1 else: return 1
Example #24
Source File: dist_utils.py From st2-auth-backend-ldap with Apache License 2.0 | 6 votes |
def check_pip_version(min_version='6.0.0'): """ Ensure that a minimum supported version of pip is installed. """ check_pip_is_installed() import pip if StrictVersion(pip.__version__) < StrictVersion(min_version): print("Upgrade pip, your version '{0}' " "is outdated. Minimum required version is '{1}':\n{2}".format(pip.__version__, min_version, GET_PIP)) sys.exit(1) return True
Example #25
Source File: ssladapter.py From hyperledger-py with Apache License 2.0 | 5 votes |
def can_override_ssl_version(self): urllib_ver = urllib3.__version__.split('-')[0] if urllib_ver is None: return False if urllib_ver == 'dev': return True return StrictVersion(urllib_ver) > StrictVersion('1.5')
Example #26
Source File: top_factors.py From healthcareai-py with MIT License | 5 votes |
def top_k_features(dataframe, linear_model, k=3): """ Get lists of top features based on an already-fit linear model. Defaults to 3 top features. Note k must be greater than or equal to the number of features in the model. Args: dataframe (pandas.core.frame.DataFrame): The dataframe for which to score top features linear_model (sklearn.base.BaseEstimator): A pre-fit scikit learn model instance that has linear coefficients. k (int): k lists of top features (the first list is the top features, the second list are the #2 features, etc) Returns: (pandas.core.frame.DataFrame): The top features for each row in dataframe format """ # Basic validation for number of features vs column count # Squeeze the array (which might be 1D or 2D down to 1D max_model_features = len(np.squeeze(linear_model.coef_)) if k > max_model_features: raise HealthcareAIError('You requested {} top features, which is more than the {} features from the original' ' model. Please choose {} or less.'.format(k, max_model_features, max_model_features)) # Multiply the values with the coefficients from the trained model and take the magnitude step1 = pd.DataFrame(np.abs(dataframe.values * linear_model.coef_), columns=dataframe.columns) if StrictVersion(pd.__version__) >= CHECK_PANDAS_VERSION: step2 = step1.apply(descending_sort, axis=1, result_type='expand') else: step2 = step1.apply(descending_sort, axis=1) results = list(step2.values[:, :k]) return results
Example #27
Source File: config.py From cutelog with MIT License | 5 votes |
def post_init(self): running_version = StrictVersion(QCoreApplication.applicationVersion()) config_version = self.options['cutelog_version'] if config_version == "" or config_version != running_version: self.save_running_version()
Example #28
Source File: ssladapter.py From deepWordBug with Apache License 2.0 | 5 votes |
def can_override_ssl_version(self): urllib_ver = urllib3.__version__.split('-')[0] if urllib_ver is None: return False if urllib_ver == 'dev': return True return StrictVersion(urllib_ver) > StrictVersion('1.5')
Example #29
Source File: dist.py From anpr with Creative Commons Attribution 4.0 International | 5 votes |
def get_metadata_version(dist_md): if dist_md.long_description_content_type or dist_md.provides_extras: return StrictVersion('2.1') elif (dist_md.maintainer is not None or dist_md.maintainer_email is not None or getattr(dist_md, 'python_requires', None) is not None): return StrictVersion('1.2') elif (dist_md.provides or dist_md.requires or dist_md.obsoletes or dist_md.classifiers or dist_md.download_url): return StrictVersion('1.1') return StrictVersion('1.0') # Based on Python 3.5 version
Example #30
Source File: main.py From streamlink with BSD 2-Clause "Simplified" License | 5 votes |
def check_version(force=False): cache = Cache(filename="cli.json") latest_version = cache.get("latest_version") if force or not latest_version: res = requests.get("https://pypi.python.org/pypi/streamlink/json") data = res.json() latest_version = data.get("info").get("version") cache.set("latest_version", latest_version, (60 * 60 * 24)) version_info_printed = cache.get("version_info_printed") if not force and version_info_printed: return installed_version = StrictVersion(streamlink.version) latest_version = StrictVersion(latest_version) if latest_version > installed_version: log.info("A new version of Streamlink ({0}) is " "available!".format(latest_version)) cache.set("version_info_printed", True, (60 * 60 * 6)) elif force: log.info("Your Streamlink version ({0}) is up to date!".format( installed_version)) if force: sys.exit()