Skip to content

Commit

Permalink
Add support for using ruamel.yaml instead of pyyaml where applicable.
Browse files Browse the repository at this point in the history
Moved yaml import into compat.py to make the import happen once.
Added deprecation notice in README.md about pyyaml.
  • Loading branch information
Grokzen committed May 15, 2016
1 parent bc604d8 commit b064c60
Show file tree
Hide file tree
Showing 8 changed files with 52 additions and 4 deletions.
18 changes: 17 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,23 @@ This readme contains a reduced version of the full documentation.
Latest stable release from pypi

```
$ pip install pykwalify
pip install -e '.[ruamel]'
```

`PyYaml` deprecated and `ruamel.yaml` support.

In release `1.6.0` `PyYaml` will be deprecated in favor of `ruamel.yaml`. `PyYaml` is still the default installed one but it will removed in release 1.7.0 and `ruamel.yaml` will be the new default one from that release and forward.

You can install it for production use with

```
pip install 'pykwalify[ruamel]'
```

or for development use with

```
pip install -e '.[ruamel]'
```


Expand Down
6 changes: 6 additions & 0 deletions docs/release-notes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,12 @@ Next release (??? ?, 2016)
- Convert all documentation to readthedocs
- True/False is no longer considered valid integer
- python3 'bytes' objects is now a valid strings and text type
- The regular PyYaml support is now deprecated in favor of ruamel.yaml, see the following link for more details about
PyYaml being deprecated https://bitbucket.org/xi/pyyaml/issues/59/has-this-project-been-abandoned
PyYaml will still be possible to use in the next major release version (1.6.0) but removed in release (1.7.0) and forward.
- ruamel.yaml is now possible to install with the following command for local development *pip install -e '.[ruamel]'*
and for production, use *pip install 'pykwalify[ruamel]'*
- ruamel.yaml is now used before PyYaml if installed on your system


1.5.1 (Mar 6, 2016)
Expand Down
7 changes: 7 additions & 0 deletions docs/upgrade-instructions.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,13 @@ This document describes all major changes to the validation rules and the API th
If new types were added, they will not be described here because it will not break existing schemas.


1.5.x --> 1.6.0
---------------

ruamel.yaml is now possible to use as a drop-in replacement for PyYaml. Install it with *pip install 'pykwalify[ruamel]'* for production use and with *pip install -e '.[ruamel]'* for development use.

PyYaml is now deprecated and will be removed in favor or ruamel.yaml in release 1.7.0.


1.4.x --> 1.5.0
---------------
Expand Down
16 changes: 16 additions & 0 deletions pykwalify/compat.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,22 @@

# python stdlib
import sys
import logging


log = logging.getLogger(__name__)


try:
from ruamel import yaml
except ImportError:
try:
import yaml
except ImportError:
log.critical("Unable to import either ruamel.yaml or pyyaml")
sys.exit(1)

log.debug("Using yaml library: {0}".format(yaml.__file__))


if sys.version_info[0] < 3:
Expand Down
2 changes: 1 addition & 1 deletion pykwalify/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
from pykwalify.types import is_scalar, tt

# 3rd party imports
import yaml
from pykwalify.compat import yaml
from dateutil.parser import parse

log = logging.getLogger(__name__)
Expand Down
3 changes: 3 additions & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@
license='MIT',
packages=['pykwalify'],
url='http://github.com/grokzen/pykwalify',
extras_require={
'ruamel': ["ruamel.yaml>=0.11.0,<0.12.0"],
},
entry_points={
'console_scripts': [
'pykwalify = pykwalify.cli:cli_entrypoint',
Expand Down
2 changes: 1 addition & 1 deletion tests/test_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

# 3rd party imports
import pytest
import yaml
from pykwalify.compat import yaml
from testfixtures import compare


Expand Down
2 changes: 1 addition & 1 deletion tests/test_unicode.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
from pykwalify.errors import SchemaError

# 3rd party imports
import yaml
from pykwalify.compat import yaml
from testfixtures import compare


Expand Down

0 comments on commit b064c60

Please sign in to comment.