| """ |
| Configures the execution environment for the wheel_tool so that it can consume the dependencies we vendor and create |
| reproducible wheels |
| """ |
| import os |
| |
| import src.extract_wheels as whl |
| |
| |
| def configure_reproducible_wheels(): |
| """ |
| Wheels created from sdists are not reproducible by default. We can however workaround this by |
| patching in some configuration with environment variables. |
| """ |
| |
| # wheel, by default, enables debug symbols in GCC. This incidentally captures the build path in the .so file |
| # We can override this behavior by disabling debug symbols entirely. |
| # https://github.com/pypa/pip/issues/6505 |
| if os.environ.get("CFLAGS") is not None: |
| os.environ["CFLAGS"] += " -g0" |
| else: |
| os.environ["CFLAGS"] = "-g0" |
| |
| # set SOURCE_DATE_EPOCH to 1980 so that we can use python wheels |
| # https://github.com/NixOS/nixpkgs/blob/master/doc/languages-frameworks/python.section.md#python-setuppy-bdist_wheel-cannot-create-whl |
| if os.environ.get("SOURCE_DATE_EPOCH") is None: |
| os.environ["SOURCE_DATE_EPOCH"] = "315532800" |
| |
| # Python wheel metadata files can be unstable. |
| # See https://bitbucket.org/pypa/wheel/pull-requests/74/make-the-output-of-metadata-files/diff |
| if os.environ.get("PYTHONHASHSEED") is None: |
| os.environ["PYTHONHASHSEED"] = "0" |
| |
| |
| if __name__ == "__main__": |
| configure_reproducible_wheels() |
| |
| whl.main() |