There is a section in the documentation for `pytho...
# general
c
There is a section in the documentation for
python-native-code
Is this only for resolving third party deps or is there a way to build c bindings locally? Was also thinking about trying
python_ditribution
h
In the latest dev releases there is actually support for local native code!
There is an example in the repo
I still need to update the documentation
c
Thanks I'll check it out.
h
This subsystem indeed was for v1 functionality tho, which we never renamed
c
Can a
python_ditribution
be used as a dep for a
python_library
was able to build the wheel that way?
h
Yep
if a
python_library
depends on a
python_distribution
then that distribution will be built locally and available for import in
test
,
run
and
repl
No intermediate publishing step required
And it'll get bundled into the pex when you
package
some binary that depends on that
python_library
c
Awesome thanks
h
It's a new feature though, so let us know if you hit any snags
c
I had issue building the native lib on Mac, though…
Copy code
$ ./pants package testprojects/src/python/native:
12:38:07.56 [ERROR] Exception caught: (pants.engine.internals.scheduler.ExecutionError)
  File "/Users/aadt/src/github/kaos/pants/src/python/pants/bin/local_pants_runner.py", line 236, in _run_inner
    return self._perform_run(goals)
  File "/Users/aadt/src/github/kaos/pants/src/python/pants/bin/local_pants_runner.py", line 175, in _perform_run
    return self._perform_run_body(goals, poll=False)
  File "/Users/aadt/src/github/kaos/pants/src/python/pants/bin/local_pants_runner.py", line 192, in _perform_run_body
    return self.graph_session.run_goal_rules(
  File "/Users/aadt/src/github/kaos/pants/src/python/pants/init/engine_initializer.py", line 135, in run_goal_rules
    exit_code = self.scheduler_session.run_goal_rule(
  File "/Users/aadt/src/github/kaos/pants/src/python/pants/engine/internals/scheduler.py", line 544, in run_goal_rule
    self._raise_on_error([t for _, t in throws])
  File "/Users/aadt/src/github/kaos/pants/src/python/pants/engine/internals/scheduler.py", line 503, in _raise_on_error
    raise ExecutionError(

Exception message: 1 Exception encountered:

Engine traceback:
  in select
  in pants.core.goals.package.package_asset
  in pants.backend.python.goals.setup_py.package_python_dist (testprojects/src/python/native:dist)
  in pants.backend.python.goals.setup_py.run_setup_py
  in pants.backend.python.util_rules.dists.run_pep517_build
  in pants.engine.process.fallible_to_exec_result_or_raise
Traceback (most recent call last):
  File "/Users/aadt/src/github/kaos/pants/src/python/pants/engine/process.py", line 270, in fallible_to_exec_result_or_raise
    raise ProcessExecutionFailure(
pants.engine.process.ProcessExecutionFailure: Process 'Run setuptools.build_meta for testprojects/src/python/native:dist' failed with exit code 1.
stdout:
running bdist_wheel
running build
running build_py
creating build
creating build/lib.macosx-11.5-x86_64-3.8
creating build/lib.macosx-11.5-x86_64-3.8/native
copying ./setup.py -> build/lib.macosx-11.5-x86_64-3.8/native
copying ./name.py -> build/lib.macosx-11.5-x86_64-3.8/native
running build_ext
building 'native.impl' extension
creating build/temp.macosx-11.5-x86_64-3.8
clang -Wno-unused-result -Wsign-compare -Wunreachable-code -DNDEBUG -g -fwrapv -O3 -Wall -I/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include -I/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include -I/Users/aadt/.cache/pants/named_caches/pex_root/venvs/short/6dae86d7/include -I/Users/aadt/.pyenv/versions/3.8.11/include/python3.8 -c impl.c -o build/temp.macosx-11.5-x86_64-3.8/impl.o

stderr:
package init file './__init__.py' not found (or not a regular file)
error: $MACOSX_DEPLOYMENT_TARGET mismatch: now "10.16" but "11.5" during configure



Use --no-process-execution-local-cleanup to preserve process chroots for inspection.

Traceback (most recent call last):
  File "/Users/aadt/src/github/kaos/pants/src/python/pants/bin/local_pants_runner.py", line 236, in _run_inner
    return self._perform_run(goals)
  File "/Users/aadt/src/github/kaos/pants/src/python/pants/bin/local_pants_runner.py", line 175, in _perform_run
    return self._perform_run_body(goals, poll=False)
  File "/Users/aadt/src/github/kaos/pants/src/python/pants/bin/local_pants_runner.py", line 192, in _perform_run_body
    return self.graph_session.run_goal_rules(
  File "/Users/aadt/src/github/kaos/pants/src/python/pants/init/engine_initializer.py", line 135, in run_goal_rules
    exit_code = self.scheduler_session.run_goal_rule(
  File "/Users/aadt/src/github/kaos/pants/src/python/pants/engine/internals/scheduler.py", line 544, in run_goal_rule
    self._raise_on_error([t for _, t in throws])
  File "/Users/aadt/src/github/kaos/pants/src/python/pants/engine/internals/scheduler.py", line 503, in _raise_on_error
    raise ExecutionError(
pants.engine.internals.scheduler.ExecutionError: 1 Exception encountered:

Engine traceback:
  in select
  in pants.core.goals.package.package_asset
  in pants.backend.python.goals.setup_py.package_python_dist (testprojects/src/python/native:dist)
  in pants.backend.python.goals.setup_py.run_setup_py
  in pants.backend.python.util_rules.dists.run_pep517_build
  in pants.engine.process.fallible_to_exec_result_or_raise
Traceback (most recent call last):
  File "/Users/aadt/src/github/kaos/pants/src/python/pants/engine/process.py", line 270, in fallible_to_exec_result_or_raise
    raise ProcessExecutionFailure(
pants.engine.process.ProcessExecutionFailure: Process 'Run setuptools.build_meta for testprojects/src/python/native:dist' failed with exit code 1.
stdout:
running bdist_wheel
running build
running build_py
creating build
creating build/lib.macosx-11.5-x86_64-3.8
creating build/lib.macosx-11.5-x86_64-3.8/native
copying ./setup.py -> build/lib.macosx-11.5-x86_64-3.8/native
copying ./name.py -> build/lib.macosx-11.5-x86_64-3.8/native
running build_ext
building 'native.impl' extension
creating build/temp.macosx-11.5-x86_64-3.8
clang -Wno-unused-result -Wsign-compare -Wunreachable-code -DNDEBUG -g -fwrapv -O3 -Wall -I/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include -I/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include -I/Users/aadt/.cache/pants/named_caches/pex_root/venvs/short/6dae86d7/include -I/Users/aadt/.pyenv/versions/3.8.11/include/python3.8 -c impl.c -o build/temp.macosx-11.5-x86_64-3.8/impl.o

stderr:
package init file './__init__.py' not found (or not a regular file)
error: $MACOSX_DEPLOYMENT_TARGET mismatch: now "10.16" but "11.5" during configure



Use --no-process-execution-local-cleanup to preserve process chroots for inspection.


(Use -ldebug for more logs. See <https://www.pantsbuild.org/v2.8/docs/troubleshooting> for common issues. Consider reaching out for help: <https://www.pantsbuild.org/v2.8/docs/getting-help.>)
12:38:07.57 [INFO] Canceled: Installing 3rdparty/python/lockfiles/user_reqs.txt
(Not sure about what the deployment target missmatch is about, I’m at 11.6, fwiw..) 😉 Also, this is not a prio for me, just something I stumbled upon…