WARNING: THIS SITE IS A MIRROR OF GITHUB.COM / IT CANNOT LOGIN OR REGISTER ACCOUNTS / THE CONTENTS ARE PROVIDED AS-IS / THIS SITE ASSUMES NO RESPONSIBILITY FOR ANY DISPLAYED CONTENT OR LINKS / IF YOU FOUND SOMETHING MAY NOT GOOD FOR EVERYONE, CONTACT ADMIN AT ilovescratch@foxmail.com
Skip to content

Conversation

@Yannic
Copy link
Collaborator

@Yannic Yannic commented Apr 30, 2025

This will make it easier for users (esp. bzlmod extensions integrating with package managers) to generate package_metadata targets.

This will make it easier for users (esp. bzlmod extensions integrating with package managers) to generate `package_metadata` targets.
"//private/purl/...",
])

_tables = json.decode("{\"percent_encoding\": {\"encode\": {\"0\": \"%00\", \"1\": \"%01\", \"2\": \"%02\", \"3\": \"%03\", \"4\": \"%04\", \"5\": \"%05\", \"6\": \"%06\", \"7\": \"%07\", \"8\": \"%08\", \"9\": \"%09\", \"10\": \"%0A\", \"11\": \"%0B\", \"12\": \"%0C\", \"13\": \"%0D\", \"14\": \"%0E\", \"15\": \"%0F\", \"16\": \"%10\", \"17\": \"%11\", \"18\": \"%12\", \"19\": \"%13\", \"20\": \"%14\", \"21\": \"%15\", \"22\": \"%16\", \"23\": \"%17\", \"24\": \"%18\", \"25\": \"%19\", \"26\": \"%1A\", \"27\": \"%1B\", \"28\": \"%1C\", \"29\": \"%1D\", \"30\": \"%1E\", \"31\": \"%1F\", \"32\": \"%20\", \"33\": \"%21\", \"34\": \"%22\", \"35\": \"%23\", \"36\": \"%24\", \"37\": \"%25\", \"38\": \"%26\", \"39\": \"%27\", \"40\": \"%28\", \"41\": \"%29\", \"42\": \"%2A\", \"43\": \"%2B\", \"44\": \"%2C\", \"45\": \"-\", \"46\": \".\", \"47\": \"/\", \"48\": \"0\", \"49\": \"1\", \"50\": \"2\", \"51\": \"3\", \"52\": \"4\", \"53\": \"5\", \"54\": \"6\", \"55\": \"7\", \"56\": \"8\", \"57\": \"9\", \"58\": \":\", \"59\": \"%3B\", \"60\": \"%3C\", \"61\": \"%3D\", \"62\": \"%3E\", \"63\": \"%3F\", \"64\": \"%40\", \"65\": \"A\", \"66\": \"B\", \"67\": \"C\", \"68\": \"D\", \"69\": \"E\", \"70\": \"F\", \"71\": \"G\", \"72\": \"H\", \"73\": \"I\", \"74\": \"J\", \"75\": \"K\", \"76\": \"L\", \"77\": \"M\", \"78\": \"N\", \"79\": \"O\", \"80\": \"P\", \"81\": \"Q\", \"82\": \"R\", \"83\": \"S\", \"84\": \"T\", \"85\": \"U\", \"86\": \"V\", \"87\": \"W\", \"88\": \"X\", \"89\": \"Y\", \"90\": \"Z\", \"91\": \"%5B\", \"92\": \"%5C\", \"93\": \"%5D\", \"94\": \"%5E\", \"95\": \"_\", \"96\": \"%60\", \"97\": \"a\", \"98\": \"b\", \"99\": \"c\", \"100\": \"d\", \"101\": \"e\", \"102\": \"f\", \"103\": \"g\", \"104\": \"h\", \"105\": \"i\", \"106\": \"j\", \"107\": \"k\", \"108\": \"l\", \"109\": \"m\", \"110\": \"n\", \"111\": \"o\", \"112\": \"p\", \"113\": \"q\", \"114\": \"r\", \"115\": \"s\", \"116\": \"t\", \"117\": \"u\", \"118\": \"v\", \"119\": \"w\", \"120\": \"x\", \"121\": \"y\", \"122\": \"z\", \"123\": \"%7B\", \"124\": \"%7C\", \"125\": \"%7D\", \"126\": \"~\", \"127\": \"%7F\", \"128\": \"%80\", \"129\": \"%81\", \"130\": \"%82\", \"131\": \"%83\", \"132\": \"%84\", \"133\": \"%85\", \"134\": \"%86\", \"135\": \"%87\", \"136\": \"%88\", \"137\": \"%89\", \"138\": \"%8A\", \"139\": \"%8B\", \"140\": \"%8C\", \"141\": \"%8D\", \"142\": \"%8E\", \"143\": \"%8F\", \"144\": \"%90\", \"145\": \"%91\", \"146\": \"%92\", \"147\": \"%93\", \"148\": \"%94\", \"149\": \"%95\", \"150\": \"%96\", \"151\": \"%97\", \"152\": \"%98\", \"153\": \"%99\", \"154\": \"%9A\", \"155\": \"%9B\", \"156\": \"%9C\", \"157\": \"%9D\", \"158\": \"%9E\", \"159\": \"%9F\", \"160\": \"%A0\", \"161\": \"%A1\", \"162\": \"%A2\", \"163\": \"%A3\", \"164\": \"%A4\", \"165\": \"%A5\", \"166\": \"%A6\", \"167\": \"%A7\", \"168\": \"%A8\", \"169\": \"%A9\", \"170\": \"%AA\", \"171\": \"%AB\", \"172\": \"%AC\", \"173\": \"%AD\", \"174\": \"%AE\", \"175\": \"%AF\", \"176\": \"%B0\", \"177\": \"%B1\", \"178\": \"%B2\", \"179\": \"%B3\", \"180\": \"%B4\", \"181\": \"%B5\", \"182\": \"%B6\", \"183\": \"%B7\", \"184\": \"%B8\", \"185\": \"%B9\", \"186\": \"%BA\", \"187\": \"%BB\", \"188\": \"%BC\", \"189\": \"%BD\", \"190\": \"%BE\", \"191\": \"%BF\", \"192\": \"%C0\", \"193\": \"%C1\", \"194\": \"%C2\", \"195\": \"%C3\", \"196\": \"%C4\", \"197\": \"%C5\", \"198\": \"%C6\", \"199\": \"%C7\", \"200\": \"%C8\", \"201\": \"%C9\", \"202\": \"%CA\", \"203\": \"%CB\", \"204\": \"%CC\", \"205\": \"%CD\", \"206\": \"%CE\", \"207\": \"%CF\", \"208\": \"%D0\", \"209\": \"%D1\", \"210\": \"%D2\", \"211\": \"%D3\", \"212\": \"%D4\", \"213\": \"%D5\", \"214\": \"%D6\", \"215\": \"%D7\", \"216\": \"%D8\", \"217\": \"%D9\", \"218\": \"%DA\", \"219\": \"%DB\", \"220\": \"%DC\", \"221\": \"%DD\", \"222\": \"%DE\", \"223\": \"%DF\", \"224\": \"%E0\", \"225\": \"%E1\", \"226\": \"%E2\", \"227\": \"%E3\", \"228\": \"%E4\", \"229\": \"%E5\", \"230\": \"%E6\", \"231\": \"%E7\", \"232\": \"%E8\", \"233\": \"%E9\", \"234\": \"%EA\", \"235\": \"%EB\", \"236\": \"%EC\", \"237\": \"%ED\", \"238\": \"%EE\", \"239\": \"%EF\", \"240\": \"%F0\", \"241\": \"%F1\", \"242\": \"%F2\", \"243\": \"%F3\", \"244\": \"%F4\", \"245\": \"%F5\", \"246\": \"%F6\", \"247\": \"%F7\", \"248\": \"%F8\", \"249\": \"%F9\", \"250\": \"%FA\", \"251\": \"%FB\", \"252\": \"%FC\", \"253\": \"%FD\", \"254\": \"%FE\", \"255\": \"%FF\"}, \"tests\": {\"foo\": \"foo\", \"Hello, World!\": \"Hello%2C%20World%21\", \"path: /foo\": \"path:%20/foo\", \"M\\u00fcnchen\": \"M%C3%BCnchen\", \"K\\u00f6ln\": \"K%C3%B6ln\", \"Sm\\u00e5land\": \"Sm%C3%A5land\", \"fran\\u00e7aise\": \"fran%C3%A7aise\", \"\\u00a1Hola Mundo!\": \"%C2%A1Hola%20Mundo%21\", \"\\u0645\\u0631\\u062d\\u0628\\u0627 \\u0628\\u0627\\u0644\\u0639\\u0627\\u0644\\u0645!\": \"%D9%85%D8%B1%D8%AD%D8%A8%D8%A7%20%D8%A8%D8%A7%D9%84%D8%B9%D8%A7%D9%84%D9%85%21\", \"\\u4f60\\u597d\\u4e16\\u754c\\uff01\": \"%E4%BD%A0%E5%A5%BD%E4%B8%96%E7%95%8C%EF%BC%81\", \"\\u3053\\u3093\\u306b\\u3061\\u306f\\u4e16\\u754c\\uff01\": \"%E3%81%93%E3%82%93%E3%81%AB%E3%81%A1%E3%81%AF%E4%B8%96%E7%95%8C%EF%BC%81\", \"\\ud83d\\ude4e\": \"%F0%9F%99%8E\", \"\\ud83d\\ude4a\": \"%F0%9F%99%8A\", \"\\ud83d\\ude4e\\ud83c\\udffe\\u200d\\u2640\\ufe0f\": \"%F0%9F%99%8E%F0%9F%8F%BE%E2%80%8D%E2%99%80%EF%B8%8F\"}}}")

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since we are generating this, why is it JSON blob rather than just a map?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bazel does not understand \uxxxx escapes in strings

