Skip to content

Commit

Permalink
now also blocked on setup_requires fix
Browse files Browse the repository at this point in the history
  • Loading branch information
cosmicexplorer committed Jul 30, 2018
1 parent 5769dbb commit afacb4c
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@

python_dist(
sources=['setup.py', 'hello.c'],
setup_requires=[
'testprojects/pants-plugins/3rdparty/python/pants',
],
# FIXME: setup_requires needs to provide transitive deps of all the requested packages too!
# setup_requires=[
# 'testprojects/pants-plugins/3rdparty/python/pants',
# ],
)

python_binary(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,16 @@

#include <Python.h>

static PyObject *hello(PyObject *self, PyObject *args) {
#ifdef PANTS_PYTHON_DIST
static const char *hello_str = "Hello from Pants!";
#else
static const char *hello_str = "Hello from outside of Pants!";
#endif

static PyObject *
hello(PyObject *self, PyObject *args) {
/* FIXME: make this depend on some env var we pass in!? */
return Py_BuildValue("s", "Hello from C!");
return Py_BuildValue("s", hello_str);
}

static PyMethodDef Methods[] = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,13 @@
try:
from pants.backend.python.distutils_extensions import pants_setup as setup
except ImportError as e:
raise e
from setuptools import setup


c_module = Extension(b'hello', sources=[b'hello.c'])

setup(
name='distutils_extensions'
name='distutils_extensions',
version='0.0.1',
ext_modules=[c_module],
packages=find_packages(),
Expand Down
6 changes: 4 additions & 2 deletions src/python/pants/backend/python/distutils_extensions.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ def customize_compiler_from_env(compiler):
linker_so=link_cmd)


class env_only_build_ext(distutils_build_ext):
class pants_build_ext(distutils_build_ext):
"""???"""

def _append_to_compiler_property(elements, append_fun):
Expand Down Expand Up @@ -96,6 +96,8 @@ def run(self):
self._append_to_compiler_property(self.rpath, self.compiler.add_runtime_library_dir)
self._append_to_compiler_property(self.link_objects, self.compiler.add_link_object)

self.compiler.define_macro('PANTS_PYTHON_DIST', None)

# Now actually compile and link everything.
self.build_extensions()

Expand All @@ -109,6 +111,6 @@ def pants_setup(cmdclass=None, *args, **kwargs):
"Overriding 'build_ext' in the 'cmdclass' keyword argument of pants_setup() "
"is not supported.")

cmdclass.add('build_ext', env_only_build_ext)
cmdclass.add('build_ext', pants_build_ext)

setuptools_setup(*args, cmdclass=cmdclass, **kwargs)

0 comments on commit afacb4c

Please sign in to comment.