-
-
Notifications
You must be signed in to change notification settings - Fork 636
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix multiple binary target case and add integration test
- Loading branch information
Chris Livingston
committed
Jan 30, 2018
1 parent
9e0b2d6
commit e8f6b98
Showing
8 changed files
with
172 additions
and
59 deletions.
There are no files selected for viewing
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
59 changes: 59 additions & 0 deletions
59
testprojects/src/python/python_targets/python_distribution/superhello/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,59 @@ | ||
# Copyright 2017 Pants project contributors (see CONTRIBUTORS.md). | ||
# Licensed under the Apache License, Version 2.0 (see LICENSE). | ||
|
||
# Like Hello world, but built with a python_dist. | ||
# python_dist allows you to use setup.py to depend on C/C++ extensions. | ||
|
||
python_dist( | ||
name='superhello', | ||
sources=[ | ||
'super_greet.c', | ||
'hello_package/hello.py', | ||
'hello_package/__init__.py', | ||
'setup.py' | ||
] | ||
) | ||
|
||
python_binary( | ||
name='bin_with_python_dist', | ||
source='main.py', | ||
dependencies=[ | ||
':superhello', | ||
] | ||
) | ||
|
||
|
||
# The targets below are for testing purposes only. | ||
# Their purpose is to expose an error that arises when a python_dist | ||
# contains a requirement that conflicts with the same requirement of | ||
# a different version in the consuming target. In this case, the pants | ||
# goal will fail and indicate that incomptible requirements exist. | ||
|
||
python_dist( | ||
name='superhello_with_conflicting_dep', | ||
sources=[ | ||
'super_greet.c', | ||
'hello_package/hello.py', | ||
'hello_package/__init__.py', | ||
'setup.py' | ||
], | ||
dependencies=[ | ||
':pex_lib' | ||
] | ||
) | ||
|
||
python_binary( | ||
name='main_with_conflicting_dep', | ||
source='main.py', | ||
dependencies=[ | ||
':superhello_with_conflicting_dep', | ||
'3rdparty/python:pex' | ||
] | ||
) | ||
|
||
python_requirement_library( | ||
name='pex_lib', | ||
requirements=[ | ||
python_requirement('pex==1.2.11'), | ||
] | ||
) |
Empty file.
12 changes: 12 additions & 0 deletions
12
testprojects/src/python/python_targets/python_distribution/superhello/hello_package/hello.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,12 @@ | ||
# coding=utf-8 | ||
# Copyright 2017 Pants project contributors (see CONTRIBUTORS.md). | ||
# Licensed under the Apache License, Version 2.0 (see LICENSE). | ||
|
||
from __future__ import (absolute_import, division, generators, nested_scopes, print_function, | ||
unicode_literals, with_statement) | ||
|
||
import super_greet | ||
|
||
def hello(): | ||
print(super_greet.super_greet()) | ||
return super_greet.super_greet() |
13 changes: 13 additions & 0 deletions
13
testprojects/src/python/python_targets/python_distribution/superhello/main.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,13 @@ | ||
# coding=utf-8 | ||
# Copyright 2017 Pants project contributors (see CONTRIBUTORS.md). | ||
# Licensed under the Apache License, Version 2.0 (see LICENSE). | ||
|
||
from __future__ import (absolute_import, division, generators, nested_scopes, print_function, | ||
unicode_literals, with_statement) | ||
|
||
# hello_package is a python module within the superhello python_distribution | ||
from hello_package import hello | ||
|
||
|
||
if __name__ == '__main__': | ||
hello.hello() |
19 changes: 19 additions & 0 deletions
19
testprojects/src/python/python_targets/python_distribution/superhello/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,19 @@ | ||
# coding=utf-8 | ||
# Copyright 2017 Pants project contributors (see CONTRIBUTORS.md). | ||
# Licensed under the Apache License, Version 2.0 (see LICENSE). | ||
|
||
from __future__ import (absolute_import, division, generators, nested_scopes, print_function, | ||
unicode_literals, with_statement) | ||
|
||
from setuptools import setup, find_packages | ||
from distutils.core import Extension | ||
|
||
|
||
c_module = Extension(str('super_greet'), sources=[str('super_greet.c')]) | ||
|
||
setup( | ||
name='superhello', | ||
version='1.0.0', | ||
ext_modules=[c_module], | ||
packages=find_packages(), | ||
) |
14 changes: 14 additions & 0 deletions
14
testprojects/src/python/python_targets/python_distribution/superhello/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,14 @@ | ||
#include <Python.h> | ||
|
||
static PyObject * super_greet(PyObject *self, PyObject *args) { | ||
return Py_BuildValue("s", "A different 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); | ||
} |
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