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

Failed to compile static python3.7.12 #91010

Closed
aprpp mannequin opened this issue Feb 25, 2022 · 9 comments
Closed

Failed to compile static python3.7.12 #91010

aprpp mannequin opened this issue Feb 25, 2022 · 9 comments
Labels
3.7 (EOL) end of life build The build process and cross-build

Comments

@aprpp
Copy link
Mannequin

aprpp mannequin commented Feb 25, 2022

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']

    @aprpp
    Copy link
    Mannequin Author

    aprpp mannequin commented Feb 25, 2022

    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

    @aprpp aprpp mannequin added 3.7 (EOL) end of life build The build process and cross-build labels Feb 25, 2022
    @aprpp
    Copy link
    Mannequin Author

    aprpp mannequin commented Feb 26, 2022

    I have signed the contributor agreement

    @ned-deily
    Copy link
    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!

    @aprpp aprpp mannequin reopened this Feb 26, 2022
    @aprpp aprpp mannequin reopened this Feb 26, 2022
    @aprpp
    Copy link
    Mannequin Author

    aprpp mannequin commented Feb 26, 2022

    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

    @aprpp
    Copy link
    Mannequin Author

    aprpp mannequin commented Feb 26, 2022

    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

    @ned-deily
    Copy link
    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/

    @ned-deily
    Copy link
    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.

    @aprpp
    Copy link
    Mannequin Author

    aprpp mannequin commented Feb 26, 2022

    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

    @aprpp aprpp mannequin reopened this Feb 26, 2022
    @aprpp aprpp mannequin reopened this Feb 26, 2022
    @ned-deily
    Copy link
    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.

    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Labels
    3.7 (EOL) end of life build The build process and cross-build
    Projects
    None yet
    Development

    No branches or pull requests

    1 participant