Skip to content

Instantly share code, notes, and snippets.

@ionelmc
Last active December 13, 2015 15:46
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ionelmc/eb11afbcca187bad5273 to your computer and use it in GitHub Desktop.
Save ionelmc/eb11afbcca187bad5273 to your computer and use it in GitHub Desktop.
This might be outdated. Updated samples here: https://github.com/ionelmc/python-nameless/tree/generative
language: python
python: '3.5'
sudo: false
env:
global:
LD_PRELOAD=/lib/x86_64-linux-gnu/libSegFault.so
matrix:
- TOXENV=check
{% for env, config in tox_environments|dictsort %}
- TOXENV={{ env }}{% if config.cover %},extension-coveralls,coveralls,codecov{% endif %}
{% endfor %}
before_install:
- python --version
- uname -a
- lsb_release -a
install:
- pip install tox
- virtualenv --version
- easy_install --version
- pip --version
- tox --version
script:
- tox -v
after_failure:
- more .tox/log/* | cat
- more .tox/*/log/* | cat
notifications:
email:
on_success: never
on_failure: always
version: '{branch}-{build}'
build: off
cache:
- '%LOCALAPPDATA%\pip\Cache'
environment:
global:
WITH_COMPILER: 'cmd /E:ON /V:ON /C .\ci\appveyor-with-compiler.cmd'
matrix:
- TOXENV: check
PYTHON_HOME: C:\Python27
PYTHON_VERSION: '2.7'
PYTHON_ARCH: '32'
{% for env, config in tox_environments|dictsort %}{% if config.python in ('python2.6', 'python2.7', 'python3.3', 'python3.4', 'python3.5') %}
- TOXENV: '{{ env }}{% if config.cover %},codecov{% endif %}'
TOXPYTHON: C:\{{ config.python.replace('.', '').capitalize() }}\python.exe
PYTHON_HOME: C:\{{ config.python.replace('.', '').capitalize() }}
PYTHON_VERSION: '{{ config.python[-3:] }}'
PYTHON_ARCH: '32'
- TOXENV: '{{ env }}{% if config.cover %},codecov{% endif %}'
TOXPYTHON: C:\{{ config.python.replace('.', '').capitalize() }}-x64\python.exe
{%- if config.python != 'python3.5' %}
WINDOWS_SDK_VERSION: v7.{{ '1' if config.python[-3] == '3' else '0' }}
{%- endif %}
PYTHON_HOME: C:\{{ config.python.replace('.', '').capitalize() }}-x64
PYTHON_VERSION: '{{ config.python[-3:] }}'
PYTHON_ARCH: '64'
{% endif %}{% endfor %}
init:
- ps: echo $env:TOXENV
- ps: ls C:\Python*
install:
- python -u ci\appveyor-bootstrap.py
- '%PYTHON_HOME%\Scripts\virtualenv --version'
- '%PYTHON_HOME%\Scripts\easy_install --version'
- '%PYTHON_HOME%\Scripts\pip --version'
- '%PYTHON_HOME%\Scripts\tox --version'
test_script:
- '%WITH_COMPILER% %PYTHON_HOME%\Scripts\tox'
after_test:
- IF "%TOXENV:~-8,8%" == "-nocov" %WITH_COMPILER% %TOXPYTHON% setup.py bdist_wheel
on_failure:
- ps: dir "env:"
- ps: get-content .tox\*\log\*
artifacts:
- path: dist\*
### To enable remote debugging uncomment this:
# - ps: $blockRdp = $true; iex ((new-object net.webclient).DownloadString('https://raw.githubusercontent.com/appveyor/ci/master/scripts/enable-rdp.ps1'))
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from __future__ import absolute_import, print_function, unicode_literals
import os
import sys
from os.path import exists
from os.path import join
from os.path import dirname
from os.path import abspath
if __name__ == "__main__":
base_path = dirname(dirname(abspath(__file__)))
print("Project path: {0}".format(base_path))
env_path = join(base_path, ".tox", "bootstrap")
if sys.platform == "win32":
bin_path = join(env_path, "Scripts")
else:
bin_path = join(env_path, "bin")
if not exists(env_path):
import subprocess
print("Making bootstrap env in: {0} ...".format(env_path))
try:
subprocess.check_call(["virtualenv", env_path])
except Exception:
subprocess.check_call([sys.executable, "-m", "virtualenv", env_path])
print("Installing `jinja2` and `matrix` into bootstrap environment ...")
subprocess.check_call([join(bin_path, "pip"), "install", "jinja2", "matrix"])
activate = join(bin_path, "activate_this.py")
exec(compile(open(activate, "rb").read(), activate, "exec"), dict(__file__=activate))
import jinja2
import matrix
jinja = jinja2.Environment(
loader=jinja2.FileSystemLoader(join(base_path)),
trim_blocks=True,
lstrip_blocks=True,
keep_trailing_newline=True
)
tox_environments = {}
for (alias, conf) in matrix.from_file(join(base_path, "setup.cfg")).items():
python = conf["python_versions"]
deps = conf["dependencies"]
if "coverage_flags" in conf:
cover = {"false": False, "true": True}[conf["coverage_flags"].lower()]
if "environment_variables" in conf:
env_vars = conf["environment_variables"]
tox_environments[alias] = {
"python": "python" + python if "py" not in python else python,
"deps": deps.split(),
}
if "coverage_flags" in conf:
tox_environments[alias].update(cover=cover)
if "environment_variables" in conf:
tox_environments[alias].update(env_vars=env_vars.split())
with open('tox.ini', 'w') as fh:
fh.write(jinja.get_template('tox.tmpl.ini').render(
tox_environments=tox_environments
))
with open('.travis.yml', 'w') as fh:
fh.write(jinja.get_template('.travis.tmpl.yml').render(
tox_environments=tox_environments
))
with open('appveyor.yml', 'w') as fh:
fh.write(jinja.get_template('appveyor.tmpl.yml').render(
tox_environments=tox_environments
))
print("DONE.")
# Just append this to your setup.cfg
[matrix]
# This is the configuration for the `./bootstrap.py` script.
# It generates `.travis.yml`, `tox.ini` and `appveyor.yml`.
#
# Syntax: [alias:] value [!variable[glob]] [&variable[glob]]
#
# alias:
# - is used to generate the tox environment
# - it's optional
# - if not present the alias will be computed from the `value`
# value:
# - a value of "-" means empty
# !variable[glob]:
# - exclude the combination of the current `value` with
# any value matching the `glob` in `variable`
# - can use as many you want
# &variable[glob]:
# - only include the combination of the current `value`
# when there's a value matching `glob` in `variable`
# - can use as many you want
python_versions =
2.6
2.7
3.3
3.4
3.5
pypy
dependencies =
1.4: Django==1.4.16 !python_versions[3.*]
1.5: Django==1.5.11
1.6: Django==1.6.8
1.7: Django==1.7.1 !python_versions[2.6]
# Deps commented above are provided as examples. That's what you would use in a Django project.
coverage_flags =
cover: true
nocov: false
environment_variables =
-
#!/usr/bin/env python
# -*- encoding: utf-8 -*-
from __future__ import absolute_import, print_function
import io
import os
import re
from glob import glob
from os.path import basename
from os.path import dirname
from os.path import join
from os.path import relpath
from os.path import splitext
from setuptools import find_packages
from setuptools import setup
from distutils.core import Extension
def read(*names, **kwargs):
return io.open(
join(dirname(__file__), *names),
encoding=kwargs.get('encoding', 'utf8')
).read()
# Enable code coverage for C code: we can't use CFLAGS=-coverage in tox.ini, since that may mess with compiling
# dependencies (e.g. numpy). Therefore we set SETUPPY_CFLAGS=-coverage in tox.ini and copy it to CFLAGS here (after
# deps have been safely installed).
if 'TOXENV' in os.environ and 'SETUPPY_CFLAGS' in os.environ:
os.environ['CFLAGS'] = os.environ['SETUPPY_CFLAGS']
setup(
name='nameless',
version='0.1.0',
license='BSD',
description='An example package. Replace this with a proper project description. Generated with https://github.com/ionelmc/cookiecutter-pylibrary',
long_description='%s\n%s' % (read('README.rst'), re.sub(':[a-z]+:`~?(.*?)`', r'``\1``', read('CHANGELOG.rst'))),
author='Ionel Cristian Mărieș',
author_email='contact@ionelmc.ro',
url='https://github.com/ionelmc/python-nameless',
packages=find_packages('src'),
package_dir={'': 'src'},
py_modules=[splitext(basename(path))[0] for path in glob('src/*.py')],
include_package_data=True,
zip_safe=False,
classifiers=[
# complete classifier list: http://pypi.python.org/pypi?%3Aaction=list_classifiers
'Development Status :: 5 - Production/Stable',
'Intended Audience :: Developers',
'License :: OSI Approved :: BSD License',
'Operating System :: Unix',
'Operating System :: POSIX',
'Operating System :: Microsoft :: Windows',
'Programming Language :: Python',
'Programming Language :: Python :: 2.6',
'Programming Language :: Python :: 2.7',
'Programming Language :: Python :: 3',
'Programming Language :: Python :: 3.3',
'Programming Language :: Python :: 3.4',
'Programming Language :: Python :: Implementation :: CPython',
'Programming Language :: Python :: Implementation :: PyPy',
'Topic :: Utilities',
],
keywords=[
# eg: 'keyword1', 'keyword2', 'keyword3',
],
install_requires=[
# eg: 'aspectlib==1.1.1', 'six>=1.7',
],
extras_require={
# eg:
# 'rst': ['docutils>=0.11'],
# ':python_version=="2.6"': ['argparse'],
},
ext_modules=[
Extension(
splitext(relpath(path, 'src').replace(os.sep, '.'))[0],
sources=[path],
include_dirs=[dirname(path)]
)
for root, _, _ in os.walk('src')
for path in glob(join(root, '*.c'))
]
)
[tox]
envlist =
clean,
check,
{% for env in tox_environments|sort %}
{{ env }},
{% endfor %}
report,
docs
[testenv]
setenv =
PYTHONPATH={toxinidir}/tests
PYTHONUNBUFFERED=yes
passenv =
*
deps =
pytest
commands =
python setup.py clean --all build_ext --force --inplace
{posargs:py.test -vv --ignore=src}
[testenv:spell]
setenv =
SPELLCHECK=1
commands =
sphinx-build -b spelling docs dist/docs
skip_install = true
usedevelop = true
deps =
-r{toxinidir}/docs/requirements.txt
sphinxcontrib-spelling
pyenchant
[testenv:docs]
deps =
-r{toxinidir}/docs/requirements.txt
commands =
sphinx-build {posargs:-E} -b html docs dist/docs
sphinx-build -b linkcheck docs dist/docs
[testenv:bootstrap]
deps =
jinja2
matrix
skip_install = true
usedevelop = false
commands =
python bootstrap.py
passenv =
*
[testenv:check]
basepython = python3.4
deps =
docutils
check-manifest
flake8
readme
pygments
skip_install = true
usedevelop = false
commands =
python setup.py check --strict --metadata --restructuredtext
check-manifest {toxinidir}
flake8 src tests
[testenv:coveralls]
deps =
coveralls
skip_install = true
usedevelop = false
commands =
coverage combine
coverage report
coveralls --merge=extension-coveralls.json []
[testenv:codecov]
deps =
codecov
skip_install = true
usedevelop = false
commands =
coverage combine
coverage report
coverage xml --ignore-errors
codecov []
[testenv:extension-coveralls]
deps =
cpp-coveralls
skip_install = true
usedevelop = false
commands =
coveralls --build-root=. --include=src --dump=extension-coveralls.json []
[testenv:report]
basepython = python3.4
deps = coverage
skip_install = true
usedevelop = false
commands =
coverage combine
coverage report
[testenv:clean]
commands = coverage erase
skip_install = true
usedevelop = false
deps = coverage
{% for env, config in tox_environments|dictsort %}
[testenv:{{ env }}]
basepython = {env:TOXPYTHON:{{ config.python }}}
{% if config.cover or config.env_vars %}
setenv =
{[testenv]setenv}
{% endif %}
{% for var in config.env_vars %}
{{ var }}
{% endfor %}
{% if config.cover %}
WITH_COVERAGE=yes
SETUPPY_CFLAGS=-coverage
usedevelop = true
commands =
python setup.py clean --all build_ext --force --inplace
{posargs:py.test --cov --cov-report=term-missing -vv}
{% endif %}
{% if config.cover or config.deps %}
deps =
{[testenv]deps}
{% endif %}
{% if config.cover %}
pytest-cov
{% endif %}
{% for dep in config.deps %}
{{ dep }}
{% endfor %}
{% endfor %}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment