forked from pantsbuild/pants
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Chris Livingston
committed
Jan 30, 2018
1 parent
ca86bf6
commit 46eab74
Showing
18 changed files
with
292 additions
and
27 deletions.
There are no files selected for viewing
13 changes: 13 additions & 0 deletions
13
examples/src/python/example/python_distribution/hello/hello2/.gitignore
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
# general things to ignore | ||
build/ | ||
dist/ | ||
*.egg-info/ | ||
*.egg | ||
*.py[cod] | ||
__pycache__/ | ||
*.so | ||
*~ | ||
|
||
# due to using tox and pytest | ||
.tox | ||
.cache |
16 changes: 16 additions & 0 deletions
16
examples/src/python/example/python_distribution/hello/hello2/.travis.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
# this file is *not* meant to cover or endorse the use of travis, but rather to | ||
# help confirm pull requests to this project. | ||
|
||
language: python | ||
|
||
env: | ||
- TOXENV=py27 | ||
- TOXENV=py33 | ||
- TOXENV=py34 | ||
|
||
install: pip install tox | ||
|
||
script: tox | ||
|
||
notifications: | ||
email: false |
8 changes: 8 additions & 0 deletions
8
examples/src/python/example/python_distribution/hello/hello2/BUILD
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
# Copyright 2014 Pants project contributors (see CONTRIBUTORS.md). | ||
# Licensed under the Apache License, Version 2.0 (see LICENSE). | ||
|
||
# Like Hello world, but built with Pants. This time, with both C++ and Py sources | ||
|
||
python_distribution( | ||
name='sample' | ||
) |
19 changes: 19 additions & 0 deletions
19
examples/src/python/example/python_distribution/hello/hello2/LICENSE.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
Copyright (c) 2016 The Python Packaging Authority (PyPA) | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy of | ||
this software and associated documentation files (the "Software"), to deal in | ||
the Software without restriction, including without limitation the rights to | ||
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies | ||
of the Software, and to permit persons to whom the Software is furnished to do | ||
so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. |
5 changes: 5 additions & 0 deletions
5
examples/src/python/example/python_distribution/hello/hello2/MANIFEST.in
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
# Include the license file | ||
include LICENSE.txt | ||
|
||
# Include the data files | ||
recursive-include data * |
25 changes: 25 additions & 0 deletions
25
examples/src/python/example/python_distribution/hello/hello2/README.rst
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
A sample Python project | ||
======================= | ||
|
||
A sample project that exists as an aid to the `Python Packaging User Guide | ||
<https://packaging.python.org>`_'s `Tutorial on Packaging and Distributing | ||
Projects <https://packaging.python.org/en/latest/distributing.html>`_. | ||
|
||
This projects does not aim to cover best practices for Python project | ||
development as a whole. For example, it does not provide guidance or tool | ||
recommendations for version control, documentation, or testing. | ||
|
||
---- | ||
|
||
This is the README file for the project. | ||
|
||
The file should use UTF-8 encoding and be written using `reStructuredText | ||
<http://docutils.sourceforge.net/rst.html>`_. It | ||
will be used to generate the project webpage on PyPI and will be displayed as | ||
the project homepage on common code-hosting services, and should be written for | ||
that purpose. | ||
|
||
Typical contents for this file would include an overview of the project, basic | ||
usage examples, etc. Generally, including the project changelog in here is not | ||
a good idea, although a simple "What's New" section for the most recent version | ||
may be appropriate. |
15 changes: 15 additions & 0 deletions
15
examples/src/python/example/python_distribution/hello/hello2/c/super_greet.c
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
|
||
#include <Python.h> | ||
|
||
static PyObject * super_greet(PyObject *self, PyObject *args) { | ||
return Py_BuildValue("s", "Super hello"); | ||
} | ||
|
||
static PyMethodDef Methods[] = { | ||
{"super_greet", super_greet, METH_VARARGS, "A super greeting"}, | ||
{NULL, NULL, 0, NULL} | ||
}; | ||
|
||
PyMODINIT_FUNC initsuper_greet(void) { | ||
(void) Py_InitModule("super_greet", Methods); | ||
} |
1 change: 1 addition & 0 deletions
1
examples/src/python/example/python_distribution/hello/hello2/data/data_file
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
some data |
7 changes: 7 additions & 0 deletions
7
examples/src/python/example/python_distribution/hello/hello2/sample/__init__.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import super_greet | ||
def main(): | ||
"""Entry point for the application script""" | ||
print("Call your main application code here") | ||
|
||
def ext(): | ||
print(super_greet.super_greet()) |
4 changes: 4 additions & 0 deletions
4
examples/src/python/example/python_distribution/hello/hello2/sample/lol.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
import super_greet | ||
|
||
def lol(): | ||
print(super_greet.super_greet()) |
1 change: 1 addition & 0 deletions
1
examples/src/python/example/python_distribution/hello/hello2/sample/package_data.dat
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
some data |
5 changes: 5 additions & 0 deletions
5
examples/src/python/example/python_distribution/hello/hello2/setup.cfg
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
[bdist_wheel] | ||
# This flag says that the code is written to work on both Python 2 and Python | ||
# 3. If at all possible, it is good practice to do this. If you cannot, you | ||
# will need to generate wheels for each Python version that you support. | ||
universal=1 |
115 changes: 115 additions & 0 deletions
115
examples/src/python/example/python_distribution/hello/hello2/setup.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,115 @@ | ||
"""A setuptools based setup module. | ||
See: | ||
https://packaging.python.org/en/latest/distributing.html | ||
https://github.com/pypa/sampleproject | ||
""" | ||
|
||
# Always prefer setuptools over distutils | ||
from setuptools import setup, find_packages | ||
# To use a consistent encoding | ||
from codecs import open | ||
from os import path | ||
from distutils.core import Extension | ||
here = path.abspath(path.dirname(__file__)) | ||
|
||
# Get the long description from the README file | ||
with open(path.join(here, 'README.rst'), encoding='utf-8') as f: | ||
long_description = f.read() | ||
|
||
c_module = Extension(str('super_greet'), sources=[str('c/super_greet.c')]) | ||
|
||
setup( | ||
name='sample', | ||
|
||
# Versions should comply with PEP440. For a discussion on single-sourcing | ||
# the version across setup.py and the project code, see | ||
# https://packaging.python.org/en/latest/single_source_version.html | ||
version='1.2.0', | ||
ext_modules=[c_module], | ||
description='A sample Python project', | ||
long_description=long_description, | ||
|
||
# The project's main homepage. | ||
url='https://github.com/pypa/sampleproject', | ||
|
||
# Author details | ||
author='The Python Packaging Authority', | ||
author_email='pypa-dev@googlegroups.com', | ||
|
||
# Choose your license | ||
license='MIT', | ||
|
||
# See https://pypi.python.org/pypi?%3Aaction=list_classifiers | ||
classifiers=[ | ||
# How mature is this project? Common values are | ||
# 3 - Alpha | ||
# 4 - Beta | ||
# 5 - Production/Stable | ||
'Development Status :: 3 - Alpha', | ||
|
||
# Indicate who your project is intended for | ||
'Intended Audience :: Developers', | ||
'Topic :: Software Development :: Build Tools', | ||
|
||
# Pick your license as you wish (should match "license" above) | ||
'License :: OSI Approved :: MIT License', | ||
|
||
# Specify the Python versions you support here. In particular, ensure | ||
# that you indicate whether you support Python 2, Python 3 or both. | ||
'Programming Language :: Python :: 2', | ||
'Programming Language :: Python :: 2.7', | ||
'Programming Language :: Python :: 3', | ||
'Programming Language :: Python :: 3.3', | ||
'Programming Language :: Python :: 3.4', | ||
'Programming Language :: Python :: 3.5', | ||
], | ||
|
||
# What does your project relate to? | ||
keywords='sample setuptools development', | ||
|
||
# You can just specify the packages manually here if your project is | ||
# simple. Or you can use find_packages(). | ||
packages=find_packages(exclude=['contrib', 'docs', 'tests']), | ||
|
||
# Alternatively, if you want to distribute just a my_module.py, uncomment | ||
# this: | ||
# py_modules=["my_module"], | ||
|
||
# List run-time dependencies here. These will be installed by pip when | ||
# your project is installed. For an analysis of "install_requires" vs pip's | ||
# requirements files see: | ||
# https://packaging.python.org/en/latest/requirements.html | ||
#install_requires=['peppercorn'], | ||
|
||
# List additional groups of dependencies here (e.g. development | ||
# dependencies). You can install these using the following syntax, | ||
# for example: | ||
# $ pip install -e .[dev,test] | ||
extras_require={ | ||
'dev': ['check-manifest'], | ||
'test': ['coverage'], | ||
}, | ||
|
||
# If there are data files included in your packages that need to be | ||
# installed, specify them here. If using Python 2.6 or less, then these | ||
# have to be included in MANIFEST.in as well. | ||
package_data={ | ||
'sample': ['package_data.dat'], | ||
}, | ||
|
||
# Although 'package_data' is the preferred approach, in some case you may | ||
# need to place data files outside of your packages. See: | ||
# http://docs.python.org/3.4/distutils/setupscript.html#installing-additional-files # noqa | ||
# In this case, 'data_file' will be installed into '<sys.prefix>/my_data' | ||
data_files=[('my_data', ['data/data_file'])], | ||
|
||
# To provide executable scripts, use entry points in preference to the | ||
# "scripts" keyword. Entry points provide cross-platform support and allow | ||
# pip to create the appropriate form of executable for the target platform. | ||
entry_points={ | ||
'console_scripts': [ | ||
'sample=sample:main', | ||
], | ||
}, | ||
) |
3 changes: 3 additions & 0 deletions
3
examples/src/python/example/python_distribution/hello/hello2/tests/__init__.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# the inclusion of the tests module is not meant to offer best practices for | ||
# testing in general, but rather to support the `find_packages` example in | ||
# setup.py that excludes installing the "tests" package |
7 changes: 7 additions & 0 deletions
7
examples/src/python/example/python_distribution/hello/hello2/tests/test_simple.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
# the inclusion of the tests module is not meant to offer best practices for | ||
# testing in general, but rather to support the `find_packages` example in | ||
# setup.py that excludes installing the "tests" package | ||
|
||
|
||
def test_success(): | ||
assert True |
33 changes: 33 additions & 0 deletions
33
examples/src/python/example/python_distribution/hello/hello2/tox.ini
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
# this file is *not* meant to cover or endorse the use of tox or pytest or | ||
# testing in general, | ||
# | ||
# It's meant to show the use of: | ||
# | ||
# - check-manifest | ||
# confirm items checked into vcs are in your sdist | ||
# - python setup.py check (using the readme_renderer extension) | ||
# confirms your long_description will render correctly on pypi | ||
# | ||
# and also to help confirm pull requests to this project. | ||
|
||
[tox] | ||
envlist = py{27,33,34} | ||
|
||
[testenv] | ||
basepython = | ||
py27: python2.7 | ||
py33: python3.3 | ||
py34: python3.4 | ||
deps = | ||
check-manifest | ||
readme_renderer | ||
flake8 | ||
pytest | ||
commands = | ||
check-manifest --ignore tox.ini,tests* | ||
python setup.py check -m -r -s | ||
flake8 . | ||
py.test tests | ||
[flake8] | ||
exclude = .tox,*.egg,build,data | ||
select = E,W,F |
15 changes: 15 additions & 0 deletions
15
examples/src/python/example/python_distribution/hello/superhello/c/super_greet.c
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
|
||
#include <Python.h> | ||
|
||
static PyObject * super_greet(PyObject *self, PyObject *args) { | ||
return Py_BuildValue("s", "Super hello"); | ||
} | ||
|
||
static PyMethodDef Methods[] = { | ||
{"super_greet", super_greet, METH_VARARGS, "A super greeting"}, | ||
{NULL, NULL, 0, NULL} | ||
}; | ||
|
||
PyMODINIT_FUNC initsuper_greet(void) { | ||
(void) Py_InitModule("super_greet", Methods); | ||
} |
27 changes: 0 additions & 27 deletions
27
examples/src/python/example/python_distribution/hello/superhello/cpp/greet.cpp
This file was deleted.
Oops, something went wrong.