More permanent solution for PEP 517/660's config_settings
#4083
abravalheri
started this conversation in
Ideas
Replies: 2 comments
-
|
I'm not sure this is actually very visible as a "discussion". Might be better as an RFC issue? |
Beta Was this translation helpful? Give feedback.
0 replies
-
We were depending on |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Request for comments / options / suggestions.
Cc @pypa/setuptools-developers, see motivation in #3896, #2491 and other related issues.
The detailed "state of the implementation" is described in #3896 (comment).
What to put in
config_settings?As discussed in #3896 (comment), I believe a more definitive solution for the
config_settingsdilema insetuptools, is to accept something like the following:The following is a list of relevant options (in my opinion) by command.
I think that for now we can focus on only allowing these options to be customised, or maybe even a smaller subset.
egg_info/dist_infobuildbuild_extbdist_wheeltag_build1debugdebug2compression3tag_dateforcedefinepy_limited_api4no_dateparallelundefpython_tag5compilerinclude_dirsplat_name6plat_name7library_dirslibrariesrpathlink_objectsswig_cppswig_optsplat_name8We can keep
--global-optionand--build-optionfor now, working as proposed in #4079 (somehow compatible withpip's legacy options).What is the challenge in passing
config_settingsfromsetuptools.build_metatosetuptools.dist.Distribution?In
setuptools/distutilsone command can not only run another command directly, but also access other command's option and even modify them.This makes it difficult to convert
config_settingsintosys.argv, because (due to the design discussed above) options work in an implicit way: even if you are callingbdist_wheel, thebuild_extoregg_infooptions will influence the build outcome.To make it worse, the following also happens:
*.dist-info9setup.pythere is an "isolation barrier" betweensetuptools.build_metaand the other parts of setuptools: currently all the communication is one way (build_meta => rest) and happens viasys.argv.10How to solve this challenge?
I think that we can use something something similar to the suggestion in #3896 (comment) (i.e. use
repr(...)to serialiseconfig_settingsso it can go tosys.argv, and then useast.parse_literal(...)on the other side to retrive it).However I would like to expand on it and also propose a "private build hook" that would allow
build_metato acess thedistobject directly (and therefore counterbalance the "isolation barier" mentioned above). All togheter it could look like the following:Then we could modify
setuptools.dist.Distribution._parse_command_opts()to callxxx_private_build_hook(dist_obj, ast.literal_eval(xxx_private_build_args)).This way
build_metacan processconfig_settingsaccordingly (and we don't have to couplesetuptools.distwith the UI choices made inbuild_meta).Probably
setuptools.build_meta:_BACKEND._finalize_build_optionscan work like the following:config_settingsthat are not related to command objects(e.g.
level = config_settings.get("log_level", "warning"); logging.setLevel(gatattr(logging, level.upper())).)config_settingsinto something that can be directly assigned to the command objects.dist_info.version_tag => dist_info.tag_build) and or values.bdist_wheel.plat_name => [bdist_wheel.plat_name, build.plat_name)Other Open Challenges
Naming and semantics
Names are hard ... and separating some options under
build, others underbuild_extand others underbdist_wheelseems a bit arbitraty.Moreover,
bdist_wheelallows you to specifyplat_namefreely, butbuildonly allowplat_nameto be specified on Windows machines (e.g.win32orwin-amd64).My interpretation is that the
buildcommand does not want to give "false hopes" about cross compiling for Linux users, and only allow windows users to specifyplat_namebecause it cannot automatically choose for them.On the other hand, I imagine that
bdist_wheelallows values on linux so other plugins (e.g.setuptools-rust) can use it when cross-compiling (vanillasetuptoolsdon't have cross-compilation capabilities, but plugins do).So we already have a disagreement between
setuptoolsandbdist_wheel.Ideally I would like to have only one option for
plat_name(e.g.build.plat_name- does it mean that we need to flexibilizebuild.plat_name?) - so we avoid the confusing situation where the user can pass 2 different values forbuild.plat_nameandbdist_wheel.plat_name...But then we are back to the problem of arbitrarily separating parameters under
build/build_ext/bdist_wheel/...How does this change impacts the other open issues in
setuptools?To solve #3237 and #3119,
we can consider setting
egg_info.egg_baseanddist_info.output_dir.This way we can use PEP 517'
metadata_directoryand/or temporary directories and avoid read only project trees.However, if we do that we stumble into a different problem: sometimes the build process is designed to have
the directory containing
*.egg-info/*.dist-infoto be available insys.path.This is required so the entry points are available to
importlib.metadata(see #3921 (comment) and the following comment).
If we want to go ahead and use "off-tree"
*.egg-info, I believe we have 2 choices:*.egg-info/*.dist-infotosys.pathMetaPathFinderwithfind_distributionsand add it tosys.meta_path.Footnotes
Maybe rename to
version_tagorlocal_version?Since
.whlfiles can have abuild tag, which is a different thing... ↩Fallback to
build.debug(so we can probably ommitbuild_ext.debug) ↩E.g.:
"stored","deflated". ↩E.g.:
cp38. ↩E.g.:
py3,py2,py2.py3,py27, ... ↩Fallback to
bdist.plat_name, which in turn fallback tobuild.plat_name,however it behaves differently from
build.plat_name, because it does accept arbitraryvalues for any operating system. See footnote7 ↩
Only valid on Windows, though... There is a validation in
distutils.Maybe we can add an
externally_crosscompiled=True/Falseoption to bypass this validation? ↩ ↩2Fallback to
build.plat_name↩So if you pass options to
egg_info/dist_infoinprepare_metadata_for_build_wheel, then you need to pass the same options again inbuild_wheel. ↩ ↩2As a result we have to implement all sorts of hacks when we need to somehow access the "rest" of setuptools, e.g.: the hack for extracting
dist.setup_requires' value. ↩Beta Was this translation helpful? Give feedback.
All reactions