Skip to content

Commit ea55e3c

Browse files
committed
First working public version forked from private repo, with test running.
1 parent 589c7f4 commit ea55e3c

10 files changed

Lines changed: 1030 additions & 2 deletions

File tree

.gitignore

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,3 +102,13 @@ venv.bak/
102102

103103
# mypy
104104
.mypy_cache/
105+
106+
# Pycharm
107+
.idea/
108+
109+
# Mkdocs
110+
site/
111+
112+
# travis CI
113+
github_travis_rsa*
114+
reports

README.md

Lines changed: 77 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,77 @@
1-
# python-yamlable
2-
Python objects to YAML. And back.
1+
# yamlable
2+
3+
*Convert Python objects to YAML and back.*
4+
5+
[![Build Status](https://travis-ci.org/smarie/python-yamlable.svg?branch=master)](https://travis-ci.org/smarie/python-yamlable) [![Tests Status](https://smarie.github.io/python-yamlable/junit/junit-badge.svg?dummy=8484744)](https://smarie.github.io/python-yamlable/junit/report.html) [![codecov](https://codecov.io/gh/smarie/python-yamlable/branch/master/graph/badge.svg)](https://codecov.io/gh/smarie/python-yamlable) [![Documentation](https://img.shields.io/badge/docs-latest-blue.svg)](https://smarie.github.io/python-yamlable/) [![PyPI](https://img.shields.io/badge/PyPI-yamlable-blue.svg)](https://pypi.python.org/pypi/yamlable/)
6+
7+
**This is the readme for developers.** The documentation for users is available here: [https://smarie.github.io/python-yamlable/](https://smarie.github.io/python-yamlable/)
8+
9+
## Want to contribute ?
10+
11+
Contributions are welcome ! Simply fork this project on github, commit your contributions, and create pull requests.
12+
13+
Here is a non-exhaustive list of interesting open topics: [https://github.com/smarie/python-yamlable/issues](https://github.com/smarie/python-yamlable/issues)
14+
15+
## Running the tests
16+
17+
This project uses `pytest`.
18+
19+
```bash
20+
pytest -v yamlable/tests/
21+
```
22+
23+
You may need to install requirements for setup beforehand, using
24+
25+
```bash
26+
pip install -r ci_tools/requirements-test.txt
27+
```
28+
29+
## Packaging
30+
31+
This project uses `setuptools_scm` to synchronise the version number. Therefore the following command should be used for development snapshots as well as official releases:
32+
33+
```bash
34+
python setup.py egg_info bdist_wheel rotate -m.whl -k3
35+
```
36+
37+
You need to [generate code](##building-from-sources--notes-on-this-projects-design-principles) before packaging.
38+
39+
You also may need to install requirements for setup beforehand, using
40+
41+
```bash
42+
pip install -r ci_tools/requirements-setup.txt
43+
```
44+
45+
## Generating the documentation page
46+
47+
This project uses `mkdocs` to generate its documentation page. Therefore building a local copy of the doc page may be done using:
48+
49+
```bash
50+
mkdocs build
51+
```
52+
53+
You may need to install requirements for doc beforehand, using
54+
55+
```bash
56+
pip install -r ci_tools/requirements-doc.txt
57+
```
58+
59+
## Generating the test reports
60+
61+
The following commands generate the html test report and the associated badge.
62+
63+
```bash
64+
pytest --junitxml=junit.xml -v yamlable/tests/
65+
ant -f ci_tools/generate-junit-html.xml
66+
python ci_tools/generate-junit-badge.py
67+
```
68+
69+
### PyPI Releasing memo
70+
71+
This project is now automatically deployed to PyPI when a tag is created. Anyway, for manual deployment we can use:
72+
73+
```bash
74+
twine upload dist/* -r pypitest
75+
twine upload dist/*
76+
```
77+

setup.cfg

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
[egg_info]
2+
#tag_date = 1 already covered by setuptools_scm
3+
#tag_build = .dev --this adds ".dev" at the end of the release name. we already use setuptools_scm so already covered.
4+
#tag_svn_revision = 1 --this adds "_r0" at the end of the release name. we already use setuptools_scm so already covered.
5+
6+
[bdist_wheel]
7+
# This flag says that the code is written to work on both Python 2 and Python
8+
# 3. If at all possible, it is good practice to do this. If you cannot, you
9+
# will need to generate wheels for each Python version that you support.
10+
universal=0
11+
12+
[metadata]
13+
description-file = README.md
14+
15+
# In order to be able to execute 'python setup.py test'
16+
# from https://docs.pytest.org/en/latest/goodpractices.html#integrating-with-setuptools-python-setup-py-test-pytest-runner
17+
[aliases]
18+
test=pytest
19+
20+
[tool:pytest]
21+
norecursedirs=tests/helpers
22+
addopts = --verbose
23+
testpaths = yamlable/tests

setup.py

Lines changed: 161 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,161 @@
1+
"""A setuptools based setup module.
2+
See:
3+
https://packaging.python.org/en/latest/distributing.html
4+
https://github.com/pypa/sampleproject
5+
"""
6+
7+
from os import path
8+
9+
from setuptools import setup, find_packages
10+
from six import raise_from
11+
12+
here = path.abspath(path.dirname(__file__))
13+
14+
# *************** Dependencies *********
15+
INSTALL_REQUIRES = ['pyyaml'] # 'typing_inspect' is now copied internally so as to be compliant with very old versions of typing module
16+
DEPENDENCY_LINKS = []
17+
SETUP_REQUIRES = ['pytest-runner', 'setuptools_scm', 'pypandoc', 'pandoc']
18+
TESTS_REQUIRE = ['pytest', 'pytest-logging', 'pytest-cov']
19+
EXTRAS_REQUIRE = {}
20+
21+
# simple check
22+
try:
23+
from setuptools_scm import get_version
24+
except Exception as e:
25+
raise_from(Exception('Required packages for setup not found. You may wish you execute '
26+
'"pip install -r ci_tools/requirements-setup.txt" to install them or alternatively install '
27+
'them manually using conda or other system. The list is : ' + str(SETUP_REQUIRES)), e)
28+
29+
# ************** ID card *****************
30+
DISTNAME = 'yamlable'
31+
DESCRIPTION = 'A thin wrapper of PyYaml to convert Python objects to YAML and back.'
32+
MAINTAINER = 'Sylvain Marié'
33+
MAINTAINER_EMAIL = 'sylvain.marie@schneider-electric.com'
34+
URL = 'https://github.com/smarie/python-yamlable'
35+
LICENSE = 'BSD 3-Clause'
36+
LICENSE_LONG = 'License :: OSI Approved :: BSD License'
37+
38+
version_for_download_url = get_version()
39+
DOWNLOAD_URL = URL + '/tarball/' + version_for_download_url
40+
41+
KEYWORDS = 'yaml file parsing parse load dump read object oo oriented codec format plugin pyYaml'
42+
# --Get the long description from the README file
43+
# with open(path.join(here, 'README.md'), encoding='utf-8') as f:
44+
# LONG_DESCRIPTION = f.read()
45+
try:
46+
import pypandoc
47+
LONG_DESCRIPTION = pypandoc.convert(path.join(here, 'README.md'), 'rst').replace('\r', '')
48+
except(ImportError):
49+
from warnings import warn
50+
warn('WARNING pypandoc could not be imported - we recommend that you install it in order to package the '
51+
'documentation correctly')
52+
LONG_DESCRIPTION = open('README.md').read()
53+
54+
# ************* VERSION A **************
55+
# --Get the Version number from VERSION file, see https://packaging.python.org/single_source_version/ option 4.
56+
# THIS IS DEPRECATED AS WE NOW USE GIT TO MANAGE VERSION
57+
# with open(path.join(here, 'VERSION')) as version_file:
58+
# VERSION = version_file.read().strip()
59+
OBSOLETES = []
60+
61+
setup(
62+
name=DISTNAME,
63+
description=DESCRIPTION,
64+
long_description=LONG_DESCRIPTION,
65+
66+
# Versions should comply with PEP440. For a discussion on single-sourcing
67+
# the version across setup.py and the project code, see
68+
# https://packaging.python.org/en/latest/single_source_version.html
69+
# version=VERSION, NOW HANDLED BY GIT
70+
71+
maintainer=MAINTAINER,
72+
maintainer_email=MAINTAINER_EMAIL,
73+
74+
license=LICENSE,
75+
url=URL,
76+
download_url=DOWNLOAD_URL,
77+
78+
# See https://pypi.python.org/pypi?%3Aaction=list_classifiers
79+
classifiers=[
80+
# How mature is this project? Common values are
81+
# 3 - Alpha
82+
# 4 - Beta
83+
# 5 - Production/Stable
84+
'Development Status :: 5 - Production/Stable',
85+
86+
# Indicate who your project is intended for
87+
'Intended Audience :: Developers',
88+
'Topic :: Software Development :: Libraries :: Python Modules',
89+
90+
# Pick your license as you wish (should match "license" above)
91+
LICENSE_LONG,
92+
93+
# Specify the Python versions you support here. In particular, ensure
94+
# that you indicate whether you support Python 2, Python 3 or both.
95+
# 'Programming Language :: Python :: 2',
96+
# 'Programming Language :: Python :: 2.6',
97+
# 'Programming Language :: Python :: 2.7',
98+
# 'Programming Language :: Python :: 3',
99+
# 'Programming Language :: Python :: 3.3',
100+
# 'Programming Language :: Python :: 3.4',
101+
'Programming Language :: Python :: 3.5',
102+
'Programming Language :: Python :: 3.6',
103+
],
104+
105+
# What does your project relate to?
106+
keywords=KEYWORDS,
107+
108+
# You can just specify the packages manually here if your project is
109+
# simple. Or you can use find_packages().
110+
packages=find_packages(exclude=['contrib', 'docs', 'tests']),
111+
112+
# Alternatively, if you want to distribute just a my_module.py, uncomment
113+
# this:
114+
# py_modules=["my_module"],
115+
116+
# List run-time dependencies here. These will be installed by pip when
117+
# your project is installed. For an analysis of "install_requires" vs pip's
118+
# requirements files see:
119+
# https://packaging.python.org/en/latest/requirements.html
120+
install_requires=INSTALL_REQUIRES,
121+
dependency_links=DEPENDENCY_LINKS,
122+
123+
# we're using git
124+
use_scm_version=True, # this provides the version + adds the date if local non-commited changes.
125+
# use_scm_version={'local_scheme':'dirty-tag'}, # provides the version + adds '+dirty' if local non-commited changes
126+
setup_requires=SETUP_REQUIRES,
127+
128+
# test
129+
# test_suite='nose.collector',
130+
tests_require=TESTS_REQUIRE,
131+
132+
# List additional groups of dependencies here (e.g. development
133+
# dependencies). You can install these using the following syntax,
134+
# for example:
135+
# $ pip install -e .[dev,test]
136+
extras_require=EXTRAS_REQUIRE,
137+
138+
obsoletes=OBSOLETES
139+
140+
# If there are data files included in your packages that need to be
141+
# installed, specify them here. If using Python 2.6 or less, then these
142+
# have to be included in MANIFEST.in as well.
143+
# package_data={
144+
# 'sample': ['package_data.dat'],
145+
# },
146+
147+
# Although 'package_data' is the preferred approach, in some case you may
148+
# need to place data files outside of your packages. See:
149+
# http://docs.python.org/3.4/distutils/setupscript.html#installing-additional-files # noqa
150+
# In this case, 'data_file' will be installed into '<sys.prefix>/my_data'
151+
# data_files=[('my_data', ['data/data_file'])],
152+
153+
# To provide executable scripts, use entry points in preference to the
154+
# "scripts" keyword. Entry points provide cross-platform support and allow
155+
# pip to create the appropriate form of executable for the target platform.
156+
# entry_points={
157+
# 'console_scripts': [
158+
# 'sample=sample:main',
159+
# ],
160+
# },
161+
)

yamlable/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
from yamlable.base import AbstractYamlObject, NONE_IGNORE_CHECKS, YT_co
2+
from yamlable.main import YamlObject2, YamlAble, yaml_info

0 commit comments

Comments
 (0)