future-oxygen-10553
08/25/2022, 6:49 PMpython_distribution
target and handling PEP 517 compliant backends. I have two specific problems, which are both demonstrated in this repo: https://github.com/bryanwweber/pep621-pants-test
First, running ./pants package src/test-flit::
, I get an error:
14:48:33.97 [ERROR] 1 Exception encountered:
Engine traceback:
in select
in pants.core.goals.package.package_asset
in pants.backend.python.goals.setup_py.package_python_dist (src/test-flit:test-flit)
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/bweber/.cache/pants/setup/bootstrap-Darwin-arm64/pants.MAN743/install/lib/python3.9/site-packages/pants/engine/process.py", line 272, in fallible_to_exec_result_or_raise
raise ProcessExecutionFailure(
pants.engine.process.ProcessExecutionFailure: Process 'Run flit_core.buildapi for src/test-flit:test-flit' failed with exit code 1.
stdout:
stderr:
Traceback (most recent call last):
File "/private/var/folders/zj/p64fbz8d6nd6st_w625_cf7r0000gq/T/pants-sandbox-MxaxV1/chroot/src/test-flit/../../../.cache/pex_root/venvs/31101af6a39067ea0ded21c13e22768ab8004113/c6158e3f0f08aecef5110af6fc1a7d94053f2bee/pex", line 229, in <module>
exec(ast, globals_map, locals_map)
File "backend_shim.py", line 16, in <module>
wheel_path = backend.build_wheel(dist_dir, wheel_config_settings) if build_wheel else None
File "/Users/bweber/.cache/pants/named_caches/pex_root/venvs/31101af6a39067ea0ded21c13e22768ab8004113/c6158e3f0f08aecef5110af6fc1a7d94053f2bee/lib/python3.10/site-packages/flit_core/buildapi.py", line 72, in build_wheel
info = make_wheel_in(pyproj_toml, Path(wheel_directory))
File "/Users/bweber/.cache/pants/named_caches/pex_root/venvs/31101af6a39067ea0ded21c13e22768ab8004113/c6158e3f0f08aecef5110af6fc1a7d94053f2bee/lib/python3.10/site-packages/flit_core/wheel.py", line 219, in make_wheel_in
(fd, temp_path) = tempfile.mkstemp(suffix='.whl', dir=str(wheel_directory))
File "/opt/homebrew/Cellar/python@3.10/3.10.6_1/Frameworks/Python.framework/Versions/3.10/lib/python3.10/tempfile.py", line 341, in mkstemp
return _mkstemp_inner(dir, prefix, suffix, flags, output_type)
File "/opt/homebrew/Cellar/python@3.10/3.10.6_1/Frameworks/Python.framework/Versions/3.10/lib/python3.10/tempfile.py", line 256, in _mkstemp_inner
fd = _os.open(file, flags, 0o600)
FileNotFoundError: [Errno 2] No such file or directory: '/private/var/folders/zj/p64fbz8d6nd6st_w625_cf7r0000gq/T/pants-sandbox-MxaxV1/chroot/src/test-flit/dist/tmplaw_7nkj.whl'
future-oxygen-10553
08/25/2022, 6:50 PMpants
2.12.0 and 2.13.0rc1future-oxygen-10553
08/25/2022, 6:51 PMsetuptools
allows this by a configuration option in setup.cfg
but pants
is not able to read this valuefuture-oxygen-10553
08/25/2022, 6:52 PM./pants package src/test-setuptools::
results in a wheel called setuptools_module-0.0.0-py3-none-any.whl
future-oxygen-10553
08/25/2022, 6:56 PMresource
for setup.cfg
future-oxygen-10553
08/25/2022, 6:56 PMhappy-kitchen-89482
08/25/2022, 7:46 PMfuture-oxygen-10553
08/25/2022, 7:50 PMpants
create it?happy-kitchen-89482
08/25/2022, 7:51 PMhappy-kitchen-89482
08/25/2022, 7:51 PMdiff --git a/src/python/pants/backend/python/util_rules/dists.py b/src/python/pants/backend/python/util_rules/dists.py
index 9aa926a8b..3cfe90602 100644
--- a/src/python/pants/backend/python/util_rules/dists.py
+++ b/src/python/pants/backend/python/util_rules/dists.py
@@ -144,6 +144,7 @@ class DistBuildResult:
_BACKEND_SHIM_BOILERPLATE = """
# DO NOT EDIT THIS FILE -- AUTOGENERATED BY PANTS
+import os
import {build_backend_module}
backend = {build_backend_object}
@@ -154,6 +155,7 @@ build_sdist = {build_sdist}
wheel_config_settings = {wheel_config_settings_str}
sdist_config_settings = {sdist_config_settings_str}
+os.makedirs(dist_dir, exist_ok=True)
wheel_path = backend.build_wheel(dist_dir, wheel_config_settings) if build_wheel else None
sdist_path = backend.build_sdist(dist_dir, sdist_config_settings) if build_sdist else None
happy-kitchen-89482
08/25/2022, 7:51 PMhappy-kitchen-89482
08/25/2022, 7:51 PMValueError: No file/folder found for module a_module
future-oxygen-10553
08/25/2022, 7:52 PMflit
test folderfuture-oxygen-10553
08/25/2022, 7:53 PMa_module
is what I had called the module at some point in the pasthappy-kitchen-89482
08/25/2022, 7:53 PMhappy-kitchen-89482
08/25/2022, 7:53 PMfuture-oxygen-10553
08/25/2022, 7:54 PMhappy-kitchen-89482
08/25/2022, 7:54 PMfuture-oxygen-10553
08/25/2022, 7:55 PMhundreds-father-404
08/25/2022, 8:08 PMfuture-oxygen-10553
08/25/2022, 8:10 PMhappy-kitchen-89482
08/25/2022, 8:16 PMhappy-kitchen-89482
08/25/2022, 8:16 PMhappy-kitchen-89482
08/26/2022, 2:14 PMhappy-kitchen-89482
08/26/2022, 2:14 PMfuture-oxygen-10553
08/26/2022, 2:26 PMfuture-oxygen-10553
08/26/2022, 2:26 PMmain
I’ll be able to use it for testing right away, so I really appreciate itfuture-oxygen-10553
08/26/2022, 2:52 PMpyproject.toml
to point to the right module, flit
packaging works as expected now!happy-kitchen-89482
08/26/2022, 2:55 PM