Skip to content

Commit bcb76b8

Browse files
committed
Initial commit
0 parents  commit bcb76b8

12 files changed

+228
-0
lines changed

.coveragerc

+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
[run]
2+
branch = True
3+
source =
4+
.
5+
omit =
6+
.tox/*
7+
/usr/*
8+
*/tmp*
9+
setup.py
10+
11+
[report]
12+
exclude_lines =
13+
# Have to re-enable the standard pragma
14+
\#\s*pragma: no cover
15+
16+
# Don't complain if tests don't hit defensive assertion code:
17+
^\s*raise AssertionError\b
18+
^\s*raise NotImplementedError\b
19+
^\s*return NotImplemented\b
20+
^\s*raise$
21+
22+
# Don't complain if non-runnable code isn't run:
23+
^if __name__ == ['"]__main__['"]:$
24+
25+
[html]
26+
directory = coverage-html
27+
28+
# vim:ft=dosini

.gitignore

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
*.egg-info
2+
*.iml
3+
*.py[cod]
4+
*.so
5+
.*.sw[a-z]
6+
.coverage
7+
.tox
8+
.venv-touch
9+
/.cache
10+
/build
11+
/venv*
12+
coverage-html
13+
dist

.pre-commit-config.yaml

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
- repo: https://github.com/pre-commit/pre-commit-hooks.git
2+
sha: 97b88d9610bcc03982ddac33caba98bb2b751f5f
3+
hooks:
4+
- id: trailing-whitespace
5+
- id: end-of-file-fixer
6+
- id: autopep8-wrapper
7+
- id: check-docstring-first
8+
- id: check-yaml
9+
- id: debug-statements
10+
- id: requirements-txt-fixer
11+
- id: flake8
12+
- repo: https://github.com/asottile/reorder_python_imports.git
13+
sha: 50e0be95e292cac913cc3c6fd44b3d6b51d104c5
14+
hooks:
15+
- id: reorder-python-imports
16+
- repo: local
17+
hooks:
18+
- id: gofmt
19+
name: gofmt
20+
language: system
21+
entry: gofmt -l -w
22+
files: \.go$

.travis.yml

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
language: python
2+
env: # These should match the tox env list
3+
- TOXENV=py27
4+
- TOXENV=py34
5+
- TOXENV=py35
6+
- TOXENV=pypy
7+
install: pip install coveralls tox
8+
script: tox
9+
after_success:
10+
- coveralls
11+
sudo: false
12+
cache:
13+
directories:
14+
- $HOME/.cache/pip
15+
- $HOME/.pre-commit

LICENSE

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
Copyright (c) 2016 Anthony Sottile
2+
3+
Permission is hereby granted, free of charge, to any person obtaining a copy
4+
of this software and associated documentation files (the "Software"), to deal
5+
in the Software without restriction, including without limitation the rights
6+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7+
copies of the Software, and to permit persons to whom the Software is
8+
furnished to do so, subject to the following conditions:
9+
10+
The above copyright notice and this permission notice shall be included in
11+
all copies or substantial portions of the Software.
12+
13+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19+
THE SOFTWARE.

Makefile

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
REBUILD_FLAG =
2+
3+
.PHONY: all
4+
all: venv test
5+
6+
.PHONY: venv
7+
venv: .venv.touch
8+
tox -e venv $(REBUILD_FLAG)
9+
10+
.PHONY: tests test
11+
tests: test
12+
test: .venv.touch
13+
tox $(REBUILD_FLAG)
14+
15+
.venv.touch: setup.py requirements-dev.txt
16+
$(eval REBUILD_FLAG := --recreate)
17+
touch .venv.touch
18+
19+
.PHONY: clean
20+
clean:
21+
find . -name '*.pyc' -delete
22+
rm -rf .tox
23+
rm -rf ./venv-*
24+
rm -f .venv.touch

README.md

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
[![Build Status](https://travis-ci.org/asottile/setuptools-golang.svg?branch=master)](https://travis-ci.org/asottile/setuptools-golang)
2+
[![Coverage Status](https://img.shields.io/coveralls/asottile/setuptools-golang.svg?branch=master)](https://coveralls.io/r/asottile/setuptools-golang)
3+
4+
setuptools-golang
5+
===================
6+
7+
A setuptools extension for building cpython extensions written in golang.
8+
9+
## Usage
10+
11+
Add `setuptools-golang` to the `setup_requires` in your setup.py and
12+
`build_golang=True`.
13+
14+
```python
15+
setup(
16+
...
17+
build_golang=True,
18+
setup_requires=['setuptools-golang'],
19+
...
20+
)
21+
```
22+
23+
## Writing cpython extensions in golang
24+
25+
TODO

requirements-dev.txt

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
-e .
2+
coverage
3+
pre-commit
4+
pytest

setup.py

+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
from setuptools import setup
2+
3+
4+
setup(
5+
name='setuptools-golang',
6+
description=(
7+
'A setuptools extension for building cpython extensions written in '
8+
'golang.'
9+
),
10+
url='https://github.com/asottile/setuptools-golang',
11+
version='0.1.0',
12+
author='Anthony Sottile',
13+
author_email='[email protected]',
14+
classifiers=[
15+
'License :: OSI Approved :: MIT License',
16+
'Programming Language :: Python :: 2',
17+
'Programming Language :: Python :: 2.7',
18+
'Programming Language :: Python :: 3',
19+
'Programming Language :: Python :: 3.4',
20+
'Programming Language :: Python :: 3.5',
21+
'Programming Language :: Python :: Implementation :: CPython',
22+
'Programming Language :: Python :: Implementation :: PyPy',
23+
],
24+
py_modules=['setuptools_golang'],
25+
install_requires=[],
26+
entry_points={
27+
'distutils.setup_keywords': [
28+
'build_golang = setuptools_golang:set_build_ext',
29+
],
30+
},
31+
)

setuptools_golang.py

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
from setuptools.command.build_ext import build_ext
2+
3+
4+
class BuildExtGolang(build_ext):
5+
pass
6+
7+
8+
def set_build_ext(dist, attr, value):
9+
if not value:
10+
return
11+
dist.cmdclass['build_ext'] = BuildExtGolang

setuptools_golang_test.py

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
from setuptools.dist import Distribution
2+
3+
import setuptools_golang
4+
5+
6+
def test_sets_cmdclass():
7+
dist = Distribution()
8+
setuptools_golang.set_build_ext(dist, 'build_golang', True)
9+
assert dist.cmdclass['build_ext'] == setuptools_golang.BuildExtGolang
10+
11+
12+
def test_sets_cmdclass_value_falsey():
13+
dist = Distribution()
14+
setuptools_golang.set_build_ext(dist, 'build_golang', False)
15+
assert dist.cmdclass.get('build_ext') != setuptools_golang.BuildExtGolang

tox.ini

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
[tox]
2+
project = setuptools-golang
3+
# These should match the travis env list
4+
envlist = py27,py34,py35,pypy
5+
6+
[testenv]
7+
deps = -rrequirements-dev.txt
8+
passenv = HOME TERM
9+
commands =
10+
coverage erase
11+
coverage run -m pytest {posargs:setuptools_golang_test.py}
12+
coverage report --show-missing --fail-under 100
13+
pre-commit install -f --install-hooks
14+
pre-commit run --all-files
15+
16+
[testenv:venv]
17+
envdir = venv-{[tox]project}
18+
commands =
19+
20+
[pep8]
21+
ignore = E265,E309,E501

0 commit comments

Comments
 (0)