Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
pola-rs
GitHub Repository: pola-rs/polars
Path: blob/main/py-polars/runtime/template.py
7884 views
1
import shutil
2
from pathlib import Path
3
4
this_dir = Path(__file__).parent
5
6
7
def template(s: str, rt: str) -> str:
8
"""Apply the runtime template substitutions."""
9
s = s.replace("{{%RT_SUFFIX%}}", rt)
10
return s
11
12
13
if __name__ == "__main__":
14
for rt in ["32", "64", "compat"]:
15
basedir = this_dir / Path("polars-runtime-" + rt)
16
shutil.rmtree(basedir, ignore_errors=True)
17
shutil.copytree(this_dir / "template", basedir)
18
shutil.copyfile(
19
this_dir / ".." / ".." / "rust-toolchain.toml",
20
basedir / "rust-toolchain.toml",
21
)
22
shutil.move(
23
basedir / "_polars_runtime_mod", basedir / ("_polars_runtime_" + rt)
24
)
25
26
# Rename Cargo.template.toml to Cargo.toml. This rename is done to avoid
27
# cargo from picking up the template file as a real Cargo.toml, see #25391.
28
shutil.move(basedir / "Cargo.template.toml", basedir / "Cargo.toml")
29
30
with (basedir / "Cargo.toml").open() as f:
31
cargo_toml = f.read()
32
with (basedir / "pyproject.toml").open() as f:
33
pyproject_toml = f.read()
34
35
with (basedir / "Cargo.toml").open("w") as f:
36
f.write(template(cargo_toml, rt))
37
with (basedir / "pyproject.toml").open("w") as f:
38
f.write(template(pyproject_toml, rt))
39
40