From 4e17e927b6e743ab2a3d769b4a334d7085dc7000 Mon Sep 17 00:00:00 2001 From: Ignas Anikevicius <240938+aignas@users.noreply.github.com> Date: Thu, 15 Feb 2024 11:10:57 +0900 Subject: [PATCH 01/23] chore(examples/bzlmod): bump deps to use wheels on linux_x86_64 (#1758) With this change all of our deps have wheel distributions available for Python 3.9 linux_x86_64, which means that we can more reliably experiment with multi-platform hub repositories. Split from #1744. --- examples/bzlmod/requirements_lock_3_9.txt | 151 +++++++++++-------- examples/bzlmod/requirements_windows_3_9.txt | 151 +++++++++++-------- 2 files changed, 180 insertions(+), 122 deletions(-) diff --git a/examples/bzlmod/requirements_lock_3_9.txt b/examples/bzlmod/requirements_lock_3_9.txt index 13ea866469..d5b36539b4 100644 --- a/examples/bzlmod/requirements_lock_3_9.txt +++ b/examples/bzlmod/requirements_lock_3_9.txt @@ -58,26 +58,44 @@ jinja2==3.1.3 \ --hash=sha256:7d6d50dd97d52cbc355597bd845fabfbac3f551e1f99619e39a35ce8c370b5fa \ --hash=sha256:ac8bd6544d4bb2c9792bf3a159e80bba8fda7f07e81bc3aed565432d5925ba90 # via sphinx -lazy-object-proxy==1.8.0 \ - --hash=sha256:0c1c7c0433154bb7c54185714c6929acc0ba04ee1b167314a779b9025517eada \ - --hash=sha256:14010b49a2f56ec4943b6cf925f597b534ee2fe1f0738c84b3bce0c1a11ff10d \ - --hash=sha256:4e2d9f764f1befd8bdc97673261b8bb888764dfdbd7a4d8f55e4fbcabb8c3fb7 \ - --hash=sha256:4fd031589121ad46e293629b39604031d354043bb5cdf83da4e93c2d7f3389fe \ - --hash=sha256:5b51d6f3bfeb289dfd4e95de2ecd464cd51982fe6f00e2be1d0bf94864d58acd \ - --hash=sha256:6850e4aeca6d0df35bb06e05c8b934ff7c533734eb51d0ceb2d63696f1e6030c \ - --hash=sha256:6f593f26c470a379cf7f5bc6db6b5f1722353e7bf937b8d0d0b3fba911998858 \ - --hash=sha256:71d9ae8a82203511a6f60ca5a1b9f8ad201cac0fc75038b2dc5fa519589c9288 \ - --hash=sha256:7e1561626c49cb394268edd00501b289053a652ed762c58e1081224c8d881cec \ - --hash=sha256:8f6ce2118a90efa7f62dd38c7dbfffd42f468b180287b748626293bf12ed468f \ - --hash=sha256:ae032743794fba4d171b5b67310d69176287b5bf82a21f588282406a79498891 \ - --hash=sha256:afcaa24e48bb23b3be31e329deb3f1858f1f1df86aea3d70cb5c8578bfe5261c \ - --hash=sha256:b70d6e7a332eb0217e7872a73926ad4fdc14f846e85ad6749ad111084e76df25 \ - --hash=sha256:c219a00245af0f6fa4e95901ed28044544f50152840c5b6a3e7b2568db34d156 \ - --hash=sha256:ce58b2b3734c73e68f0e30e4e725264d4d6be95818ec0a0be4bb6bf9a7e79aa8 \ - --hash=sha256:d176f392dbbdaacccf15919c77f526edf11a34aece58b55ab58539807b85436f \ - --hash=sha256:e20bfa6db17a39c706d24f82df8352488d2943a3b7ce7d4c22579cb89ca8896e \ - --hash=sha256:eac3a9a5ef13b332c059772fd40b4b1c3d45a3a2b05e33a361dee48e54a4dad0 \ - --hash=sha256:eb329f8d8145379bf5dbe722182410fe8863d186e51bf034d2075eb8d85ee25b +lazy-object-proxy==1.10.0 \ + --hash=sha256:009e6bb1f1935a62889ddc8541514b6a9e1fcf302667dcb049a0be5c8f613e56 \ + --hash=sha256:02c83f957782cbbe8136bee26416686a6ae998c7b6191711a04da776dc9e47d4 \ + --hash=sha256:0aefc7591920bbd360d57ea03c995cebc204b424524a5bd78406f6e1b8b2a5d8 \ + --hash=sha256:127a789c75151db6af398b8972178afe6bda7d6f68730c057fbbc2e96b08d282 \ + --hash=sha256:18dd842b49456aaa9a7cf535b04ca4571a302ff72ed8740d06b5adcd41fe0757 \ + --hash=sha256:217138197c170a2a74ca0e05bddcd5f1796c735c37d0eee33e43259b192aa424 \ + --hash=sha256:2297f08f08a2bb0d32a4265e98a006643cd7233fb7983032bd61ac7a02956b3b \ + --hash=sha256:2fc0a92c02fa1ca1e84fc60fa258458e5bf89d90a1ddaeb8ed9cc3147f417255 \ + --hash=sha256:30b339b2a743c5288405aa79a69e706a06e02958eab31859f7f3c04980853b70 \ + --hash=sha256:366c32fe5355ef5fc8a232c5436f4cc66e9d3e8967c01fb2e6302fd6627e3d94 \ + --hash=sha256:3ad54b9ddbe20ae9f7c1b29e52f123120772b06dbb18ec6be9101369d63a4074 \ + --hash=sha256:5ad9e6ed739285919aa9661a5bbed0aaf410aa60231373c5579c6b4801bd883c \ + --hash=sha256:5faf03a7d8942bb4476e3b62fd0f4cf94eaf4618e304a19865abf89a35c0bbee \ + --hash=sha256:75fc59fc450050b1b3c203c35020bc41bd2695ed692a392924c6ce180c6f1dc9 \ + --hash=sha256:76a095cfe6045c7d0ca77db9934e8f7b71b14645f0094ffcd842349ada5c5fb9 \ + --hash=sha256:78247b6d45f43a52ef35c25b5581459e85117225408a4128a3daf8bf9648ac69 \ + --hash=sha256:782e2c9b2aab1708ffb07d4bf377d12901d7a1d99e5e410d648d892f8967ab1f \ + --hash=sha256:7ab7004cf2e59f7c2e4345604a3e6ea0d92ac44e1c2375527d56492014e690c3 \ + --hash=sha256:80b39d3a151309efc8cc48675918891b865bdf742a8616a337cb0090791a0de9 \ + --hash=sha256:80fa48bd89c8f2f456fc0765c11c23bf5af827febacd2f523ca5bc1893fcc09d \ + --hash=sha256:855e068b0358ab916454464a884779c7ffa312b8925c6f7401e952dcf3b89977 \ + --hash=sha256:92f09ff65ecff3108e56526f9e2481b8116c0b9e1425325e13245abfd79bdb1b \ + --hash=sha256:952c81d415b9b80ea261d2372d2a4a2332a3890c2b83e0535f263ddfe43f0d43 \ + --hash=sha256:9a3a87cf1e133e5b1994144c12ca4aa3d9698517fe1e2ca82977781b16955658 \ + --hash=sha256:9e4ed0518a14dd26092614412936920ad081a424bdcb54cc13349a8e2c6d106a \ + --hash=sha256:a899b10e17743683b293a729d3a11f2f399e8a90c73b089e29f5d0fe3509f0dd \ + --hash=sha256:b1f711e2c6dcd4edd372cf5dec5c5a30d23bba06ee012093267b3376c079ec83 \ + --hash=sha256:b4f87d4ed9064b2628da63830986c3d2dca7501e6018347798313fcf028e2fd4 \ + --hash=sha256:cb73507defd385b7705c599a94474b1d5222a508e502553ef94114a143ec6696 \ + --hash=sha256:dc0d2fc424e54c70c4bc06787e4072c4f3b1aa2f897dfdc34ce1013cf3ceef05 \ + --hash=sha256:e221060b701e2aa2ea991542900dd13907a5c90fa80e199dbf5a03359019e7a3 \ + --hash=sha256:e271058822765ad5e3bca7f05f2ace0de58a3f4e62045a8c90a0dfd2f8ad8cc6 \ + --hash=sha256:e2adb09778797da09d2b5ebdbceebf7dd32e2c96f79da9052b2e87b6ea495895 \ + --hash=sha256:e333e2324307a7b5d86adfa835bb500ee70bfcd1447384a822e96495796b0ca4 \ + --hash=sha256:e98c8af98d5707dcdecc9ab0863c0ea6e88545d42ca7c3feffb6b4d1e370c7ba \ + --hash=sha256:edb45bb8278574710e68a6b021599a10ce730d156e5b254941754a9cc0b17d03 \ + --hash=sha256:fec03caabbc6b59ea4a638bee5fce7117be8e99a4103d9d5ad77f15d6f81020c # via astroid markupsafe==2.1.3 \ --hash=sha256:05fb21170423db021895e1ea1e1f3ab3adb85d1c2333cbc2310f2a26bc77272e \ @@ -181,47 +199,58 @@ python-magic==0.4.27 \ --hash=sha256:c1ba14b08e4a5f5c31a302b7721239695b2f0f058d125bd5ce1ee36b9d9d3c3b \ --hash=sha256:c212960ad306f700aa0d01e5d7a325d20548ff97eb9920dcd29513174f0294d3 # via s3cmd -pyyaml==6.0 \ - --hash=sha256:01b45c0191e6d66c470b6cf1b9531a771a83c1c4208272ead47a3ae4f2f603bf \ - --hash=sha256:0283c35a6a9fbf047493e3a0ce8d79ef5030852c51e9d911a27badfde0605293 \ - --hash=sha256:055d937d65826939cb044fc8c9b08889e8c743fdc6a32b33e2390f66013e449b \ - --hash=sha256:07751360502caac1c067a8132d150cf3d61339af5691fe9e87803040dbc5db57 \ - --hash=sha256:0b4624f379dab24d3725ffde76559cff63d9ec94e1736b556dacdfebe5ab6d4b \ - --hash=sha256:0ce82d761c532fe4ec3f87fc45688bdd3a4c1dc5e0b4a19814b9009a29baefd4 \ - --hash=sha256:1e4747bc279b4f613a09eb64bba2ba602d8a6664c6ce6396a4d0cd413a50ce07 \ - --hash=sha256:213c60cd50106436cc818accf5baa1aba61c0189ff610f64f4a3e8c6726218ba \ - --hash=sha256:231710d57adfd809ef5d34183b8ed1eeae3f76459c18fb4a0b373ad56bedcdd9 \ - --hash=sha256:277a0ef2981ca40581a47093e9e2d13b3f1fbbeffae064c1d21bfceba2030287 \ - --hash=sha256:2cd5df3de48857ed0544b34e2d40e9fac445930039f3cfe4bcc592a1f836d513 \ - --hash=sha256:40527857252b61eacd1d9af500c3337ba8deb8fc298940291486c465c8b46ec0 \ - --hash=sha256:432557aa2c09802be39460360ddffd48156e30721f5e8d917f01d31694216782 \ - --hash=sha256:473f9edb243cb1935ab5a084eb238d842fb8f404ed2193a915d1784b5a6b5fc0 \ - --hash=sha256:48c346915c114f5fdb3ead70312bd042a953a8ce5c7106d5bfb1a5254e47da92 \ - --hash=sha256:50602afada6d6cbfad699b0c7bb50d5ccffa7e46a3d738092afddc1f9758427f \ - --hash=sha256:68fb519c14306fec9720a2a5b45bc9f0c8d1b9c72adf45c37baedfcd949c35a2 \ - --hash=sha256:77f396e6ef4c73fdc33a9157446466f1cff553d979bd00ecb64385760c6babdc \ - --hash=sha256:81957921f441d50af23654aa6c5e5eaf9b06aba7f0a19c18a538dc7ef291c5a1 \ - --hash=sha256:819b3830a1543db06c4d4b865e70ded25be52a2e0631ccd2f6a47a2822f2fd7c \ - --hash=sha256:897b80890765f037df3403d22bab41627ca8811ae55e9a722fd0392850ec4d86 \ - --hash=sha256:98c4d36e99714e55cfbaaee6dd5badbc9a1ec339ebfc3b1f52e293aee6bb71a4 \ - --hash=sha256:9df7ed3b3d2e0ecfe09e14741b857df43adb5a3ddadc919a2d94fbdf78fea53c \ - --hash=sha256:9fa600030013c4de8165339db93d182b9431076eb98eb40ee068700c9c813e34 \ - --hash=sha256:a80a78046a72361de73f8f395f1f1e49f956c6be882eed58505a15f3e430962b \ - --hash=sha256:afa17f5bc4d1b10afd4466fd3a44dc0e245382deca5b3c353d8b757f9e3ecb8d \ - --hash=sha256:b3d267842bf12586ba6c734f89d1f5b871df0273157918b0ccefa29deb05c21c \ - --hash=sha256:b5b9eccad747aabaaffbc6064800670f0c297e52c12754eb1d976c57e4f74dcb \ - --hash=sha256:bfaef573a63ba8923503d27530362590ff4f576c626d86a9fed95822a8255fd7 \ - --hash=sha256:c5687b8d43cf58545ade1fe3e055f70eac7a5a1a0bf42824308d868289a95737 \ - --hash=sha256:cba8c411ef271aa037d7357a2bc8f9ee8b58b9965831d9e51baf703280dc73d3 \ - --hash=sha256:d15a181d1ecd0d4270dc32edb46f7cb7733c7c508857278d3d378d14d606db2d \ - --hash=sha256:d4b0ba9512519522b118090257be113b9468d804b19d63c71dbcf4a48fa32358 \ - --hash=sha256:d4db7c7aef085872ef65a8fd7d6d09a14ae91f691dec3e87ee5ee0539d516f53 \ - --hash=sha256:d4eccecf9adf6fbcc6861a38015c2a64f38b9d94838ac1810a9023a0609e1b78 \ - --hash=sha256:d67d839ede4ed1b28a4e8909735fc992a923cdb84e618544973d7dfc71540803 \ - --hash=sha256:daf496c58a8c52083df09b80c860005194014c3698698d1a57cbcfa182142a3a \ - --hash=sha256:dbad0e9d368bb989f4515da330b88a057617d16b6a8245084f1b05400f24609f \ - --hash=sha256:e61ceaab6f49fb8bdfaa0f92c4b57bcfbea54c09277b1b4f7ac376bfb7a7c174 \ - --hash=sha256:f84fbc98b019fef2ee9a1cb3ce93e3187a6df0b2538a651bfb890254ba9f90b5 +pyyaml==6.0.1 \ + --hash=sha256:04ac92ad1925b2cff1db0cfebffb6ffc43457495c9b3c39d3fcae417d7125dc5 \ + --hash=sha256:062582fca9fabdd2c8b54a3ef1c978d786e0f6b3a1510e0ac93ef59e0ddae2bc \ + --hash=sha256:0d3304d8c0adc42be59c5f8a4d9e3d7379e6955ad754aa9d6ab7a398b59dd1df \ + --hash=sha256:1635fd110e8d85d55237ab316b5b011de701ea0f29d07611174a1b42f1444741 \ + --hash=sha256:184c5108a2aca3c5b3d3bf9395d50893a7ab82a38004c8f61c258d4428e80206 \ + --hash=sha256:18aeb1bf9a78867dc38b259769503436b7c72f7a1f1f4c93ff9a17de54319b27 \ + --hash=sha256:1d4c7e777c441b20e32f52bd377e0c409713e8bb1386e1099c2415f26e479595 \ + --hash=sha256:1e2722cc9fbb45d9b87631ac70924c11d3a401b2d7f410cc0e3bbf249f2dca62 \ + --hash=sha256:1fe35611261b29bd1de0070f0b2f47cb6ff71fa6595c077e42bd0c419fa27b98 \ + --hash=sha256:28c119d996beec18c05208a8bd78cbe4007878c6dd15091efb73a30e90539696 \ + --hash=sha256:326c013efe8048858a6d312ddd31d56e468118ad4cdeda36c719bf5bb6192290 \ + --hash=sha256:40df9b996c2b73138957fe23a16a4f0ba614f4c0efce1e9406a184b6d07fa3a9 \ + --hash=sha256:42f8152b8dbc4fe7d96729ec2b99c7097d656dc1213a3229ca5383f973a5ed6d \ + --hash=sha256:49a183be227561de579b4a36efbb21b3eab9651dd81b1858589f796549873dd6 \ + --hash=sha256:4fb147e7a67ef577a588a0e2c17b6db51dda102c71de36f8549b6816a96e1867 \ + --hash=sha256:50550eb667afee136e9a77d6dc71ae76a44df8b3e51e41b77f6de2932bfe0f47 \ + --hash=sha256:510c9deebc5c0225e8c96813043e62b680ba2f9c50a08d3724c7f28a747d1486 \ + --hash=sha256:5773183b6446b2c99bb77e77595dd486303b4faab2b086e7b17bc6bef28865f6 \ + --hash=sha256:596106435fa6ad000c2991a98fa58eeb8656ef2325d7e158344fb33864ed87e3 \ + --hash=sha256:6965a7bc3cf88e5a1c3bd2e0b5c22f8d677dc88a455344035f03399034eb3007 \ + --hash=sha256:69b023b2b4daa7548bcfbd4aa3da05b3a74b772db9e23b982788168117739938 \ + --hash=sha256:6c22bec3fbe2524cde73d7ada88f6566758a8f7227bfbf93a408a9d86bcc12a0 \ + --hash=sha256:704219a11b772aea0d8ecd7058d0082713c3562b4e271b849ad7dc4a5c90c13c \ + --hash=sha256:7e07cbde391ba96ab58e532ff4803f79c4129397514e1413a7dc761ccd755735 \ + --hash=sha256:81e0b275a9ecc9c0c0c07b4b90ba548307583c125f54d5b6946cfee6360c733d \ + --hash=sha256:855fb52b0dc35af121542a76b9a84f8d1cd886ea97c84703eaa6d88e37a2ad28 \ + --hash=sha256:8d4e9c88387b0f5c7d5f281e55304de64cf7f9c0021a3525bd3b1c542da3b0e4 \ + --hash=sha256:9046c58c4395dff28dd494285c82ba00b546adfc7ef001486fbf0324bc174fba \ + --hash=sha256:9eb6caa9a297fc2c2fb8862bc5370d0303ddba53ba97e71f08023b6cd73d16a8 \ + --hash=sha256:a08c6f0fe150303c1c6b71ebcd7213c2858041a7e01975da3a99aed1e7a378ef \ + --hash=sha256:a0cd17c15d3bb3fa06978b4e8958dcdc6e0174ccea823003a106c7d4d7899ac5 \ + --hash=sha256:afd7e57eddb1a54f0f1a974bc4391af8bcce0b444685d936840f125cf046d5bd \ + --hash=sha256:b1275ad35a5d18c62a7220633c913e1b42d44b46ee12554e5fd39c70a243d6a3 \ + --hash=sha256:b786eecbdf8499b9ca1d697215862083bd6d2a99965554781d0d8d1ad31e13a0 \ + --hash=sha256:ba336e390cd8e4d1739f42dfe9bb83a3cc2e80f567d8805e11b46f4a943f5515 \ + --hash=sha256:baa90d3f661d43131ca170712d903e6295d1f7a0f595074f151c0aed377c9b9c \ + --hash=sha256:bc1bf2925a1ecd43da378f4db9e4f799775d6367bdb94671027b73b393a7c42c \ + --hash=sha256:bd4af7373a854424dabd882decdc5579653d7868b8fb26dc7d0e99f823aa5924 \ + --hash=sha256:bf07ee2fef7014951eeb99f56f39c9bb4af143d8aa3c21b1677805985307da34 \ + --hash=sha256:bfdf460b1736c775f2ba9f6a92bca30bc2095067b8a9d77876d1fad6cc3b4a43 \ + --hash=sha256:c8098ddcc2a85b61647b2590f825f3db38891662cfc2fc776415143f599bb859 \ + --hash=sha256:d2b04aac4d386b172d5b9692e2d2da8de7bfb6c387fa4f801fbf6fb2e6ba4673 \ + --hash=sha256:d483d2cdf104e7c9fa60c544d92981f12ad66a457afae824d146093b8c294c54 \ + --hash=sha256:d858aa552c999bc8a8d57426ed01e40bef403cd8ccdd0fc5f6f04a00414cac2a \ + --hash=sha256:e7d73685e87afe9f3b36c799222440d6cf362062f78be1013661b00c5c6f678b \ + --hash=sha256:f003ed9ad21d6a4713f0a9b5a7a0a79e08dd0f221aff4525a2be4c346ee60aab \ + --hash=sha256:f22ac1c3cac4dbc50079e965eba2c1058622631e526bd9afd45fedd49ba781fa \ + --hash=sha256:faca3bdcf85b2fc05d06ff3fbc1f83e1391b3e724afa3feba7d13eeab355484c \ + --hash=sha256:fca0e3a251908a499833aa292323f32437106001d436eca0e6e7833256674585 \ + --hash=sha256:fd1592b3fdf65fff2ad0004b5e363300ef59ced41c2e6b3a99d4089fa8c5435d \ + --hash=sha256:fd66fc5d0da6d9815ba2cebeb4205f95818ff4b79c3ebe268e75d961704af52f # via yamllint requests==2.25.1 \ --hash=sha256:27973dd4a904a4f13b263a19c866c13b92a39ed1c964655f025f3f8d3d75b804 \ diff --git a/examples/bzlmod/requirements_windows_3_9.txt b/examples/bzlmod/requirements_windows_3_9.txt index bea0acf36d..a67a574bfe 100644 --- a/examples/bzlmod/requirements_windows_3_9.txt +++ b/examples/bzlmod/requirements_windows_3_9.txt @@ -61,26 +61,44 @@ jinja2==3.1.3 \ --hash=sha256:7d6d50dd97d52cbc355597bd845fabfbac3f551e1f99619e39a35ce8c370b5fa \ --hash=sha256:ac8bd6544d4bb2c9792bf3a159e80bba8fda7f07e81bc3aed565432d5925ba90 # via sphinx -lazy-object-proxy==1.8.0 \ - --hash=sha256:0c1c7c0433154bb7c54185714c6929acc0ba04ee1b167314a779b9025517eada \ - --hash=sha256:14010b49a2f56ec4943b6cf925f597b534ee2fe1f0738c84b3bce0c1a11ff10d \ - --hash=sha256:4e2d9f764f1befd8bdc97673261b8bb888764dfdbd7a4d8f55e4fbcabb8c3fb7 \ - --hash=sha256:4fd031589121ad46e293629b39604031d354043bb5cdf83da4e93c2d7f3389fe \ - --hash=sha256:5b51d6f3bfeb289dfd4e95de2ecd464cd51982fe6f00e2be1d0bf94864d58acd \ - --hash=sha256:6850e4aeca6d0df35bb06e05c8b934ff7c533734eb51d0ceb2d63696f1e6030c \ - --hash=sha256:6f593f26c470a379cf7f5bc6db6b5f1722353e7bf937b8d0d0b3fba911998858 \ - --hash=sha256:71d9ae8a82203511a6f60ca5a1b9f8ad201cac0fc75038b2dc5fa519589c9288 \ - --hash=sha256:7e1561626c49cb394268edd00501b289053a652ed762c58e1081224c8d881cec \ - --hash=sha256:8f6ce2118a90efa7f62dd38c7dbfffd42f468b180287b748626293bf12ed468f \ - --hash=sha256:ae032743794fba4d171b5b67310d69176287b5bf82a21f588282406a79498891 \ - --hash=sha256:afcaa24e48bb23b3be31e329deb3f1858f1f1df86aea3d70cb5c8578bfe5261c \ - --hash=sha256:b70d6e7a332eb0217e7872a73926ad4fdc14f846e85ad6749ad111084e76df25 \ - --hash=sha256:c219a00245af0f6fa4e95901ed28044544f50152840c5b6a3e7b2568db34d156 \ - --hash=sha256:ce58b2b3734c73e68f0e30e4e725264d4d6be95818ec0a0be4bb6bf9a7e79aa8 \ - --hash=sha256:d176f392dbbdaacccf15919c77f526edf11a34aece58b55ab58539807b85436f \ - --hash=sha256:e20bfa6db17a39c706d24f82df8352488d2943a3b7ce7d4c22579cb89ca8896e \ - --hash=sha256:eac3a9a5ef13b332c059772fd40b4b1c3d45a3a2b05e33a361dee48e54a4dad0 \ - --hash=sha256:eb329f8d8145379bf5dbe722182410fe8863d186e51bf034d2075eb8d85ee25b +lazy-object-proxy==1.10.0 \ + --hash=sha256:009e6bb1f1935a62889ddc8541514b6a9e1fcf302667dcb049a0be5c8f613e56 \ + --hash=sha256:02c83f957782cbbe8136bee26416686a6ae998c7b6191711a04da776dc9e47d4 \ + --hash=sha256:0aefc7591920bbd360d57ea03c995cebc204b424524a5bd78406f6e1b8b2a5d8 \ + --hash=sha256:127a789c75151db6af398b8972178afe6bda7d6f68730c057fbbc2e96b08d282 \ + --hash=sha256:18dd842b49456aaa9a7cf535b04ca4571a302ff72ed8740d06b5adcd41fe0757 \ + --hash=sha256:217138197c170a2a74ca0e05bddcd5f1796c735c37d0eee33e43259b192aa424 \ + --hash=sha256:2297f08f08a2bb0d32a4265e98a006643cd7233fb7983032bd61ac7a02956b3b \ + --hash=sha256:2fc0a92c02fa1ca1e84fc60fa258458e5bf89d90a1ddaeb8ed9cc3147f417255 \ + --hash=sha256:30b339b2a743c5288405aa79a69e706a06e02958eab31859f7f3c04980853b70 \ + --hash=sha256:366c32fe5355ef5fc8a232c5436f4cc66e9d3e8967c01fb2e6302fd6627e3d94 \ + --hash=sha256:3ad54b9ddbe20ae9f7c1b29e52f123120772b06dbb18ec6be9101369d63a4074 \ + --hash=sha256:5ad9e6ed739285919aa9661a5bbed0aaf410aa60231373c5579c6b4801bd883c \ + --hash=sha256:5faf03a7d8942bb4476e3b62fd0f4cf94eaf4618e304a19865abf89a35c0bbee \ + --hash=sha256:75fc59fc450050b1b3c203c35020bc41bd2695ed692a392924c6ce180c6f1dc9 \ + --hash=sha256:76a095cfe6045c7d0ca77db9934e8f7b71b14645f0094ffcd842349ada5c5fb9 \ + --hash=sha256:78247b6d45f43a52ef35c25b5581459e85117225408a4128a3daf8bf9648ac69 \ + --hash=sha256:782e2c9b2aab1708ffb07d4bf377d12901d7a1d99e5e410d648d892f8967ab1f \ + --hash=sha256:7ab7004cf2e59f7c2e4345604a3e6ea0d92ac44e1c2375527d56492014e690c3 \ + --hash=sha256:80b39d3a151309efc8cc48675918891b865bdf742a8616a337cb0090791a0de9 \ + --hash=sha256:80fa48bd89c8f2f456fc0765c11c23bf5af827febacd2f523ca5bc1893fcc09d \ + --hash=sha256:855e068b0358ab916454464a884779c7ffa312b8925c6f7401e952dcf3b89977 \ + --hash=sha256:92f09ff65ecff3108e56526f9e2481b8116c0b9e1425325e13245abfd79bdb1b \ + --hash=sha256:952c81d415b9b80ea261d2372d2a4a2332a3890c2b83e0535f263ddfe43f0d43 \ + --hash=sha256:9a3a87cf1e133e5b1994144c12ca4aa3d9698517fe1e2ca82977781b16955658 \ + --hash=sha256:9e4ed0518a14dd26092614412936920ad081a424bdcb54cc13349a8e2c6d106a \ + --hash=sha256:a899b10e17743683b293a729d3a11f2f399e8a90c73b089e29f5d0fe3509f0dd \ + --hash=sha256:b1f711e2c6dcd4edd372cf5dec5c5a30d23bba06ee012093267b3376c079ec83 \ + --hash=sha256:b4f87d4ed9064b2628da63830986c3d2dca7501e6018347798313fcf028e2fd4 \ + --hash=sha256:cb73507defd385b7705c599a94474b1d5222a508e502553ef94114a143ec6696 \ + --hash=sha256:dc0d2fc424e54c70c4bc06787e4072c4f3b1aa2f897dfdc34ce1013cf3ceef05 \ + --hash=sha256:e221060b701e2aa2ea991542900dd13907a5c90fa80e199dbf5a03359019e7a3 \ + --hash=sha256:e271058822765ad5e3bca7f05f2ace0de58a3f4e62045a8c90a0dfd2f8ad8cc6 \ + --hash=sha256:e2adb09778797da09d2b5ebdbceebf7dd32e2c96f79da9052b2e87b6ea495895 \ + --hash=sha256:e333e2324307a7b5d86adfa835bb500ee70bfcd1447384a822e96495796b0ca4 \ + --hash=sha256:e98c8af98d5707dcdecc9ab0863c0ea6e88545d42ca7c3feffb6b4d1e370c7ba \ + --hash=sha256:edb45bb8278574710e68a6b021599a10ce730d156e5b254941754a9cc0b17d03 \ + --hash=sha256:fec03caabbc6b59ea4a638bee5fce7117be8e99a4103d9d5ad77f15d6f81020c # via astroid markupsafe==2.1.3 \ --hash=sha256:05fb21170423db021895e1ea1e1f3ab3adb85d1c2333cbc2310f2a26bc77272e \ @@ -184,47 +202,58 @@ python-magic==0.4.27 \ --hash=sha256:c1ba14b08e4a5f5c31a302b7721239695b2f0f058d125bd5ce1ee36b9d9d3c3b \ --hash=sha256:c212960ad306f700aa0d01e5d7a325d20548ff97eb9920dcd29513174f0294d3 # via s3cmd -pyyaml==6.0 \ - --hash=sha256:01b45c0191e6d66c470b6cf1b9531a771a83c1c4208272ead47a3ae4f2f603bf \ - --hash=sha256:0283c35a6a9fbf047493e3a0ce8d79ef5030852c51e9d911a27badfde0605293 \ - --hash=sha256:055d937d65826939cb044fc8c9b08889e8c743fdc6a32b33e2390f66013e449b \ - --hash=sha256:07751360502caac1c067a8132d150cf3d61339af5691fe9e87803040dbc5db57 \ - --hash=sha256:0b4624f379dab24d3725ffde76559cff63d9ec94e1736b556dacdfebe5ab6d4b \ - --hash=sha256:0ce82d761c532fe4ec3f87fc45688bdd3a4c1dc5e0b4a19814b9009a29baefd4 \ - --hash=sha256:1e4747bc279b4f613a09eb64bba2ba602d8a6664c6ce6396a4d0cd413a50ce07 \ - --hash=sha256:213c60cd50106436cc818accf5baa1aba61c0189ff610f64f4a3e8c6726218ba \ - --hash=sha256:231710d57adfd809ef5d34183b8ed1eeae3f76459c18fb4a0b373ad56bedcdd9 \ - --hash=sha256:277a0ef2981ca40581a47093e9e2d13b3f1fbbeffae064c1d21bfceba2030287 \ - --hash=sha256:2cd5df3de48857ed0544b34e2d40e9fac445930039f3cfe4bcc592a1f836d513 \ - --hash=sha256:40527857252b61eacd1d9af500c3337ba8deb8fc298940291486c465c8b46ec0 \ - --hash=sha256:432557aa2c09802be39460360ddffd48156e30721f5e8d917f01d31694216782 \ - --hash=sha256:473f9edb243cb1935ab5a084eb238d842fb8f404ed2193a915d1784b5a6b5fc0 \ - --hash=sha256:48c346915c114f5fdb3ead70312bd042a953a8ce5c7106d5bfb1a5254e47da92 \ - --hash=sha256:50602afada6d6cbfad699b0c7bb50d5ccffa7e46a3d738092afddc1f9758427f \ - --hash=sha256:68fb519c14306fec9720a2a5b45bc9f0c8d1b9c72adf45c37baedfcd949c35a2 \ - --hash=sha256:77f396e6ef4c73fdc33a9157446466f1cff553d979bd00ecb64385760c6babdc \ - --hash=sha256:81957921f441d50af23654aa6c5e5eaf9b06aba7f0a19c18a538dc7ef291c5a1 \ - --hash=sha256:819b3830a1543db06c4d4b865e70ded25be52a2e0631ccd2f6a47a2822f2fd7c \ - --hash=sha256:897b80890765f037df3403d22bab41627ca8811ae55e9a722fd0392850ec4d86 \ - --hash=sha256:98c4d36e99714e55cfbaaee6dd5badbc9a1ec339ebfc3b1f52e293aee6bb71a4 \ - --hash=sha256:9df7ed3b3d2e0ecfe09e14741b857df43adb5a3ddadc919a2d94fbdf78fea53c \ - --hash=sha256:9fa600030013c4de8165339db93d182b9431076eb98eb40ee068700c9c813e34 \ - --hash=sha256:a80a78046a72361de73f8f395f1f1e49f956c6be882eed58505a15f3e430962b \ - --hash=sha256:afa17f5bc4d1b10afd4466fd3a44dc0e245382deca5b3c353d8b757f9e3ecb8d \ - --hash=sha256:b3d267842bf12586ba6c734f89d1f5b871df0273157918b0ccefa29deb05c21c \ - --hash=sha256:b5b9eccad747aabaaffbc6064800670f0c297e52c12754eb1d976c57e4f74dcb \ - --hash=sha256:bfaef573a63ba8923503d27530362590ff4f576c626d86a9fed95822a8255fd7 \ - --hash=sha256:c5687b8d43cf58545ade1fe3e055f70eac7a5a1a0bf42824308d868289a95737 \ - --hash=sha256:cba8c411ef271aa037d7357a2bc8f9ee8b58b9965831d9e51baf703280dc73d3 \ - --hash=sha256:d15a181d1ecd0d4270dc32edb46f7cb7733c7c508857278d3d378d14d606db2d \ - --hash=sha256:d4b0ba9512519522b118090257be113b9468d804b19d63c71dbcf4a48fa32358 \ - --hash=sha256:d4db7c7aef085872ef65a8fd7d6d09a14ae91f691dec3e87ee5ee0539d516f53 \ - --hash=sha256:d4eccecf9adf6fbcc6861a38015c2a64f38b9d94838ac1810a9023a0609e1b78 \ - --hash=sha256:d67d839ede4ed1b28a4e8909735fc992a923cdb84e618544973d7dfc71540803 \ - --hash=sha256:daf496c58a8c52083df09b80c860005194014c3698698d1a57cbcfa182142a3a \ - --hash=sha256:dbad0e9d368bb989f4515da330b88a057617d16b6a8245084f1b05400f24609f \ - --hash=sha256:e61ceaab6f49fb8bdfaa0f92c4b57bcfbea54c09277b1b4f7ac376bfb7a7c174 \ - --hash=sha256:f84fbc98b019fef2ee9a1cb3ce93e3187a6df0b2538a651bfb890254ba9f90b5 +pyyaml==6.0.1 \ + --hash=sha256:04ac92ad1925b2cff1db0cfebffb6ffc43457495c9b3c39d3fcae417d7125dc5 \ + --hash=sha256:062582fca9fabdd2c8b54a3ef1c978d786e0f6b3a1510e0ac93ef59e0ddae2bc \ + --hash=sha256:0d3304d8c0adc42be59c5f8a4d9e3d7379e6955ad754aa9d6ab7a398b59dd1df \ + --hash=sha256:1635fd110e8d85d55237ab316b5b011de701ea0f29d07611174a1b42f1444741 \ + --hash=sha256:184c5108a2aca3c5b3d3bf9395d50893a7ab82a38004c8f61c258d4428e80206 \ + --hash=sha256:18aeb1bf9a78867dc38b259769503436b7c72f7a1f1f4c93ff9a17de54319b27 \ + --hash=sha256:1d4c7e777c441b20e32f52bd377e0c409713e8bb1386e1099c2415f26e479595 \ + --hash=sha256:1e2722cc9fbb45d9b87631ac70924c11d3a401b2d7f410cc0e3bbf249f2dca62 \ + --hash=sha256:1fe35611261b29bd1de0070f0b2f47cb6ff71fa6595c077e42bd0c419fa27b98 \ + --hash=sha256:28c119d996beec18c05208a8bd78cbe4007878c6dd15091efb73a30e90539696 \ + --hash=sha256:326c013efe8048858a6d312ddd31d56e468118ad4cdeda36c719bf5bb6192290 \ + --hash=sha256:40df9b996c2b73138957fe23a16a4f0ba614f4c0efce1e9406a184b6d07fa3a9 \ + --hash=sha256:42f8152b8dbc4fe7d96729ec2b99c7097d656dc1213a3229ca5383f973a5ed6d \ + --hash=sha256:49a183be227561de579b4a36efbb21b3eab9651dd81b1858589f796549873dd6 \ + --hash=sha256:4fb147e7a67ef577a588a0e2c17b6db51dda102c71de36f8549b6816a96e1867 \ + --hash=sha256:50550eb667afee136e9a77d6dc71ae76a44df8b3e51e41b77f6de2932bfe0f47 \ + --hash=sha256:510c9deebc5c0225e8c96813043e62b680ba2f9c50a08d3724c7f28a747d1486 \ + --hash=sha256:5773183b6446b2c99bb77e77595dd486303b4faab2b086e7b17bc6bef28865f6 \ + --hash=sha256:596106435fa6ad000c2991a98fa58eeb8656ef2325d7e158344fb33864ed87e3 \ + --hash=sha256:6965a7bc3cf88e5a1c3bd2e0b5c22f8d677dc88a455344035f03399034eb3007 \ + --hash=sha256:69b023b2b4daa7548bcfbd4aa3da05b3a74b772db9e23b982788168117739938 \ + --hash=sha256:6c22bec3fbe2524cde73d7ada88f6566758a8f7227bfbf93a408a9d86bcc12a0 \ + --hash=sha256:704219a11b772aea0d8ecd7058d0082713c3562b4e271b849ad7dc4a5c90c13c \ + --hash=sha256:7e07cbde391ba96ab58e532ff4803f79c4129397514e1413a7dc761ccd755735 \ + --hash=sha256:81e0b275a9ecc9c0c0c07b4b90ba548307583c125f54d5b6946cfee6360c733d \ + --hash=sha256:855fb52b0dc35af121542a76b9a84f8d1cd886ea97c84703eaa6d88e37a2ad28 \ + --hash=sha256:8d4e9c88387b0f5c7d5f281e55304de64cf7f9c0021a3525bd3b1c542da3b0e4 \ + --hash=sha256:9046c58c4395dff28dd494285c82ba00b546adfc7ef001486fbf0324bc174fba \ + --hash=sha256:9eb6caa9a297fc2c2fb8862bc5370d0303ddba53ba97e71f08023b6cd73d16a8 \ + --hash=sha256:a08c6f0fe150303c1c6b71ebcd7213c2858041a7e01975da3a99aed1e7a378ef \ + --hash=sha256:a0cd17c15d3bb3fa06978b4e8958dcdc6e0174ccea823003a106c7d4d7899ac5 \ + --hash=sha256:afd7e57eddb1a54f0f1a974bc4391af8bcce0b444685d936840f125cf046d5bd \ + --hash=sha256:b1275ad35a5d18c62a7220633c913e1b42d44b46ee12554e5fd39c70a243d6a3 \ + --hash=sha256:b786eecbdf8499b9ca1d697215862083bd6d2a99965554781d0d8d1ad31e13a0 \ + --hash=sha256:ba336e390cd8e4d1739f42dfe9bb83a3cc2e80f567d8805e11b46f4a943f5515 \ + --hash=sha256:baa90d3f661d43131ca170712d903e6295d1f7a0f595074f151c0aed377c9b9c \ + --hash=sha256:bc1bf2925a1ecd43da378f4db9e4f799775d6367bdb94671027b73b393a7c42c \ + --hash=sha256:bd4af7373a854424dabd882decdc5579653d7868b8fb26dc7d0e99f823aa5924 \ + --hash=sha256:bf07ee2fef7014951eeb99f56f39c9bb4af143d8aa3c21b1677805985307da34 \ + --hash=sha256:bfdf460b1736c775f2ba9f6a92bca30bc2095067b8a9d77876d1fad6cc3b4a43 \ + --hash=sha256:c8098ddcc2a85b61647b2590f825f3db38891662cfc2fc776415143f599bb859 \ + --hash=sha256:d2b04aac4d386b172d5b9692e2d2da8de7bfb6c387fa4f801fbf6fb2e6ba4673 \ + --hash=sha256:d483d2cdf104e7c9fa60c544d92981f12ad66a457afae824d146093b8c294c54 \ + --hash=sha256:d858aa552c999bc8a8d57426ed01e40bef403cd8ccdd0fc5f6f04a00414cac2a \ + --hash=sha256:e7d73685e87afe9f3b36c799222440d6cf362062f78be1013661b00c5c6f678b \ + --hash=sha256:f003ed9ad21d6a4713f0a9b5a7a0a79e08dd0f221aff4525a2be4c346ee60aab \ + --hash=sha256:f22ac1c3cac4dbc50079e965eba2c1058622631e526bd9afd45fedd49ba781fa \ + --hash=sha256:faca3bdcf85b2fc05d06ff3fbc1f83e1391b3e724afa3feba7d13eeab355484c \ + --hash=sha256:fca0e3a251908a499833aa292323f32437106001d436eca0e6e7833256674585 \ + --hash=sha256:fd1592b3fdf65fff2ad0004b5e363300ef59ced41c2e6b3a99d4089fa8c5435d \ + --hash=sha256:fd66fc5d0da6d9815ba2cebeb4205f95818ff4b79c3ebe268e75d961704af52f # via yamllint requests==2.25.1 \ --hash=sha256:27973dd4a904a4f13b263a19c866c13b92a39ed1c964655f025f3f8d3d75b804 \ From 7e3005874b8c139aca7d3bf876b65f1c671a8efe Mon Sep 17 00:00:00 2001 From: Ignas Anikevicius <240938+aignas@users.noreply.github.com> Date: Thu, 15 Feb 2024 11:11:46 +0900 Subject: [PATCH 02/23] test(bzlmod): make the check for hub repo naming less strict (#1757) When adding a whl-only hub that gets selected for a particular platform only, this check needed to be adjusted (as seen in #1744). --- examples/bzlmod/libs/my_lib/__init__.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/examples/bzlmod/libs/my_lib/__init__.py b/examples/bzlmod/libs/my_lib/__init__.py index 6db2e85191..8ce96ea207 100644 --- a/examples/bzlmod/libs/my_lib/__init__.py +++ b/examples/bzlmod/libs/my_lib/__init__.py @@ -17,6 +17,6 @@ def websockets_is_for_python_version(sanitized_version_check): # We are checking that the name of the repository folders - # match the expexted generated names. If we update the folder - # structure or naming we will need to modify this test - return f"pip_{sanitized_version_check}_websockets" in websockets.__file__ + # match the expected generated names. If we update the folder + # structure or naming we will need to modify this test. + return f"_{sanitized_version_check}_websockets" in websockets.__file__ From c0c690163cf65457a1216cfc60bf2b8130504fe9 Mon Sep 17 00:00:00 2001 From: Ignas Anikevicius <240938+aignas@users.noreply.github.com> Date: Thu, 15 Feb 2024 13:54:34 +0900 Subject: [PATCH 03/23] internal: support repo prefixes and config settings in alias rendering (#1756) This does not change any logic/features in the bzlmod or legacy code, but just changes the interfaces and how the parameters are passed. The final result should be the same. Summary: - introduce a `whl_alias` struct to make code more object oriented. - make the interface of the function as small as possible. - unify the bzlmod and legacy code paths and simplify tests. - allow to specify arbitrary repos and config settings when generating aliases, which is useful in multi-platform hub generation. --------- Co-authored-by: Richard Levasseur --- python/pip_install/pip_repository.bzl | 10 +- python/private/bzlmod/pip.bzl | 22 ++- python/private/bzlmod/pip_repository.bzl | 16 +- python/private/render_pkg_aliases.bzl | 144 ++++++++-------- .../render_pkg_aliases_test.bzl | 160 ++++++++++-------- 5 files changed, 192 insertions(+), 160 deletions(-) diff --git a/python/pip_install/pip_repository.bzl b/python/pip_install/pip_repository.bzl index 110ade19d7..7b8160e956 100644 --- a/python/pip_install/pip_repository.bzl +++ b/python/pip_install/pip_repository.bzl @@ -26,7 +26,7 @@ load("//python/private:envsubst.bzl", "envsubst") load("//python/private:normalize_name.bzl", "normalize_name") load("//python/private:parse_whl_name.bzl", "parse_whl_name") load("//python/private:patch_whl.bzl", "patch_whl") -load("//python/private:render_pkg_aliases.bzl", "render_pkg_aliases") +load("//python/private:render_pkg_aliases.bzl", "render_pkg_aliases", "whl_alias") load("//python/private:repo_utils.bzl", "REPO_DEBUG_ENV_VAR", "repo_utils") load("//python/private:toolchains_repo.bzl", "get_host_os_arch") load("//python/private:whl_target_platforms.bzl", "whl_target_platforms") @@ -374,7 +374,13 @@ def _pip_repository_impl(rctx): config["experimental_target_platforms"] = rctx.attr.experimental_target_platforms macro_tmpl = "@%s//{}:{}" % rctx.attr.name - aliases = render_pkg_aliases(repo_name = rctx.attr.name, bzl_packages = bzl_packages) + + aliases = render_pkg_aliases( + aliases = { + pkg: [whl_alias(repo = rctx.attr.name + "_" + pkg)] + for pkg in bzl_packages or [] + }, + ) for path, contents in aliases.items(): rctx.file(path, contents) diff --git a/python/private/bzlmod/pip.bzl b/python/private/bzlmod/pip.bzl index b4dbf2f1fe..a017089803 100644 --- a/python/private/bzlmod/pip.bzl +++ b/python/private/bzlmod/pip.bzl @@ -27,6 +27,7 @@ load( load("//python/pip_install:requirements_parser.bzl", parse_requirements = "parse") load("//python/private:normalize_name.bzl", "normalize_name") load("//python/private:parse_whl_name.bzl", "parse_whl_name") +load("//python/private:render_pkg_aliases.bzl", "whl_alias") load("//python/private:version_label.bzl", "version_label") load(":pip_repository.bzl", "pip_repository") @@ -179,8 +180,9 @@ def _create_whl_repos(module_ctx, pip_attr, whl_map, whl_overrides): group_name = whl_group_mapping.get(whl_name) group_deps = requirement_cycles.get(group_name, []) + repo_name = "{}_{}".format(pip_name, whl_name) whl_library( - name = "%s_%s" % (pip_name, whl_name), + name = repo_name, requirement = requirement_line, repo = pip_name, repo_prefix = pip_name + "_", @@ -205,10 +207,15 @@ def _create_whl_repos(module_ctx, pip_attr, whl_map, whl_overrides): group_deps = group_deps, ) - if whl_name not in whl_map[hub_name]: - whl_map[hub_name][whl_name] = {} - - whl_map[hub_name][whl_name][_major_minor_version(pip_attr.python_version)] = pip_name + "_" + major_minor = _major_minor_version(pip_attr.python_version) + whl_map[hub_name].setdefault(whl_name, []).append( + whl_alias( + repo = repo_name, + version = major_minor, + # Call Label() to canonicalize because its used in a different context + config_setting = Label("//python/config_settings:is_python_" + major_minor), + ), + ) def _pip_impl(module_ctx): """Implementation of a class tag that creates the pip hub and corresponding pip spoke whl repositories. @@ -358,7 +365,10 @@ def _pip_impl(module_ctx): pip_repository( name = hub_name, repo_name = hub_name, - whl_map = whl_map, + whl_map = { + key: json.encode(value) + for key, value in whl_map.items() + }, default_version = _major_minor_version(DEFAULT_PYTHON_VERSION), ) diff --git a/python/private/bzlmod/pip_repository.bzl b/python/private/bzlmod/pip_repository.bzl index 8ea5ee7526..d96131dad7 100644 --- a/python/private/bzlmod/pip_repository.bzl +++ b/python/private/bzlmod/pip_repository.bzl @@ -14,7 +14,7 @@ "" -load("//python/private:render_pkg_aliases.bzl", "render_pkg_aliases") +load("//python/private:render_pkg_aliases.bzl", "render_pkg_aliases", "whl_alias") load("//python/private:text_util.bzl", "render") _BUILD_FILE_CONTENTS = """\ @@ -27,10 +27,11 @@ exports_files(["requirements.bzl"]) def _pip_repository_impl(rctx): bzl_packages = rctx.attr.whl_map.keys() aliases = render_pkg_aliases( - repo_name = rctx.attr.repo_name, - rules_python = rctx.attr._template.workspace_name, + aliases = { + key: [whl_alias(**v) for v in json.decode(values)] + for key, values in rctx.attr.whl_map.items() + }, default_version = rctx.attr.default_version, - whl_map = rctx.attr.whl_map, ) for path, contents in aliases.items(): rctx.file(path, contents) @@ -71,9 +72,12 @@ setting.""", mandatory = True, doc = "The apparent name of the repo. This is needed because in bzlmod, the name attribute becomes the canonical name.", ), - "whl_map": attr.string_list_dict( + "whl_map": attr.string_dict( mandatory = True, - doc = "The wheel map where values are python versions", + doc = """\ +The wheel map where values are json.encoded strings of the whl_map constructed +in the pip.parse tag class. +""", ), "_template": attr.label( default = ":requirements.bzl.tmpl", diff --git a/python/private/render_pkg_aliases.bzl b/python/private/render_pkg_aliases.bzl index 02ba75bbc4..e38f13321d 100644 --- a/python/private/render_pkg_aliases.bzl +++ b/python/private/render_pkg_aliases.bzl @@ -16,9 +16,8 @@ This is used in bzlmod and non-bzlmod setups.""" -load("//python/private:normalize_name.bzl", "normalize_name") +load(":normalize_name.bzl", "normalize_name") load(":text_util.bzl", "render") -load(":version_label.bzl", "version_label") NO_MATCH_ERROR_MESSAGE_TEMPLATE = """\ No matching wheel for current configuration's Python version. @@ -42,56 +41,31 @@ which has a "null" version value and will not match version constraints. def _render_whl_library_alias( *, name, - repo_name, - dep, - target, default_version, - versions, - rules_python): - """Render an alias for common targets - - If the versions is passed, then the `rules_python` must be passed as well and - an alias with a select statement based on the python version is going to be - generated. - """ - if versions == None: + aliases): + """Render an alias for common targets.""" + if len(aliases) == 1 and not aliases[0].version: + alias = aliases[0] return render.alias( name = name, - actual = repr("@{repo_name}_{dep}//:{target}".format( - repo_name = repo_name, - dep = dep, - target = target, - )), + actual = repr("@{repo}//:{name}".format(repo = alias.repo, name = name)), ) # Create the alias repositories which contains different select # statements These select statements point to the different pip # whls that are based on a specific version of Python. selects = {} - for full_version in versions: - condition = "@@{rules_python}//python/config_settings:is_python_{full_python_version}".format( - rules_python = rules_python, - full_python_version = full_version, - ) - actual = "@{repo_name}_{version}_{dep}//:{target}".format( - repo_name = repo_name, - version = version_label(full_version), - dep = dep, - target = target, - ) - selects[condition] = actual - - if default_version: - no_match_error = None - default_actual = "@{repo_name}_{version}_{dep}//:{target}".format( - repo_name = repo_name, - version = version_label(default_version), - dep = dep, - target = target, - ) - selects["//conditions:default"] = default_actual - else: - no_match_error = "_NO_MATCH_ERROR" + no_match_error = "_NO_MATCH_ERROR" + default = None + for alias in sorted(aliases, key = lambda x: x.version): + actual = "@{repo}//:{name}".format(repo = alias.repo, name = name) + selects[alias.config_setting] = actual + if alias.version == default_version: + default = actual + no_match_error = None + + if default: + selects["//conditions:default"] = default return render.alias( name = name, @@ -101,22 +75,21 @@ def _render_whl_library_alias( ), ) -def _render_common_aliases(repo_name, name, versions = None, default_version = None, rules_python = None): +def _render_common_aliases(*, name, aliases, default_version = None): lines = [ """package(default_visibility = ["//visibility:public"])""", ] - if versions: - versions = sorted(versions) + versions = None + if aliases: + versions = sorted([v.version for v in aliases if v.version]) - if not versions: - pass - elif default_version in versions: + if not versions or default_version in versions: pass else: error_msg = NO_MATCH_ERROR_MESSAGE_TEMPLATE.format( supported_versions = ", ".join(versions), - rules_python = rules_python, + rules_python = "rules_python", ) lines.append("_NO_MATCH_ERROR = \"\"\"\\\n{error_msg}\"\"\"".format( @@ -137,12 +110,8 @@ def _render_common_aliases(repo_name, name, versions = None, default_version = N [ _render_whl_library_alias( name = target, - repo_name = repo_name, - dep = name, - target = target, - versions = versions, default_version = default_version, - rules_python = rules_python, + aliases = aliases, ) for target in ["pkg", "whl", "data", "dist_info"] ], @@ -150,7 +119,7 @@ def _render_common_aliases(repo_name, name, versions = None, default_version = N return "\n\n".join(lines) -def render_pkg_aliases(*, repo_name, bzl_packages = None, whl_map = None, rules_python = None, default_version = None): +def render_pkg_aliases(*, aliases, default_version = None): """Create alias declarations for each PyPI package. The aliases should be appended to the pip_repository BUILD.bazel file. These aliases @@ -158,36 +127,55 @@ def render_pkg_aliases(*, repo_name, bzl_packages = None, whl_map = None, rules_ when using bzlmod. Args: - repo_name: the repository name of the hub repository that is visible to the users that is - also used as the prefix for the spoke repo names (e.g. "pip", "pypi"). - bzl_packages: the list of packages to setup, if not specified, whl_map.keys() will be used instead. - whl_map: the whl_map for generating Python version aware aliases. + aliases: dict, the keys are normalized distribution names and values are the + whl_alias instances. default_version: the default version to be used for the aliases. - rules_python: the name of the rules_python workspace. Returns: A dict of file paths and their contents. """ - if not bzl_packages and whl_map: - bzl_packages = list(whl_map.keys()) - contents = {} - if not bzl_packages: + if not aliases: return contents + elif type(aliases) != type({}): + fail("The aliases need to be provided as a dict, got: {}".format(type(aliases))) - for name in bzl_packages: - versions = None - if whl_map != None: - versions = whl_map[name] - name = normalize_name(name) - - filename = "{}/BUILD.bazel".format(name) - contents[filename] = _render_common_aliases( - repo_name = repo_name, - name = name, - versions = versions, - rules_python = rules_python, + return { + "{}/BUILD.bazel".format(normalize_name(name)): _render_common_aliases( + name = normalize_name(name), + aliases = pkg_aliases, default_version = default_version, ).strip() + for name, pkg_aliases in aliases.items() + } - return contents +def whl_alias(*, repo, version = None, config_setting = None): + """The bzl_packages value used by by the render_pkg_aliases function. + + This contains the minimum amount of information required to generate correct + aliases in a hub repository. + + Args: + repo: str, the repo of where to find the things to be aliased. + version: optional(str), the version of the python toolchain that this + whl alias is for. If not set, then non-version aware aliases will be + constructed. This is mainly used for better error messages when there + is no match found during a select. + config_setting: optional(Label or str), the config setting that we should use. Defaults + to "@rules_python//python/config_settings:is_python_{version}". + + Returns: + a struct with the validated and parsed values. + """ + if not repo: + fail("'repo' must be specified") + + if version: + config_setting = config_setting or Label("//python/config_settings:is_python_" + version) + config_setting = str(config_setting) + + return struct( + repo = repo, + version = version, + config_setting = config_setting, + ) diff --git a/tests/pip_hub_repository/render_pkg_aliases/render_pkg_aliases_test.bzl b/tests/pip_hub_repository/render_pkg_aliases/render_pkg_aliases_test.bzl index 513c2783e9..c61e5ef9b6 100644 --- a/tests/pip_hub_repository/render_pkg_aliases/render_pkg_aliases_test.bzl +++ b/tests/pip_hub_repository/render_pkg_aliases/render_pkg_aliases_test.bzl @@ -15,14 +15,37 @@ """render_pkg_aliases tests""" load("@rules_testing//lib:test_suite.bzl", "test_suite") -load("//python/private:render_pkg_aliases.bzl", "render_pkg_aliases") # buildifier: disable=bzl-visibility +load("//python/private:bzlmod_enabled.bzl", "BZLMOD_ENABLED") # buildifier: disable=bzl-visibility +load("//python/private:render_pkg_aliases.bzl", "render_pkg_aliases", "whl_alias") # buildifier: disable=bzl-visibility + +def _normalize_label_strings(want): + """normalize expected strings. + + This function ensures that the desired `render_pkg_aliases` outputs are + normalized from `bzlmod` to `WORKSPACE` values so that we don't have to + have to sets of expected strings. The main difference is that under + `bzlmod` the `str(Label("//my_label"))` results in `"@@//my_label"` whereas + under `non-bzlmod` we have `"@//my_label"`. This function does + `string.replace("@@", "@")` to normalize the strings. + + NOTE, in tests, we should only use keep `@@` usage in expectation values + for the test cases where the whl_alias has the `config_setting` constructed + from a `Label` instance. + """ + if "@@" not in want: + fail("The expected string does not have '@@' labels, consider not using the function") + + if BZLMOD_ENABLED: + # our expectations are already with double @ + return want + + return want.replace("@@", "@") _tests = [] def _test_empty(env): actual = render_pkg_aliases( - bzl_packages = None, - repo_name = "pypi", + aliases = None, ) want = {} @@ -33,12 +56,15 @@ _tests.append(_test_empty) def _test_legacy_aliases(env): actual = render_pkg_aliases( - bzl_packages = ["foo"], - repo_name = "pypi", + aliases = { + "foo": [ + whl_alias(repo = "pypi_foo"), + ], + }, ) - want = { - "foo/BUILD.bazel": """\ + want_key = "foo/BUILD.bazel" + want_content = """\ package(default_visibility = ["//visibility:public"]) alias( @@ -64,37 +90,24 @@ alias( alias( name = "dist_info", actual = "@pypi_foo//:dist_info", -)""", - } +)""" - env.expect.that_dict(actual).contains_exactly(want) + env.expect.that_dict(actual).contains_exactly({want_key: want_content}) _tests.append(_test_legacy_aliases) -def _test_all_legacy_aliases_are_created(env): - actual = render_pkg_aliases( - bzl_packages = ["foo", "bar"], - repo_name = "pypi", - ) - - want_files = ["bar/BUILD.bazel", "foo/BUILD.bazel"] - - env.expect.that_dict(actual).keys().contains_exactly(want_files) - -_tests.append(_test_all_legacy_aliases_are_created) - def _test_bzlmod_aliases(env): actual = render_pkg_aliases( default_version = "3.2", - repo_name = "pypi", - rules_python = "rules_python", - whl_map = { - "bar-baz": ["3.2"], + aliases = { + "bar-baz": [ + whl_alias(version = "3.2", repo = "pypi_32_bar_baz", config_setting = "//:my_config_setting"), + ], }, ) - want = { - "bar_baz/BUILD.bazel": """\ + want_key = "bar_baz/BUILD.bazel" + want_content = """\ package(default_visibility = ["//visibility:public"]) alias( @@ -106,7 +119,7 @@ alias( name = "pkg", actual = select( { - "@@rules_python//python/config_settings:is_python_3.2": "@pypi_32_bar_baz//:pkg", + "//:my_config_setting": "@pypi_32_bar_baz//:pkg", "//conditions:default": "@pypi_32_bar_baz//:pkg", }, ), @@ -116,7 +129,7 @@ alias( name = "whl", actual = select( { - "@@rules_python//python/config_settings:is_python_3.2": "@pypi_32_bar_baz//:whl", + "//:my_config_setting": "@pypi_32_bar_baz//:whl", "//conditions:default": "@pypi_32_bar_baz//:whl", }, ), @@ -126,7 +139,7 @@ alias( name = "data", actual = select( { - "@@rules_python//python/config_settings:is_python_3.2": "@pypi_32_bar_baz//:data", + "//:my_config_setting": "@pypi_32_bar_baz//:data", "//conditions:default": "@pypi_32_bar_baz//:data", }, ), @@ -136,24 +149,30 @@ alias( name = "dist_info", actual = select( { - "@@rules_python//python/config_settings:is_python_3.2": "@pypi_32_bar_baz//:dist_info", + "//:my_config_setting": "@pypi_32_bar_baz//:dist_info", "//conditions:default": "@pypi_32_bar_baz//:dist_info", }, ), -)""", - } +)""" - env.expect.that_dict(actual).contains_exactly(want) + env.expect.that_collection(actual.keys()).contains_exactly([want_key]) + env.expect.that_str(actual[want_key]).equals(want_content) _tests.append(_test_bzlmod_aliases) def _test_bzlmod_aliases_with_no_default_version(env): actual = render_pkg_aliases( default_version = None, - repo_name = "pypi", - rules_python = "rules_python", - whl_map = { - "bar-baz": ["3.2", "3.1"], + aliases = { + "bar-baz": [ + whl_alias( + version = "3.2", + repo = "pypi_32_bar_baz", + # pass the label to ensure that it gets converted to string + config_setting = Label("//python/config_settings:is_python_3.2"), + ), + whl_alias(version = "3.1", repo = "pypi_31_bar_baz"), + ], }, ) @@ -189,8 +208,8 @@ alias( name = "pkg", actual = select( { - "@@rules_python//python/config_settings:is_python_3.1": "@pypi_31_bar_baz//:pkg", - "@@rules_python//python/config_settings:is_python_3.2": "@pypi_32_bar_baz//:pkg", + "@@//python/config_settings:is_python_3.1": "@pypi_31_bar_baz//:pkg", + "@@//python/config_settings:is_python_3.2": "@pypi_32_bar_baz//:pkg", }, no_match_error = _NO_MATCH_ERROR, ), @@ -200,8 +219,8 @@ alias( name = "whl", actual = select( { - "@@rules_python//python/config_settings:is_python_3.1": "@pypi_31_bar_baz//:whl", - "@@rules_python//python/config_settings:is_python_3.2": "@pypi_32_bar_baz//:whl", + "@@//python/config_settings:is_python_3.1": "@pypi_31_bar_baz//:whl", + "@@//python/config_settings:is_python_3.2": "@pypi_32_bar_baz//:whl", }, no_match_error = _NO_MATCH_ERROR, ), @@ -211,8 +230,8 @@ alias( name = "data", actual = select( { - "@@rules_python//python/config_settings:is_python_3.1": "@pypi_31_bar_baz//:data", - "@@rules_python//python/config_settings:is_python_3.2": "@pypi_32_bar_baz//:data", + "@@//python/config_settings:is_python_3.1": "@pypi_31_bar_baz//:data", + "@@//python/config_settings:is_python_3.2": "@pypi_32_bar_baz//:data", }, no_match_error = _NO_MATCH_ERROR, ), @@ -222,15 +241,15 @@ alias( name = "dist_info", actual = select( { - "@@rules_python//python/config_settings:is_python_3.1": "@pypi_31_bar_baz//:dist_info", - "@@rules_python//python/config_settings:is_python_3.2": "@pypi_32_bar_baz//:dist_info", + "@@//python/config_settings:is_python_3.1": "@pypi_31_bar_baz//:dist_info", + "@@//python/config_settings:is_python_3.2": "@pypi_32_bar_baz//:dist_info", }, no_match_error = _NO_MATCH_ERROR, ), )""" env.expect.that_collection(actual.keys()).contains_exactly([want_key]) - env.expect.that_str(actual[want_key]).equals(want_content) + env.expect.that_str(actual[want_key]).equals(_normalize_label_strings(want_content)) _tests.append(_test_bzlmod_aliases_with_no_default_version) @@ -244,10 +263,11 @@ def _test_bzlmod_aliases_for_non_root_modules(env): # non-root module, then we will have a no-match-error because the default_version # is not in the list of the versions in the whl_map. default_version = "3.3", - repo_name = "pypi", - rules_python = "rules_python", - whl_map = { - "bar-baz": ["3.2", "3.1"], + aliases = { + "bar-baz": [ + whl_alias(version = "3.2", repo = "pypi_32_bar_baz"), + whl_alias(version = "3.1", repo = "pypi_31_bar_baz"), + ], }, ) @@ -283,8 +303,8 @@ alias( name = "pkg", actual = select( { - "@@rules_python//python/config_settings:is_python_3.1": "@pypi_31_bar_baz//:pkg", - "@@rules_python//python/config_settings:is_python_3.2": "@pypi_32_bar_baz//:pkg", + "@@//python/config_settings:is_python_3.1": "@pypi_31_bar_baz//:pkg", + "@@//python/config_settings:is_python_3.2": "@pypi_32_bar_baz//:pkg", }, no_match_error = _NO_MATCH_ERROR, ), @@ -294,8 +314,8 @@ alias( name = "whl", actual = select( { - "@@rules_python//python/config_settings:is_python_3.1": "@pypi_31_bar_baz//:whl", - "@@rules_python//python/config_settings:is_python_3.2": "@pypi_32_bar_baz//:whl", + "@@//python/config_settings:is_python_3.1": "@pypi_31_bar_baz//:whl", + "@@//python/config_settings:is_python_3.2": "@pypi_32_bar_baz//:whl", }, no_match_error = _NO_MATCH_ERROR, ), @@ -305,8 +325,8 @@ alias( name = "data", actual = select( { - "@@rules_python//python/config_settings:is_python_3.1": "@pypi_31_bar_baz//:data", - "@@rules_python//python/config_settings:is_python_3.2": "@pypi_32_bar_baz//:data", + "@@//python/config_settings:is_python_3.1": "@pypi_31_bar_baz//:data", + "@@//python/config_settings:is_python_3.2": "@pypi_32_bar_baz//:data", }, no_match_error = _NO_MATCH_ERROR, ), @@ -316,26 +336,30 @@ alias( name = "dist_info", actual = select( { - "@@rules_python//python/config_settings:is_python_3.1": "@pypi_31_bar_baz//:dist_info", - "@@rules_python//python/config_settings:is_python_3.2": "@pypi_32_bar_baz//:dist_info", + "@@//python/config_settings:is_python_3.1": "@pypi_31_bar_baz//:dist_info", + "@@//python/config_settings:is_python_3.2": "@pypi_32_bar_baz//:dist_info", }, no_match_error = _NO_MATCH_ERROR, ), )""" env.expect.that_collection(actual.keys()).contains_exactly([want_key]) - env.expect.that_str(actual[want_key]).equals(want_content) + env.expect.that_str(actual[want_key]).equals(_normalize_label_strings(want_content)) _tests.append(_test_bzlmod_aliases_for_non_root_modules) -def _test_bzlmod_aliases_are_created_for_all_wheels(env): +def _test_aliases_are_created_for_all_wheels(env): actual = render_pkg_aliases( default_version = "3.2", - repo_name = "pypi", - rules_python = "rules_python", - whl_map = { - "bar": ["3.1", "3.2"], - "foo": ["3.1", "3.2"], + aliases = { + "bar": [ + whl_alias(version = "3.1", repo = "pypi_31_bar"), + whl_alias(version = "3.2", repo = "pypi_32_bar"), + ], + "foo": [ + whl_alias(version = "3.1", repo = "pypi_32_foo"), + whl_alias(version = "3.2", repo = "pypi_31_foo"), + ], }, ) @@ -346,7 +370,7 @@ def _test_bzlmod_aliases_are_created_for_all_wheels(env): env.expect.that_dict(actual).keys().contains_exactly(want_files) -_tests.append(_test_bzlmod_aliases_are_created_for_all_wheels) +_tests.append(_test_aliases_are_created_for_all_wheels) def render_pkg_aliases_test_suite(name): """Create the test suite. From f7a6840443f8878d3ecca2f74f8b2e513a0eb07c Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 15 Feb 2024 22:48:40 +0900 Subject: [PATCH 04/23] build(deps): bump certifi from 2022.12.7 to 2023.7.22 in /examples/pip_parse (#1374) Bumps [certifi](https://github.com/certifi/python-certifi) from 2022.12.7 to 2023.7.22.
Commits

[![Dependabot compatibility score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=certifi&package-manager=pip&previous-version=2022.12.7&new-version=2023.7.22)](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores) You can trigger a rebase of this PR by commenting `@dependabot rebase`. [//]: # (dependabot-automerge-start) [//]: # (dependabot-automerge-end) ---
Dependabot commands and options
You can trigger Dependabot actions by commenting on this PR: - `@dependabot rebase` will rebase this PR - `@dependabot recreate` will recreate this PR, overwriting any edits that have been made to it - `@dependabot merge` will merge this PR after your CI passes on it - `@dependabot squash and merge` will squash and merge this PR after your CI passes on it - `@dependabot cancel merge` will cancel a previously requested merge and block automerging - `@dependabot reopen` will reopen this PR if it is closed - `@dependabot close` will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually - `@dependabot show ignore conditions` will show all of the ignore conditions of the specified dependency - `@dependabot ignore this major version` will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself) - `@dependabot ignore this minor version` will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself) - `@dependabot ignore this dependency` will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself) You can disable automated security fix PRs for this repo from the [Security Alerts page](https://github.com/bazelbuild/rules_python/network/alerts).
> **Note** > Automatic rebases have been disabled on this pull request as it has been open for over 30 days. Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- examples/pip_parse/requirements_lock.txt | 6 +++--- examples/pip_parse/requirements_windows.txt | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/examples/pip_parse/requirements_lock.txt b/examples/pip_parse/requirements_lock.txt index f0e0c08134..2eaed619b7 100644 --- a/examples/pip_parse/requirements_lock.txt +++ b/examples/pip_parse/requirements_lock.txt @@ -12,9 +12,9 @@ babel==2.13.1 \ --hash=sha256:33e0952d7dd6374af8dbf6768cc4ddf3ccfefc244f9986d4074704f2fbd18900 \ --hash=sha256:7077a4984b02b6727ac10f1f7294484f737443d7e2e66c5e4380e41a3ae0b4ed # via sphinx -certifi==2022.12.7 \ - --hash=sha256:35824b4c3a97115964b408844d64aa14db1cc518f6562e8d7261699d1350a9e3 \ - --hash=sha256:4ad3232f5e926d6718ec31cfc1fcadfde020920e278684144551c91769c7bc18 +certifi==2023.7.22 \ + --hash=sha256:539cc1d13202e33ca466e88b2807e29f4c13049d6d87031a3c110744495cb082 \ + --hash=sha256:92d6037539857d8206b8f6ae472e8b77db8058fec5937a1ef3f54304089edbb9 # via requests chardet==4.0.0 \ --hash=sha256:0d6f53a15db4120f2b08c94f11e7d93d2c911ee118b6b30a04ec3ee8310179fa \ diff --git a/examples/pip_parse/requirements_windows.txt b/examples/pip_parse/requirements_windows.txt index 930ced7fbf..07a5622619 100644 --- a/examples/pip_parse/requirements_windows.txt +++ b/examples/pip_parse/requirements_windows.txt @@ -12,9 +12,9 @@ babel==2.13.1 \ --hash=sha256:33e0952d7dd6374af8dbf6768cc4ddf3ccfefc244f9986d4074704f2fbd18900 \ --hash=sha256:7077a4984b02b6727ac10f1f7294484f737443d7e2e66c5e4380e41a3ae0b4ed # via sphinx -certifi==2022.12.7 \ - --hash=sha256:35824b4c3a97115964b408844d64aa14db1cc518f6562e8d7261699d1350a9e3 \ - --hash=sha256:4ad3232f5e926d6718ec31cfc1fcadfde020920e278684144551c91769c7bc18 +certifi==2023.7.22 \ + --hash=sha256:539cc1d13202e33ca466e88b2807e29f4c13049d6d87031a3c110744495cb082 \ + --hash=sha256:92d6037539857d8206b8f6ae472e8b77db8058fec5937a1ef3f54304089edbb9 # via requests chardet==4.0.0 \ --hash=sha256:0d6f53a15db4120f2b08c94f11e7d93d2c911ee118b6b30a04ec3ee8310179fa \ From c6941a8dad4c7a221125fbad7c8bfaac377e00ba Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 15 Feb 2024 23:16:09 +0900 Subject: [PATCH 05/23] build(deps): bump certifi from 2022.12.7 to 2023.7.22 in /examples/bzlmod_build_file_generation (#1378) Bumps [certifi](https://github.com/certifi/python-certifi) from 2022.12.7 to 2023.7.22.
Commits

[![Dependabot compatibility score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=certifi&package-manager=pip&previous-version=2022.12.7&new-version=2023.7.22)](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores) You can trigger a rebase of this PR by commenting `@dependabot rebase`. [//]: # (dependabot-automerge-start) [//]: # (dependabot-automerge-end) ---
Dependabot commands and options
You can trigger Dependabot actions by commenting on this PR: - `@dependabot rebase` will rebase this PR - `@dependabot recreate` will recreate this PR, overwriting any edits that have been made to it - `@dependabot merge` will merge this PR after your CI passes on it - `@dependabot squash and merge` will squash and merge this PR after your CI passes on it - `@dependabot cancel merge` will cancel a previously requested merge and block automerging - `@dependabot reopen` will reopen this PR if it is closed - `@dependabot close` will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually - `@dependabot show ignore conditions` will show all of the ignore conditions of the specified dependency - `@dependabot ignore this major version` will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself) - `@dependabot ignore this minor version` will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself) - `@dependabot ignore this dependency` will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself) You can disable automated security fix PRs for this repo from the [Security Alerts page](https://github.com/bazelbuild/rules_python/network/alerts).
> **Note** > Automatic rebases have been disabled on this pull request as it has been open for over 30 days. Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- examples/bzlmod_build_file_generation/requirements_lock.txt | 6 +++--- .../bzlmod_build_file_generation/requirements_windows.txt | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/examples/bzlmod_build_file_generation/requirements_lock.txt b/examples/bzlmod_build_file_generation/requirements_lock.txt index 3fd053f777..8ba315be1c 100644 --- a/examples/bzlmod_build_file_generation/requirements_lock.txt +++ b/examples/bzlmod_build_file_generation/requirements_lock.txt @@ -8,9 +8,9 @@ astroid==2.12.13 \ --hash=sha256:10e0ad5f7b79c435179d0d0f0df69998c4eef4597534aae44910db060baeb907 \ --hash=sha256:1493fe8bd3dfd73dc35bd53c9d5b6e49ead98497c47b2307662556a5692d29d7 # via pylint -certifi==2022.12.7 \ - --hash=sha256:35824b4c3a97115964b408844d64aa14db1cc518f6562e8d7261699d1350a9e3 \ - --hash=sha256:4ad3232f5e926d6718ec31cfc1fcadfde020920e278684144551c91769c7bc18 +certifi==2023.7.22 \ + --hash=sha256:539cc1d13202e33ca466e88b2807e29f4c13049d6d87031a3c110744495cb082 \ + --hash=sha256:92d6037539857d8206b8f6ae472e8b77db8058fec5937a1ef3f54304089edbb9 # via requests chardet==4.0.0 \ --hash=sha256:0d6f53a15db4120f2b08c94f11e7d93d2c911ee118b6b30a04ec3ee8310179fa \ diff --git a/examples/bzlmod_build_file_generation/requirements_windows.txt b/examples/bzlmod_build_file_generation/requirements_windows.txt index 15e92288dc..09971f9663 100644 --- a/examples/bzlmod_build_file_generation/requirements_windows.txt +++ b/examples/bzlmod_build_file_generation/requirements_windows.txt @@ -8,9 +8,9 @@ astroid==2.12.13 \ --hash=sha256:10e0ad5f7b79c435179d0d0f0df69998c4eef4597534aae44910db060baeb907 \ --hash=sha256:1493fe8bd3dfd73dc35bd53c9d5b6e49ead98497c47b2307662556a5692d29d7 # via pylint -certifi==2022.12.7 \ - --hash=sha256:35824b4c3a97115964b408844d64aa14db1cc518f6562e8d7261699d1350a9e3 \ - --hash=sha256:4ad3232f5e926d6718ec31cfc1fcadfde020920e278684144551c91769c7bc18 +certifi==2023.7.22 \ + --hash=sha256:539cc1d13202e33ca466e88b2807e29f4c13049d6d87031a3c110744495cb082 \ + --hash=sha256:92d6037539857d8206b8f6ae472e8b77db8058fec5937a1ef3f54304089edbb9 # via requests chardet==4.0.0 \ --hash=sha256:0d6f53a15db4120f2b08c94f11e7d93d2c911ee118b6b30a04ec3ee8310179fa \ From 8247a51415e17490f39f99b401d4980bd1da3082 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 16 Feb 2024 09:07:39 +0900 Subject: [PATCH 06/23] build(deps): bump certifi from 2022.12.7 to 2023.7.22 in /tools/publish (#1377) Bumps [certifi](https://github.com/certifi/python-certifi) from 2022.12.7 to 2023.7.22.
Commits

[![Dependabot compatibility score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=certifi&package-manager=pip&previous-version=2022.12.7&new-version=2023.7.22)](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores) You can trigger a rebase of this PR by commenting `@dependabot rebase`. [//]: # (dependabot-automerge-start) [//]: # (dependabot-automerge-end) ---
Dependabot commands and options
You can trigger Dependabot actions by commenting on this PR: - `@dependabot rebase` will rebase this PR - `@dependabot recreate` will recreate this PR, overwriting any edits that have been made to it - `@dependabot merge` will merge this PR after your CI passes on it - `@dependabot squash and merge` will squash and merge this PR after your CI passes on it - `@dependabot cancel merge` will cancel a previously requested merge and block automerging - `@dependabot reopen` will reopen this PR if it is closed - `@dependabot close` will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually - `@dependabot show ignore conditions` will show all of the ignore conditions of the specified dependency - `@dependabot ignore this major version` will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself) - `@dependabot ignore this minor version` will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself) - `@dependabot ignore this dependency` will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself) You can disable automated security fix PRs for this repo from the [Security Alerts page](https://github.com/bazelbuild/rules_python/network/alerts).
> **Note** > Automatic rebases have been disabled on this pull request as it has been open for over 30 days. Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- tools/publish/requirements_darwin.txt | 6 +++--- tools/publish/requirements_windows.txt | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/tools/publish/requirements_darwin.txt b/tools/publish/requirements_darwin.txt index 1203ba2bfc..5bf8544c0a 100644 --- a/tools/publish/requirements_darwin.txt +++ b/tools/publish/requirements_darwin.txt @@ -8,9 +8,9 @@ bleach==6.0.0 \ --hash=sha256:1a1a85c1595e07d8db14c5f09f09e6433502c51c595970edc090551f0db99414 \ --hash=sha256:33c16e3353dbd13028ab4799a0f89a83f113405c766e9c122df8a06f5b85b3f4 # via readme-renderer -certifi==2022.12.7 \ - --hash=sha256:35824b4c3a97115964b408844d64aa14db1cc518f6562e8d7261699d1350a9e3 \ - --hash=sha256:4ad3232f5e926d6718ec31cfc1fcadfde020920e278684144551c91769c7bc18 +certifi==2023.7.22 \ + --hash=sha256:539cc1d13202e33ca466e88b2807e29f4c13049d6d87031a3c110744495cb082 \ + --hash=sha256:92d6037539857d8206b8f6ae472e8b77db8058fec5937a1ef3f54304089edbb9 # via requests charset-normalizer==3.0.1 \ --hash=sha256:00d3ffdaafe92a5dc603cb9bd5111aaa36dfa187c8285c543be562e61b755f6b \ diff --git a/tools/publish/requirements_windows.txt b/tools/publish/requirements_windows.txt index 25d7776f5a..128c0b56b6 100644 --- a/tools/publish/requirements_windows.txt +++ b/tools/publish/requirements_windows.txt @@ -8,9 +8,9 @@ bleach==6.0.0 \ --hash=sha256:1a1a85c1595e07d8db14c5f09f09e6433502c51c595970edc090551f0db99414 \ --hash=sha256:33c16e3353dbd13028ab4799a0f89a83f113405c766e9c122df8a06f5b85b3f4 # via readme-renderer -certifi==2022.12.7 \ - --hash=sha256:35824b4c3a97115964b408844d64aa14db1cc518f6562e8d7261699d1350a9e3 \ - --hash=sha256:4ad3232f5e926d6718ec31cfc1fcadfde020920e278684144551c91769c7bc18 +certifi==2023.7.22 \ + --hash=sha256:539cc1d13202e33ca466e88b2807e29f4c13049d6d87031a3c110744495cb082 \ + --hash=sha256:92d6037539857d8206b8f6ae472e8b77db8058fec5937a1ef3f54304089edbb9 # via requests charset-normalizer==3.0.1 \ --hash=sha256:00d3ffdaafe92a5dc603cb9bd5111aaa36dfa187c8285c543be562e61b755f6b \ From 76f1c76f60ccb536d3b3e2c9f023d8063f40bcd5 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 16 Feb 2024 10:14:22 +0900 Subject: [PATCH 07/23] build(deps): bump jinja2 from 3.0.3 to 3.1.3 in /tests/integration/pip_repository_entry_points (#1684) Bumps [jinja2](https://github.com/pallets/jinja) from 3.0.3 to 3.1.3.
Release notes

Sourced from jinja2's releases.

3.1.3

This is a fix release for the 3.1.x feature branch.

3.1.2

This is a fix release for the 3.1.0 feature release.

3.1.1

3.1.0

This is a feature release, which includes new features and removes previously deprecated features. The 3.1.x branch is now the supported bugfix branch, the 3.0.x branch has become a tag marking the end of support for that branch. We encourage everyone to upgrade, and to use a tool such as pip-tools to pin all dependencies and control upgrades. We also encourage upgrading to MarkupSafe 2.1.1, the latest version at this time.

Changelog

Sourced from jinja2's changelog.

Version 3.1.3

Released 2024-01-10

  • Fix compiler error when checking if required blocks in parent templates are empty. :pr:1858
  • xmlattr filter does not allow keys with spaces. GHSA-h5c8-rqwp-cp95
  • Make error messages stemming from invalid nesting of {% trans %} blocks more helpful. :pr:1918

Version 3.1.2

Released 2022-04-28

  • Add parameters to Environment.overlay to match __init__. :issue:1645
  • Handle race condition in FileSystemBytecodeCache. :issue:1654

Version 3.1.1

Released 2022-03-25

  • The template filename on Windows uses the primary path separator. :issue:1637

Version 3.1.0

Released 2022-03-24

  • Drop support for Python 3.6. :pr:1534

  • Remove previously deprecated code. :pr:1544

    • WithExtension and AutoEscapeExtension are built-in now.
    • contextfilter and contextfunction are replaced by pass_context. evalcontextfilter and evalcontextfunction are replaced by pass_eval_context. environmentfilter and environmentfunction are replaced by pass_environment.
    • Markup and escape should be imported from MarkupSafe.
    • Compiled templates from very old Jinja versions may need to be recompiled.
    • Legacy resolve mode for Context subclasses is no longer supported. Override resolve_or_missing instead of

... (truncated)

Commits

[![Dependabot compatibility score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=jinja2&package-manager=pip&previous-version=3.0.3&new-version=3.1.3)](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores) Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting `@dependabot rebase`. [//]: # (dependabot-automerge-start) [//]: # (dependabot-automerge-end) ---
Dependabot commands and options
You can trigger Dependabot actions by commenting on this PR: - `@dependabot rebase` will rebase this PR - `@dependabot recreate` will recreate this PR, overwriting any edits that have been made to it - `@dependabot merge` will merge this PR after your CI passes on it - `@dependabot squash and merge` will squash and merge this PR after your CI passes on it - `@dependabot cancel merge` will cancel a previously requested merge and block automerging - `@dependabot reopen` will reopen this PR if it is closed - `@dependabot close` will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually - `@dependabot show ignore conditions` will show all of the ignore conditions of the specified dependency - `@dependabot ignore this major version` will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself) - `@dependabot ignore this minor version` will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself) - `@dependabot ignore this dependency` will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself) You can disable automated security fix PRs for this repo from the [Security Alerts page](https://github.com/bazelbuild/rules_python/network/alerts).
Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- .../pip_repository_entry_points/requirements_windows.txt | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/integration/pip_repository_entry_points/requirements_windows.txt b/tests/integration/pip_repository_entry_points/requirements_windows.txt index aeff5226b9..904024e6bb 100644 --- a/tests/integration/pip_repository_entry_points/requirements_windows.txt +++ b/tests/integration/pip_repository_entry_points/requirements_windows.txt @@ -38,9 +38,9 @@ imagesize==1.3.0 \ --hash=sha256:1db2f82529e53c3e929e8926a1fa9235aa82d0bd0c580359c67ec31b2fddaa8c \ --hash=sha256:cd1750d452385ca327479d45b64d9c7729ecf0b3969a58148298c77092261f9d # via sphinx -jinja2==3.0.3 \ - --hash=sha256:077ce6014f7b40d03b47d1f1ca4b0fc8328a692bd284016f806ed0eaca390ad8 \ - --hash=sha256:611bb273cd68f3b993fabdc4064fc858c5b47a973cb5aa7999ec1ba405c87cd7 +jinja2==3.1.3 \ + --hash=sha256:7d6d50dd97d52cbc355597bd845fabfbac3f551e1f99619e39a35ce8c370b5fa \ + --hash=sha256:ac8bd6544d4bb2c9792bf3a159e80bba8fda7f07e81bc3aed565432d5925ba90 # via sphinx markupsafe==2.0.1 \ --hash=sha256:01a9b8ea66f1658938f65b93a85ebe8bc016e6769611be228d797c9d998dd298 \ From 9a1a524cb0f9c048fbd0abc9837d4a757d98b9c5 Mon Sep 17 00:00:00 2001 From: Matt Brown Date: Tue, 20 Feb 2024 18:38:23 -0500 Subject: [PATCH 08/23] docs(getting-started): fix link to python-build-standalone quirks (#1771) The `python-build-standalone.readthedocs.io` site seems to be dead. --------- Co-authored-by: Richard Levasseur --- docs/sphinx/getting-started.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/sphinx/getting-started.md b/docs/sphinx/getting-started.md index d7542faba6..fbecd7b6b2 100644 --- a/docs/sphinx/getting-started.md +++ b/docs/sphinx/getting-started.md @@ -159,7 +159,7 @@ pip_parse( After registration, your Python targets will use the toolchain's interpreter during execution, but a system-installed interpreter is still used to 'bootstrap' Python targets (see https://github.com/bazelbuild/rules_python/issues/691). -You may also find some quirks while using this toolchain. Please refer to [python-build-standalone documentation's _Quirks_ section](https://python-build-standalone.readthedocs.io/en/latest/quirks.html). +You may also find some quirks while using this toolchain. Please refer to [python-build-standalone documentation's _Quirks_ section](https://gregoryszorc.com/docs/python-build-standalone/main/quirks.html). ## Toolchain usage in other rules From 627830e0756e6f7c09f2a95561963121dff9c166 Mon Sep 17 00:00:00 2001 From: Jesse Schalken Date: Tue, 27 Feb 2024 20:01:05 +1100 Subject: [PATCH 09/23] fix(internal): correctly template error message in repository rules (#1779) Fixes "Error in format: Missing argument 'path'" error and correctly templates the binary name and `PATH`. ``` (17:54:57) ERROR: /Users/jesses/work/canva/WORKSPACE:120:17: fetching whl_library rule //external:pypi_jsmin: Traceback (most recent call last): File "/private/var/tmp/_bazel_jesses/06c990151bb0d0bcaaf7ea85520191a3/external/rules_python/python/pip_install/pip_repository.bzl", line 783, column 59, in _whl_library_impl environment = _create_repository_execution_environment(rctx, python_interpreter) File "/private/var/tmp/_bazel_jesses/06c990151bb0d0bcaaf7ea85520191a3/external/rules_python/python/pip_install/pip_repository.bzl", line 257, column 47, in _create_repository_execution_environment cppflags.extend(_get_xcode_location_cflags(rctx)) File "/private/var/tmp/_bazel_jesses/06c990151bb0d0bcaaf7ea85520191a3/external/rules_python/python/pip_install/pip_repository.bzl", line 121, column 46, in _get_xcode_location_cflags arguments = [repo_utils.which_checked(rctx, "xcode-select"), "--print-path"], File "/private/var/tmp/_bazel_jesses/06c990151bb0d0bcaaf7ea85520191a3/external/rules_python/python/private/repo_utils.bzl", line 164, column 39, in _which_checked " PATH = {path}".format(rctx.os.environ.get("PATH")))) Error in format: Missing argument 'path' ``` --- python/private/repo_utils.bzl | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/python/private/repo_utils.bzl b/python/private/repo_utils.bzl index d42a67aee9..7a5921781d 100644 --- a/python/private/repo_utils.bzl +++ b/python/private/repo_utils.bzl @@ -160,8 +160,13 @@ def _which_checked(rctx, binary_name): """ binary = rctx.which(binary_name) if binary == None: - fail(("Unable to find the binary '{binary_name}' on PATH.\n" + - " PATH = {path}".format(rctx.os.environ.get("PATH")))) + fail(( + "Unable to find the binary '{binary_name}' on PATH.\n" + + " PATH = {path}" + ).format( + binary_name = binary_name, + path = rctx.os.environ.get("PATH"), + )) return binary def _args_to_str(arguments): From 4dcfd21b4a3f1e0ee3e10a8e42efed5ad635f5b2 Mon Sep 17 00:00:00 2001 From: Douglas Thor Date: Tue, 27 Feb 2024 17:22:40 -0800 Subject: [PATCH 10/23] docs(gazelle): Add details about python_root directive. (#1782) While figuring out how to use gazelle with a `src` dir (see https://github.com/bazelbuild/rules_python/issues/1775) (I figured it out by the way, hence this PR), I noticed that the docs were a little unclear. This PR updates the `gazelle` docs to include details about the `python_root` directive and how to use it. I also fix a the default value for the `python_generation_mode_per_file_include_init` directive, as it was incorrectly listed as "package". --- gazelle/README.md | 43 ++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 40 insertions(+), 3 deletions(-) diff --git a/gazelle/README.md b/gazelle/README.md index c1221a6015..117aacbd14 100644 --- a/gazelle/README.md +++ b/gazelle/README.md @@ -176,8 +176,8 @@ Python-specific directives are as follows: |--------------------------------------|-------------------| | `# gazelle:python_extension` | `enabled` | | Controls whether the Python extension is enabled or not. Sub-packages inherit this value. Can be either "enabled" or "disabled". | | -| `# gazelle:python_root` | n/a | -| Sets a Bazel package as a Python root. This is used on monorepos with multiple Python projects that don't share the top-level of the workspace as the root. | | +| [`# gazelle:python_root`](#directive-python_root) | n/a | +| Sets a Bazel package as a Python root. This is used on monorepos with multiple Python projects that don't share the top-level of the workspace as the root. See [Directive: `python_root`](#directive-python_root) below. | | | `# gazelle:python_manifest_file_name`| `gazelle_python.yaml` | | Overrides the default manifest file name. | | | `# gazelle:python_ignore_files` | n/a | @@ -188,7 +188,7 @@ Python-specific directives are as follows: | Controls whether the Python import statements should be validated. Can be "true" or "false" | | | `# gazelle:python_generation_mode`| `package` | | Controls the target generation mode. Can be "file", "package", or "project" | | -| `# gazelle:python_generation_mode_per_file_include_init`| `package` | +| `# gazelle:python_generation_mode_per_file_include_init`| `false` | | Controls whether `__init__.py` files are included as srcs in each generated target when target generation mode is "file". Can be "true", or "false" | | | `# gazelle:python_library_naming_convention`| `$package_name$` | | Controls the `py_library` naming convention. It interpolates `$package_name$` with the Bazel package name. E.g. if the Bazel package name is `foo`, setting this to `$package_name$_my_lib` would result in a generated target named `foo_my_lib`. | | @@ -199,6 +199,43 @@ Python-specific directives are as follows: | `# gazelle:resolve py ...` | n/a | | Instructs the plugin what target to add as a dependency to satisfy a given import statement. The syntax is `# gazelle:resolve py import-string label` where `import-string` is the symbol in the python `import` statement, and `label` is the Bazel label that Gazelle should write in `deps`. | | + +#### Directive: `python_root`: + +Set this directive within the Bazel package that you want to use as the Python root. +For example, if using a `src` dir (as recommended by the [Python Packaging User +Guide][python-packaging-user-guide]), then set this directive in `src/BUILD.bazel`: + +```starlark +# ./src/BUILD.bazel +# Tell gazelle that are python root is the same dir as this Bazel package. +# gazelle:python_root +``` + +Note that the directive does not have any arguments. + +Gazelle will then add the necessary `imports` attribute to all targets that it +generates: + +```starlark +# in ./src/foo/BUILD.bazel +py_libary( + ... + imports = [".."], # Gazelle adds this + ... +) + +# in ./src/foo/bar/BUILD.bazel +py_libary( + ... + imports = ["../.."], # Gazelle adds this + ... +) +``` + +[python-packaging-user-guide]: https://github.com/pypa/packaging.python.org/blob/4c86169a/source/tutorials/packaging-projects.rst + + ### Libraries Python source files are those ending in `.py` but not ending in `_test.py`. From 3f40e98d3901068aa25fa7ff2573f6bdb5b1fe81 Mon Sep 17 00:00:00 2001 From: Trent Schmidt Date: Wed, 28 Feb 2024 02:15:47 -0800 Subject: [PATCH 11/23] chore: add python 3.12.2, 3.11.8 toolchain (#1781) Updates versions: * 3.11.7 -> 3.11.8 * 3.12.1 -> 3.12.2 Adds python versions: 3.11.8, 3.12.2 --- CHANGELOG.md | 9 +++++++++ WORKSPACE | 2 +- python/versions.bzl | 30 ++++++++++++++++++++++++++++-- 3 files changed, 38 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ed8c27445c..0e29f84d85 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -19,6 +19,15 @@ A brief description of the categories of changes: ## Unreleased +### Changed + +### Fixed + +### Added + +* New Python versions available: `3.11.8`, `3.12.2` using + https://github.com/indygreg/python-build-standalone/releases/tag/20240224. + [0.XX.0]: https://github.com/bazelbuild/rules_python/releases/tag/0.XX.0 ## [0.31.0] - 2024-02-12 diff --git a/WORKSPACE b/WORKSPACE index 9112e6884d..75c8e5663a 100644 --- a/WORKSPACE +++ b/WORKSPACE @@ -85,7 +85,7 @@ load("@rules_python_gazelle_plugin//:deps.bzl", _py_gazelle_deps = "gazelle_deps _py_gazelle_deps() # This interpreter is used for various rules_python dev-time tools -load("@python//3.11.7:defs.bzl", "interpreter") +load("@python//3.11.8:defs.bzl", "interpreter") ##################### # Install twine for our own runfiles wheel publishing. diff --git a/python/versions.bzl b/python/versions.bzl index 9a28f15b43..668d2374a7 100644 --- a/python/versions.bzl +++ b/python/versions.bzl @@ -369,6 +369,19 @@ TOOL_VERSIONS = { }, "strip_prefix": "python", }, + "3.11.8": { + "url": "20240224/cpython-{python_version}+20240224-{platform}-{build}.tar.gz", + "sha256": { + "aarch64-apple-darwin": "389a51139f5abe071a0d70091ca5df3e7a3dfcfcbe3e0ba6ad85fb4c5638421e", + "aarch64-unknown-linux-gnu": "389b9005fb78dd5a6f68df5ea45ab7b30d9a4b3222af96999e94fd20d4ad0c6a", + "ppc64le-unknown-linux-gnu": "eb2b31f8e50309aae493c6a359c32b723a676f07c641f5e8fe4b6aa4dbb50946", + "s390x-unknown-linux-gnu": "844f64f4c16e24965778281da61d1e0e6cd1358a581df1662da814b1eed096b9", + "x86_64-apple-darwin": "097f467b0c36706bfec13f199a2eaf924e668f70c6e2bd1f1366806962f7e86e", + "x86_64-pc-windows-msvc": "b618f1f047349770ee1ef11d1b05899840abd53884b820fd25c7dfe2ec1664d4", + "x86_64-unknown-linux-gnu": "94e13d0e5ad417035b80580f3e893a72e094b0900d5d64e7e34ab08e95439987", + }, + "strip_prefix": "python", + }, "3.12.0": { "url": "20231002/cpython-{python_version}+20231002-{platform}-{build}.tar.gz", "sha256": { @@ -395,6 +408,19 @@ TOOL_VERSIONS = { }, "strip_prefix": "python", }, + "3.12.2": { + "url": "20240224/cpython-{python_version}+20240224-{platform}-{build}.tar.gz", + "sha256": { + "aarch64-apple-darwin": "01c064c00013b0175c7858b159989819ead53f4746d40580b5b0b35b6e80fba6", + "aarch64-unknown-linux-gnu": "e52550379e7c4ac27a87de832d172658bc04150e4e27d4e858e6d8cbb96fd709", + "ppc64le-unknown-linux-gnu": "74bc02c4bbbd26245c37b29b9e12d0a9c1b7ab93477fed8b651c988b6a9a6251", + "s390x-unknown-linux-gnu": "ecd6b0285e5eef94deb784b588b4b425a15a43ae671bf206556659dc141a9825", + "x86_64-apple-darwin": "a53a6670a202c96fec0b8c55ccc780ea3af5307eb89268d5b41a9775b109c094", + "x86_64-pc-windows-msvc": "1e5655a6ccb1a64a78460e4e3ee21036c70246800f176a6c91043a3fe3654a3b", + "x86_64-unknown-linux-gnu": "57a37b57f8243caa4cdac016176189573ad7620f0b6da5941c5e40660f9468ab", + }, + "strip_prefix": "python", + }, } # buildifier: disable=unsorted-dict-items @@ -402,8 +428,8 @@ MINOR_MAPPING = { "3.8": "3.8.18", "3.9": "3.9.18", "3.10": "3.10.13", - "3.11": "3.11.7", - "3.12": "3.12.1", + "3.11": "3.11.8", + "3.12": "3.12.2", } PLATFORMS = { From da10ac49efee1b02cbfa3b22a39e68bf3fe5bbe2 Mon Sep 17 00:00:00 2001 From: Douglas Thor Date: Thu, 29 Feb 2024 23:59:49 -0800 Subject: [PATCH 12/23] feat(gazelle): Add "python_visibility" directive that appends additional visibility labels (#1784) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fixes #1783. Add a new gazelle directive, `python_visibility`, that allows users to add labels to the `visibility` attribute of generated targets. out by the way, hence this PR), I noticed that the docs were a little This directive acts similar to[^1] the [`go_visibility` directive](https://github.com/bazelbuild/bazel-gazelle#directives). The primary use case is for python projects that separate unit test files from the python packages/modules that they test, like so: ``` packaging_tutorial/ ├── LICENSE ├── pyproject.toml ├── README.md ├── src/ │ └── mypackage/ │ ├── __init__.py │ └── foo.py └── tests/ ├── __init__.py └── test_foo.py ``` A future PR will add an example to the `./examples` directory (issue #1775). [^1]: At least, similar based on docs. I haven't done any actual comparison. --- gazelle/README.md | 46 +++++++++++++++++++ gazelle/python/configure.go | 3 ++ gazelle/python/generate.go | 3 +- gazelle/python/target.go | 8 ++-- .../directive_python_visibility/BUILD.in | 4 ++ .../directive_python_visibility/BUILD.out | 16 +++++++ .../directive_python_visibility/README.md | 4 ++ .../directive_python_visibility/WORKSPACE | 1 + .../directive_python_visibility/foo.py | 2 + .../subdir/BUILD.in | 4 ++ .../subdir/BUILD.out | 20 ++++++++ .../subdir/__init__.py | 0 .../directive_python_visibility/subdir/bar.py | 0 .../directive_python_visibility/test.yaml | 17 +++++++ gazelle/pythonconfig/pythonconfig.go | 17 +++++++ 15 files changed, 141 insertions(+), 4 deletions(-) create mode 100644 gazelle/python/testdata/directive_python_visibility/BUILD.in create mode 100644 gazelle/python/testdata/directive_python_visibility/BUILD.out create mode 100644 gazelle/python/testdata/directive_python_visibility/README.md create mode 100644 gazelle/python/testdata/directive_python_visibility/WORKSPACE create mode 100644 gazelle/python/testdata/directive_python_visibility/foo.py create mode 100644 gazelle/python/testdata/directive_python_visibility/subdir/BUILD.in create mode 100644 gazelle/python/testdata/directive_python_visibility/subdir/BUILD.out create mode 100644 gazelle/python/testdata/directive_python_visibility/subdir/__init__.py create mode 100644 gazelle/python/testdata/directive_python_visibility/subdir/bar.py create mode 100644 gazelle/python/testdata/directive_python_visibility/test.yaml diff --git a/gazelle/README.md b/gazelle/README.md index 117aacbd14..00170345e7 100644 --- a/gazelle/README.md +++ b/gazelle/README.md @@ -198,6 +198,8 @@ Python-specific directives are as follows: | Controls the `py_test` naming convention. Follows the same interpolation rules as `python_library_naming_convention`. | | | `# gazelle:resolve py ...` | n/a | | Instructs the plugin what target to add as a dependency to satisfy a given import statement. The syntax is `# gazelle:resolve py import-string label` where `import-string` is the symbol in the python `import` statement, and `label` is the Bazel label that Gazelle should write in `deps`. | | +| [`# gazelle:python_visibility label`](#directive-python_visibility) | | +| Appends additional visibility labels to each generated target. This directive can be set multiple times. | | #### Directive: `python_root`: @@ -236,6 +238,50 @@ py_libary( [python-packaging-user-guide]: https://github.com/pypa/packaging.python.org/blob/4c86169a/source/tutorials/packaging-projects.rst +#### Directive: `python_visibility`: + +Appends additional `visibility` labels to each generated target. + +This directive can be set multiple times. The generated `visibility` attribute +will include the default visibility and all labels defined by this directive. +All labels will be ordered alphabetically. + +```starlark +# ./BUILD.bazel +# gazelle:python_visibility //tests:__pkg__ +# gazelle:python_visibility //bar:baz + +py_library( + ... + visibility = [ + "//:__subpackages__", # default visibility + "//bar:baz", + "//tests:__pkg__", + ], + ... +) +``` + +Child Bazel packages inherit values from parents: + +```starlark +# ./bar/BUILD.bazel +# gazelle:python_visibility //tests:__subpackages__ + +py_library( + ... + visibility = [ + "//:__subpackages__", # default visibility + "//bar:baz", # defined in ../BUILD.bazel + "//tests:__pkg__", # defined in ../BUILD.bazel + "//tests:__subpackages__", # defined in this ./BUILD.bazel + ], + ... +) + +``` + + ### Libraries Python source files are those ending in `.py` but not ending in `_test.py`. diff --git a/gazelle/python/configure.go b/gazelle/python/configure.go index 69d276266e..431568829b 100644 --- a/gazelle/python/configure.go +++ b/gazelle/python/configure.go @@ -63,6 +63,7 @@ func (py *Configurer) KnownDirectives() []string { pythonconfig.LibraryNamingConvention, pythonconfig.BinaryNamingConvention, pythonconfig.TestNamingConvention, + pythonconfig.Visibility, } } @@ -162,6 +163,8 @@ func (py *Configurer) Configure(c *config.Config, rel string, f *rule.File) { config.SetBinaryNamingConvention(strings.TrimSpace(d.Value)) case pythonconfig.TestNamingConvention: config.SetTestNamingConvention(strings.TrimSpace(d.Value)) + case pythonconfig.Visibility: + config.AppendVisibility(strings.TrimSpace(d.Value)) } } diff --git a/gazelle/python/generate.go b/gazelle/python/generate.go index ba273be2b7..6973d2ded8 100644 --- a/gazelle/python/generate.go +++ b/gazelle/python/generate.go @@ -212,7 +212,8 @@ func (py *Python) GenerateRules(args language.GenerateArgs) language.GenerateRes } parser := newPython3Parser(args.Config.RepoRoot, args.Rel, cfg.IgnoresDependency) - visibility := fmt.Sprintf("//%s:__subpackages__", pythonProjectRoot) + visibility := []string{fmt.Sprintf("//%s:__subpackages__", pythonProjectRoot)} + visibility = append(visibility, cfg.Visibility()...) var result language.GenerateResult result.Gen = make([]*rule.Rule, 0) diff --git a/gazelle/python/target.go b/gazelle/python/target.go index e3104058b2..a941a7cc7e 100644 --- a/gazelle/python/target.go +++ b/gazelle/python/target.go @@ -99,9 +99,11 @@ func (t *targetBuilder) addResolvedDependency(dep string) *targetBuilder { return t } -// addVisibility adds a visibility to the target. -func (t *targetBuilder) addVisibility(visibility string) *targetBuilder { - t.visibility.Add(visibility) +// addVisibility adds visibility labels to the target. +func (t *targetBuilder) addVisibility(visibility []string) *targetBuilder { + for _, item := range visibility { + t.visibility.Add(item) + } return t } diff --git a/gazelle/python/testdata/directive_python_visibility/BUILD.in b/gazelle/python/testdata/directive_python_visibility/BUILD.in new file mode 100644 index 0000000000..c1ba9e455e --- /dev/null +++ b/gazelle/python/testdata/directive_python_visibility/BUILD.in @@ -0,0 +1,4 @@ +# Directives can be added in any order. They will be ordered alphabetically +# when added. +# gazelle:python_visibility //tests:__pkg__ +# gazelle:python_visibility //bar:baz diff --git a/gazelle/python/testdata/directive_python_visibility/BUILD.out b/gazelle/python/testdata/directive_python_visibility/BUILD.out new file mode 100644 index 0000000000..70715e86fa --- /dev/null +++ b/gazelle/python/testdata/directive_python_visibility/BUILD.out @@ -0,0 +1,16 @@ +load("@rules_python//python:defs.bzl", "py_library") + +# Directives can be added in any order. They will be ordered alphabetically +# when added. +# gazelle:python_visibility //tests:__pkg__ +# gazelle:python_visibility //bar:baz + +py_library( + name = "directive_python_visibility", + srcs = ["foo.py"], + visibility = [ + "//:__subpackages__", + "//bar:baz", + "//tests:__pkg__", + ], +) diff --git a/gazelle/python/testdata/directive_python_visibility/README.md b/gazelle/python/testdata/directive_python_visibility/README.md new file mode 100644 index 0000000000..51ab7aef6b --- /dev/null +++ b/gazelle/python/testdata/directive_python_visibility/README.md @@ -0,0 +1,4 @@ +# Directive: `python_visibility` + +This test case asserts that the `# gazelle:python_visibility` directive correctly +appends multiple labels to the target's `visibility` parameter. diff --git a/gazelle/python/testdata/directive_python_visibility/WORKSPACE b/gazelle/python/testdata/directive_python_visibility/WORKSPACE new file mode 100644 index 0000000000..faff6af87a --- /dev/null +++ b/gazelle/python/testdata/directive_python_visibility/WORKSPACE @@ -0,0 +1 @@ +# This is a Bazel workspace for the Gazelle test data. diff --git a/gazelle/python/testdata/directive_python_visibility/foo.py b/gazelle/python/testdata/directive_python_visibility/foo.py new file mode 100644 index 0000000000..98907eb794 --- /dev/null +++ b/gazelle/python/testdata/directive_python_visibility/foo.py @@ -0,0 +1,2 @@ +def func(): + print("library_func") diff --git a/gazelle/python/testdata/directive_python_visibility/subdir/BUILD.in b/gazelle/python/testdata/directive_python_visibility/subdir/BUILD.in new file mode 100644 index 0000000000..5193e69587 --- /dev/null +++ b/gazelle/python/testdata/directive_python_visibility/subdir/BUILD.in @@ -0,0 +1,4 @@ +# python_visibilty directive applies to all child bazel packages. +# Thus, the generated file for this package will also have vis for +# //tests:__pkg__ and //bar:baz in addition to the default. +# gazelle:python_visibility //tests:__subpackages__ diff --git a/gazelle/python/testdata/directive_python_visibility/subdir/BUILD.out b/gazelle/python/testdata/directive_python_visibility/subdir/BUILD.out new file mode 100644 index 0000000000..722c840432 --- /dev/null +++ b/gazelle/python/testdata/directive_python_visibility/subdir/BUILD.out @@ -0,0 +1,20 @@ +load("@rules_python//python:defs.bzl", "py_library") + +# python_visibilty directive applies to all child bazel packages. +# Thus, the generated file for this package will also have vis for +# //tests:__pkg__ and //bar:baz in addition to the default. +# gazelle:python_visibility //tests:__subpackages__ + +py_library( + name = "subdir", + srcs = [ + "__init__.py", + "bar.py", + ], + visibility = [ + "//:__subpackages__", + "//bar:baz", + "//tests:__pkg__", + "//tests:__subpackages__", + ], +) diff --git a/gazelle/python/testdata/directive_python_visibility/subdir/__init__.py b/gazelle/python/testdata/directive_python_visibility/subdir/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/gazelle/python/testdata/directive_python_visibility/subdir/bar.py b/gazelle/python/testdata/directive_python_visibility/subdir/bar.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/gazelle/python/testdata/directive_python_visibility/test.yaml b/gazelle/python/testdata/directive_python_visibility/test.yaml new file mode 100644 index 0000000000..2410223e59 --- /dev/null +++ b/gazelle/python/testdata/directive_python_visibility/test.yaml @@ -0,0 +1,17 @@ +# Copyright 2023 The Bazel Authors. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +--- +expect: + exit_code: 0 diff --git a/gazelle/pythonconfig/pythonconfig.go b/gazelle/pythonconfig/pythonconfig.go index cecf9dcea0..e350a7cb60 100644 --- a/gazelle/pythonconfig/pythonconfig.go +++ b/gazelle/pythonconfig/pythonconfig.go @@ -67,6 +67,10 @@ const ( // naming convention. See python_library_naming_convention for more info on // the package name interpolation. TestNamingConvention = "python_test_naming_convention" + // Visibility represents the directive that controls what additional + // visibility labels are added to generated targets. It mimics the behavior + // of the `go_visibility` directive. + Visibility = "python_visibility" ) // GenerationModeType represents one of the generation modes for the Python @@ -136,6 +140,7 @@ type Config struct { libraryNamingConvention string binaryNamingConvention string testNamingConvention string + visibility []string } // New creates a new Config. @@ -157,6 +162,7 @@ func New( libraryNamingConvention: packageNameNamingConventionSubstitution, binaryNamingConvention: fmt.Sprintf("%s_bin", packageNameNamingConventionSubstitution), testNamingConvention: fmt.Sprintf("%s_test", packageNameNamingConventionSubstitution), + visibility: []string{}, } } @@ -183,6 +189,7 @@ func (c *Config) NewChild() *Config { libraryNamingConvention: c.libraryNamingConvention, binaryNamingConvention: c.binaryNamingConvention, testNamingConvention: c.testNamingConvention, + visibility: c.visibility, } } @@ -388,3 +395,13 @@ func (c *Config) SetTestNamingConvention(testNamingConvention string) { func (c *Config) RenderTestName(packageName string) string { return strings.ReplaceAll(c.testNamingConvention, packageNameNamingConventionSubstitution, packageName) } + +// AppendVisibility adds additional items to the target's visibility. +func (c *Config) AppendVisibility(visibility string) { + c.visibility = append(c.visibility, visibility) +} + +// Visibility returns the target's visibility. +func (c *Config) Visibility() []string { + return c.visibility +} From fdf941013a2520ec42ee09608a5169394a715a35 Mon Sep 17 00:00:00 2001 From: Douglas Thor Date: Tue, 12 Mar 2024 02:30:50 -0700 Subject: [PATCH 13/23] build(internal_deps): Update 'maintained by' comments to be correct (#1794) This fixes a minor error in the "maintained by" comments in `./MODULE.bazel` and `./python/pip_install/repositories.bzl`. The comments now agree with what `DEVELOPING.md` says. --- MODULE.bazel | 4 ++-- python/pip_install/repositories.bzl | 4 ++-- tools/private/update_deps/update_pip_deps.py | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/MODULE.bazel b/MODULE.bazel index e89b8ef679..3ed92dbee6 100644 --- a/MODULE.bazel +++ b/MODULE.bazel @@ -17,7 +17,7 @@ internal_deps.install() use_repo( internal_deps, "rules_python_internal", - # START: maintained by 'bazel run //tools/private:update_pip_deps' + # START: maintained by 'bazel run //tools/private/update_deps:update_pip_deps' "pypi__build", "pypi__click", "pypi__colorama", @@ -33,7 +33,7 @@ use_repo( "pypi__tomli", "pypi__wheel", "pypi__zipp", - # END: maintained by 'bazel run //tools/private:update_pip_deps' + # END: maintained by 'bazel run //tools/private/update_deps:update_pip_deps' ) # We need to do another use_extension call to expose the "pythons_hub" diff --git a/python/pip_install/repositories.bzl b/python/pip_install/repositories.bzl index 91bdd4b56e..b8679e5ef0 100644 --- a/python/pip_install/repositories.bzl +++ b/python/pip_install/repositories.bzl @@ -18,7 +18,7 @@ load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") load("@bazel_tools//tools/build_defs/repo:utils.bzl", "maybe") _RULE_DEPS = [ - # START: maintained by 'bazel run //tools/private:update_pip_deps' + # START: maintained by 'bazel run //tools/private/update_deps:update_pip_deps' ( "pypi__build", "https://files.pythonhosted.org/packages/58/91/17b00d5fac63d3dca605f1b8269ba3c65e98059e1fd99d00283e42a454f0/build-0.10.0-py3-none-any.whl", @@ -94,7 +94,7 @@ _RULE_DEPS = [ "https://files.pythonhosted.org/packages/8c/08/d3006317aefe25ea79d3b76c9650afabaf6d63d1c8443b236e7405447503/zipp-3.16.2-py3-none-any.whl", "679e51dd4403591b2d6838a48de3d283f3d188412a9782faadf845f298736ba0", ), - # END: maintained by 'bazel run //tools/private:update_pip_deps' + # END: maintained by 'bazel run //tools/private/update_deps:update_pip_deps' ] _GENERIC_WHEEL = """\ diff --git a/tools/private/update_deps/update_pip_deps.py b/tools/private/update_deps/update_pip_deps.py index 8a2dd5f8da..3c4b46ecfd 100755 --- a/tools/private/update_deps/update_pip_deps.py +++ b/tools/private/update_deps/update_pip_deps.py @@ -111,13 +111,13 @@ def main(): parser.add_argument( "--start", type=str, - default="# START: maintained by 'bazel run //tools/private:update_pip_deps'", + default="# START: maintained by 'bazel run //tools/private/update_deps:update_pip_deps'", help="The text to match in a file when updating them.", ) parser.add_argument( "--end", type=str, - default="# END: maintained by 'bazel run //tools/private:update_pip_deps'", + default="# END: maintained by 'bazel run //tools/private/update_deps:update_pip_deps'", help="The text to match in a file when updating them.", ) parser.add_argument( From 5ab3e9cca2a1cbd5a320ccb5aa4db093af019374 Mon Sep 17 00:00:00 2001 From: Christian von Schultz Date: Tue, 12 Mar 2024 13:56:02 +0100 Subject: [PATCH 14/23] docs: Update notice about rctx.getenv on Bazel 7 (#1797) Bazel 7.1 has been released, and includes support for `repository_ctx.getenv`. Therefore, update the comments and docs to reflect the current status of the feature with released Bazel versions. --- python/pip_install/pip_repository.bzl | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/python/pip_install/pip_repository.bzl b/python/pip_install/pip_repository.bzl index 7b8160e956..ded7112144 100644 --- a/python/pip_install/pip_repository.bzl +++ b/python/pip_install/pip_repository.bzl @@ -202,10 +202,9 @@ def _parse_optional_attrs(rctx, args): if use_isolated(rctx, rctx.attr): args.append("--isolated") - # At the time of writing, the very latest Bazel, as in `USE_BAZEL_VERSION=last_green bazelisk` - # supports rctx.getenv(name, default): When building incrementally, any change to the value of - # the variable named by name will cause this repository to be re-fetched. That hasn't yet made - # its way into the official releases, though. + # Bazel version 7.1.0 and later (and rolling releases from version 8.0.0-pre.20240128.3) + # support rctx.getenv(name, default): When building incrementally, any change to the value of + # the variable named by name will cause this repository to be re-fetched. if "getenv" in dir(rctx): getenv = rctx.getenv else: @@ -457,7 +456,7 @@ A list of environment variables to substitute (e.g. `["PIP_INDEX_URL", "PIP_RETRIES"]`). The corresponding variables are expanded in `extra_pip_args` using the syntax `$VARNAME` or `${VARNAME}` (expanding to empty string if unset) or `${VARNAME:-default}` (expanding to default if the variable is unset or empty -in the environment). Note: On Bazel 6 and Bazel 7 changes to the variables named +in the environment). Note: On Bazel 6 and Bazel 7.0 changes to the variables named here do not cause packages to be re-fetched. Don't fetch different things based on the value of these variables. """, From 9c538eab62f280256d1c9889e8e19b138854e3a2 Mon Sep 17 00:00:00 2001 From: Douglas Thor Date: Tue, 12 Mar 2024 20:30:38 -0700 Subject: [PATCH 15/23] docs(changelog) Update changelog from PR #1784 (#1802) Add the missing changelog from PR #1784. --- CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0e29f84d85..28b453a929 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -27,6 +27,8 @@ A brief description of the categories of changes: * New Python versions available: `3.11.8`, `3.12.2` using https://github.com/indygreg/python-build-standalone/releases/tag/20240224. +* (gazelle) Added a new `python_visibility` directive to control visibility + of generated targets by appending additional visibility labels. [0.XX.0]: https://github.com/bazelbuild/rules_python/releases/tag/0.XX.0 From 9bc3aa89eda40959f491a0b0c86c47b2b9d57049 Mon Sep 17 00:00:00 2001 From: Richard Levasseur Date: Thu, 14 Mar 2024 10:07:39 -0700 Subject: [PATCH 16/23] docs: Add some missing attribute docs (#1805) Adds docs for: stamp, srcs, deps, srcs_version, data, and python_version --- python/private/common/attributes.bzl | 47 ++++++++++++++++++++++++- python/private/common/py_executable.bzl | 1 + 2 files changed, 47 insertions(+), 1 deletion(-) diff --git a/python/private/common/attributes.bzl b/python/private/common/attributes.bzl index 85361dbb91..2111419372 100644 --- a/python/private/common/attributes.bzl +++ b/python/private/common/attributes.bzl @@ -30,7 +30,28 @@ _PackageSpecificationInfo = getattr(py_internal, "PackageSpecificationInfo", Non _STAMP_VALUES = [-1, 0, 1] def create_stamp_attr(**kwargs): - return {"stamp": attr.int(values = _STAMP_VALUES, **kwargs)} + return { + "stamp": attr.int( + values = _STAMP_VALUES, + doc = """ +Whether to encode build information into the binary. Possible values: + +* `stamp = 1`: Always stamp the build information into the binary, even in + `--nostamp` builds. **This setting should be avoided**, since it potentially kills + remote caching for the binary and any downstream actions that depend on it. +* `stamp = 0`: Always replace build information by constant values. This gives + good build result caching. +* `stamp = -1`: Embedding of build information is controlled by the + `--[no]stamp` flag. + +Stamped binaries are not rebuilt unless their dependencies change. + +WARNING: Stamping can harm build performance by reducing cache hits and should +be avoided if possible. +""", + **kwargs + ), + } def create_srcs_attr(*, mandatory): return { @@ -40,6 +61,12 @@ def create_srcs_attr(*, mandatory): mandatory = mandatory, # Necessary for --compile_one_dependency to work. flags = ["DIRECT_COMPILE_TIME_INPUT"], + doc = """ +The list of Python source files that are processed to create the target. This +includes all your checked-in code and may include generated source files. The +`.py` files belong in `srcs` and library targets belong in `deps`. Other binary +files that may be needed at run time belong in `data`. +""", ), } @@ -51,6 +78,7 @@ def create_srcs_version_attr(values): "srcs_version": attr.string( default = "PY2AND3", values = values, + doc = "Defunct, unused, does nothing.", ), } @@ -81,6 +109,13 @@ DATA_ATTRS = { "data": attr.label_list( allow_files = True, flags = ["SKIP_CONSTRAINTS_OVERRIDE"], + doc = """ +The list of files need by this library at runtime. See comments about +the [`data` attribute typically defined by rules](https://bazel.build/reference/be/common-definitions#typical-attributes). + +There is no `py_embed_data` like there is `cc_embed_data` and `go_embed_data`. +This is because Python has a concept of runtime resources. +""", ), } @@ -136,6 +171,16 @@ PY_SRCS_ATTRS = union_attrs( # TODO(b/228692666): Google-specific; remove these allowances once # the depot is cleaned up. allow_rules = DEPS_ATTR_ALLOW_RULES, + doc = """ +List of additional libraries to be linked in to the target. +See comments about +the [`deps` attribute typically defined by +rules](https://bazel.build/reference/be/common-definitions#typical-attributes). +These are typically `py_library` rules. + +Targets that only provide data files used at runtime belong in the `data` +attribute. +""", ), # Required attribute, but details vary by rule. # Use create_srcs_attr to create one. diff --git a/python/private/common/py_executable.bzl b/python/private/common/py_executable.bzl index 410fb1d0b5..bc0d0f2f1e 100644 --- a/python/private/common/py_executable.bzl +++ b/python/private/common/py_executable.bzl @@ -93,6 +93,7 @@ filename in `srcs`, `main` must be specified. default = "PY3", # NOTE: Some tests care about the order of these values. values = ["PY2", "PY3"], + doc = "Defunct, unused, does nothing.", ), "_windows_constraints": attr.label_list( default = [ From 565a531d167a6f066ff555d8831a30a38dacb74c Mon Sep 17 00:00:00 2001 From: Michael Krasnyk Date: Fri, 15 Mar 2024 09:36:25 +0100 Subject: [PATCH 17/23] chore: update coveragepy to 7.4.3 (#1798) The updated covergepy version contains a fix for https://github.com/nedbat/coveragepy/issues/1733 which leads to sporadic issues ``` .../rules_python~~python~python_3_12_x86_64-unknown-linux-gnu_coverage/coverage/collector.py", line 511, in flush_data for fname, packeds in packed_data.items(): RuntimeError: dictionary changed size during iteration ``` --- CHANGELOG.md | 4 ++ python/private/coverage_deps.bzl | 80 ++++++++++++++++---------------- 2 files changed, 44 insertions(+), 40 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 28b453a929..9aaebd4695 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -32,6 +32,10 @@ A brief description of the categories of changes: [0.XX.0]: https://github.com/bazelbuild/rules_python/releases/tag/0.XX.0 +### Changed + +* (coverage) Bump `coverage.py` to [7.4.3](https://github.com/nedbat/coveragepy/blob/master/CHANGES.rst#version-743--2024-02-23). + ## [0.31.0] - 2024-02-12 [0.31.0]: https://github.com/bazelbuild/rules_python/releases/tag/0.31.0 diff --git a/python/private/coverage_deps.bzl b/python/private/coverage_deps.bzl index 62764d93c0..d69fab9ecd 100644 --- a/python/private/coverage_deps.bzl +++ b/python/private/coverage_deps.bzl @@ -23,92 +23,92 @@ load("//python/private:version_label.bzl", "version_label") _coverage_deps = { "cp310": { "aarch64-apple-darwin": ( - "https://files.pythonhosted.org/packages/ed/2d/db83db65d0c3d457f993830b97271a80f11bdc051d86dd44405c436db147/coverage-7.4.1-cp310-cp310-macosx_11_0_arm64.whl", - "0193657651f5399d433c92f8ae264aff31fc1d066deee4b831549526433f3f61", + "https://files.pythonhosted.org/packages/a3/36/b5ae380c05f58544a40ff36f87fa1d6e45f5c2f299335586aac140c341ce/coverage-7.4.3-cp310-cp310-macosx_11_0_arm64.whl", + "718187eeb9849fc6cc23e0d9b092bc2348821c5e1a901c9f8975df0bc785bfd4", ), "aarch64-unknown-linux-gnu": ( - "https://files.pythonhosted.org/packages/8f/bf/9b1e104690d4976b17d515ee49b648c26d7244e148d1c845708d58b8f4fe/coverage-7.4.1-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", - "d17bbc946f52ca67adf72a5ee783cd7cd3477f8f8796f59b4974a9b59cacc9ee", + "https://files.pythonhosted.org/packages/9e/48/5ae1ccf4601500af0ca36eba0a2c1f1796e58fb7495de6da55ed43e13e5f/coverage-7.4.3-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", + "767b35c3a246bcb55b8044fd3a43b8cd553dd1f9f2c1eeb87a302b1f8daa0524", ), "x86_64-apple-darwin": ( - "https://files.pythonhosted.org/packages/26/1f/430384b8e428c87950583e775fee97bc83bcfd93a2ecc00b5e55a5a052a5/coverage-7.4.1-cp310-cp310-macosx_10_9_x86_64.whl", - "077d366e724f24fc02dbfe9d946534357fda71af9764ff99d73c3c596001bbd7", + "https://files.pythonhosted.org/packages/50/5a/d727fcd2e0fc3aba61591b6f0fe1e87865ea9b6275f58f35810d6f85b05b/coverage-7.4.3-cp310-cp310-macosx_10_9_x86_64.whl", + "8580b827d4746d47294c0e0b92854c85a92c2227927433998f0d3320ae8a71b6", ), "x86_64-unknown-linux-gnu": ( - "https://files.pythonhosted.org/packages/49/d5/9d66fd984979b58927588efb0398953acbdb4c45eb7cfcd74fa9b8d51d12/coverage-7.4.1-cp310-cp310-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl", - "6dceb61d40cbfcf45f51e59933c784a50846dc03211054bd76b421a713dcdf19", + "https://files.pythonhosted.org/packages/23/0a/ab5b0f6d6b24f7156624e7697ec7ab49f9d5cdac922da90d9927ae5de1cf/coverage-7.4.3-cp310-cp310-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl", + "ba3a8aaed13770e970b3df46980cb068d1c24af1a1968b7818b69af8c4347efb", ), }, "cp311": { "aarch64-apple-darwin": ( - "https://files.pythonhosted.org/packages/12/8d/e078f0ccc4e91aa44f7754f0bac18bd6c62780a029b5d30f6242c6e06b23/coverage-7.4.1-cp311-cp311-macosx_11_0_arm64.whl", - "3cacfaefe6089d477264001f90f55b7881ba615953414999c46cc9713ff93c8c", + "https://files.pythonhosted.org/packages/f8/a1/161102d2e26fde2d878d68cc1ed303758dc7b01ee14cc6aa70f5fd1b910d/coverage-7.4.3-cp311-cp311-macosx_11_0_arm64.whl", + "489763b2d037b164846ebac0cbd368b8a4ca56385c4090807ff9fad817de4113", ), "aarch64-unknown-linux-gnu": ( - "https://files.pythonhosted.org/packages/87/71/0d90c4cda220c1f20f0eeaa997633eb1ec0bcaf5d8250c299d0f27a5885d/coverage-7.4.1-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", - "5d6850e6e36e332d5511a48a251790ddc545e16e8beaf046c03985c69ccb2676", + "https://files.pythonhosted.org/packages/a7/af/1510df1132a68ca876013c0417ca46836252e43871d2623b489e4339c980/coverage-7.4.3-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", + "451f433ad901b3bb00184d83fd83d135fb682d780b38af7944c9faeecb1e0bfe", ), "x86_64-apple-darwin": ( - "https://files.pythonhosted.org/packages/0b/bd/008f9dad615d67e47221a983cd46cb5e87002e569dec60daa84d1b422859/coverage-7.4.1-cp311-cp311-macosx_10_9_x86_64.whl", - "b8ffb498a83d7e0305968289441914154fb0ef5d8b3157df02a90c6695978295", + "https://files.pythonhosted.org/packages/ca/77/f17a5b199e8ca0443ace312f7e07ff3e4e7ba7d7c52847567d6f1edb22a7/coverage-7.4.3-cp311-cp311-macosx_10_9_x86_64.whl", + "cbbe5e739d45a52f3200a771c6d2c7acf89eb2524890a4a3aa1a7fa0695d2a47", ), "x86_64-unknown-linux-gnu": ( - "https://files.pythonhosted.org/packages/d5/a7/36bd1c439fab5d450c69b7cdf4be4291d56885ae8be11ebed9ec240b919f/coverage-7.4.1-cp311-cp311-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl", - "dfd1e1b9f0898817babf840b77ce9fe655ecbe8b1b327983df485b30df8cc011", + "https://files.pythonhosted.org/packages/a9/1a/e2120233177b3e2ea9dcfd49a050748060166c74792b2b1db4a803307da4/coverage-7.4.3-cp311-cp311-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl", + "b3ec74cfef2d985e145baae90d9b1b32f85e1741b04cd967aaf9cfa84c1334f3", ), }, "cp312": { "aarch64-apple-darwin": ( - "https://files.pythonhosted.org/packages/de/37/4f3eb8e6f4be39eeca4318e3c2ef10e954e86871a68b0e71f004835d6a30/coverage-7.4.1-cp312-cp312-macosx_11_0_arm64.whl", - "23b27b8a698e749b61809fb637eb98ebf0e505710ec46a8aa6f1be7dc0dc43a6", + "https://files.pythonhosted.org/packages/9d/d8/111ec1a65fef57ad2e31445af627d481f660d4a9218ee5c774b45187812a/coverage-7.4.3-cp312-cp312-macosx_11_0_arm64.whl", + "d6cdecaedea1ea9e033d8adf6a0ab11107b49571bbb9737175444cea6eb72328", ), "aarch64-unknown-linux-gnu": ( - "https://files.pythonhosted.org/packages/10/97/ca7dec2d9a1262bc0dbfb757989444fec8cde908083b15fb3339210aa7b8/coverage-7.4.1-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", - "3e3424c554391dc9ef4a92ad28665756566a28fecf47308f91841f6c49288e66", + "https://files.pythonhosted.org/packages/8f/eb/28416f1721a3b7fa28ea499e8a6f867e28146ea2453839c2bca04a001eeb/coverage-7.4.3-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", + "3b2eccb883368f9e972e216c7b4c7c06cabda925b5f06dde0650281cb7666a30", ), "x86_64-apple-darwin": ( - "https://files.pythonhosted.org/packages/37/34/2089e0b24759a207184b41a4e4b4af7004282a5b3a93bb408c2fa19b9b16/coverage-7.4.1-cp312-cp312-macosx_10_9_x86_64.whl", - "f68ef3660677e6624c8cace943e4765545f8191313a07288a53d3da188bd8581", + "https://files.pythonhosted.org/packages/11/5c/2cf3e794fa5d1eb443aa8544e2ba3837d75073eaf25a1fda64d232065609/coverage-7.4.3-cp312-cp312-macosx_10_9_x86_64.whl", + "b51bfc348925e92a9bd9b2e48dad13431b57011fd1038f08316e6bf1df107d10", ), "x86_64-unknown-linux-gnu": ( - "https://files.pythonhosted.org/packages/c3/92/f2d89715c3397e76fe365b1ecbb861d1279ff8d47d23635040a358bc75dc/coverage-7.4.1-cp312-cp312-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl", - "fe558371c1bdf3b8fa03e097c523fb9645b8730399c14fe7721ee9c9e2a545d3", + "https://files.pythonhosted.org/packages/2f/db/70900f10b85a66f761a3a28950ccd07757d51548b1d10157adc4b9415f15/coverage-7.4.3-cp312-cp312-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl", + "b9a4a8dd3dcf4cbd3165737358e4d7dfbd9d59902ad11e3b15eebb6393b0446e", ), }, "cp38": { "aarch64-apple-darwin": ( - "https://files.pythonhosted.org/packages/13/4e/66a3821f6fc8a28d07740d9115fdacffb7e7d61431b9ae112bacde846327/coverage-7.4.1-cp38-cp38-macosx_11_0_arm64.whl", - "918440dea04521f499721c039863ef95433314b1db00ff826a02580c1f503e45", + "https://files.pythonhosted.org/packages/96/71/1c299b12e80d231e04a2bfd695e761fb779af7ab66f8bd3cb15649be82b3/coverage-7.4.3-cp38-cp38-macosx_11_0_arm64.whl", + "280459f0a03cecbe8800786cdc23067a8fc64c0bd51dc614008d9c36e1659d7e", ), "aarch64-unknown-linux-gnu": ( - "https://files.pythonhosted.org/packages/2a/12/89d5f08eb9be53910e3b9b2d02dd932f9b50bac10281272cdbaf8dee58d9/coverage-7.4.1-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", - "379d4c7abad5afbe9d88cc31ea8ca262296480a86af945b08214eb1a556a3e4d", + "https://files.pythonhosted.org/packages/c7/a7/b00eaa53d904193478eae01625d784b2af8b522a98028f47c831dcc95663/coverage-7.4.3-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", + "6c0cdedd3500e0511eac1517bf560149764b7d8e65cb800d8bf1c63ebf39edd2", ), "x86_64-apple-darwin": ( - "https://files.pythonhosted.org/packages/3c/75/a4abb6a0d1d4814fbcf8d9e552fd08b579236d8f5c5bb4cfd8a566c43612/coverage-7.4.1-cp38-cp38-macosx_10_9_x86_64.whl", - "8bdb0285a0202888d19ec6b6d23d5990410decb932b709f2b0dfe216d031d218", + "https://files.pythonhosted.org/packages/e2/bc/f54b24b476db0069ac04ff2cdeb28cd890654c8619761bf818726022c76a/coverage-7.4.3-cp38-cp38-macosx_10_9_x86_64.whl", + "28ca2098939eabab044ad68850aac8f8db6bf0b29bc7f2887d05889b17346454", ), "x86_64-unknown-linux-gnu": ( - "https://files.pythonhosted.org/packages/b3/b9/49b1028a69b1e9476db7508705fc67a1218ece54af07b87339eac1b5600a/coverage-7.4.1-cp38-cp38-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl", - "f2f5968608b1fe2a1d00d01ad1017ee27efd99b3437e08b83ded9b7af3f6f766", + "https://files.pythonhosted.org/packages/d0/3a/e882caceca2c7d65791a4a759764a1bf803bbbd10caf38ec41d73a45219e/coverage-7.4.3-cp38-cp38-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl", + "dec9de46a33cf2dd87a5254af095a409ea3bf952d85ad339751e7de6d962cde6", ), }, "cp39": { "aarch64-apple-darwin": ( - "https://files.pythonhosted.org/packages/ce/e1/df16e7e353c2ba5a5b3e02a6bad7dbf1bc62d5b9cfe5c06ed0e31fc64122/coverage-7.4.1-cp39-cp39-macosx_11_0_arm64.whl", - "46342fed0fff72efcda77040b14728049200cbba1279e0bf1188f1f2078c1d70", + "https://files.pythonhosted.org/packages/66/f2/57f5d3c9d2e78c088e4c8dbc933b85fa81c424f23641f10c1aa64052ee4f/coverage-7.4.3-cp39-cp39-macosx_11_0_arm64.whl", + "77fbfc5720cceac9c200054b9fab50cb2a7d79660609200ab83f5db96162d20c", ), "aarch64-unknown-linux-gnu": ( - "https://files.pythonhosted.org/packages/86/25/6b70cb21b6e62158aab40a0e930361d4397f4ef4cbd2a04d3d01b6e4c5cf/coverage-7.4.1-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", - "9641e21670c68c7e57d2053ddf6c443e4f0a6e18e547e86af3fad0795414a628", + "https://files.pythonhosted.org/packages/ad/3f/cde6fd2e4cc447bd24e3dc2e79abd2e0fba67ac162996253d3505f8efef4/coverage-7.4.3-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", + "6679060424faa9c11808598504c3ab472de4531c571ab2befa32f4971835788e", ), "x86_64-apple-darwin": ( - "https://files.pythonhosted.org/packages/9f/ae/0d439dc9adc0111ffbed38149d73ddf34f7a8768e377020181e624cf2634/coverage-7.4.1-cp39-cp39-macosx_10_9_x86_64.whl", - "8e738a492b6221f8dcf281b67129510835461132b03024830ac0e554311a5c54", + "https://files.pythonhosted.org/packages/d6/cf/4094ac6410b680c91c5e55a56f25f4b3a878e2fcbf773c1cecfbdbaaec4f/coverage-7.4.3-cp39-cp39-macosx_10_9_x86_64.whl", + "3b253094dbe1b431d3a4ac2f053b6d7ede2664ac559705a704f621742e034f1f", ), "x86_64-unknown-linux-gnu": ( - "https://files.pythonhosted.org/packages/ff/e3/351477165426da841458f2c1b732360dd42da140920e3cd4b70676e5b77f/coverage-7.4.1-cp39-cp39-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl", - "d12c923757de24e4e2110cf8832d83a886a4cf215c6e61ed506006872b43a6d1", + "https://files.pythonhosted.org/packages/b5/ad/effc12b8f72321cb847c5ba7f4ea7ce3e5c19c641f6418131f8fb0ab2f61/coverage-7.4.3-cp39-cp39-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl", + "8640f1fde5e1b8e3439fe482cdc2b0bb6c329f4bb161927c28d2e8879c6029ee", ), }, } From bdb2aa2e5c0ca435918037aa3568c0b0c4c9c1ab Mon Sep 17 00:00:00 2001 From: Douglas Thor Date: Sat, 16 Mar 2024 19:28:29 -0700 Subject: [PATCH 18/23] feat(gazelle): Add "python_default_visibility" directive (#1787) Fixes #1783. Provides a way to fix #1682. Add the `python_default_visibility` directive. This directive sets the `visibility` attribute on all generated `py_*` rules. It accepts a comma-separated list of labels to add as visibility targets, similar to how the base `default_visibility` directive works. Setting this directive multiple times will override previous values. Two special values are also accepted: `NONE` and `DEFAULT`. See ./gazelle/README.md#directive-python_default_visibility for details. The directive also accepts a special string `"$python_root"` that gets replaced with the `python_root` value, if set. If not set, `"$python_root"` is replaced with the empty string. --------- Co-authored-by: Thulio Ferraz Assis <3149049+f0rmiga@users.noreply.github.com> --- CHANGELOG.md | 4 + gazelle/README.md | 77 +++++++++++++++++++ gazelle/python/configure.go | 16 ++++ gazelle/python/generate.go | 3 +- .../README.md | 21 +++++ .../WORKSPACE | 1 + .../test.yaml | 17 ++++ .../test1_default/BUILD.in | 1 + .../test1_default/BUILD.out | 9 +++ .../test1_default/test1.py | 2 + .../test2_default_with_python_root/BUILD.in | 1 + .../test2_default_with_python_root/BUILD.out | 12 +++ .../__init__.py | 0 .../test2_default_with_python_root/test2.py | 2 + .../test3_injection/BUILD.in | 2 + .../test3_injection/BUILD.out | 13 ++++ .../test3_injection/__init__.py | 0 .../test3_injection/test3.py | 2 + .../test4_multiple_labels/BUILD.in | 1 + .../test4_multiple_labels/BUILD.out | 13 ++++ .../test4_multiple_labels/test4.py | 2 + .../test5_none_label/BUILD.in | 1 + .../test5_none_label/BUILD.out | 8 ++ .../test5_none_label/test5.py | 2 + .../test6_default_label/BUILD.in | 1 + .../test6_default_label/BUILD.out | 9 +++ .../test6_default_label/subpkg/BUILD.in | 2 + .../test6_default_label/subpkg/BUILD.out | 10 +++ .../test6_default_label/subpkg/test6_sub.py | 2 + .../test6_default_label/test6.py | 2 + .../test7_none_label_with_extra_vis/BUILD.in | 5 ++ .../test7_none_label_with_extra_vis/BUILD.out | 16 ++++ .../test7_none_label_with_extra_vis/test7.py | 2 + .../test8_multiple_python_root_dirs/BUILD.in | 2 + .../test8_multiple_python_root_dirs/BUILD.out | 2 + .../proj1/src/BUILD.in | 1 + .../proj1/src/BUILD.out | 1 + .../proj1/src/pkg1/BUILD.in | 2 + .../proj1/src/pkg1/BUILD.out | 14 ++++ .../proj1/src/pkg1/file1.py | 0 .../proj2/src/BUILD.in | 1 + .../proj2/src/BUILD.out | 1 + .../proj2/src/pkg2/BUILD.in | 3 + .../proj2/src/pkg2/BUILD.out | 16 ++++ .../proj2/src/pkg2/file2.py | 0 .../BUILD.in | 1 + .../BUILD.out | 9 +++ .../subpkg1/BUILD.in | 1 + .../subpkg1/BUILD.out | 12 +++ .../subpkg1/foo.py | 0 .../subpkg2/BUILD.in | 3 + .../subpkg2/BUILD.out | 16 ++++ .../subpkg2/foo.py | 0 .../test9.py | 0 gazelle/pythonconfig/pythonconfig.go | 24 +++++- 55 files changed, 364 insertions(+), 4 deletions(-) create mode 100644 gazelle/python/testdata/directive_python_default_visibility/README.md create mode 100644 gazelle/python/testdata/directive_python_default_visibility/WORKSPACE create mode 100644 gazelle/python/testdata/directive_python_default_visibility/test.yaml create mode 100644 gazelle/python/testdata/directive_python_default_visibility/test1_default/BUILD.in create mode 100644 gazelle/python/testdata/directive_python_default_visibility/test1_default/BUILD.out create mode 100644 gazelle/python/testdata/directive_python_default_visibility/test1_default/test1.py create mode 100644 gazelle/python/testdata/directive_python_default_visibility/test2_default_with_python_root/BUILD.in create mode 100644 gazelle/python/testdata/directive_python_default_visibility/test2_default_with_python_root/BUILD.out create mode 100644 gazelle/python/testdata/directive_python_default_visibility/test2_default_with_python_root/__init__.py create mode 100644 gazelle/python/testdata/directive_python_default_visibility/test2_default_with_python_root/test2.py create mode 100644 gazelle/python/testdata/directive_python_default_visibility/test3_injection/BUILD.in create mode 100644 gazelle/python/testdata/directive_python_default_visibility/test3_injection/BUILD.out create mode 100644 gazelle/python/testdata/directive_python_default_visibility/test3_injection/__init__.py create mode 100644 gazelle/python/testdata/directive_python_default_visibility/test3_injection/test3.py create mode 100644 gazelle/python/testdata/directive_python_default_visibility/test4_multiple_labels/BUILD.in create mode 100644 gazelle/python/testdata/directive_python_default_visibility/test4_multiple_labels/BUILD.out create mode 100644 gazelle/python/testdata/directive_python_default_visibility/test4_multiple_labels/test4.py create mode 100644 gazelle/python/testdata/directive_python_default_visibility/test5_none_label/BUILD.in create mode 100644 gazelle/python/testdata/directive_python_default_visibility/test5_none_label/BUILD.out create mode 100644 gazelle/python/testdata/directive_python_default_visibility/test5_none_label/test5.py create mode 100644 gazelle/python/testdata/directive_python_default_visibility/test6_default_label/BUILD.in create mode 100644 gazelle/python/testdata/directive_python_default_visibility/test6_default_label/BUILD.out create mode 100644 gazelle/python/testdata/directive_python_default_visibility/test6_default_label/subpkg/BUILD.in create mode 100644 gazelle/python/testdata/directive_python_default_visibility/test6_default_label/subpkg/BUILD.out create mode 100644 gazelle/python/testdata/directive_python_default_visibility/test6_default_label/subpkg/test6_sub.py create mode 100644 gazelle/python/testdata/directive_python_default_visibility/test6_default_label/test6.py create mode 100644 gazelle/python/testdata/directive_python_default_visibility/test7_none_label_with_extra_vis/BUILD.in create mode 100644 gazelle/python/testdata/directive_python_default_visibility/test7_none_label_with_extra_vis/BUILD.out create mode 100644 gazelle/python/testdata/directive_python_default_visibility/test7_none_label_with_extra_vis/test7.py create mode 100644 gazelle/python/testdata/directive_python_default_visibility/test8_multiple_python_root_dirs/BUILD.in create mode 100644 gazelle/python/testdata/directive_python_default_visibility/test8_multiple_python_root_dirs/BUILD.out create mode 100644 gazelle/python/testdata/directive_python_default_visibility/test8_multiple_python_root_dirs/proj1/src/BUILD.in create mode 100644 gazelle/python/testdata/directive_python_default_visibility/test8_multiple_python_root_dirs/proj1/src/BUILD.out create mode 100644 gazelle/python/testdata/directive_python_default_visibility/test8_multiple_python_root_dirs/proj1/src/pkg1/BUILD.in create mode 100644 gazelle/python/testdata/directive_python_default_visibility/test8_multiple_python_root_dirs/proj1/src/pkg1/BUILD.out create mode 100644 gazelle/python/testdata/directive_python_default_visibility/test8_multiple_python_root_dirs/proj1/src/pkg1/file1.py create mode 100644 gazelle/python/testdata/directive_python_default_visibility/test8_multiple_python_root_dirs/proj2/src/BUILD.in create mode 100644 gazelle/python/testdata/directive_python_default_visibility/test8_multiple_python_root_dirs/proj2/src/BUILD.out create mode 100644 gazelle/python/testdata/directive_python_default_visibility/test8_multiple_python_root_dirs/proj2/src/pkg2/BUILD.in create mode 100644 gazelle/python/testdata/directive_python_default_visibility/test8_multiple_python_root_dirs/proj2/src/pkg2/BUILD.out create mode 100644 gazelle/python/testdata/directive_python_default_visibility/test8_multiple_python_root_dirs/proj2/src/pkg2/file2.py create mode 100644 gazelle/python/testdata/directive_python_default_visibility/test9_default_vis_with_python_vis/BUILD.in create mode 100644 gazelle/python/testdata/directive_python_default_visibility/test9_default_vis_with_python_vis/BUILD.out create mode 100644 gazelle/python/testdata/directive_python_default_visibility/test9_default_vis_with_python_vis/subpkg1/BUILD.in create mode 100644 gazelle/python/testdata/directive_python_default_visibility/test9_default_vis_with_python_vis/subpkg1/BUILD.out create mode 100644 gazelle/python/testdata/directive_python_default_visibility/test9_default_vis_with_python_vis/subpkg1/foo.py create mode 100644 gazelle/python/testdata/directive_python_default_visibility/test9_default_vis_with_python_vis/subpkg2/BUILD.in create mode 100644 gazelle/python/testdata/directive_python_default_visibility/test9_default_vis_with_python_vis/subpkg2/BUILD.out create mode 100644 gazelle/python/testdata/directive_python_default_visibility/test9_default_vis_with_python_vis/subpkg2/foo.py create mode 100644 gazelle/python/testdata/directive_python_default_visibility/test9_default_vis_with_python_vis/test9.py diff --git a/CHANGELOG.md b/CHANGELOG.md index 9aaebd4695..142df6a208 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -29,8 +29,12 @@ A brief description of the categories of changes: https://github.com/indygreg/python-build-standalone/releases/tag/20240224. * (gazelle) Added a new `python_visibility` directive to control visibility of generated targets by appending additional visibility labels. +* (gazelle) Added a new `python_default_visibility` directive to control the + _default_ visibility of generated targets. See the [docs][python_default_visibility] + for details. [0.XX.0]: https://github.com/bazelbuild/rules_python/releases/tag/0.XX.0 +[python_default_visibility]: gazelle/README.md#directive-python_default_visibility ### Changed diff --git a/gazelle/README.md b/gazelle/README.md index 00170345e7..1caa677d34 100644 --- a/gazelle/README.md +++ b/gazelle/README.md @@ -198,6 +198,8 @@ Python-specific directives are as follows: | Controls the `py_test` naming convention. Follows the same interpolation rules as `python_library_naming_convention`. | | | `# gazelle:resolve py ...` | n/a | | Instructs the plugin what target to add as a dependency to satisfy a given import statement. The syntax is `# gazelle:resolve py import-string label` where `import-string` is the symbol in the python `import` statement, and `label` is the Bazel label that Gazelle should write in `deps`. | | +| [`# gazelle:python_default_visibility labels`](#directive-python_default_visibility) | | +| Instructs gazelle to use these visibility labels on all python targets. `labels` is a comma-separated list of labels (without spaces). | `//$python_root:__subpackages__` | | [`# gazelle:python_visibility label`](#directive-python_visibility) | | | Appends additional visibility labels to each generated target. This directive can be set multiple times. | | @@ -238,6 +240,81 @@ py_libary( [python-packaging-user-guide]: https://github.com/pypa/packaging.python.org/blob/4c86169a/source/tutorials/packaging-projects.rst +#### Directive: `python_default_visibility`: + +Instructs gazelle to use these visibility labels on all _python_ targets +(typically `py_*`, but can be modified via the `map_kind` directive). The arg +to this directive is a a comma-separated list (without spaces) of labels. + +For example: + +```starlark +# gazelle:python_default_visibility //:__subpackages__,//tests:__subpackages__ +``` + +produces the following visibility attribute: + +```starlark +py_library( + ..., + visibility = [ + "//:__subpackages__", + "//tests:__subpackages__", + ], + ..., +) +``` + +You can also inject the `python_root` value by using the exact string +`$python_root`. All instances of this string will be replaced by the `python_root` +value. + +```starlark +# gazelle:python_default_visibility //$python_root:__pkg__,//foo/$python_root/tests:__subpackages__ + +# Assuming the "# gazelle:python_root" directive is set in ./py/src/BUILD.bazel, +# the results will be: +py_library( + ..., + visibility = [ + "//foo/py/src/tests:__subpackages__", # sorted alphabetically + "//py/src:__pkg__", + ], + ..., +) +``` + +Two special values are also accepted as an argument to the directive: + ++ `NONE`: This removes all default visibility. Labels added by the + `python_visibility` directive are still included. ++ `DEFAULT`: This resets the default visibility. + +For example: + +```starlark +# gazelle:python_default_visibility NONE + +py_library( + name = "...", + srcs = [...], +) +``` + +```starlark +# gazelle:python_default_visibility //foo:bar +# gazelle:python_default_visibility DEFAULT + +py_library( + ..., + visibility = ["//:__subpackages__"], + ..., +) +``` + +These special values can be useful for sub-packages. + + #### Directive: `python_visibility`: Appends additional `visibility` labels to each generated target. diff --git a/gazelle/python/configure.go b/gazelle/python/configure.go index 431568829b..843609605c 100644 --- a/gazelle/python/configure.go +++ b/gazelle/python/configure.go @@ -63,6 +63,7 @@ func (py *Configurer) KnownDirectives() []string { pythonconfig.LibraryNamingConvention, pythonconfig.BinaryNamingConvention, pythonconfig.TestNamingConvention, + pythonconfig.DefaultVisibilty, pythonconfig.Visibility, } } @@ -119,6 +120,7 @@ func (py *Configurer) Configure(c *config.Config, rel string, f *rule.File) { } case pythonconfig.PythonRootDirective: config.SetPythonProjectRoot(rel) + config.SetDefaultVisibility([]string{fmt.Sprintf(pythonconfig.DefaultVisibilityFmtString, rel)}) case pythonconfig.PythonManifestFileNameDirective: gazelleManifestFilename = strings.TrimSpace(d.Value) case pythonconfig.IgnoreFilesDirective: @@ -163,6 +165,20 @@ func (py *Configurer) Configure(c *config.Config, rel string, f *rule.File) { config.SetBinaryNamingConvention(strings.TrimSpace(d.Value)) case pythonconfig.TestNamingConvention: config.SetTestNamingConvention(strings.TrimSpace(d.Value)) + case pythonconfig.DefaultVisibilty: + switch directiveArg := strings.TrimSpace(d.Value); directiveArg { + case "NONE": + config.SetDefaultVisibility([]string{}) + case "DEFAULT": + pythonProjectRoot := config.PythonProjectRoot() + defaultVisibility := fmt.Sprintf(pythonconfig.DefaultVisibilityFmtString, pythonProjectRoot) + config.SetDefaultVisibility([]string{defaultVisibility}) + default: + // Handle injecting the python root. Assume that the user used the + // exact string "$python_root". + labels := strings.ReplaceAll(directiveArg, "$python_root", config.PythonProjectRoot()) + config.SetDefaultVisibility(strings.Split(labels, ",")) + } case pythonconfig.Visibility: config.AppendVisibility(strings.TrimSpace(d.Value)) } diff --git a/gazelle/python/generate.go b/gazelle/python/generate.go index 6973d2ded8..400c25e0b4 100644 --- a/gazelle/python/generate.go +++ b/gazelle/python/generate.go @@ -212,8 +212,7 @@ func (py *Python) GenerateRules(args language.GenerateArgs) language.GenerateRes } parser := newPython3Parser(args.Config.RepoRoot, args.Rel, cfg.IgnoresDependency) - visibility := []string{fmt.Sprintf("//%s:__subpackages__", pythonProjectRoot)} - visibility = append(visibility, cfg.Visibility()...) + visibility := cfg.Visibility() var result language.GenerateResult result.Gen = make([]*rule.Rule, 0) diff --git a/gazelle/python/testdata/directive_python_default_visibility/README.md b/gazelle/python/testdata/directive_python_default_visibility/README.md new file mode 100644 index 0000000000..be42792375 --- /dev/null +++ b/gazelle/python/testdata/directive_python_default_visibility/README.md @@ -0,0 +1,21 @@ +# Directive: `python_default_visibility` + +This test case asserts that the `# gazelle:python_default_visibility` directive +correctly: + +1. Uses the default value when `python_default_visibility` is not set. +2. Uses the correct default value when `python_root` is set and + `python_default_visibility` is not set. +3. Supports injecting `python_root` +4. Supports multiple labels +5. Setting the label to "NONE" removes all visibility attibutes. +6. Setting the label to "DEFAULT" reverts to using the default. +7. Adding `python_visibility` directive with `python_default_visibility NONE` + only adds the items listed by `python_visibility`. +8. Multiple `python_root` dirs [GH #1682][gh-1682] uses correct value when + injecting `python_root`. +9. Setting both `python_default_visibility` and `python_visibility` and how + they interact with sub-packages. + + +[gh-1682]: https://github.com/bazelbuild/rules_python/issues/1682 diff --git a/gazelle/python/testdata/directive_python_default_visibility/WORKSPACE b/gazelle/python/testdata/directive_python_default_visibility/WORKSPACE new file mode 100644 index 0000000000..faff6af87a --- /dev/null +++ b/gazelle/python/testdata/directive_python_default_visibility/WORKSPACE @@ -0,0 +1 @@ +# This is a Bazel workspace for the Gazelle test data. diff --git a/gazelle/python/testdata/directive_python_default_visibility/test.yaml b/gazelle/python/testdata/directive_python_default_visibility/test.yaml new file mode 100644 index 0000000000..2410223e59 --- /dev/null +++ b/gazelle/python/testdata/directive_python_default_visibility/test.yaml @@ -0,0 +1,17 @@ +# Copyright 2023 The Bazel Authors. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +--- +expect: + exit_code: 0 diff --git a/gazelle/python/testdata/directive_python_default_visibility/test1_default/BUILD.in b/gazelle/python/testdata/directive_python_default_visibility/test1_default/BUILD.in new file mode 100644 index 0000000000..690a65151d --- /dev/null +++ b/gazelle/python/testdata/directive_python_default_visibility/test1_default/BUILD.in @@ -0,0 +1 @@ +# python_default_visibility is not set. diff --git a/gazelle/python/testdata/directive_python_default_visibility/test1_default/BUILD.out b/gazelle/python/testdata/directive_python_default_visibility/test1_default/BUILD.out new file mode 100644 index 0000000000..47fd2d87d5 --- /dev/null +++ b/gazelle/python/testdata/directive_python_default_visibility/test1_default/BUILD.out @@ -0,0 +1,9 @@ +load("@rules_python//python:defs.bzl", "py_library") + +# python_default_visibility is not set. + +py_library( + name = "test1_default", + srcs = ["test1.py"], + visibility = ["//:__subpackages__"], +) diff --git a/gazelle/python/testdata/directive_python_default_visibility/test1_default/test1.py b/gazelle/python/testdata/directive_python_default_visibility/test1_default/test1.py new file mode 100644 index 0000000000..98907eb794 --- /dev/null +++ b/gazelle/python/testdata/directive_python_default_visibility/test1_default/test1.py @@ -0,0 +1,2 @@ +def func(): + print("library_func") diff --git a/gazelle/python/testdata/directive_python_default_visibility/test2_default_with_python_root/BUILD.in b/gazelle/python/testdata/directive_python_default_visibility/test2_default_with_python_root/BUILD.in new file mode 100644 index 0000000000..6948b47b10 --- /dev/null +++ b/gazelle/python/testdata/directive_python_default_visibility/test2_default_with_python_root/BUILD.in @@ -0,0 +1 @@ +# gazelle:python_root diff --git a/gazelle/python/testdata/directive_python_default_visibility/test2_default_with_python_root/BUILD.out b/gazelle/python/testdata/directive_python_default_visibility/test2_default_with_python_root/BUILD.out new file mode 100644 index 0000000000..c3b51bd50e --- /dev/null +++ b/gazelle/python/testdata/directive_python_default_visibility/test2_default_with_python_root/BUILD.out @@ -0,0 +1,12 @@ +load("@rules_python//python:defs.bzl", "py_library") + +# gazelle:python_root + +py_library( + name = "test2_default_with_python_root", + srcs = [ + "__init__.py", + "test2.py", + ], + visibility = ["//test2_default_with_python_root:__subpackages__"], +) diff --git a/gazelle/python/testdata/directive_python_default_visibility/test2_default_with_python_root/__init__.py b/gazelle/python/testdata/directive_python_default_visibility/test2_default_with_python_root/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/gazelle/python/testdata/directive_python_default_visibility/test2_default_with_python_root/test2.py b/gazelle/python/testdata/directive_python_default_visibility/test2_default_with_python_root/test2.py new file mode 100644 index 0000000000..98907eb794 --- /dev/null +++ b/gazelle/python/testdata/directive_python_default_visibility/test2_default_with_python_root/test2.py @@ -0,0 +1,2 @@ +def func(): + print("library_func") diff --git a/gazelle/python/testdata/directive_python_default_visibility/test3_injection/BUILD.in b/gazelle/python/testdata/directive_python_default_visibility/test3_injection/BUILD.in new file mode 100644 index 0000000000..dd64538ef1 --- /dev/null +++ b/gazelle/python/testdata/directive_python_default_visibility/test3_injection/BUILD.in @@ -0,0 +1,2 @@ +# gazelle:python_root +# gazelle:python_default_visibility //foo/$python_root/bar:__pkg__ diff --git a/gazelle/python/testdata/directive_python_default_visibility/test3_injection/BUILD.out b/gazelle/python/testdata/directive_python_default_visibility/test3_injection/BUILD.out new file mode 100644 index 0000000000..1dc862bfd3 --- /dev/null +++ b/gazelle/python/testdata/directive_python_default_visibility/test3_injection/BUILD.out @@ -0,0 +1,13 @@ +load("@rules_python//python:defs.bzl", "py_library") + +# gazelle:python_root +# gazelle:python_default_visibility //foo/$python_root/bar:__pkg__ + +py_library( + name = "test3_injection", + srcs = [ + "__init__.py", + "test3.py", + ], + visibility = ["//foo/test3_injection/bar:__pkg__"], +) diff --git a/gazelle/python/testdata/directive_python_default_visibility/test3_injection/__init__.py b/gazelle/python/testdata/directive_python_default_visibility/test3_injection/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/gazelle/python/testdata/directive_python_default_visibility/test3_injection/test3.py b/gazelle/python/testdata/directive_python_default_visibility/test3_injection/test3.py new file mode 100644 index 0000000000..98907eb794 --- /dev/null +++ b/gazelle/python/testdata/directive_python_default_visibility/test3_injection/test3.py @@ -0,0 +1,2 @@ +def func(): + print("library_func") diff --git a/gazelle/python/testdata/directive_python_default_visibility/test4_multiple_labels/BUILD.in b/gazelle/python/testdata/directive_python_default_visibility/test4_multiple_labels/BUILD.in new file mode 100644 index 0000000000..53eb8a352d --- /dev/null +++ b/gazelle/python/testdata/directive_python_default_visibility/test4_multiple_labels/BUILD.in @@ -0,0 +1 @@ +# gazelle:python_default_visibility //foo/bar:__pkg__,//tests:__subpackages__,//a:b diff --git a/gazelle/python/testdata/directive_python_default_visibility/test4_multiple_labels/BUILD.out b/gazelle/python/testdata/directive_python_default_visibility/test4_multiple_labels/BUILD.out new file mode 100644 index 0000000000..2c3a433275 --- /dev/null +++ b/gazelle/python/testdata/directive_python_default_visibility/test4_multiple_labels/BUILD.out @@ -0,0 +1,13 @@ +load("@rules_python//python:defs.bzl", "py_library") + +# gazelle:python_default_visibility //foo/bar:__pkg__,//tests:__subpackages__,//a:b + +py_library( + name = "test4_multiple_labels", + srcs = ["test4.py"], + visibility = [ + "//a:b", + "//foo/bar:__pkg__", + "//tests:__subpackages__", + ], +) diff --git a/gazelle/python/testdata/directive_python_default_visibility/test4_multiple_labels/test4.py b/gazelle/python/testdata/directive_python_default_visibility/test4_multiple_labels/test4.py new file mode 100644 index 0000000000..98907eb794 --- /dev/null +++ b/gazelle/python/testdata/directive_python_default_visibility/test4_multiple_labels/test4.py @@ -0,0 +1,2 @@ +def func(): + print("library_func") diff --git a/gazelle/python/testdata/directive_python_default_visibility/test5_none_label/BUILD.in b/gazelle/python/testdata/directive_python_default_visibility/test5_none_label/BUILD.in new file mode 100644 index 0000000000..7810eea7ae --- /dev/null +++ b/gazelle/python/testdata/directive_python_default_visibility/test5_none_label/BUILD.in @@ -0,0 +1 @@ +# gazelle:python_default_visibility NONE diff --git a/gazelle/python/testdata/directive_python_default_visibility/test5_none_label/BUILD.out b/gazelle/python/testdata/directive_python_default_visibility/test5_none_label/BUILD.out new file mode 100644 index 0000000000..fc410f6866 --- /dev/null +++ b/gazelle/python/testdata/directive_python_default_visibility/test5_none_label/BUILD.out @@ -0,0 +1,8 @@ +load("@rules_python//python:defs.bzl", "py_library") + +# gazelle:python_default_visibility NONE + +py_library( + name = "test5_none_label", + srcs = ["test5.py"], +) diff --git a/gazelle/python/testdata/directive_python_default_visibility/test5_none_label/test5.py b/gazelle/python/testdata/directive_python_default_visibility/test5_none_label/test5.py new file mode 100644 index 0000000000..98907eb794 --- /dev/null +++ b/gazelle/python/testdata/directive_python_default_visibility/test5_none_label/test5.py @@ -0,0 +1,2 @@ +def func(): + print("library_func") diff --git a/gazelle/python/testdata/directive_python_default_visibility/test6_default_label/BUILD.in b/gazelle/python/testdata/directive_python_default_visibility/test6_default_label/BUILD.in new file mode 100644 index 0000000000..65b51e30ee --- /dev/null +++ b/gazelle/python/testdata/directive_python_default_visibility/test6_default_label/BUILD.in @@ -0,0 +1 @@ +# gazelle:python_default_visibility //foo:bar diff --git a/gazelle/python/testdata/directive_python_default_visibility/test6_default_label/BUILD.out b/gazelle/python/testdata/directive_python_default_visibility/test6_default_label/BUILD.out new file mode 100644 index 0000000000..3df11b4024 --- /dev/null +++ b/gazelle/python/testdata/directive_python_default_visibility/test6_default_label/BUILD.out @@ -0,0 +1,9 @@ +load("@rules_python//python:defs.bzl", "py_library") + +# gazelle:python_default_visibility //foo:bar + +py_library( + name = "test6_default_label", + srcs = ["test6.py"], + visibility = ["//foo:bar"], +) diff --git a/gazelle/python/testdata/directive_python_default_visibility/test6_default_label/subpkg/BUILD.in b/gazelle/python/testdata/directive_python_default_visibility/test6_default_label/subpkg/BUILD.in new file mode 100644 index 0000000000..2a54cfda68 --- /dev/null +++ b/gazelle/python/testdata/directive_python_default_visibility/test6_default_label/subpkg/BUILD.in @@ -0,0 +1,2 @@ +# Reset the default visibility to the default for all child packages. +# gazelle:python_default_visibility DEFAULT diff --git a/gazelle/python/testdata/directive_python_default_visibility/test6_default_label/subpkg/BUILD.out b/gazelle/python/testdata/directive_python_default_visibility/test6_default_label/subpkg/BUILD.out new file mode 100644 index 0000000000..61693674ea --- /dev/null +++ b/gazelle/python/testdata/directive_python_default_visibility/test6_default_label/subpkg/BUILD.out @@ -0,0 +1,10 @@ +load("@rules_python//python:defs.bzl", "py_library") + +# Reset the default visibility to the default for all child packages. +# gazelle:python_default_visibility DEFAULT + +py_library( + name = "subpkg", + srcs = ["test6_sub.py"], + visibility = ["//:__subpackages__"], +) diff --git a/gazelle/python/testdata/directive_python_default_visibility/test6_default_label/subpkg/test6_sub.py b/gazelle/python/testdata/directive_python_default_visibility/test6_default_label/subpkg/test6_sub.py new file mode 100644 index 0000000000..98907eb794 --- /dev/null +++ b/gazelle/python/testdata/directive_python_default_visibility/test6_default_label/subpkg/test6_sub.py @@ -0,0 +1,2 @@ +def func(): + print("library_func") diff --git a/gazelle/python/testdata/directive_python_default_visibility/test6_default_label/test6.py b/gazelle/python/testdata/directive_python_default_visibility/test6_default_label/test6.py new file mode 100644 index 0000000000..98907eb794 --- /dev/null +++ b/gazelle/python/testdata/directive_python_default_visibility/test6_default_label/test6.py @@ -0,0 +1,2 @@ +def func(): + print("library_func") diff --git a/gazelle/python/testdata/directive_python_default_visibility/test7_none_label_with_extra_vis/BUILD.in b/gazelle/python/testdata/directive_python_default_visibility/test7_none_label_with_extra_vis/BUILD.in new file mode 100644 index 0000000000..d64169facb --- /dev/null +++ b/gazelle/python/testdata/directive_python_default_visibility/test7_none_label_with_extra_vis/BUILD.in @@ -0,0 +1,5 @@ +# python_visibility directives that happen either before _or_ after the +# NONE reset both get applied. +# gazelle:python_visibility //foo:bar +# gazelle:python_default_visibility NONE +# gazelle:python_visibility //bar:baz diff --git a/gazelle/python/testdata/directive_python_default_visibility/test7_none_label_with_extra_vis/BUILD.out b/gazelle/python/testdata/directive_python_default_visibility/test7_none_label_with_extra_vis/BUILD.out new file mode 100644 index 0000000000..f912ac6fe5 --- /dev/null +++ b/gazelle/python/testdata/directive_python_default_visibility/test7_none_label_with_extra_vis/BUILD.out @@ -0,0 +1,16 @@ +load("@rules_python//python:defs.bzl", "py_library") + +# python_visibility directives that happen either before _or_ after the +# NONE reset both get applied. +# gazelle:python_visibility //foo:bar +# gazelle:python_default_visibility NONE +# gazelle:python_visibility //bar:baz + +py_library( + name = "test7_none_label_with_extra_vis", + srcs = ["test7.py"], + visibility = [ + "//bar:baz", + "//foo:bar", + ], +) diff --git a/gazelle/python/testdata/directive_python_default_visibility/test7_none_label_with_extra_vis/test7.py b/gazelle/python/testdata/directive_python_default_visibility/test7_none_label_with_extra_vis/test7.py new file mode 100644 index 0000000000..98907eb794 --- /dev/null +++ b/gazelle/python/testdata/directive_python_default_visibility/test7_none_label_with_extra_vis/test7.py @@ -0,0 +1,2 @@ +def func(): + print("library_func") diff --git a/gazelle/python/testdata/directive_python_default_visibility/test8_multiple_python_root_dirs/BUILD.in b/gazelle/python/testdata/directive_python_default_visibility/test8_multiple_python_root_dirs/BUILD.in new file mode 100644 index 0000000000..4e90bdcff5 --- /dev/null +++ b/gazelle/python/testdata/directive_python_default_visibility/test8_multiple_python_root_dirs/BUILD.in @@ -0,0 +1,2 @@ +# For funzies, also throw in some additional visibility. +# gazelle:python_visibility //tests:__pkg__ diff --git a/gazelle/python/testdata/directive_python_default_visibility/test8_multiple_python_root_dirs/BUILD.out b/gazelle/python/testdata/directive_python_default_visibility/test8_multiple_python_root_dirs/BUILD.out new file mode 100644 index 0000000000..4e90bdcff5 --- /dev/null +++ b/gazelle/python/testdata/directive_python_default_visibility/test8_multiple_python_root_dirs/BUILD.out @@ -0,0 +1,2 @@ +# For funzies, also throw in some additional visibility. +# gazelle:python_visibility //tests:__pkg__ diff --git a/gazelle/python/testdata/directive_python_default_visibility/test8_multiple_python_root_dirs/proj1/src/BUILD.in b/gazelle/python/testdata/directive_python_default_visibility/test8_multiple_python_root_dirs/proj1/src/BUILD.in new file mode 100644 index 0000000000..6948b47b10 --- /dev/null +++ b/gazelle/python/testdata/directive_python_default_visibility/test8_multiple_python_root_dirs/proj1/src/BUILD.in @@ -0,0 +1 @@ +# gazelle:python_root diff --git a/gazelle/python/testdata/directive_python_default_visibility/test8_multiple_python_root_dirs/proj1/src/BUILD.out b/gazelle/python/testdata/directive_python_default_visibility/test8_multiple_python_root_dirs/proj1/src/BUILD.out new file mode 100644 index 0000000000..6948b47b10 --- /dev/null +++ b/gazelle/python/testdata/directive_python_default_visibility/test8_multiple_python_root_dirs/proj1/src/BUILD.out @@ -0,0 +1 @@ +# gazelle:python_root diff --git a/gazelle/python/testdata/directive_python_default_visibility/test8_multiple_python_root_dirs/proj1/src/pkg1/BUILD.in b/gazelle/python/testdata/directive_python_default_visibility/test8_multiple_python_root_dirs/proj1/src/pkg1/BUILD.in new file mode 100644 index 0000000000..0151a68526 --- /dev/null +++ b/gazelle/python/testdata/directive_python_default_visibility/test8_multiple_python_root_dirs/proj1/src/pkg1/BUILD.in @@ -0,0 +1,2 @@ +# proj1 depends on proj2 +# We can leave the default visibility. diff --git a/gazelle/python/testdata/directive_python_default_visibility/test8_multiple_python_root_dirs/proj1/src/pkg1/BUILD.out b/gazelle/python/testdata/directive_python_default_visibility/test8_multiple_python_root_dirs/proj1/src/pkg1/BUILD.out new file mode 100644 index 0000000000..a473ba5e02 --- /dev/null +++ b/gazelle/python/testdata/directive_python_default_visibility/test8_multiple_python_root_dirs/proj1/src/pkg1/BUILD.out @@ -0,0 +1,14 @@ +load("@rules_python//python:defs.bzl", "py_library") + +# proj1 depends on proj2 +# We can leave the default visibility. + +py_library( + name = "pkg1", + srcs = ["file1.py"], + imports = [".."], + visibility = [ + "//test8_multiple_python_root_dirs/proj1/src:__subpackages__", + "//tests:__pkg__", + ], +) diff --git a/gazelle/python/testdata/directive_python_default_visibility/test8_multiple_python_root_dirs/proj1/src/pkg1/file1.py b/gazelle/python/testdata/directive_python_default_visibility/test8_multiple_python_root_dirs/proj1/src/pkg1/file1.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/gazelle/python/testdata/directive_python_default_visibility/test8_multiple_python_root_dirs/proj2/src/BUILD.in b/gazelle/python/testdata/directive_python_default_visibility/test8_multiple_python_root_dirs/proj2/src/BUILD.in new file mode 100644 index 0000000000..6948b47b10 --- /dev/null +++ b/gazelle/python/testdata/directive_python_default_visibility/test8_multiple_python_root_dirs/proj2/src/BUILD.in @@ -0,0 +1 @@ +# gazelle:python_root diff --git a/gazelle/python/testdata/directive_python_default_visibility/test8_multiple_python_root_dirs/proj2/src/BUILD.out b/gazelle/python/testdata/directive_python_default_visibility/test8_multiple_python_root_dirs/proj2/src/BUILD.out new file mode 100644 index 0000000000..6948b47b10 --- /dev/null +++ b/gazelle/python/testdata/directive_python_default_visibility/test8_multiple_python_root_dirs/proj2/src/BUILD.out @@ -0,0 +1 @@ +# gazelle:python_root diff --git a/gazelle/python/testdata/directive_python_default_visibility/test8_multiple_python_root_dirs/proj2/src/pkg2/BUILD.in b/gazelle/python/testdata/directive_python_default_visibility/test8_multiple_python_root_dirs/proj2/src/pkg2/BUILD.in new file mode 100644 index 0000000000..be5aae68f0 --- /dev/null +++ b/gazelle/python/testdata/directive_python_default_visibility/test8_multiple_python_root_dirs/proj2/src/pkg2/BUILD.in @@ -0,0 +1,3 @@ +# proj1 depends on proj2 +# So we have to make sure that proj2 is visible by proj1 +# gazelle:python_default_visibility //$python_root:__subpackages__,//test8_multiple_python_root_dirs/proj1/src:__subpackages__ diff --git a/gazelle/python/testdata/directive_python_default_visibility/test8_multiple_python_root_dirs/proj2/src/pkg2/BUILD.out b/gazelle/python/testdata/directive_python_default_visibility/test8_multiple_python_root_dirs/proj2/src/pkg2/BUILD.out new file mode 100644 index 0000000000..d6942c4e33 --- /dev/null +++ b/gazelle/python/testdata/directive_python_default_visibility/test8_multiple_python_root_dirs/proj2/src/pkg2/BUILD.out @@ -0,0 +1,16 @@ +load("@rules_python//python:defs.bzl", "py_library") + +# proj1 depends on proj2 +# So we have to make sure that proj2 is visible by proj1 +# gazelle:python_default_visibility //$python_root:__subpackages__,//test8_multiple_python_root_dirs/proj1/src:__subpackages__ + +py_library( + name = "pkg2", + srcs = ["file2.py"], + imports = [".."], + visibility = [ + "//test8_multiple_python_root_dirs/proj1/src:__subpackages__", + "//test8_multiple_python_root_dirs/proj2/src:__subpackages__", + "//tests:__pkg__", + ], +) diff --git a/gazelle/python/testdata/directive_python_default_visibility/test8_multiple_python_root_dirs/proj2/src/pkg2/file2.py b/gazelle/python/testdata/directive_python_default_visibility/test8_multiple_python_root_dirs/proj2/src/pkg2/file2.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/gazelle/python/testdata/directive_python_default_visibility/test9_default_vis_with_python_vis/BUILD.in b/gazelle/python/testdata/directive_python_default_visibility/test9_default_vis_with_python_vis/BUILD.in new file mode 100644 index 0000000000..44e23ed1c4 --- /dev/null +++ b/gazelle/python/testdata/directive_python_default_visibility/test9_default_vis_with_python_vis/BUILD.in @@ -0,0 +1 @@ +# gazelle:python_default_visibility //tests:__pkg__ diff --git a/gazelle/python/testdata/directive_python_default_visibility/test9_default_vis_with_python_vis/BUILD.out b/gazelle/python/testdata/directive_python_default_visibility/test9_default_vis_with_python_vis/BUILD.out new file mode 100644 index 0000000000..69587b1b2a --- /dev/null +++ b/gazelle/python/testdata/directive_python_default_visibility/test9_default_vis_with_python_vis/BUILD.out @@ -0,0 +1,9 @@ +load("@rules_python//python:defs.bzl", "py_library") + +# gazelle:python_default_visibility //tests:__pkg__ + +py_library( + name = "test9_default_vis_with_python_vis", + srcs = ["test9.py"], + visibility = ["//tests:__pkg__"], +) diff --git a/gazelle/python/testdata/directive_python_default_visibility/test9_default_vis_with_python_vis/subpkg1/BUILD.in b/gazelle/python/testdata/directive_python_default_visibility/test9_default_vis_with_python_vis/subpkg1/BUILD.in new file mode 100644 index 0000000000..6e484ffb55 --- /dev/null +++ b/gazelle/python/testdata/directive_python_default_visibility/test9_default_vis_with_python_vis/subpkg1/BUILD.in @@ -0,0 +1 @@ +# gazelle:python_visibility //some/new:target diff --git a/gazelle/python/testdata/directive_python_default_visibility/test9_default_vis_with_python_vis/subpkg1/BUILD.out b/gazelle/python/testdata/directive_python_default_visibility/test9_default_vis_with_python_vis/subpkg1/BUILD.out new file mode 100644 index 0000000000..6b7f7c3bcd --- /dev/null +++ b/gazelle/python/testdata/directive_python_default_visibility/test9_default_vis_with_python_vis/subpkg1/BUILD.out @@ -0,0 +1,12 @@ +load("@rules_python//python:defs.bzl", "py_library") + +# gazelle:python_visibility //some/new:target + +py_library( + name = "subpkg1", + srcs = ["foo.py"], + visibility = [ + "//some/new:target", + "//tests:__pkg__", + ], +) diff --git a/gazelle/python/testdata/directive_python_default_visibility/test9_default_vis_with_python_vis/subpkg1/foo.py b/gazelle/python/testdata/directive_python_default_visibility/test9_default_vis_with_python_vis/subpkg1/foo.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/gazelle/python/testdata/directive_python_default_visibility/test9_default_vis_with_python_vis/subpkg2/BUILD.in b/gazelle/python/testdata/directive_python_default_visibility/test9_default_vis_with_python_vis/subpkg2/BUILD.in new file mode 100644 index 0000000000..912134a5b8 --- /dev/null +++ b/gazelle/python/testdata/directive_python_default_visibility/test9_default_vis_with_python_vis/subpkg2/BUILD.in @@ -0,0 +1,3 @@ +# gazelle:python_default_visibility //a:b,//a:c +# gazelle:python_visibility //c:d +# gazelle:python_visibility //e:f diff --git a/gazelle/python/testdata/directive_python_default_visibility/test9_default_vis_with_python_vis/subpkg2/BUILD.out b/gazelle/python/testdata/directive_python_default_visibility/test9_default_vis_with_python_vis/subpkg2/BUILD.out new file mode 100644 index 0000000000..a43fc0ca86 --- /dev/null +++ b/gazelle/python/testdata/directive_python_default_visibility/test9_default_vis_with_python_vis/subpkg2/BUILD.out @@ -0,0 +1,16 @@ +load("@rules_python//python:defs.bzl", "py_library") + +# gazelle:python_default_visibility //a:b,//a:c +# gazelle:python_visibility //c:d +# gazelle:python_visibility //e:f + +py_library( + name = "subpkg2", + srcs = ["foo.py"], + visibility = [ + "//a:b", + "//a:c", + "//c:d", + "//e:f", + ], +) diff --git a/gazelle/python/testdata/directive_python_default_visibility/test9_default_vis_with_python_vis/subpkg2/foo.py b/gazelle/python/testdata/directive_python_default_visibility/test9_default_vis_with_python_vis/subpkg2/foo.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/gazelle/python/testdata/directive_python_default_visibility/test9_default_vis_with_python_vis/test9.py b/gazelle/python/testdata/directive_python_default_visibility/test9_default_vis_with_python_vis/test9.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/gazelle/pythonconfig/pythonconfig.go b/gazelle/pythonconfig/pythonconfig.go index e350a7cb60..a0bc9f689d 100644 --- a/gazelle/pythonconfig/pythonconfig.go +++ b/gazelle/pythonconfig/pythonconfig.go @@ -67,6 +67,9 @@ const ( // naming convention. See python_library_naming_convention for more info on // the package name interpolation. TestNamingConvention = "python_test_naming_convention" + // DefaultVisibilty represents the directive that controls what visibility + // labels are added to generated python targets. + DefaultVisibilty = "python_default_visibility" // Visibility represents the directive that controls what additional // visibility labels are added to generated targets. It mimics the behavior // of the `go_visibility` directive. @@ -93,6 +96,11 @@ const ( packageNameNamingConventionSubstitution = "$package_name$" ) +// The default visibility label, including a format placeholder for `python_root`. +const ( + DefaultVisibilityFmtString = "//%s:__subpackages__" +) + // defaultIgnoreFiles is the list of default values used in the // python_ignore_files option. var defaultIgnoreFiles = map[string]struct{}{ @@ -140,6 +148,7 @@ type Config struct { libraryNamingConvention string binaryNamingConvention string testNamingConvention string + defaultVisibility []string visibility []string } @@ -162,6 +171,7 @@ func New( libraryNamingConvention: packageNameNamingConventionSubstitution, binaryNamingConvention: fmt.Sprintf("%s_bin", packageNameNamingConventionSubstitution), testNamingConvention: fmt.Sprintf("%s_test", packageNameNamingConventionSubstitution), + defaultVisibility: []string{fmt.Sprintf(DefaultVisibilityFmtString, "")}, visibility: []string{}, } } @@ -189,6 +199,7 @@ func (c *Config) NewChild() *Config { libraryNamingConvention: c.libraryNamingConvention, binaryNamingConvention: c.binaryNamingConvention, testNamingConvention: c.testNamingConvention, + defaultVisibility: c.defaultVisibility, visibility: c.visibility, } } @@ -246,7 +257,6 @@ func (c *Config) FindThirdPartyDependency(modName string) (string, bool) { } sanitizedDistribution := SanitizeDistribution(distributionName) - // @// lbl := label.New(distributionRepositoryName, sanitizedDistribution, sanitizedDistribution) return lbl.String(), true @@ -403,5 +413,15 @@ func (c *Config) AppendVisibility(visibility string) { // Visibility returns the target's visibility. func (c *Config) Visibility() []string { - return c.visibility + return append(c.defaultVisibility, c.visibility...) +} + +// SetDefaultVisibility sets the default visibility of the target. +func (c *Config) SetDefaultVisibility(visibility []string) { + c.defaultVisibility = visibility +} + +// DefaultVisibilty returns the target's default visibility. +func (c *Config) DefaultVisibilty() []string { + return c.defaultVisibility } From c9c2768ac38040edc1d56f74a0db4f8538c7ef5f Mon Sep 17 00:00:00 2001 From: Ignas Anikevicius <240938+aignas@users.noreply.github.com> Date: Mon, 18 Mar 2024 16:16:26 +0900 Subject: [PATCH 19/23] internal(config_settings): make config_setting creation reusable (#1750) The PR #1743 explored the idea of creating extra config settings for each target platform that our toolchain is targetting, however that has a drawback of not being usable in `bzlmod` if someone built Python for a platform that we don't provide a toolchain for and tried to use the `pip.parse` machinery with that by providing the `python_interpreter_target`. That is a niche usecase, but `rules_python` is a core ruleset that should only provide abstractions/helpers that work in all cases or make it possible to extend things. This explores a way to decouple the definition of the available `config_settings` values and how they are constructed by adding an extra `is_python_config_setting` macro, that could be used to declare the config settings from within the `pip.parse` hub repo. This makes the work in #1744 to support whl-only hub repos more self-contained. Supersedes #1743. --------- Co-authored-by: Richard Levasseur --- python/config_settings/BUILD.bazel | 2 - python/config_settings/config_settings.bzl | 115 ++--------- python/private/BUILD.bazel | 9 + python/private/config_settings.bzl | 190 ++++++++++++++++++ .../construct_config_settings_tests.bzl | 102 +++++++++- 5 files changed, 303 insertions(+), 115 deletions(-) create mode 100644 python/private/config_settings.bzl diff --git a/python/config_settings/BUILD.bazel b/python/config_settings/BUILD.bazel index 4f12ef4791..a017f9767e 100644 --- a/python/config_settings/BUILD.bazel +++ b/python/config_settings/BUILD.bazel @@ -1,4 +1,3 @@ -load("//python:versions.bzl", "TOOL_VERSIONS") load(":config_settings.bzl", "construct_config_settings") filegroup( @@ -12,5 +11,4 @@ filegroup( construct_config_settings( name = "construct_config_settings", - python_versions = TOOL_VERSIONS.keys(), ) diff --git a/python/config_settings/config_settings.bzl b/python/config_settings/config_settings.bzl index 9e6bbd6595..f1d2ff0e06 100644 --- a/python/config_settings/config_settings.bzl +++ b/python/config_settings/config_settings.bzl @@ -15,105 +15,16 @@ """This module is used to construct the config settings in the BUILD file in this same package. """ -load("@bazel_skylib//lib:selects.bzl", "selects") -load("@bazel_skylib//rules:common_settings.bzl", "string_flag") -load("//python:versions.bzl", "MINOR_MAPPING") - -def construct_config_settings(name, python_versions): - """Constructs a set of configs for all Python versions. - - Args: - name: str, unused; only specified to satisfy buildifier lint checks - and allow programatic modification of the target. - python_versions: list of all (x.y.z) Python versions supported by rules_python. - """ - - # Maps e.g. "3.8" -> ["3.8.1", "3.8.2", etc] - minor_to_micro_versions = {} - - allowed_flag_values = [] - for micro_version in python_versions: - minor, _, _ = micro_version.rpartition(".") - minor_to_micro_versions.setdefault(minor, []).append(micro_version) - allowed_flag_values.append(micro_version) - - allowed_flag_values.extend(list(minor_to_micro_versions)) - - string_flag( - name = "python_version", - # TODO: The default here should somehow match the MODULE config. Until - # then, use the empty string to indicate an unknown version. This - # also prevents version-unaware targets from inadvertently matching - # a select condition when they shouldn't. - build_setting_default = "", - values = [""] + sorted(allowed_flag_values), - visibility = ["//visibility:public"], - ) - - for minor_version, micro_versions in minor_to_micro_versions.items(): - # This matches the raw flag value, e.g. --//python/config_settings:python_version=3.8 - # It's private because matching the concept of e.g. "3.8" value is done - # using the `is_python_X.Y` config setting group, which is aware of the - # minor versions that could match instead. - equals_minor_version_name = "_python_version_flag_equals_" + minor_version - native.config_setting( - name = equals_minor_version_name, - flag_values = {":python_version": minor_version}, - ) - matches_minor_version_names = [equals_minor_version_name] - - default_micro_version = MINOR_MAPPING[minor_version] - - for micro_version in micro_versions: - is_micro_version_name = "is_python_" + micro_version - if default_micro_version != micro_version: - native.config_setting( - name = is_micro_version_name, - flag_values = {":python_version": micro_version}, - visibility = ["//visibility:public"], - ) - matches_minor_version_names.append(is_micro_version_name) - continue - - # Ensure that is_python_3.9.8 is matched if python_version is set - # to 3.9 if MINOR_MAPPING points to 3.9.8 - equals_micro_name = "_python_version_flag_equals_" + micro_version - native.config_setting( - name = equals_micro_name, - flag_values = {":python_version": micro_version}, - ) - - # An alias pointing to an underscore-prefixed config_setting_group - # is used because config_setting_group creates - # `is_{minor}_N` targets, which are easily confused with the - # `is_{minor}.{micro}` (dot) targets. - selects.config_setting_group( - name = "_" + is_micro_version_name, - match_any = [ - equals_micro_name, - equals_minor_version_name, - ], - ) - native.alias( - name = is_micro_version_name, - actual = "_" + is_micro_version_name, - visibility = ["//visibility:public"], - ) - matches_minor_version_names.append(equals_micro_name) - - # This is prefixed with an underscore to prevent confusion due to how - # config_setting_group is implemented and how our micro-version targets - # are named. config_setting_group will generate targets like - # "is_python_3.10_1" (where the `_N` suffix is len(match_any). - # Meanwhile, the micro-version tarets are named "is_python_3.10.1" -- - # just a single dot vs underscore character difference. - selects.config_setting_group( - name = "_is_python_" + minor_version, - match_any = matches_minor_version_names, - ) - - native.alias( - name = "is_python_" + minor_version, - actual = "_is_python_" + minor_version, - visibility = ["//visibility:public"], - ) +load( + "//python/private:config_settings.bzl", + _construct_config_settings = "construct_config_settings", + _is_python_config_setting = "is_python_config_setting", +) + +# This is exposed only for cases where the pip hub repo needs to use this rule +# to define hub-repo scoped config_settings for platform specific wheel +# support. +is_python_config_setting = _is_python_config_setting + +# This is exposed for usage in rules_python only. +construct_config_settings = _construct_config_settings diff --git a/python/private/BUILD.bazel b/python/private/BUILD.bazel index 221c3b7a65..d3d6e76a35 100644 --- a/python/private/BUILD.bazel +++ b/python/private/BUILD.bazel @@ -68,6 +68,15 @@ bzl_library( srcs = ["bzlmod_enabled.bzl"], ) +bzl_library( + name = "config_settings_bzl", + srcs = ["config_settings.bzl"], + deps = [ + "//python:versions_bzl", + "@bazel_skylib//lib:selects", + ], +) + bzl_library( name = "coverage_deps_bzl", srcs = ["coverage_deps.bzl"], diff --git a/python/private/config_settings.bzl b/python/private/config_settings.bzl new file mode 100644 index 0000000000..75f88de4ac --- /dev/null +++ b/python/private/config_settings.bzl @@ -0,0 +1,190 @@ +# Copyright 2024 The Bazel Authors. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +"""This module is used to construct the config settings in the BUILD file in this same package. +""" + +load("@bazel_skylib//lib:selects.bzl", "selects") +load("@bazel_skylib//rules:common_settings.bzl", "string_flag") +load("//python:versions.bzl", "MINOR_MAPPING", "TOOL_VERSIONS") + +_PYTHON_VERSION_FLAG = str(Label("//python/config_settings:python_version")) + +def _ver_key(s): + major, _, s = s.partition(".") + minor, _, s = s.partition(".") + micro, _, s = s.partition(".") + return (int(major), int(minor), int(micro)) + +def _flag_values(python_versions): + """Construct a map of python_version to a list of toolchain values. + + This mapping maps the concept of a config setting to a list of compatible toolchain versions. + For using this in the code, the VERSION_FLAG_VALUES should be used instead. + + Args: + python_versions: list of strings; all X.Y.Z python versions + + Returns: + A `map[str, list[str]]`. Each key is a python_version flag value. Each value + is a list of the python_version flag values that should match when for the + `key`. For example: + ``` + "3.8" -> ["3.8", "3.8.1", "3.8.2", ..., "3.8.19"] # All 3.8 versions + "3.8.2" -> ["3.8.2"] # Only 3.8.2 + "3.8.19" -> ["3.8.19", "3.8"] # The latest version should also match 3.8 so + as when the `3.8` toolchain is used we just use the latest `3.8` toolchain. + this makes the `select("is_python_3.8.19")` work no matter how the user + specifies the latest python version to use. + ``` + """ + ret = {} + + for micro_version in sorted(python_versions, key = _ver_key): + minor_version, _, _ = micro_version.rpartition(".") + + # This matches the raw flag value, e.g. --//python/config_settings:python_version=3.8 + # It's private because matching the concept of e.g. "3.8" value is done + # using the `is_python_X.Y` config setting group, which is aware of the + # minor versions that could match instead. + ret.setdefault(minor_version, [minor_version]).append(micro_version) + + # Ensure that is_python_3.9.8 is matched if python_version is set + # to 3.9 if MINOR_MAPPING points to 3.9.8 + default_micro_version = MINOR_MAPPING[minor_version] + ret[micro_version] = [micro_version, minor_version] if default_micro_version == micro_version else [micro_version] + + return ret + +VERSION_FLAG_VALUES = _flag_values(TOOL_VERSIONS.keys()) + +def is_python_config_setting(name, *, python_version, reuse_conditions = None, **kwargs): + """Create a config setting for matching 'python_version' configuration flag. + + This function is mainly intended for internal use within the `whl_library` and `pip_parse` + machinery. + + The matching of the 'python_version' flag depends on the value passed in + `python_version` and here is the example for `3.8` (but the same applies + to other python versions present in @//python:versions.bzl#TOOL_VERSIONS): + * "3.8" -> ["3.8", "3.8.1", "3.8.2", ..., "3.8.19"] # All 3.8 versions + * "3.8.2" -> ["3.8.2"] # Only 3.8.2 + * "3.8.19" -> ["3.8.19", "3.8"] # The latest version should also match 3.8 so + as when the `3.8` toolchain is used we just use the latest `3.8` toolchain. + this makes the `select("is_python_3.8.19")` work no matter how the user + specifies the latest python version to use. + + Args: + name: name for the target that will be created to be used in select statements. + python_version: The python_version to be passed in the `flag_values` in the + `config_setting`. Depending on the version, the matching python version list + can be as described above. + reuse_conditions: A dict of version to version label for which we should + reuse config_setting targets instead of creating them from scratch. This + is useful when using is_python_config_setting multiple times in the + same package with the same `major.minor` python versions. + **kwargs: extra kwargs passed to the `config_setting`. + """ + if python_version not in name: + fail("The name '{}' must have the python version '{}' in it".format(name, python_version)) + + if python_version not in VERSION_FLAG_VALUES: + fail("The 'python_version' must be known to 'rules_python', choose from the values: {}".format(VERSION_FLAG_VALUES.keys())) + + python_versions = VERSION_FLAG_VALUES[python_version] + if len(python_versions) == 1: + native.config_setting( + name = name, + flag_values = { + _PYTHON_VERSION_FLAG: python_version, + }, + **kwargs + ) + return + + reuse_conditions = reuse_conditions or {} + create_config_settings = { + "_{}".format(name).replace(python_version, version): {_PYTHON_VERSION_FLAG: version} + for version in python_versions + if not reuse_conditions or version not in reuse_conditions + } + match_any = list(create_config_settings.keys()) + for version, condition in reuse_conditions.items(): + if len(VERSION_FLAG_VALUES[version]) == 1: + match_any.append(condition) + continue + + # Convert the name to an internal label that this function would create, + # so that we are hitting the config_setting and not the config_setting_group. + condition = Label(condition) + if hasattr(condition, "same_package_label"): + condition = condition.same_package_label("_" + condition.name) + else: + condition = condition.relative("_" + condition.name) + + match_any.append(condition) + + for name_, flag_values_ in create_config_settings.items(): + native.config_setting( + name = name_, + flag_values = flag_values_, + **kwargs + ) + + # An alias pointing to an underscore-prefixed config_setting_group + # is used because config_setting_group creates + # `is_{version}_N` targets, which are easily confused with the + # `is_{minor}.{micro}` (dot) targets. + selects.config_setting_group( + name = "_{}_group".format(name), + match_any = match_any, + visibility = ["//visibility:private"], + ) + native.alias( + name = name, + actual = "_{}_group".format(name), + visibility = kwargs.get("visibility", []), + ) + +def construct_config_settings(name = None): # buildifier: disable=function-docstring + """Create a 'python_version' config flag and construct all config settings used in rules_python. + + This mainly includes the targets that are used in the toolchain and pip hub + repositories that only match on the 'python_version' flag values. + + Args: + name(str): A dummy name value that is no-op for now. + """ + string_flag( + name = "python_version", + # TODO: The default here should somehow match the MODULE config. Until + # then, use the empty string to indicate an unknown version. This + # also prevents version-unaware targets from inadvertently matching + # a select condition when they shouldn't. + build_setting_default = "", + values = [""] + VERSION_FLAG_VALUES.keys(), + visibility = ["//visibility:public"], + ) + + for version, matching_versions in VERSION_FLAG_VALUES.items(): + is_python_config_setting( + name = "is_python_{}".format(version), + python_version = version, + reuse_conditions = { + v: native.package_relative_label("is_python_{}".format(v)) + for v in matching_versions + if v != version + }, + visibility = ["//visibility:public"], + ) diff --git a/tests/config_settings/construct_config_settings_tests.bzl b/tests/config_settings/construct_config_settings_tests.bzl index 61beb9cd40..b1b2e062f9 100644 --- a/tests/config_settings/construct_config_settings_tests.bzl +++ b/tests/config_settings/construct_config_settings_tests.bzl @@ -18,6 +18,7 @@ load("@rules_testing//lib:analysis_test.bzl", "analysis_test") load("@rules_testing//lib:test_suite.bzl", "test_suite") load("@rules_testing//lib:truth.bzl", "subjects") load("@rules_testing//lib:util.bzl", rt_util = "util") +load("//python/config_settings:config_settings.bzl", "is_python_config_setting") _tests = [] @@ -28,25 +29,51 @@ def _subject_impl(ctx): _subject = rule( implementation = _subject_impl, attrs = { + "match_cpu": attr.string(), "match_micro": attr.string(), "match_minor": attr.string(), + "match_os": attr.string(), + "match_os_cpu": attr.string(), "no_match": attr.string(), "no_match_micro": attr.string(), }, ) def _test_minor_version_matching(name): + minor_matches = { + # Having it here ensures that we can mix and match config settings defined in + # the repo and elsewhere + str(Label("//python/config_settings:is_python_3.11")): "matched-3.11", + "//conditions:default": "matched-default", + } + minor_cpu_matches = { + str(Label(":is_python_3.11_aarch64")): "matched-3.11-aarch64", + str(Label(":is_python_3.11_ppc")): "matched-3.11-ppc", + str(Label(":is_python_3.11_s390x")): "matched-3.11-s390x", + str(Label(":is_python_3.11_x86_64")): "matched-3.11-x86_64", + } + minor_os_matches = { + str(Label(":is_python_3.11_linux")): "matched-3.11-linux", + str(Label(":is_python_3.11_osx")): "matched-3.11-osx", + str(Label(":is_python_3.11_windows")): "matched-3.11-windows", + } + minor_os_cpu_matches = { + str(Label(":is_python_3.11_linux_aarch64")): "matched-3.11-linux-aarch64", + str(Label(":is_python_3.11_linux_ppc")): "matched-3.11-linux-ppc", + str(Label(":is_python_3.11_linux_s390x")): "matched-3.11-linux-s390x", + str(Label(":is_python_3.11_linux_x86_64")): "matched-3.11-linux-x86_64", + str(Label(":is_python_3.11_osx_aarch64")): "matched-3.11-osx-aarch64", + str(Label(":is_python_3.11_osx_x86_64")): "matched-3.11-osx-x86_64", + str(Label(":is_python_3.11_windows_x86_64")): "matched-3.11-windows-x86_64", + } + rt_util.helper_target( _subject, name = name + "_subject", - match_minor = select({ - "//python/config_settings:is_python_3.11": "matched-3.11", - "//conditions:default": "matched-default", - }), - match_micro = select({ - "//python/config_settings:is_python_3.11": "matched-3.11", - "//conditions:default": "matched-default", - }), + match_minor = select(minor_matches), + match_cpu = select(minor_matches | minor_cpu_matches), + match_os = select(minor_matches | minor_os_matches), + match_os_cpu = select(minor_matches | minor_cpu_matches | minor_os_matches | minor_os_cpu_matches), no_match = select({ "//python/config_settings:is_python_3.12": "matched-3.12", "//conditions:default": "matched-default", @@ -59,16 +86,23 @@ def _test_minor_version_matching(name): impl = _test_minor_version_matching_impl, config_settings = { str(Label("//python/config_settings:python_version")): "3.11.1", + "//command_line_option:platforms": str(Label("//tests/config_settings:linux_aarch64")), }, ) def _test_minor_version_matching_impl(env, target): target = env.expect.that_target(target) + target.attr("match_cpu", factory = subjects.str).equals( + "matched-3.11-aarch64", + ) target.attr("match_minor", factory = subjects.str).equals( "matched-3.11", ) - target.attr("match_micro", factory = subjects.str).equals( - "matched-3.11", + target.attr("match_os", factory = subjects.str).equals( + "matched-3.11-linux", + ) + target.attr("match_os_cpu", factory = subjects.str).equals( + "matched-3.11-linux-aarch64", ) target.attr("no_match", factory = subjects.str).equals( "matched-default", @@ -124,8 +158,54 @@ def _test_latest_micro_version_matching_impl(env, target): _tests.append(_test_latest_micro_version_matching) -def construct_config_settings_test_suite(name): +def construct_config_settings_test_suite(name): # buildifier: disable=function-docstring + # We have CI runners running on a great deal of the platforms from the list below, + # hence use all of them within tests. + for os in ["linux", "osx", "windows"]: + is_python_config_setting( + name = "is_python_3.11_" + os, + constraint_values = [ + "@platforms//os:" + os, + ], + python_version = "3.11", + ) + + for cpu in ["s390x", "ppc", "x86_64", "aarch64"]: + is_python_config_setting( + name = "is_python_3.11_" + cpu, + constraint_values = [ + "@platforms//cpu:" + cpu, + ], + python_version = "3.11", + ) + + for (os, cpu) in [ + ("linux", "aarch64"), + ("linux", "ppc"), + ("linux", "s390x"), + ("linux", "x86_64"), + ("osx", "aarch64"), + ("osx", "x86_64"), + ("windows", "x86_64"), + ]: + is_python_config_setting( + name = "is_python_3.11_{}_{}".format(os, cpu), + constraint_values = [ + "@platforms//cpu:" + cpu, + "@platforms//os:" + os, + ], + python_version = "3.11", + ) + test_suite( name = name, tests = _tests, ) + + native.platform( + name = "linux_aarch64", + constraint_values = [ + "@platforms//os:linux", + "@platforms//cpu:aarch64", + ], + ) From c11045d3e9e77063f0bafc3420eb11a5135aa42f Mon Sep 17 00:00:00 2001 From: Ignas Anikevicius <240938+aignas@users.noreply.github.com> Date: Mon, 18 Mar 2024 22:27:56 +0900 Subject: [PATCH 20/23] fix(whl_library): correctly parse wheel target platforms (#1811) The #1693 PR incorrectly assumed that the platform tag will be os-arch specific if and only if the abi tag is of form cpxy. However, there are many wheels that are not like this (e.g. watchdog, tornado, libclang). This fixes the starlark code that is overriding the user platforms with something that only the wheel supports by also taking into account the ABI. Fixes #1810. --- CHANGELOG.md | 4 ++ python/pip_install/pip_repository.bzl | 7 ++- python/private/whl_target_platforms.bzl | 27 +++++++++--- .../whl_target_platforms_tests.bzl | 43 +++++++++++++++---- 4 files changed, 64 insertions(+), 17 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 142df6a208..9b7ab25545 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -23,6 +23,10 @@ A brief description of the categories of changes: ### Fixed +* (whl_library): Fix the experimental_target_platforms overriding for platform + specific wheels when the wheels are for any python interpreter version. Fixes + [#1810](https://github.com/bazelbuild/rules_python/issues/1810). + ### Added * New Python versions available: `3.11.8`, `3.12.2` using diff --git a/python/pip_install/pip_repository.bzl b/python/pip_install/pip_repository.bzl index ded7112144..3d5f3c1eb8 100644 --- a/python/pip_install/pip_repository.bzl +++ b/python/pip_install/pip_repository.bzl @@ -801,8 +801,11 @@ def _whl_library_impl(rctx): # NOTE @aignas 2023-12-04: if the wheel is a platform specific # wheel, we only include deps for that target platform target_platforms = [ - "{}_{}_{}".format(parsed_whl.abi_tag, p.os, p.cpu) - for p in whl_target_platforms(parsed_whl.platform_tag) + p.target_platform + for p in whl_target_platforms( + platform_tag = parsed_whl.platform_tag, + abi_tag = parsed_whl.abi_tag, + ) ] repo_utils.execute_checked( diff --git a/python/private/whl_target_platforms.bzl b/python/private/whl_target_platforms.bzl index 2c63efe26f..30e4dd4c7a 100644 --- a/python/private/whl_target_platforms.bzl +++ b/python/private/whl_target_platforms.bzl @@ -40,28 +40,41 @@ _OS_PREFIXES = { "win": "windows", } # buildifier: disable=unsorted-dict-items -def whl_target_platforms(tag): - """Parse the wheel platform tag and return (os, cpu) tuples. +def whl_target_platforms(platform_tag, abi_tag = ""): + """Parse the wheel abi and platform tags and return (os, cpu) tuples. Args: - tag (str): The platform_tag part of the wheel name. See + platform_tag (str): The platform_tag part of the wheel name. See ./parse_whl_name.bzl for more details. + abi_tag (str): The abi tag that should be used for parsing. Returns: A list of structs, with attributes: * os: str, one of the _OS_PREFIXES values * cpu: str, one of the _CPU_PREFIXES values + * abi: str, the ABI that the interpreter should have if it is passed. + * target_platform: str, the target_platform that can be given to the + wheel_installer for parsing whl METADATA. """ - cpus = _cpu_from_tag(tag) + cpus = _cpu_from_tag(platform_tag) + + abi = None + if abi_tag not in ["", "none", "abi3"]: + abi = abi_tag for prefix, os in _OS_PREFIXES.items(): - if tag.startswith(prefix): + if platform_tag.startswith(prefix): return [ - struct(os = os, cpu = cpu) + struct( + os = os, + cpu = cpu, + abi = abi, + target_platform = "_".join([abi, os, cpu] if abi else [os, cpu]), + ) for cpu in cpus ] - fail("unknown tag os: {}".format(tag)) + fail("unknown platform_tag os: {}".format(platform_tag)) def _cpu_from_tag(tag): candidate = [ diff --git a/tests/private/whl_target_platforms/whl_target_platforms_tests.bzl b/tests/private/whl_target_platforms/whl_target_platforms_tests.bzl index 9ccff0e485..f52437fd3c 100644 --- a/tests/private/whl_target_platforms/whl_target_platforms_tests.bzl +++ b/tests/private/whl_target_platforms/whl_target_platforms_tests.bzl @@ -22,29 +22,56 @@ _tests = [] def _test_simple(env): tests = { "macosx_10_9_arm64": [ - struct(os = "osx", cpu = "aarch64"), + struct(os = "osx", cpu = "aarch64", abi = None, target_platform = "osx_aarch64"), ], "macosx_10_9_universal2": [ - struct(os = "osx", cpu = "x86_64"), - struct(os = "osx", cpu = "aarch64"), + struct(os = "osx", cpu = "x86_64", abi = None, target_platform = "osx_x86_64"), + struct(os = "osx", cpu = "aarch64", abi = None, target_platform = "osx_aarch64"), ], "manylinux1_i686.manylinux_2_17_i686": [ - struct(os = "linux", cpu = "x86_32"), + struct(os = "linux", cpu = "x86_32", abi = None, target_platform = "linux_x86_32"), ], "musllinux_1_1_ppc64le": [ - struct(os = "linux", cpu = "ppc"), + struct(os = "linux", cpu = "ppc", abi = None, target_platform = "linux_ppc"), ], "win_amd64": [ - struct(os = "windows", cpu = "x86_64"), + struct(os = "windows", cpu = "x86_64", abi = None, target_platform = "windows_x86_64"), ], } for give, want in tests.items(): - got = whl_target_platforms(give) - env.expect.that_collection(got).contains_exactly(want) + for abi in ["", "abi3", "none"]: + got = whl_target_platforms(give, abi) + env.expect.that_collection(got).contains_exactly(want) _tests.append(_test_simple) +def _test_with_abi(env): + tests = { + "macosx_10_9_arm64": [ + struct(os = "osx", cpu = "aarch64", abi = "cp39", target_platform = "cp39_osx_aarch64"), + ], + "macosx_10_9_universal2": [ + struct(os = "osx", cpu = "x86_64", abi = "cp310", target_platform = "cp310_osx_x86_64"), + struct(os = "osx", cpu = "aarch64", abi = "cp310", target_platform = "cp310_osx_aarch64"), + ], + "manylinux1_i686.manylinux_2_17_i686": [ + struct(os = "linux", cpu = "x86_32", abi = "cp38", target_platform = "cp38_linux_x86_32"), + ], + "musllinux_1_1_ppc64le": [ + struct(os = "linux", cpu = "ppc", abi = "cp311", target_platform = "cp311_linux_ppc"), + ], + "win_amd64": [ + struct(os = "windows", cpu = "x86_64", abi = "cp311", target_platform = "cp311_windows_x86_64"), + ], + } + + for give, want in tests.items(): + got = whl_target_platforms(give, want[0].abi) + env.expect.that_collection(got).contains_exactly(want) + +_tests.append(_test_with_abi) + def whl_target_platforms_test_suite(name): """Create the test suite. From b5d32cd6374f04716f74dbd20824af0c10e0ac3c Mon Sep 17 00:00:00 2001 From: Ivo List Date: Mon, 18 Mar 2024 16:43:29 +0100 Subject: [PATCH 21/23] cleanup: Remove uses of legacy struct providers (#1812) The code still supported legacy struct providers, although none were generated or used. --- python/private/common/py_executable.bzl | 14 ++++---------- python/private/common/py_executable_bazel.bzl | 8 ++------ python/private/common/py_test_rule_bazel.bzl | 2 +- 3 files changed, 7 insertions(+), 17 deletions(-) diff --git a/python/private/common/py_executable.bzl b/python/private/common/py_executable.bzl index bc0d0f2f1e..df739273e4 100644 --- a/python/private/common/py_executable.bzl +++ b/python/private/common/py_executable.bzl @@ -183,7 +183,7 @@ def py_executable_base_impl(ctx, *, semantics, is_test, inherited_environment = data_runfiles = runfiles_details.data_runfiles.merge(extra_exec_runfiles), ) - legacy_providers, modern_providers = _create_providers( + return _create_providers( ctx = ctx, executable = executable, runfiles_details = runfiles_details, @@ -197,10 +197,6 @@ def py_executable_base_impl(ctx, *, semantics, is_test, inherited_environment = semantics = semantics, output_groups = exec_result.output_groups, ) - return struct( - legacy_providers = legacy_providers, - providers = modern_providers, - ) def _get_build_info(ctx, cc_toolchain): build_info_files = py_internal.cc_toolchain_build_info_files(cc_toolchain) @@ -749,9 +745,7 @@ def _create_providers( semantics: BinarySemantics struct; see create_binary_semantics() Returns: - A two-tuple of: - 1. A dict of legacy providers. - 2. A list of modern providers. + A list of modern providers. """ providers = [ DefaultInfo( @@ -821,13 +815,13 @@ def _create_providers( providers.append(builtin_py_info) providers.append(create_output_group_info(py_info.transitive_sources, output_groups)) - extra_legacy_providers, extra_providers = semantics.get_extra_providers( + extra_providers = semantics.get_extra_providers( ctx, main_py = main_py, runtime_details = runtime_details, ) providers.extend(extra_providers) - return extra_legacy_providers, providers + return providers def _create_run_environment_info(ctx, inherited_environment): expanded_env = {} diff --git a/python/private/common/py_executable_bazel.bzl b/python/private/common/py_executable_bazel.bzl index 6e905d42ba..ff4e3c1fb0 100644 --- a/python/private/common/py_executable_bazel.bzl +++ b/python/private/common/py_executable_bazel.bzl @@ -99,16 +99,12 @@ def create_executable_rule(*, attrs, **kwargs): def py_executable_bazel_impl(ctx, *, is_test, inherited_environment): """Common code for executables for Bazel.""" - result = py_executable_base_impl( + return py_executable_base_impl( ctx = ctx, semantics = create_binary_semantics_bazel(), is_test = is_test, inherited_environment = inherited_environment, ) - return struct( - providers = result.providers, - **result.legacy_providers - ) def create_binary_semantics_bazel(): return create_binary_semantics_struct( @@ -143,7 +139,7 @@ def _get_debugger_deps(ctx, runtime_details): def _get_extra_providers(ctx, main_py, runtime_details): _ = ctx, main_py, runtime_details # @unused - return {}, [] + return [] def _get_stamp_flag(ctx): # NOTE: Undocumented API; private to builtins diff --git a/python/private/common/py_test_rule_bazel.bzl b/python/private/common/py_test_rule_bazel.bzl index 3479d03318..369360d90f 100644 --- a/python/private/common/py_test_rule_bazel.bzl +++ b/python/private/common/py_test_rule_bazel.bzl @@ -45,7 +45,7 @@ def _py_test_impl(ctx): is_test = True, inherited_environment = ctx.attr.env_inherit, ) - maybe_add_test_execution_info(providers.providers, ctx) + maybe_add_test_execution_info(providers, ctx) return providers py_test = create_executable_rule( From e86252ffd6d1a1bf32ae99933acc5ab49b78ec1e Mon Sep 17 00:00:00 2001 From: Jan Schlosser Date: Mon, 18 Mar 2024 16:46:55 +0100 Subject: [PATCH 22/23] feat: Make Sphinx integration experimental publicly visible (#1813) With this commit the visibility settings are adjusted to use the Sphinx Integration from rules_python also in other (dependent) projects. Since the Sphinx integration is not yet stable, we denote in the documentation that this is done under the experimental API support. Meaning, breaking changes can occure at any point in time. See the discussion in #1796 --- sphinxdocs/private/BUILD.bazel | 8 ++++---- sphinxdocs/sphinx.bzl | 2 ++ 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/sphinxdocs/private/BUILD.bazel b/sphinxdocs/private/BUILD.bazel index 01758b3cad..ec6a945ac5 100644 --- a/sphinxdocs/private/BUILD.bazel +++ b/sphinxdocs/private/BUILD.bazel @@ -34,7 +34,7 @@ exports_files( "sphinx_build.py", "sphinx_server.py", ], - visibility = ["//:__subpackages__"], + visibility = ["//visibility:public"], ) bzl_library( @@ -70,14 +70,14 @@ py_binary( name = "inventory_builder", srcs = ["inventory_builder.py"], # Only public because it's an implicit attribute - visibility = ["//:__subpackages__"], + visibility = ["//visibility:public"], ) py_binary( name = "proto_to_markdown", srcs = ["proto_to_markdown.py"], # Only public because it's an implicit attribute - visibility = ["//:__subpackages__"], + visibility = ["//visibility:public"], deps = [":proto_to_markdown_lib"], ) @@ -85,7 +85,7 @@ py_library( name = "proto_to_markdown_lib", srcs = ["proto_to_markdown.py"], # Only public because it's an implicit attribute - visibility = ["//:__subpackages__"], + visibility = ["//visibility:public"], deps = [ ":stardoc_output_proto_py_pb2", ], diff --git a/sphinxdocs/sphinx.bzl b/sphinxdocs/sphinx.bzl index a0b1a05804..d9385bda3f 100644 --- a/sphinxdocs/sphinx.bzl +++ b/sphinxdocs/sphinx.bzl @@ -23,6 +23,8 @@ The general usage of the Sphinx rules requires two pieces: Defining your own `sphinx-build` binary is necessary because Sphinx uses a plugin model to support extensibility. + +The Sphinx integration is still experimental. """ load( From 4fb96fe0c482ba3f31490e5650db6e93b0b390fc Mon Sep 17 00:00:00 2001 From: Harneet Singh Date: Fri, 8 Nov 2024 22:45:56 -0500 Subject: [PATCH 23/23] Bump dependencies for pip upgrade to 23.3.2 --- python/pip_install/repositories.bzl | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/python/pip_install/repositories.bzl b/python/pip_install/repositories.bzl index b8679e5ef0..d8c5ffc4e9 100644 --- a/python/pip_install/repositories.bzl +++ b/python/pip_install/repositories.bzl @@ -21,8 +21,8 @@ _RULE_DEPS = [ # START: maintained by 'bazel run //tools/private/update_deps:update_pip_deps' ( "pypi__build", - "https://files.pythonhosted.org/packages/58/91/17b00d5fac63d3dca605f1b8269ba3c65e98059e1fd99d00283e42a454f0/build-0.10.0-py3-none-any.whl", - "af266720050a66c893a6096a2f410989eeac74ff9a68ba194b3f6473e8e26171", + "https://files.pythonhosted.org/packages/93/dd/b464b728b866aaa62785a609e0dd8c72201d62c5f7c53e7c20f4dceb085f/build-1.0.3-py3-none-any.whl", + "589bf99a67df7c9cf07ec0ac0e5e2ea5d4b37ac63301c4986d1acb126aa83f8f", ), ( "pypi__click", @@ -61,13 +61,14 @@ _RULE_DEPS = [ ), ( "pypi__pip", - "https://files.pythonhosted.org/packages/50/c2/e06851e8cc28dcad7c155f4753da8833ac06a5c704c109313b8d5a62968a/pip-23.2.1-py3-none-any.whl", - "7ccf472345f20d35bdc9d1841ff5f313260c2c33fe417f48c30ac46cccabf5be", + # Use a vendored pip which will retry HTTP 502s + "https://codeartifact-proxy.abnormal.dev/pip/23.3.2.post1+abnormal.c4b5c8f260f/pip-23.3.2.post1+abnormal.c4b5c8f260f-py3-none-any.whl", + "11332fe289235c7dcb50f1e86078087f26bd2e356a12db2f41b1ff43c7a22dae", ), ( "pypi__pip_tools", - "https://files.pythonhosted.org/packages/e8/df/47e6267c6b5cdae867adbdd84b437393e6202ce4322de0a5e0b92960e1d6/pip_tools-7.3.0-py3-none-any.whl", - "8717693288720a8c6ebd07149c93ab0be1fced0b5191df9e9decd3263e20d85e", + "https://files.pythonhosted.org/packages/0d/dc/38f4ce065e92c66f058ea7a368a9c5de4e702272b479c0992059f7693941/pip_tools-7.4.1-py3-none-any.whl", + "4c690e5fbae2f21e87843e89c26191f0d9454f362d8acdbd695716493ec8b3a9", ), ( "pypi__pyproject_hooks",