The encoded string.
"""

return "".join([_encode_byte(b) for b in _to_bytes(string)])

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could this be
return "".join([_encode_byte(hash(c)) for c in string.elems()])

and we woudl not have _to_bytes. It would save an allocation of the byte array.

Yannic and others added 5 commits July 3, 2025 17:03
Instead of having to write `purl = "pkg:bazel/{}@{}".format(module_name(), module_version()) if module_version() else "pkg:bazel/{}".format(module_name())` everywhere to construct a `purl`, users can now write `purl = purl.bazel(module_name(), module_version())` and it'll automatically do the right thing.
@Yannic Yannic changed the base branch from main to yannic-purl-bazel July 5, 2025 18:46
@Yannic Yannic changed the base branch from yannic-purl-bazel to main July 6, 2025 09:21
@Yannic Yannic marked this pull request as draft July 6, 2025 09:21
@Yannic Yannic changed the base branch from main to yannic-purl-bazel July 13, 2025 10:27
"//purl/...",
])

tables = json.decode("{\"percent_encoding\": {\"encode\": {\"0\": \"%00\", \"1\": \"%01\", \"2\": \"%02\", \"3\": \"%03\", \"4\": \"%04\", \"5\": \"%05\", \"6\": \"%06\", \"7\": \"%07\", \"8\": \"%08\", \"9\": \"%09\", \"10\": \"%0A\", \"11\": \"%0B\", \"12\": \"%0C\", \"13\": \"%0D\", \"14\": \"%0E\", \"15\": \"%0F\", \"16\": \"%10\", \"17\": \"%11\", \"18\": \"%12\", \"19\": \"%13\", \"20\": \"%14\", \"21\": \"%15\", \"22\": \"%16\", \"23\": \"%17\", \"24\": \"%18\", \"25\": \"%19\", \"26\": \"%1A\", \"27\": \"%1B\", \"28\": \"%1C\", \"29\": \"%1D\", \"30\": \"%1E\", \"31\": \"%1F\", \"32\": \"%20\", \"33\": \"%21\", \"34\": \"%22\", \"35\": \"%23\", \"36\": \"%24\", \"37\": \"%25\", \"38\": \"%26\", \"39\": \"%27\", \"40\": \"%28\", \"41\": \"%29\", \"42\": \"%2A\", \"43\": \"%2B\", \"44\": \"%2C\", \"45\": \"-\", \"46\": \".\", \"47\": \"/\", \"48\": \"0\", \"49\": \"1\", \"50\": \"2\", \"51\": \"3\", \"52\": \"4\", \"53\": \"5\", \"54\": \"6\", \"55\": \"7\", \"56\": \"8\", \"57\": \"9\", \"58\": \":\", \"59\": \"%3B\", \"60\": \"%3C\", \"61\": \"%3D\", \"62\": \"%3E\", \"63\": \"%3F\", \"64\": \"%40\", \"65\": \"A\", \"66\": \"B\", \"67\": \"C\", \"68\": \"D\", \"69\": \"E\", \"70\": \"F\", \"71\": \"G\", \"72\": \"H\", \"73\": \"I\", \"74\": \"J\", \"75\": \"K\", \"76\": \"L\", \"77\": \"M\", \"78\": \"N\", \"79\": \"O\", \"80\": \"P\", \"81\": \"Q\", \"82\": \"R\", \"83\": \"S\", \"84\": \"T\", \"85\": \"U\", \"86\": \"V\", \"87\": \"W\", \"88\": \"X\", \"89\": \"Y\", \"90\": \"Z\", \"91\": \"%5B\", \"92\": \"%5C\", \"93\": \"%5D\", \"94\": \"%5E\", \"95\": \"_\", \"96\": \"%60\", \"97\": \"a\", \"98\": \"b\", \"99\": \"c\", \"100\": \"d\", \"101\": \"e\", \"102\": \"f\", \"103\": \"g\", \"104\": \"h\", \"105\": \"i\", \"106\": \"j\", \"107\": \"k\", \"108\": \"l\", \"109\": \"m\", \"110\": \"n\", \"111\": \"o\", \"112\": \"p\", \"113\": \"q\", \"114\": \"r\", \"115\": \"s\", \"116\": \"t\", \"117\": \"u\", \"118\": \"v\", \"119\": \"w\", \"120\": \"x\", \"121\": \"y\", \"122\": \"z\", \"123\": \"%7B\", \"124\": \"%7C\", \"125\": \"%7D\", \"126\": \"~\", \"127\": \"%7F\", \"128\": \"%80\", \"129\": \"%81\", \"130\": \"%82\", \"131\": \"%83\", \"132\": \"%84\", \"133\": \"%85\", \"134\": \"%86\", \"135\": \"%87\", \"136\": \"%88\", \"137\": \"%89\", \"138\": \"%8A\", \"139\": \"%8B\", \"140\": \"%8C\", \"141\": \"%8D\", \"142\": \"%8E\", \"143\": \"%8F\", \"144\": \"%90\", \"145\": \"%91\", \"146\": \"%92\", \"147\": \"%93\", \"148\": \"%94\", \"149\": \"%95\", \"150\": \"%96\", \"151\": \"%97\", \"152\": \"%98\", \"153\": \"%99\", \"154\": \"%9A\", \"155\": \"%9B\", \"156\": \"%9C\", \"157\": \"%9D\", \"158\": \"%9E\", \"159\": \"%9F\", \"160\": \"%A0\", \"161\": \"%A1\", \"162\": \"%A2\", \"163\": \"%A3\", \"164\": \"%A4\", \"165\": \"%A5\", \"166\": \"%A6\", \"167\": \"%A7\", \"168\": \"%A8\", \"169\": \"%A9\", \"170\": \"%AA\", \"171\": \"%AB\", \"172\": \"%AC\", \"173\": \"%AD\", \"174\": \"%AE\", \"175\": \"%AF\", \"176\": \"%B0\", \"177\": \"%B1\", \"178\": \"%B2\", \"179\": \"%B3\", \"180\": \"%B4\", \"181\": \"%B5\", \"182\": \"%B6\", \"183\": \"%B7\", \"184\": \"%B8\", \"185\": \"%B9\", \"186\": \"%BA\", \"187\": \"%BB\", \"188\": \"%BC\", \"189\": \"%BD\", \"190\": \"%BE\", \"191\": \"%BF\", \"192\": \"%C0\", \"193\": \"%C1\", \"194\": \"%C2\", \"195\": \"%C3\", \"196\": \"%C4\", \"197\": \"%C5\", \"198\": \"%C6\", \"199\": \"%C7\", \"200\": \"%C8\", \"201\": \"%C9\", \"202\": \"%CA\", \"203\": \"%CB\", \"204\": \"%CC\", \"205\": \"%CD\", \"206\": \"%CE\", \"207\": \"%CF\", \"208\": \"%D0\", \"209\": \"%D1\", \"210\": \"%D2\", \"211\": \"%D3\", \"212\": \"%D4\", \"213\": \"%D5\", \"214\": \"%D6\", \"215\": \"%D7\", \"216\": \"%D8\", \"217\": \"%D9\", \"218\": \"%DA\", \"219\": \"%DB\", \"220\": \"%DC\", \"221\": \"%DD\", \"222\": \"%DE\", \"223\": \"%DF\", \"224\": \"%E0\", \"225\": \"%E1\", \"226\": \"%E2\", \"227\": \"%E3\", \"228\": \"%E4\", \"229\": \"%E5\", \"230\": \"%E6\", \"231\": \"%E7\", \"232\": \"%E8\", \"233\": \"%E9\", \"234\": \"%EA\", \"235\": \"%EB\", \"236\": \"%EC\", \"237\": \"%ED\", \"238\": \"%EE\", \"239\": \"%EF\", \"240\": \"%F0\", \"241\": \"%F1\", \"242\": \"%F2\", \"243\": \"%F3\", \"244\": \"%F4\", \"245\": \"%F5\", \"246\": \"%F6\", \"247\": \"%F7\", \"248\": \"%F8\", \"249\": \"%F9\", \"250\": \"%FA\", \"251\": \"%FB\", \"252\": \"%FC\", \"253\": \"%FD\", \"254\": \"%FE\", \"255\": \"%FF\"}, \"tests\": {\"foo\": \"foo\", \"Hello, World!\": \"Hello%2C%20World%21\", \"path: /foo\": \"path:%20/foo\", \"M\\u00fcnchen\": \"M%C3%BCnchen\", \"K\\u00f6ln\": \"K%C3%B6ln\", \"Sm\\u00e5land\": \"Sm%C3%A5land\", \"fran\\u00e7aise\": \"fran%C3%A7aise\", \"\\u00a1Hola Mundo!\": \"%C2%A1Hola%20Mundo%21\", \"\\u0645\\u0631\\u062d\\u0628\\u0627 \\u0628\\u0627\\u0644\\u0639\\u0627\\u0644\\u0645!\": \"%D9%85%D8%B1%D8%AD%D8%A8%D8%A7%20%D8%A8%D8%A7%D9%84%D8%B9%D8%A7%D9%84%D9%85%21\", \"\\u4f60\\u597d\\u4e16\\u754c\\uff01\": \"%E4%BD%A0%E5%A5%BD%E4%B8%96%E7%95%8C%EF%BC%81\", \"\\u3053\\u3093\\u306b\\u3061\\u306f\\u4e16\\u754c\\uff01\": \"%E3%81%93%E3%82%93%E3%81%AB%E3%81%A1%E3%81%AF%E4%B8%96%E7%95%8C%EF%BC%81\", \"\\ud83d\\ude4e\": \"%F0%9F%99%8E\", \"\\ud83d\\ude4a\": \"%F0%9F%99%8A\", \"\\ud83d\\ude4e\\ud83c\\udffe\\u200d\\u2640\\ufe0f\": \"%F0%9F%99%8E%F0%9F%8F%BE%E2%80%8D%E2%99%80%EF%B8%8F\"}}}")
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IIUC, this has the runtime data in it as well as the test.
Is that the intent?

Base automatically changed from yannic-purl-bazel to main July 18, 2025 08:16
@aiuto
Copy link
Collaborator

aiuto commented Jul 24, 2025

I got the tests to pass on bazel 7 in #38

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants