Skip to content

Provide pure-Python implementation of Programs/_freeze_module for cross building #90107

Closed

Description

@tiran
BPO 45949
Nosy @gvanrossum, @tiran, @ericsnowcurrently, @moreati
PRs
  • bpo-45949: Pure Python freeze module for cross builds (GH-29899) #29899
  • Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

    Show more details

    GitHub fields:

    assignee = 'https://github.com/tiran'
    closed_at = <Date 2021-12-13.19:53:06.801>
    created_at = <Date 2021-12-01.15:34:28.428>
    labels = ['type-feature', 'build', '3.11']
    title = 'Provide pure-Python implementation of Programs/_freeze_module for cross building'
    updated_at = <Date 2021-12-13.20:32:52.812>
    user = 'https://github.com/tiran'

    bugs.python.org fields:

    activity = <Date 2021-12-13.20:32:52.812>
    actor = 'eric.snow'
    assignee = 'christian.heimes'
    closed = True
    closed_date = <Date 2021-12-13.19:53:06.801>
    closer = 'christian.heimes'
    components = ['Build', 'Cross-Build']
    creation = <Date 2021-12-01.15:34:28.428>
    creator = 'christian.heimes'
    dependencies = []
    files = []
    hgrepos = []
    issue_num = 45949
    keywords = ['patch']
    message_count = 8.0
    messages = ['407459', '407465', '407466', '408134', '408315', '408477', '408478', '408481']
    nosy_count = 4.0
    nosy_names = ['gvanrossum', 'christian.heimes', 'eric.snow', 'Alex.Willmer']
    pr_nums = ['29899']
    priority = 'normal'
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = 'enhancement'
    url = 'https://bugs.python.org/issue45949'
    versions = ['Python 3.11']

    Activity

    1. tiran commented on Dec 1, 2021

      @tiran
      MemberAuthor

      As of today 3.11-dev requires Programs/_freeze_module to compile Python code to byte code. The dependency on an extra and special tool makes cross building more complicated. The _freeze_module is trivial and can be easily implemented in pure Python code. The re-introduction of _bootstrap_python helper would allow us to use a pure Python freeze_module for all modules except two importlib bootstrap modules. I have a proof of concept implementation that works for me.

      Proposal for standard builds:

      Proposal for cross builds:

      • use user-provider Python interpreter (./configure --with-build-python) to generate all Python/frozen_modules/*.h with new freezemodule.py tool.

      When cross building the user must already provide a Python interpreter with same version and bytecode version as the build target. Users would no longer need to provide a _freeze_module binary with ./configure --with-freeze-module.

    2. self-assigned this
      on Dec 1, 2021
    3. added
      buildThe build process and cross-build
      type-featureA feature request or enhancement
      3.11only security fixes
      on Dec 1, 2021
    4. self-assigned this
      on Dec 1, 2021
    5. added
      buildThe build process and cross-build
      type-featureA feature request or enhancement
      on Dec 1, 2021
    6. ericsnowcurrently commented on Dec 1, 2021

      @ericsnowcurrently
      Member

      IIRC, Programs/_freeze_module.c was originally a C implementation of the basic functionality in Tools/freeze/freeze.py.

    7. ericsnowcurrently commented on Dec 1, 2021

      @ericsnowcurrently
      Member

      Ideally we would not have two scripts that do the same thing.

    8. tiran commented on Dec 9, 2021

      @tiran
      MemberAuthor

      Eric, could you review my PR, please? It simplifies cross building to other platforms.

      I took a look at Tools/freeze/freeze.py. The freeze tool creates different output than Program/_freeze_module.c.

    9. tiran commented on Dec 11, 2021

      @tiran
      MemberAuthor

      In his code review Eric made a point that the relationship of variables and their impact on normal and cross builds are not obvious. I'm going to introduce new variables for freezing and freezing dependencies. Bonus: Cross builds no longer build non-functional _bootstrap_python and Programs/_freeze_module.

      Normal build:

      PYTHON_FOR_FREEZE=./_bootstrap_python
      FREEZE_MODULE_BOOTSTRAP=./Programs/_freeze_module
      FREEZE_MODULE_BOOTSTRAP_DEPS=Programs/_freeze_module
      FREEZE_MODULE=$(PYTHON_FOR_FREEZE) $(srcdir)/Programs/_freeze_module.py
      FREEZE_MODULE_DEPS=_bootstrap_python $(srcdir)/Programs/_freeze_module.py

      Cross build:

      PYTHON_FOR_FREEZE=/path/to/build/python
      FREEZE_MODULE_BOOTSTRAP=$(PYTHON_FOR_FREEZE) $(srcdir)/Programs/_freeze_module.py
      FREEZE_MODULE_BOOTSTRAP_DEPS=$(srcdir)/Programs/_freeze_module.py
      FREEZE_MODULE=$(FREEZE_MODULE_BOOTSTRAP)
      FREEZE_MODULE_DEPS=$(FREEZE_MODULE_BOOTSTRAP_DEPS)

    10. tiran commented on Dec 13, 2021

      @tiran
      MemberAuthor

      New changeset eb483c4 by Christian Heimes in branch 'main':
      bpo-45949: Pure Python freeze module for cross builds (GH-29899)
      eb483c4

    11. tiran commented on Dec 13, 2021

      @tiran
      MemberAuthor

      Thanks for your review, Eric!

    12. ericsnowcurrently commented on Dec 13, 2021

      @ericsnowcurrently
      Member

      You're welcome! Thanks for doing the work!

    13. transferred this issue fromon Apr 10, 2022
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

    Metadata

    Metadata

    Assignees

    Labels

    3.11only security fixesbuildThe build process and cross-buildtype-featureA feature request or enhancement

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions