Skip to content

Commit 80a54b0

Browse files
authored
Merge pull request #1589 from dalcinl/source_date_epoch
feature: Automatically pass SOURCE_DATE_EPOCH to Linux containers
2 parents 76dba0b + 4f888e2 commit 80a54b0

File tree

3 files changed

+15
-0
lines changed

3 files changed

+15
-0
lines changed

cibuildwheel/oci_container.py

+1
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,7 @@ def __enter__(self) -> OCIContainer:
117117
self.engine.name,
118118
"create",
119119
"--env=CIBUILDWHEEL",
120+
"--env=SOURCE_DATE_EPOCH",
120121
f"--name={self.name}",
121122
"--interactive",
122123
"--volume=/:/host", # ignored on CircleCI

docs/options.md

+3
Original file line numberDiff line numberDiff line change
@@ -680,6 +680,9 @@ A list of environment variables to pass into the linux container during the buil
680680

681681
To specify more than one environment variable, separate the variable names by spaces.
682682

683+
!!! note
684+
cibuildwheel automatically passes the environment variable [`SOURCE_DATE_EPOCH`](https://reproducible-builds.org/docs/source-date-epoch/) if defined.
685+
683686
#### Examples
684687

685688
!!! tab examples "Environment passthrough"

unit_test/oci_container_test.py

+11
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,17 @@ def test_environment(container_engine):
7272
)
7373

7474

75+
def test_environment_pass(container_engine, monkeypatch):
76+
monkeypatch.setenv("CIBUILDWHEEL", "1")
77+
monkeypatch.setenv("SOURCE_DATE_EPOCH", "1489957071")
78+
with OCIContainer(engine=container_engine, image=DEFAULT_IMAGE) as container:
79+
assert container.call(["sh", "-c", "echo $CIBUILDWHEEL"], capture_output=True) == "1\n"
80+
assert (
81+
container.call(["sh", "-c", "echo $SOURCE_DATE_EPOCH"], capture_output=True)
82+
== "1489957071\n"
83+
)
84+
85+
7586
def test_cwd(container_engine):
7687
with OCIContainer(
7788
engine=container_engine, image=DEFAULT_IMAGE, cwd="/cibuildwheel/working_directory"

0 commit comments

Comments
 (0)