Skip to content

Failed to compile static python3.7.12 #91010

Closed

Description

@aprpp
mannequin
BPO 46854
Nosy @ned-deily
Files
  • 截图.PNG: compile error log
  • Setup.PNG: Modules/Setup Definition
  • 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 = None
    closed_at = <Date 2022-02-26.05:30:36.363>
    created_at = <Date 2022-02-25.03:46:49.224>
    labels = ['build', '3.7']
    title = 'Failed to compile static python3.7.12'
    updated_at = <Date 2022-02-26.05:30:36.362>
    user = 'https://bugs.python.org/aprpp'

    bugs.python.org fields:

    activity = <Date 2022-02-26.05:30:36.362>
    actor = 'ned.deily'
    assignee = 'none'
    closed = True
    closed_date = <Date 2022-02-26.05:30:36.363>
    closer = 'ned.deily'
    components = ['Build']
    creation = <Date 2022-02-25.03:46:49.224>
    creator = 'aprpp'
    dependencies = []
    files = ['50643', '50644']
    hgrepos = []
    issue_num = 46854
    keywords = []
    message_count = 9.0
    messages = ['413958', '414054', '414059', '414061', '414063', '414065', '414066', '414069', '414073']
    nosy_count = 2.0
    nosy_names = ['ned.deily', 'aprpp']
    pr_nums = []
    priority = 'normal'
    resolution = 'out of date'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = 'compile error'
    url = 'https://bugs.python.org/issue46854'
    versions = ['Python 3.7']

    Activity

    1. aprpp commented on Feb 25, 2022

      aprppmannequin
      MannequinAuthor

      I compile static version of python3.7.12, I added the static standard library that I want to compile in Modules/Setup, reference Modules/Setup.dist in python source, like this:

      static

      Modules that should always be present (non UNIX dependent):
      array arraymodule.c # array objects
      cmath cmathmodule.c _math.c # -lm # complex math library functions
      math mathmodule.c _math.c # -lm # math library functions, e.g. sin()
      _contextvars _contextvarsmodule.c # Context Variables
      _struct _struct.c # binary structure packing/unpacking

      But there are still many modules that fail to compile, these modules with no commented out build definitions in the Modules/Setup.dist file. How do I add these modules build definitions to the Modules/Setup, yes they compile successfully ?

      Failed to build these modules:
      _bz2 _ctypes _ctypes_test
      _decimal _hashlib _json
      _lsprof _lzma _multiprocessing
      _opcode _ssl _testbuffer
      _testimportmultiple _testmultiphase _uuid
      _xxtestfuzz ossaudiodev xxlimited

    2. added
      buildThe build process and cross-build
      on Feb 25, 2022
    3. aprpp commented on Feb 26, 2022

      aprppmannequin
      MannequinAuthor

      I have signed the contributor agreement

    4. ned-deily commented on Feb 26, 2022

      @ned-deily
      Member

      Successfully building a statically-linked version of Python depends greatly on the environment in which you are trying to build it and is really beyond the scope of this bug tracker. You don't say on which OS platform and version you are attempting this so it is hard to give any meaningful suggestions other than to make sure you have installed development versions (those including header files) of the various third-party libraries Python builds depend on (like libssl and libcrypto from OpenSSL), if your platform has a package manager, or build the required third-party libraries yourself. In any case, you will probably need to further edit the Setup file to reflect the location of the various third-party headers and libraries. As a rule, we don't do a lot of testing of static builds using Setup directly but some of the downstream distributors of Python do. Also note that Python 3.7 is now in the security-fix-only phase of its lifecycle prior to end-of-life in 2023, so further changes to the build process in 3.7 at this point would be out-of-scope. For what it's worth, there has been a significant amount of work in this area that is going into the next Python feature release, 3.11.0, planned for later this year so it should be significantly easier to do static builds and the like in 3.11. If you still run into problems with 3.7, suggest you ask in help forums like StackOverflow. Good luck!

    5. reopened this on Feb 26, 2022
    6. reopened this on Feb 26, 2022
    7. aprpp commented on Feb 26, 2022

      aprppmannequin
      MannequinAuthor

      The platform i build python3.7.12 on is Ubuntu18.04, I would like to know how the modules I fail to build, like _ctypes, should be added in Modules/Setup.
      The steps for my build are:
      1.tar -zxvf Python-3.7.12.tgz && cd Python-3.7.12
      2.edit Modules/Setup, add modules build definitions in the Modules/Setup
      3../configure LDFLAGS="-static" --disable-shared --prefix=/home/python3
      4.make LDFLAGS="-static" LINKFORSHARED=" "

      How to build python3.7 statically without relying on editing Modules/Setup?

    8. aprpp commented on Feb 26, 2022

      aprppmannequin
      MannequinAuthor

      As shown in the attachment, how should I add the definition of module _ctypes to Modules/Setup? Modules like _ctypes are not given in Modules/Setup.dist, I really don't know what they depend on

    9. ned-deily commented on Feb 26, 2022

      @ned-deily
      Member

      Sorry, I'll repeat: "Successfully building a statically-linked version of Python depends greatly on the environment in which you are trying to build it and is really beyond the scope of this bug tracker." Note, a quick web search found this page which should give you some suggestions on what dev packages need to be installed in an Ubuntu 18.04 environment. But also note that the directions there are for a normal, non-static Python build using setup.py and not Modules/Setup which, again, we don't normally test for 3.7. Good luck!

      https://linuxize.com/post/how-to-install-python-3-7-on-ubuntu-18-04/

    10. ned-deily commented on Feb 26, 2022

      @ned-deily
      Member

      P.S. One other suggestion: try building a non-static version of Python 3.7 first, i.e. without modifying Modules/Setup, and, once you get that working, it should be easier to examine the output from the build and copy those paths that setup.py found into your Modules/Setup.

    11. aprpp commented on Feb 26, 2022

      aprppmannequin
      MannequinAuthor

      I'm really sorry, I would like to know what environment is the official recommendation for static python3.7 compilation? What are the steps and commands for compilation officially required? Because the static python3.7 is very important to me, it has been a week and it has not been compiled successfully.Hope to get official help.Thanks

    12. reopened this on Feb 26, 2022
    13. reopened this on Feb 26, 2022
    14. ned-deily commented on Feb 26, 2022

      @ned-deily
      Member

      “I would like to know what environment is the official recommendation for static python3.7 compilation.”

      There is no official recommendation. As I’ve mentioned, we normally do not build with modified Modules/Setup configurations when developing and releasing Python. It’s complicated. That’s why setup.py and using Distutils to build the standard library modules was introduced years ago. Most users don’t need a statically linked Python. Please accept that you need to look elsewhere for assistance.

    15. 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

    No one assigned

      Labels

      3.7 (EOL)end of lifebuildThe build process and cross-build

      Projects

      No projects

        Milestone

        No milestone

        Relationships

        None yet

        Development

        No branches or pull requests

        Issue actions