ssato / python-anyconfig

Python library provides common APIs to load and dump configuration files in various formats
MIT License
277 stars 31 forks source link

ruamel.yaml backend cannot be used w/o PyYAML installed #99

Closed ssato closed 5 years ago

ssato commented 5 years ago

Forked from #96 originally reported by @gsemet.

Hi. I have configuration where is does not work (ruamel.yaml without pyyaml package)

Python 3.5.2 (default, Nov 12 2018, 13:43:14) 
[GCC 5.4.0 20160609] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import anyconfig
>>> anyconfig.backend.yaml.ryaml
False
>>> dir(anyconfig.backend.yaml)
['PARSERS', '__builtins__', '__cached__', '__doc__', '__file__', '__loader__', '__name__', '__package__', '__path__', '__spec__', 'absolute_import', 'ryaml']
>>> anyconfig.backend.yaml.PARSERS
[]
>>> import ruamel.yaml
>>> ruamel.yaml
<module 'ruamel.yaml' from '/home/username/projects/myproject/.venv/lib/python3.5/site-packages/ruamel/yaml/__init__.py'>

pip freeze shows ruamel.yaml==0.15.87 and anyconfig==0.9.8.

Installing pyyaml seem to enable the ruamel backend:

$ pip install pyyaml
$ python
>>> import anyconfig.backend.yaml
>>> anyconfig.backend.yaml.PARSERS
[<class 'anyconfig.backend.yaml.pyyaml.Parser'>, <class 'anyconfig.backend.yaml.ruamel_yaml.Parser'>]

Originally posted by @gsemet in https://github.com/ssato/python-anyconfig/issues/96#issuecomment-460653473

ssato commented 5 years ago

This is because that ruamel_yaml.py depends on pyyaml.py depends on PyYAML currently: https://github.com/ssato/python-anyconfig/blob/next/anyconfig/backend/yaml/ruamel_yaml.py#L44

ssato commented 5 years ago

I guess that the commit 4f8286b may fix this issue.

gsemet commented 5 years ago

seems to work indeed

ssato commented 5 years ago

I've just released the version 0.9.9 contains the fixes for this issue. Please re-open this issue if any further issues on this.