aboutsummaryrefslogtreecommitdiff
path: root/pym
Commit message (Collapse)AuthorAgeFilesLines
* merge_driver_ekeyword: Add build systemMatt Turner2024-06-254-0/+49
| | | | Signed-off-by: Matt Turner <mattst88@gentoo.org>
* merge_driver_ekeyword: Run blackMatt Turner2024-06-201-21/+39
| | | | Signed-off-by: Matt Turner <mattst88@gentoo.org>
* merge_driver_ekeyword: Add testsMatt Turner2024-06-2017-0/+681
| | | | | | And provide a Makefile to generate the test data from gentoo.git. Signed-off-by: Matt Turner <mattst88@gentoo.org>
* merge_driver-ekeyword: split out merge_keywords functionMatt Turner2024-06-071-15/+19
| | | | Signed-off-by: Matt Turner <mattst88@gentoo.org>
* bin/merge-driver-ekeyword: Move logic to a separate moduleMatt Turner2024-06-072-0/+143
| | | | | | To facilitate unit testing. Signed-off-by: Matt Turner <mattst88@gentoo.org>
* ekeyword: Remove dead MakefileMatt Turner2024-06-072-19/+0
| | | | | | Has been dead since commit c819d14 in 2009. Signed-off-by: Matt Turner <mattst88@gentoo.org>
* eclean: dist: make VCS cleaning dependent on --deepSam James2024-05-031-3/+3
| | | | | | | | | | | | The man page clearly says that without --deep, users can expect eclean-dist to be conservative in cleaning up, and not consider the VDB, just the repo state. Honour that promise by making VCS cleaning dependent on --deep, given it involves VDB inspection to see what's installed. Bug: https://bugs.gentoo.org/923369 Signed-off-by: Sam James <sam@gentoo.org>
* package: update example PORTDIR pathSam James2024-05-031-3/+3
| | | | Signed-off-by: Sam James <sam@gentoo.org>
* eclean: dist: fix crash with excluded itemsSam James2024-05-031-0/+1
| | | | | Bug: https://bugs.gentoo.org/915055 Signed-off-by: Sam James <sam@gentoo.org>
* eclean: dist: fix printing VCS clean items with --quietSam James2024-05-031-2/+5
| | | | | Bug: https://bugs.gentoo.org/928951 Signed-off-by: Sam James <sam@gentoo.org>
* eclean: dist: fix copyright headersSam James2024-05-034-4/+4
| | | | Signed-off-by: Sam James <sam@gentoo.org>
* eclean: dist: fix typo in commentSam James2024-05-031-2/+2
| | | | Signed-off-by: Sam James <sam@gentoo.org>
* eclean: dist: fix operating on an empty directorySam James2024-05-031-1/+2
| | | | | | | | Zac pointed out that not all return paths had been updated. Bug: https://bugs.gentoo.org/928138 Fixes: 87912b460c533f8b010617018fdad42246db85f0 Signed-off-by: Sam James <sam@gentoo.org>
* depends.py: rename DependPrinter to PrinterJohn Turner2024-03-071-4/+4
| | | | | | | | | | | The DependPrinter class name and documentation indicated that it was meant to be part of the gentoolkit.dependencies API, to print Dependencies objects. This Printer class is used exclusively for printering equery depends output and is not a public API outside of the depends.py module Signed-off-by: John Turner <jturner.usa@gmail.com> Signed-off-by: Sam James <sam@gentoo.org>
* equery/depends: print output in module rather than with a callbackJohn Turner2024-03-071-11/+18
| | | | | | | | | | | | | | | | | The depends module can now iterate over the results of the graph_reverse_depends function and print the items as they are yielded. Before, it passed in a callback printer function, and expected the Dependencies class to call it correctly. This setup is nicer because it does not tie together this module and the Dependencies class, and the old setup most likely existed due to performance and interactivity concerns which are now fixed by turning graph_reverse_depends into an iterator. Signed-off-by: John Turner <jturner.usa@gmail.com> Signed-off-by: Sam James <sam@gentoo.org>
* dependencies.py: rewrite graph_reverse_depends to pass testsJohn Turner2024-03-071-66/+36
| | | | | | | | | | | | | | | | | | | The graph_reverse_depends method was not able to pass the unit tests introduced in the previous commits. It has been rewritten to pass them. This also has adding types to the method, and yields the results as an iterator rather than collecting them into a list in one shot. The printer callback parameter has been removed. This callback most likely existed so that results would be shown to the user as soon as they were available instead of delaying printing until the method completed, which could take seconds or minutes depending on the parameters. By making this method an iterator, the same effect is acheived by having the caller print every item as its yielded from the method. Signed-off-by: John Turner <jturner.usa@gmail.com> Signed-off-by: Sam James <sam@gentoo.org>
* dependencies.py: introduce unit testing for graph_reverse_dependsJohn Turner2024-03-071-0/+71
| | | | | | | | | | | | | | | | | | | This commit introduces a new file with a basic unit test for the graph_reverse_depends method on the Dependencies class. Only 1 test exists right now, but various setup code and the general pattern of the tests are valuable for creating more advanced tests, and more tests for the Dependencies class in general. Pytest is used to run all of the functions in the file that start with test_, and a monkeypatch object is passed into test cases and allows us to mock out methods on the Dependencies class, specifically the "environment" method, which is used to query for packages variables like DEPEND and RDEPEND. We are able to test against a small fake denendency graph by patching the method! Signed-off-by: John Turner <jturner.usa@gmail.com> Signed-off-by: Sam James <sam@gentoo.org>
* dependencies.py: use Enum rather than StrEnum for DependencyKindJohn Turner2024-03-071-4/+4
| | | | | | | | | | | | | | | | StrEnum is only supported in Python versions 3.11 and newer. Gentoolkit should not require >=3.11, so DependencyKind will use the regular Enum feature instead. The difference between StrEnum and Enum is that StrEnum members are strings and can generally be used in place of strings in APIs expecting string input. Non-StrEnum members are not strings, but you can get members values by accessing their value field (DependencyKind.DEPEND.value). Fixes: 78464ec40bad9a0f824b063506f58296cc3ed9f3 Signed-off-by: John Turner <jturner.usa@gmail.com> Closes: https://github.com/gentoo/gentoolkit/pull/46 Signed-off-by: Sam James <sam@gentoo.org>
* eclean/search.py: Fix find_packages docstring for invalid_pathsBrian Dolbec2024-02-171-3/+2
| | | | Signed-off-by: Brian Dolbec <dolsen@gentoo.org>
* Initial tests for _deps_equal()Brian Dolbec2024-02-171-0/+157
| | | | Signed-off-by: Brian Dolbec <dolsen@gentoo.org>
* eclean: Handle InvalidDepstring info in _deps_equalBrian Dolbec2024-02-171-6/+48
| | | | | | | | | | | | Add try/except pair to _deps_equal() to output relavent details causing the exception in order to aid the user to fix the issue. Mark binpkg dep failures as a non match for possible deletion. Make the ebuild dep failure a warning only, return True to save the binpkg. Add parameter docstring info Bug: https://bugs.gentoo.org/923439 Signed-off-by: Brian Dolbec <dolsen@gentoo.org>
* gentoolkit: fix flake8 lint error (F401, unused import)Sam James2024-02-171-1/+0
| | | | | | | pym/gentoolkit/dependencies.py:24:1: F401 'gentoolkit.helpers.uniqify' imported but unused Fixes: c0300517671076db453204c796637e206bf977e5 Signed-off-by: Sam James <sam@gentoo.org>
* enalyze: placate blackSam James2024-02-161-1/+1
| | | | Signed-off-by: Sam James <sam@gentoo.org>
* dependencies.py: replace hand rolled depcache with functools.cacheJohn Turner2024-02-161-9/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | functools.cache caches the output of functions "automatically" without requiring any manual management of a cache value. When used on class methods, the cache is associated with each class instance and only lives as long as the instance does. The Dependencies.graph_reverse_depends method used a dict to cache the output from pkg.get_all_depends. The get_all_depends method involves calling portage's aux_get and parsing the DEPEND string that is returned by it. This dict has been removed and replaced with functools.cache. The graph_reverse_depends method did not cache the output of the "raw=True" get_all_depends calls. This "raw" output is the literal string value for the pkgdeps *DEPEND variables as returned by aux_get. Searching this for a category/package sub-string allows quickly ruling out non-matching pkgdeps, which allows skipping parsing the DEPEND string into a list of Atoms. Using functools cache the method that fetches the raw DEPEND string massively improves performance for graph_reverse_depends when searching for indirect reverse dependencies. "equery depends --indirect emacs" runtime is ~2s with the raw value being cached, and ~60s without. Searching for only direct reverse dependencies does not utilize the cache and does not see any chance in runtime for me. Signed-off-by: John Turner <jturner.usa@gmail.com> Closes: https://github.com/gentoo/gentoolkit/pull/44 Signed-off-by: Sam James <sam@gentoo.org>
* dependencies.py: unify get_*depend methodsJohn Turner2024-02-161-17/+15
| | | | | | | | | | | | | | | | | Instead of having separate functions for each DEPEND kind, the unified method returns a dict with all of the packages *DEPEND values inside of it. The dict can be indexed with a string or a field of the DependencyKind enum. This will be espeically useful for a future change that adds the ability to filter out specific DEPEND kinds from the query. The Dependencies class did not search IDEPEND dependencies, the unified method searches all dependency kinds defined in the DependencyKind enum, which includes IDEPEND! Signed-off-by: John Turner <jturner.usa@gmail.com> Signed-off-by: Sam James <sam@gentoo.org>
* dependencies.py: create DependencyKind enumJohn Turner2024-02-161-0/+10
| | | | | | | | | The DependencyKind enum allows iterating over the different dependency kinds and represents each dependency kind as a type. This could later be used in APIs for selecting specific dependency kinds in queries. Signed-off-by: John Turner <jturner.usa@gmail.com> Signed-off-by: Sam James <sam@gentoo.org>
* eclean: handle when git3-src doesn't exist (port to Pathlib)Siddhanth Rathod2024-01-191-25/+25
| | | | | | | | | Followup to c584d83705a2ca08961e4f0b541442fdf9a75947. Bug: https://bugs.gentoo.org/922455 Signed-off-by: Siddhanth Rathod <xsiddhanthrathod@gmail.com> Closes: https://github.com/gentoo/gentoolkit/pull/41 Signed-off-by: Sam James <sam@gentoo.org>
* eclean: fix eclean-dist with no git3-src dirSam James2024-01-191-0/+3
| | | | | Bug: https://bugs.gentoo.org/922455 Signed-off-by: Sam James <sam@gentoo.org>
* eclean: Strip libc dependencies from --changed-deps calculationsMatt Turner2024-01-121-1/+7
| | | | | | Closes: https://bugs.gentoo.org/921679 Closes: https://github.com/gentoo/gentoolkit/pull/38 Signed-off-by: Matt Turner <mattst88@gentoo.org>
* Enhancement: eclean-dist handle git checkoutsSiddhanth Rathod2023-12-033-16/+89
| | | | | | | | | | | A new feature for eclean-dist to clean git3-src. Optionally, cleaning the vcs-src can be skipped with --skip-vcs. Bug: https://bugs.gentoo.org/622938 Signed-off-by: Siddhanth Rathod <xsiddhanthrathod@gmail.com> Closes: https://github.com/gentoo/gentoolkit/pull/33 Signed-off-by: Sam James <sam@gentoo.org>
* Migrate to PEP517 meson-python buildgentoolkit-0.6.3Zac Medico2023-10-1220-9/+238
| | | | | | | Bug: https://bugs.gentoo.org/909888 Signed-off-by: Zac Medico <zmedico@gentoo.org> Closes: https://github.com/gentoo/gentoolkit/pull/36 Signed-off-by: Sam James <sam@gentoo.org>
* eclean: pkg: suppress invalid binary errorSiddhanth Rathod2023-10-081-1/+4
| | | | | | | | | | [sam: Note that this needs https://github.com/gentoo/portage/pull/1123 on the Portage side.] Bug: https://bugs.gentoo.org/900224 Signed-off-by: Siddhanth Rathod <xsiddhanthrathod@gmail.com> Closes: https://github.com/gentoo/gentoolkit/pull/35 Signed-off-by: Sam James <sam@gentoo.org>
* eclean: pkg: fix pkgindex handlingSiddhanth Rathod2023-10-082-92/+11
| | | | | | | | | | Last implemention was importing binhost module incorrectly: calling Modules() from portage.module which sets binhost var to the BinhostHandler class which would always fail as it needs name and namepath, leading to always call emaint via a subprocess call. Signed-off-by: Siddhanth Rathod <xsiddhanthrathod@gmail.com> Signed-off-by: Sam James <sam@gentoo.org>
* eclean-pkg: fix compatibility with FEATURES=pkgdir-index-trustedgentoolkit-0.6.2Siddhanth Rathod2023-09-291-3/+8
| | | | | | | | | | | | | | Portage recently enabled FEATURES=pkgdir-index-trusted by default which breaks the eclean-invalids feature. Force reindexing after cleaning up to fix this. See-also: https://github.com/gentoo/portage/commit/3bc7bfef51d88fd716e882d3931f2873e3493e01 Bug: https://bugs.gentoo.org/889300 Bug: https://bugs.gentoo.org/900224 Signed-off-by: Siddhanth Rathod <xsiddhanthrathod@gmail.com> Closes: https://github.com/gentoo/gentoolkit/pull/34 Signed-off-by: Sam James <sam@gentoo.org>
* equery meta: map the remote-id to the respective urlSiddhanth Rathod2023-09-191-10/+41
| | | | | | | Bug: https://bugs.gentoo.org/877519 Signed-off-by: Siddhanth Rathod <xsiddhanthrathod@gmail.com> Closes: https://github.com/gentoo/gentoolkit/pull/32 Signed-off-by: Sam James <sam@gentoo.org>
* eclean: Make cleaning invalid defaultSiddhanth Rathod2023-08-241-7/+8
| | | | | | | Bug: https://bugs.gentoo.org/900224 Signed-off-by: Siddhanth Rathod <xsiddhanthrathod@gmail.com> Closes: https://github.com/gentoo/gentoolkit/pull/31 Signed-off-by: Sam James <sam@gentoo.org>
* eclean-pkg: placate blackSam James2023-08-221-2/+1
| | | | Signed-off-by: Sam James <sam@gentoo.org>
* Drop useless imports (fix flake8)Sam James2023-08-222-2/+0
| | | | Signed-off-by: Sam James <sam@gentoo.org>
* eclean-pkg: fix --help alignment, mention shortopt for clean-invalidSam James2023-08-221-2/+2
| | | | | Bug: https://bugs.gentoo.org/900224 Signed-off-by: Sam James <sam@gentoo.org>
* eclean-pkg: fix --unique-use shortoptSam James2023-08-221-1/+1
| | | | Signed-off-by: Sam James <sam@gentoo.org>
* eclean-pkg: add --clean-invalid to help, fix parsingSam James2023-08-221-7/+12
| | | | | | | | | | | | | | | | | * Rename --clean-invalids -> --clean-invalid * Add --clean-invalid to help * Make it default-off for now to match the option name (rather than the help saying --no-clean-invalids). (I could go either way on what the actual default should be, but this is more conservative for now.) * Fix typo in option name. * Make it a package specific arg, not a global one. Bug: https://bugs.gentoo.org/900224 Fixes: 204b1abca2c0cbbdad188c7fd4b84452c2f630a0 Fixes: a16d0d4fbfb4614832c4b682b41284a9050af29f Signed-off-by: Sam James <sam@gentoo.org>
* eclean-pkg: Limit invalid search to 'packages' actionSiddhanth Rathod2023-08-221-22/+24
| | | | | | | | Bug: https://bugs.gentoo.org/900224 Fixes: a16d0d4fbfb4614832c4b682b41284a9050af29f Signed-off-by: Siddhanth Rathod <xsiddhanthrathod@gmail.com> Closes: https://github.com/gentoo/gentoolkit/pull/30 Signed-off-by: Sam James <sam@gentoo.org>
* eclean-pkg: deal with invalid binpkgsSiddhanth Rathod2023-08-213-6/+64
| | | | | | | | Changes required in portage -> https://github.com/gentoo/portage/pull/1016 Bug: https://bugs.gentoo.org/900224 Signed-off-by: Siddhanth Rathod <xsiddhanthrathod@gmail.com> Signed-off-by: Sam James <sam@gentoo.org>
* eclean: Add type hintsSiddhanth Rathod2023-08-211-8/+9
| | | | | Signed-off-by: Siddhanth Rathod <xsiddhanthrathod@gmail.com> Signed-off-by: Sam James <sam@gentoo.org>
* Run `pyupgrade --py39-plus`Sam James2023-08-0748-231/+191
| | | | Signed-off-by: Sam James <sam@gentoo.org>
* equery: reformat with blackSam James2023-08-051-2/+8
| | | | | Fixes: 637bfbfb27d2104a81d80e5c67a7878d2e874966 Signed-off-by: Sam James <sam@gentoo.org>
* equery: list: correctly handle installed packages no longer in treeRafał Mużyło2023-07-181-2/+2
| | | | | Closes: https://bugs.gentoo.org/369581 Signed-off-by: Sam James <sam@gentoo.org>
* equery: depgraph: Fix --linear shortopt (-l)Sam James2023-07-181-1/+1
| | | | | Closes: https://bugs.gentoo.org/709816 Signed-off-by: Sam James <sam@gentoo.org>
* enalyze/analyze.py: fix typosDiego Viola2023-06-041-3/+3
| | | | | | Signed-off-by: Diego Viola <diego.viola@gmail.com> Closes: https://github.com/gentoo/gentoolkit/pull/27 Signed-off-by: Mike Gilbert <floppym@gentoo.org>
* Support the NO_COLOR environment variableUlrich Müller2023-03-224-9/+18
| | | | | | | Bug: https://bugs.gentoo.org/902551 Signed-off-by: Ulrich Müller <ulm@gentoo.org> Closes: https://github.com/gentoo/gentoolkit/pull/26 Signed-off-by: Sam James <sam@gentoo.org>