Comments (6)
Hi all, we are releasing a hermetic toolchain based on indygreg/python-build-standalone this week. (also hi @LegNeato, I submitted a few patches for juniper a couple of years back :) )
from buck2.
I'm currently looking for a way to bundle a static python build with a rust program. The closest I've found is https://github.com/python-cmake-buildsystem/python-cmake-buildsystem (although that goes only up to 3.6) which replaces the configure logic of cpython with cmake scripts, the same would presumably be needed for buck2 as well so that one could have a rust/cpp program build by buck2 and then statically link against cpython. I've found that this conceptually easy task is really not that well supported yet anywhere (see https://pyo3.rs/v0.14.0/building_and_distribution#statically-embedding-the-python-interpreter as well).
This is helpful if one needs/ wants python, but does not rely on much of its ecosystem/ packages and just wants a scripting language which is known by many developers for some parts of a system.
(python-build-standalone
seems to be a wrapper around the configure scripts of the core cpython distribution + relies on docker which is a step I'd like to avoid)
from buck2.
This is a little bit hacky, but I was asked to share how I fixed this problem:
(please ignore the fact this is python3.8 😓 )
BUCK
http_archive(
name = "python-standalone-archive",
# TODO self host this
urls = [ "https://github.com/indygreg/python-build-standalone/releases/download/20231002/cpython-3.8.18+20231002-x86_64-unknown-linux-gnu-pgo-full.tar.zst"],
sha256 = "3209542fbcaf7c3ef5658b344ea357c4aabf5fe7cbf1b5dea4a0b78b64835fc0",
visibility = ["PUBLIC"],
)
standalone_python(
name = "python-standalone",
archive = ":python-standalone-archive",
visibility = ["PUBLIC"]
)
prebuilt_cxx_library(
name = "python-headers",
header_dirs = [ "@toolchains//python:python-standalone[includes]"],
visibility = ["PUBLIC"],
)
defs.bzl
def _standalone_python_impl(ctx: AnalysisContext) -> list[Provider]:
# generate a runnable python3 binary
python = ctx.actions.declare_output("__python", dir = True)
ctx.actions.copy_dir(python, ctx.attrs.archive)
interpreter = cmd_args(python, format = "{}/python/install/bin/python3").hidden(python)
# provide relavant headers for pybind
includes = ctx.actions.declare_output("include", dir = True)
ctx.actions.copy_file(includes, python.project("python/install/include/python3.8"))
return [
DefaultInfo(sub_targets = {
"interpreter": [RunInfo(interpreter)],
"includes": [DefaultInfo(includes)],
})
]
standalone_python = rule(
impl = _standalone_python_impl,
attrs = {
"archive": attrs.source(),
}
)
toolchain//BUCK
system_python_toolchain(
name = "python",
interpreter = "toolchains//python:python-standalone[interpreter]",
visibility = ["PUBLIC"],
)
from buck2.
Here's what Pants is trying to do pantsbuild/pants#7369
from buck2.
You might want to look into https://github.com/indygreg/PyOxidizer and https://gregoryszorc.com/blog/2022/05/10/announcing-the-pyoxy-python-runner/ and https://github.com/indygreg/python-build-standalone/
from buck2.
Ah, I see it is mentioned in the pants issue
from buck2.
Related Issues (20)
- Watchman/buck2 integration HOT 2
- How can you get a library's output path from bxl? HOT 7
- Why does bxl_actions require an execution platform? HOT 1
- Remote execution can't find executable HOT 13
- haskell_library fails on MacOS
- Feature Request: Shutdown buck2 server after some idle time
- --show-output (and related options show nothing in column 2) when using DefaultInfo with default_outs HOT 1
- Full rebuild after killing daemon HOT 8
- Suggestion: Use tar or zip for release artifacts
- Why can not Buck trigger Buildbarn's g++ using system_cxx_toolchain?
- 'buck2 build //tests:' can not find 'sh' when using case 'buck2/examples/remote_execution/buildbarn/tests'
- License details (for SPDX compliance) HOT 2
- Buck2 performance on single-file update in erlang project HOT 13
- `SRCDIR` is not absolute in genrule script HOT 2
- It should be possible to consume multiple `default_outputs` in an `attrs.list(attrs.source())` HOT 5
- RE: upload cancelled with "stream error: stream no longer needed" HOT 5
- Zig support HOT 2
- Handling environment variables for local and remote builds HOT 1
- How can I check and/or override the path for the linker for rust/cxx? HOT 1
- C++ mixed linking HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from buck2.