Merge pull request #1589 from dalcinl/source_date_epoch
feature: Automatically pass SOURCE_DATE_EPOCH to Linux containers
This commit is contained in:
@@ -117,6 +117,7 @@ class OCIContainer:
|
|||||||
self.engine.name,
|
self.engine.name,
|
||||||
"create",
|
"create",
|
||||||
"--env=CIBUILDWHEEL",
|
"--env=CIBUILDWHEEL",
|
||||||
|
"--env=SOURCE_DATE_EPOCH",
|
||||||
f"--name={self.name}",
|
f"--name={self.name}",
|
||||||
"--interactive",
|
"--interactive",
|
||||||
"--volume=/:/host", # ignored on CircleCI
|
"--volume=/:/host", # ignored on CircleCI
|
||||||
|
|||||||
@@ -680,6 +680,9 @@ A list of environment variables to pass into the linux container during the buil
|
|||||||
|
|
||||||
To specify more than one environment variable, separate the variable names by spaces.
|
To specify more than one environment variable, separate the variable names by spaces.
|
||||||
|
|
||||||
|
!!! note
|
||||||
|
cibuildwheel automatically passes the environment variable [`SOURCE_DATE_EPOCH`](https://reproducible-builds.org/docs/source-date-epoch/) if defined.
|
||||||
|
|
||||||
#### Examples
|
#### Examples
|
||||||
|
|
||||||
!!! tab examples "Environment passthrough"
|
!!! tab examples "Environment passthrough"
|
||||||
|
|||||||
@@ -72,6 +72,17 @@ def test_environment(container_engine):
|
|||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
def test_environment_pass(container_engine, monkeypatch):
|
||||||
|
monkeypatch.setenv("CIBUILDWHEEL", "1")
|
||||||
|
monkeypatch.setenv("SOURCE_DATE_EPOCH", "1489957071")
|
||||||
|
with OCIContainer(engine=container_engine, image=DEFAULT_IMAGE) as container:
|
||||||
|
assert container.call(["sh", "-c", "echo $CIBUILDWHEEL"], capture_output=True) == "1\n"
|
||||||
|
assert (
|
||||||
|
container.call(["sh", "-c", "echo $SOURCE_DATE_EPOCH"], capture_output=True)
|
||||||
|
== "1489957071\n"
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
def test_cwd(container_engine):
|
def test_cwd(container_engine):
|
||||||
with OCIContainer(
|
with OCIContainer(
|
||||||
engine=container_engine, image=DEFAULT_IMAGE, cwd="/cibuildwheel/working_directory"
|
engine=container_engine, image=DEFAULT_IMAGE, cwd="/cibuildwheel/working_directory"
|
||||||
|
|||||||
Reference in New Issue
Block a user