Friday, 2025-01-03

clarkbnow there is a new problem with pip install -e and pip install having apparently different behaviors when it comes to writing out the consoel scripts00:01
clarkboh maybe it is because I cannot spell00:08
Clark[m]Ok I need to stop for the day but I think the issue is pyproject.toml goes through a different path for console scripts so the pbr files aren't used?00:38
Clark[m]After fixing my issues the install -e also fails00:38
fungiyeah, creating the console scripts is pip's responsibility (they're not packed inside sdists and wheels)14:20
fungiso it's a question of making pip notice, i guess14:21
fungii think it's expecting a [project.scripts] table in pyproject.toml14:22
fungithe footnote at https://setuptools.pypa.io/en/latest/userguide/pyproject_config.html#id3 looks relevant. i think that means it might prefer a [tool.setuptools.dynamic.entry-points] table instead with a console_scripts subtable?14:27
fungilooks like pep 621 is where project.scripts was standardized14:38
fungifwiw, we may need to duplicate some values between setup.cfg and pyproject.toml to make this work, at least until we reach the point where we can drop setup.cfg/setup.py entirely14:40
fungithough maybe tool.setuptools.dynamic.entry-points is the backdoor to letting pbr fill the console_scripts metadata instead of relying on the project.scripts table?14:44
fungiyeah, in the project where i'm using pbr with a project.scripts table in pyproject.toml, setuptools puts an entry_points.txt in the wheel containing a [console_scripts] block with the mapping of script name to module:function, which pip then uses to add the scripts at installation14:49
fungiso it does at least work that way, though not having to duplicate it between setup.cfg and pyproject.toml would be great14:49
fungipart of the problem, i think, is the notion that the existence of pyproject.toml in a project means most of its metadata is statically defined in the file, and in order to dynamically feed it to setuptools (or any other backend) with a plugin you need to basically state in pyproject.toml that it will be "dynamic" (i need to do that for the version in mine, for example, because pbr14:54
fungiwill be determining that rather than it being a fixed string in pyproject.toml)14:54
fungisomething like...14:55
fungi[project]14:55
fungidynamic = ["console_scripts","version"]14:55
fungi(and anything else that's going to live exclusively in setup.cfg or get generated by pbr on the fly at build time)14:56
fungilooks setuptools as of 75.6.0 should also have started emitting warnings about ignoring them when not flagged as dynamic per https://github.com/pypa/setuptools/pull/4012/files15:00
fungii think the expectation in the python packaging ecosystem is that, if your project is going to have both a pyproject.toml and old-style (setup.py, setup.cfg, requirements.txt...) files, you should duplicate as much as possible into pyproject.toml and then mark the rest as dynamic15:02
fungiin the case of my project, i really only need dynamic = ["version"] in order to allow pbr to generate version strings (otherwise tools are supposed to expect a hard-coded project.version string in pyproject.toml)15:04
Clark[m]fungi: to be clear pip writes out console scripts for us but they are not using the PBR content for those scripts. You think marking console scripts as dynamic will allow pbr/setup tools to write them instead?15:24
fungihow does pbr's version of the scripts differ?15:24
Clark[m]The difference isn't huge. I think in the before times PBR was cutting out pkg_resources slowness15:25
fungiand no, what *should* matter at least is if the package metadata in your sdist and/or wheel have the right console_scripts list15:25
Clark[m]Today they are much more similar 15:25
fungisince console_scripts is what pip is looking at to create the scripts15:26
Clark[m]Right but we explicitly don't want pip to create anything for us15:26
Clark[m]It's doing that now and doing it "wrong"15:26
fungii don't think setuptools/pbr even can create those scripts? where in the wheel would they end up?15:26
fungiunless you mean exclusively in the editable case, maybe that's where setuptools/pbr are on the hook for making the script files15:27
Clark[m]I don't know but it works in testing with setup.py stuff today before I started changing stuff15:27
Clark[m]It works for both editable and not editable installs prior to my changes15:27
fungiwhen i was testing using pbr with pyproject.toml files in the past, i basically created sdists and wheels both with and without, and then diffed the resulting metadata file contents15:28
Clark[m]I'm going to push an update to testing that adds pip instead of replacing setup.py as a base change and we can compare/build from there 15:29
fungisetuptools/pbr don't get executed at install time, only at build time. the distinction between build and install is a little fuzzy when "installing" a source tree or sdist, but for wheels there is a pretty clear separation (and modern pip tries to enforce that by building a wheel and then installing the wheel)15:29
fungiso all the data pip is going to be acting on in the wheel install case has to be contained inside the wheel, and there is nowhere in a wheel that i'm aware of to record full entrypoint script contents (only the mapping of name to function)15:31
clarkbI see so this may be a consequence of changing from setup.py to pip (because setuptools isn't available on python3.12 by default) and not a switch from setup.cfg and setup.py metadata to pyproject.toml metdata15:33
fungientirely possible15:33
clarkbgive me a few minutes to write this change and load ssh keys and CI should confirm for us then we can decide what an appropriate course of action will be (I'm thinking accept it and move on may be appropriate)15:33
clarkbfungi: pbr commit 8e58c2fa58fd1aa6f9985dcb4e210508a73e1df7 says that the console scripts were replaced because the defaults are complex and slow15:46
clarkband it points at entry poitns as the problem which seems to align with what I suspected15:46
clarkbI guess importantly if the behavior is different between the two paths we've probably already been relying on the pip supplied script content without knowing it and that has worked for us. Could still be slow I suppose but would be functional15:49
clarkbfungi: look like pip install -e gets you the PBR generated console script but pip install does not in the no pyproject.toml case. The updates I made to add pyproject.toml switch to pip supplied script for both cases (whcih makes sense now that pep660 and editable wheel installs can occur with pyproject.toml)15:58
clarkbhttps://zuul.opendev.org/t/openstack/build/30d08bf1a1b440b5bccfb09ea079054915:58
clarkbconsidering that is the existing behavior whether pbr likes it or not I think I'll go ahead and encode that into the updated test so that we can land it and at least start enforcing things so we detect behavior changes in the future15:59
fungiyeah, that was my suspicion. pip install (no -e) builds a wheel and then installs just what's in that, so loses any chance for setuptools/pbr to decide what the internals of the script look like16:18
clarkbthe pip script is almost identical to the pbr one too16:19
clarkba big change from what setuptools is/was generating with lots of entry point magic iirc16:19
clarkbya thinking about this anyone using pip recently would've gotten this behavior anyway (and by recently I mean for at least a few years)16:21
clarkbso I think from our perspective its ok to accept that behavior, test that it doesn't change (so that we know if it does) and not worry about it too much16:22
fungiright, i think editable installs are already enough of a corner case that any regression in performance which makes them closer to regular installs is acceptable (maybe even preferable)16:32
clarkbfungi: the major question I've got is whether or not it is safe to put six>=1.16.0 in requirements.txt for pbr. I've limited the setuptools installation there to python3.12 and newer. I susppose I could do similar for six and then continue to manually install six where we need it elsewhere?17:16
clarkbthe problem is pbr does actually rely on six and it doesn't seem to be consistently available at this point like it was in the past so I'm trying to be more explicit about it17:17
clarkbin theory it works with python2.7 and the python3 ersions we do test though so I think it is safe17:17
clarkbtheory backed with our testing I mean17:17
fungiwhat is pbr still using six for?17:27
fungias a bridge for its remaining 2.7 support?17:27
clarkbhrm looks like its mostly in testing with one location in the sphinx integration for a config parser import?17:28
clarkbwe can probably just remove six17:28
clarkbI think that is a better idea. remove six, then redo packaging and testing17:29
fungididn't we also drop the sphinx integration bits? or no i guess we just dropped the sphinx building wrapper?17:30
clarkbya its just the command that got dropped iirc17:30
fungiright, because it had to be called as a setup.py subcommand and directly calling setup.py is deprecated17:31
fungilooks like the current patchset for 938332 is going to work everywhere besides noble18:26
clarkbyup I have a fix queued up locally that also rebases the entire stack on top of the six removal. I want zuul to post reuslts though so they are easier to find in the future so I'm waiting18:27
fungilooks like it has to do with missing setuptools in newer python venvs?18:30
clarkbyup I was trying to remove the use of setuptools from as many locations as possible to exercise teh inclusion of setuptools via requirements.txt and pyproject.toml. but in that case we're invoking setup.py directly so it doesn't work. I'm just going to add that case back in18:33
clarkbthe entire test case could really be rewritten/reimagined with modern tools18:33
clarkbfungi: ok new patchsets pushed. I think this might be happy now. Then its a matter of determining if we are hapyp with it as reviewers18:36
fungihaving skimmed all 4 up to this point, i think i am, but will give them a closer look once known passing18:37
clarkbthe first two changes in the stack should be pretty safe. They are just improving what is already there without changing behaviors. The second two potentially change runtime behavior18:40
clarkboh there is the fifth change to correct the testing of pbr changes in the integration tests too18:43
clarkbthat one should also be safe18:43
fungiyeah, i already reviewed that one a while back18:43
fungido these need rebasing onto it to ensure testing is complete?18:43
clarkbfungi: the last change in the stack depends on it18:44
fungiah, good, i missed that it was using depends-on18:44
clarkbwhich I think is probably sufficient coverage if we look at things as a whole18:44
fungiagreed18:44
clarkbgerrit_file_diff and git_file_diff caches for gerrit are eachin the ~20GB size range for the backing file now19:06
clarkbstill quite a bit smaller than the one extra large file we had previously. I'm beginning to wonder if we should detune our cache sizes so that daily cachine pruning has more room to trim which might keep the files smaller?19:07
clarkbwhen it isn't holiday hangover time we should also apply the update to compact the files on shutdown19:08
clarkbfungi: reading your comments how do you install pip into a venv without it being preinstalled? I'm guessing there is some magic with get-pip.py running against the venv python?19:34
clarkband ya I think testing with build and wheel are good ideas but maybe as followups?19:35
fungiagreed, i don't think they need to be included in that change, just brainstorming19:36
fungias for installing pip, these days you can run it without "installing" by downloading and executing its zipapp directly from python19:37
clarkbI'll clean things up a bit as far as comments and commit messages explaining things go after lunch today. I think adding more tools and updating mkvenv to install pip would be fine as followups but don't seem super necesasry in this first pass 19:38
clarkbalso checking the resulting pbr wheel is a good idea19:38
clarkbit does seem to work glancing at the integration testing job logs. We install a dev version of pbr from source that then functions to enable setup.py things to run against test-project19:38
clarkbbut confirming directly is a good idea19:39
fungias for a pip zipapp, you can find various versions (also virtualenv) under https://bootstrap.pypa.io/19:39
fungicpython can treat a pyz file like an installed module19:40
fungiworth thinking about in the future since it might be simpler than get-pip.py19:40
fungihttps://python.readthedocs.io/en/stable/library/zipapp.html for the basic functionality. does work with 3.6 (though there's likely not an old enough pip.pyz for 3.6 support), but not with 2.719:42
fungiyeah, pip-22.3.1.pyz is the oldest available and that requires_python>=3.719:44
fungiall 5 changes lgtm, i left comments/questions on some but they look fine to merge19:51
fungiand barring any last-minute failures in the tempest-full jobs it seems like zuul will agree19:52
fungiclarkb: i've run build in both the tip of master and a checkout of 938332 and am starting to compare them for differences19:57
fungifirst thing i notice is that the before sdist includes a pbr.egg-info/requires.txt while the after is missing it, but the after sdist has a requirements.txt that wasn't in the before19:58
fungihttps://paste.opendev.org/show/bJ253Xx1CYFxIiVgU7xe/20:00
fungino, i misread. both the pbr.egg-info/requires.txt and requirements.txt are present, i suppose that's because of the setuptools addition20:01
fungiboth are present in the after and not the before, i mean20:01
fungiyeah, pbr.egg-info/requires.txt just contains "setuptools" while requirements.txt contains "setuptools;python_version>='3.12'" so those can be attributed as expected outcomes of 93833220:04
fungithe wheel file lists for before and after are identical, adjusting for where the version string gets embedded in the dist-info directory name20:10
fungidiffing the content of the metadata files between the wheels: https://paste.opendev.org/show/bxjvHTkMvglHyiPzodDZ/20:12
fungithe only thing that's mildly concerning is the Generator field in the WHEEL file, which seems like we're somehow making setuptools think the pbr version is the version of setuptools20:13
fungii wonder if we're shadowing or unintentionally monkeypatching one of its methods20:13
fungibut all things considered it's extremely minor20:13
fungihttps://paste.opendev.org/show/b2y7S3WZfoNpV4TEEKr7/ is a similar diff of the sdist metadata files and the only oddity i see is the addition of AUTHORS as a license-file entry but i think that's setuptools' automated license file finder coming into play20:20
fungioverall i'm satisfied we're not introducing any breakage to the package contents or metadata with this change, though it might still be a good to figure out why the wheel's "generator" has pbr's version listed instead of setuptools'20:22
fungii do have a separate concern looking at these, but it already exists in master: we're declaring "Metadata-Version: 2.1" but have fields that aren't valid until 2.4 (e.g. license-file)20:24
fungihttps://packaging.python.org/en/latest/specifications/core-metadata/#license-file-multiple-use20:25
fungihowever, i gather pypi/warehouse is currently rejecting metadata 2.4 uploads, so that might be for the best20:25
fungianyway, all 5 changes are green in zuul and have my +220:28
Clark[m]Cool I do want to make some of your suggested edits once I've finished eating. Re the PBR version could it be due to having pbr essentially hand over to setup tools? So really it is setup tools generating for us?20:46
fungiwell, it's claiming "Generator: setuptools (6.1.1.dev5)" in the new wheel20:52
fungiwhereas the old wheel had "Generator: setuptools (75.6.0)"20:52
fungibut 6.1.1.dev5 is the version of pbr, not the version of setuptools20:53
fungii don't think pbr is expressing that metadata field directly either way20:54
fungibut the wheel library is determining that setuptools is the metadata generator, yet for some reason finding the version string for pbr rather than setuptools20:55
fungimight be a bug in build/wheel, or it could be a sign that pbr is unintentionally shadowing setuptools' version string internally20:56
clarkbfungi: I just pushed some updates based on your feedback. Thanks21:22
fungiyep, i'm already checking the diffs. thanks!21:22
clarkbI'm not seeing anything obvious in setuptools that produces the Generator metadata. (it could still bein there and I'm missing it). I suspect that pip or build or whatever is running the pep517/pep660 process is producing that?21:27
fungii think wheel sets it, but i'm not certain as i haven't started looking yet21:28
clarkbmy hunch is that the pep517 hooks (or maybe less formal expectations?) get the generator via the hook so get setuptools since we're just a shim to setuptools but then when asking for the version do something like footool.version or whatever and get the pbr version?21:29
clarkbbut ya we'd need to find what produces it first to understand that better. wheel does seem like a likely candidate21:30
fungiyeah, whatever it is, it's most likely being naive about deciding what to query for the version21:30
fungioh, yes https://pypi.org/p/pyproject-hooks is also a possibility21:31
clarkboh ok maybe setuptools is doing it. I dismissed the email related content but apparently they use that as a stdlib hack to get headers into a file21:37
clarkbself, wheelfile_base: str, generator: str = f"setuptools ({__version__})"21:38
clarkbI dont' see pbr setting __version__ though21:39
fungii think __version__ may get automagically set under some circumstances21:44
fungiin theory there's supposed to be a distinction between the "dist package" version and the "import package" version reported by importlib, but pbr has traditionally equated the two for simplicity/consistency21:45

Generated by irclog2html.py 2.17.3 by Marius Gedminas - find it at https://mg.pov.lt/irclog2html/!