Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Build configuration settings to facilitate complete link control #1793

Merged
merged 2 commits into from
Aug 31, 2021

Commits on Aug 30, 2021

  1. build: support emitting arbitrary lines from pyo3 build script

    PyOxidizer needs to do some... questionable things with regards to
    configuring how the Python interpreter is linked. The way I solved this
    problem for the `cpython` / `python3-sys` crates was by adding a bunch
    of crate features to control what `cargo:` lines were emitted by the
    build scripts. This added a lot of complexity to the those crates for
    a target audience of ~1.
    
    Now that PyO3 has support for config files to control settings, this
    provides a richer mechanism than crate features to influence the build
    script.
    
    This commit defines a new field on the `InterpreterConfig` struct to
    hold an arbitrary list of strings/lines that should be emitted by
    the build script. This field is only every populated when parsing config
    files and it is only read by pyo3's build script to `println!()`
    additional values.
    
    My intended use case for this is to have PyOxidizer effectively control
    the interpreter link settings via the config file (at my own peril)
    while having minimal impact on the maintainability of PyO3's code base.
    Given the complexity of the link hacks employed, you probably don't want
    this polluting pyo3's code base.
    indygreg committed Aug 30, 2021
    Configuration menu
    Copy the full SHA
    04c77e3 View commit details
    Browse the repository at this point in the history
  2. build: enable suppression of cargo:rustc-link-* lines

    PyOxidizer requires advanced control over the settings used to link
    libpython. We recently implemented support for configuration files
    defining explicit lines to emit from build scripts to give callers
    control over what lines to emit from build scripts so use cases
    like PyOxidizer's are feasible without hacks in PyO3's code base.
    
    However, the default logic in `emit_link_config()` may not be
    appropriate in scenarios where link settings are provided via this
    "extra lines" mechanism. The default logic may prohibit use of or
    interfere with desired settings provided externally.
    
    This commit defines a new field on the interpreter config that
    suppresses the emission of the default link control logic from the
    `pyo3` build script. It effectively gives advanced consumers like
    PyOxidizer full control over link logic while minimally polluting
    PyO3's build logic.
    
    I thought about implementing this control as a crate feature. But
    given the expected target audience size of ~1, I thought a crate
    feature was too visible for a power user feature and decided to
    implement it via the configuration file.
    indygreg committed Aug 30, 2021
    Configuration menu
    Copy the full SHA
    c9c606f View commit details
    Browse the repository at this point in the history