Title: Using it in a Bazel project · python/prebuilt-cpython · Discussion #10 · GitHub
Open Graph Title: Using it in a Bazel project · python/prebuilt-cpython · Discussion #10
X Title: Using it in a Bazel project · python/prebuilt-cpython · Discussion #10
Description: Using it in a Bazel project
Open Graph Description: Hi, I'm a owner of rules_python, which is a framework for building Python programs using Bazel. I suspect that some of our users would be interested in this, so I wanted to give a quick brain dump ...
X Description: Hi, I'm a owner of rules_python, which is a framework for building Python programs using Bazel. I suspect that some of our users would be interested in this, so I wanted to give a quick brain d...
Opengraph URL: https://github.com/python/prebuilt-cpython/discussions/10
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"QAPage","mainEntity":{"@type":"Question","name":"Using it in a Bazel project","text":"\u003cp dir=\"auto\"\u003eHi,\u003c/p\u003e\n\u003cp dir=\"auto\"\u003eI'm a owner of rules_python, which is a framework for building Python programs using Bazel.\u003c/p\u003e\n\u003cp dir=\"auto\"\u003eI suspect that some of our users would be interested in this, so I wanted to give a quick brain dump on the sort of functionality that would make that easier with the constraints Bazel imposes.\u003c/p\u003e\n\u003cp dir=\"auto\"\u003eThe main constraint comes from cross-platform building. The net implication is that you can't run Python itself to get information about Python because the Python runtime to query is for another platform. This, in turn, means that running things like \u003ccode class=\"notranslate\"\u003epython-config\u003c/code\u003e or \u003ccode class=\"notranslate\"\u003epython -c \"import sysconfig; ...\"\u003c/code\u003e etc to get information about where Python headers are, C ABI settings, etc can't be done.\u003c/p\u003e\n\u003cp dir=\"auto\"\u003eInstead, with Bazel, this information has to be provided in a platform-neutral format so that Bazel's \"setup phase\"[1] can transform it into appropriate Bazel configuration information. This setup phase can run arbitrary local programs and Starlark code (Bazel's platform-agnostic DSL).\u003c/p\u003e\n\u003cp dir=\"auto\"\u003eAll of this is to say: if the archive of the runtime includes e.g. a JSON file with information, e.g. where headers are, path to the interpreter binary, python version, abi settings, etc etc), then it can read that and generate the appropriate internal configuration. (I mention JSON because Starlark has builtin support for parsing that, but most any machine readable format can suffice)\u003c/p\u003e\n\u003cp dir=\"auto\"\u003eWhat information needs to be provided? The more, the better; it's easy to ignore extra info, harder to reconstruct it after the fact. But a lower bound looks something like:\u003c/p\u003e\n\u003col dir=\"auto\"\u003e\n\u003cli\u003eThe information needed to copy the runtime somewhere else; the files needed at runtime, e.g. the interpreter, but not necessarily the headers.\u003c/li\u003e\n\u003cli\u003eThe information needed to build Python C extensions, e.g. headers, shared libs, abi etc\u003c/li\u003e\n\u003cli\u003eGeneral meta-data, e.g. python version, implementation name, etc\u003c/li\u003e\n\u003c/ol\u003e\n\u003cp dir=\"auto\"\u003eHope this was helpful / informative!\u003c/p\u003e","upvoteCount":1,"answerCount":1,"acceptedAnswer":{"@type":"Answer","text":"\u003cp dir=\"auto\"\u003eI would be curious to know the answer to these as well, as it's probably better to do this for CPython in general and not specific to this endeavour.\u003c/p\u003e","upvoteCount":0,"url":"https://github.com/python/prebuilt-cpython/discussions/10#discussioncomment-14733105"}}}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| route-pattern | /_view_fragments/Voltron::DiscussionsFragmentsController/show/:user_id/:repository/:discussion_number/discussion_layout(.:format) |
| route-controller | voltron_discussions_fragments |
| route-action | discussion_layout |
| fetch-nonce | v2:85a2c88e-f74c-7597-93f7-fe753aa278ef |
| current-catalog-service-hash | 9f0abe34da433c9b6db74bffa2466494a717b579a96b30a5d252e5090baea7be |
| request-id | 9ABC:E9D16:3AE9EE3:4AA9F28:6B023406 |
| html-safe-nonce | 7ff005401021b390dfcde8ef05fa01c4b695d73cfebcd3b11697bbdab5a4d6da |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI5QUJDOkU5RDE2OjNBRTlFRTM6NEFBOUYyODo2QjAyMzQwNiIsInZpc2l0b3JfaWQiOiI0NTYyMTM1MjYxNzAxNjE2NjQ2IiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | c1286b132b165338ecb673705e81a3d38096075bc9fe4b191a6f3cd8abf67d57 |
| hovercard-subject-tag | discussion:9041068 |
| github-keyboard-shortcuts | repository,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/Voltron::DiscussionsFragmentsController/show/python/prebuilt-cpython/10/discussion_layout |
| twitter:image | https://opengraph.githubassets.com/fce6178cb4e8116930c5e63077bb77da2864ec02939cea039a2760ddecbb75a3/python/prebuilt-cpython/discussions/10 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/fce6178cb4e8116930c5e63077bb77da2864ec02939cea039a2760ddecbb75a3/python/prebuilt-cpython/discussions/10 |
| og:image:alt | Hi, I'm a owner of rules_python, which is a framework for building Python programs using Bazel. I suspect that some of our users would be interested in this, so I wanted to give a quick brain dump ... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| hostname | github.com |
| expected-hostname | github.com |
| None | 87e774ee7c6b3bee0490394e4d3e57ec9dbc956f74b87ea685dc8996c1676456 |
| turbo-cache-control | no-preview |
| go-import | github.com/python/prebuilt-cpython git https://github.com/python/prebuilt-cpython.git |
| octolytics-dimension-user_id | 1525981 |
| octolytics-dimension-user_login | python |
| octolytics-dimension-repository_id | 1075604713 |
| octolytics-dimension-repository_nwo | python/prebuilt-cpython |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 1075604713 |
| octolytics-dimension-repository_network_root_nwo | python/prebuilt-cpython |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 423dbb54c5e7bfecc838eb387c1435eb3d0e760d |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width