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
-
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_settings
dilema 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_info
build
build_ext
bdist_wheel
tag_build
1debug
debug
2compression
3tag_date
force
define
py_limited_api
4no_date
parallel
undef
python_tag
5compiler
include_dirs
plat_name
6plat_name
7library_dirs
libraries
rpath
link_objects
swig_cpp
swig_opts
plat_name
8We can keep
--global-option
and--build-option
for now, working as proposed in #4079 (somehow compatible withpip
's legacy options).What is the challenge in passing
config_settings
fromsetuptools.build_meta
tosetuptools.dist.Distribution
?In
setuptools
/distutils
one 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_settings
intosys.argv
, because (due to the design discussed above) options work in an implicit way: even if you are callingbdist_wheel
, thebuild_ext
oregg_info
options will influence the build outcome.To make it worse, the following also happens:
*.dist-info
9setup.py
there is an "isolation barrier" betweensetuptools.build_meta
and 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_settings
so 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_meta
to acess thedist
object 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_meta
can processconfig_settings
accordingly (and we don't have to couplesetuptools.dist
with the UI choices made inbuild_meta
).Probably
setuptools.build_meta:_BACKEND._finalize_build_options
can work like the following:config_settings
that are not related to command objects(e.g.
level = config_settings.get("log_level", "warning"); logging.setLevel(gatattr(logging, level.upper()))
.)config_settings
into 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_ext
and others underbdist_wheel
seems a bit arbitraty.Moreover,
bdist_wheel
allows you to specifyplat_name
freely, butbuild
only allowplat_name
to be specified on Windows machines (e.g.win32
orwin-amd64
).My interpretation is that the
build
command does not want to give "false hopes" about cross compiling for Linux users, and only allow windows users to specifyplat_name
because it cannot automatically choose for them.On the other hand, I imagine that
bdist_wheel
allows values on linux so other plugins (e.g.setuptools-rust
) can use it when cross-compiling (vanillasetuptools
don't have cross-compilation capabilities, but plugins do).So we already have a disagreement between
setuptools
andbdist_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_name
andbdist_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_base
anddist_info.output_dir
.This way we can use PEP 517'
metadata_directory
and/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-info
to 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-info
tosys.path
MetaPathFinder
withfind_distributions
and add it tosys.meta_path
.Footnotes
Maybe rename to
version_tag
orlocal_version
?Since
.whl
files 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/False
option to bypass this validation? ↩ ↩2Fallback to
build.plat_name
↩So if you pass options to
egg_info
/dist_info
inprepare_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