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

bpo-42504: fix for MACOSX_DEPLOYMENT_TARGET=11 #23556

Merged
merged 2 commits into from
Dec 3, 2020

Conversation

fxcoudert
Copy link
Contributor

@fxcoudert fxcoudert commented Nov 29, 2020

@the-knights-who-say-ni
Copy link

Hello, and thanks for your contribution!

I'm a bot set up to make sure that the project can legally accept this contribution by verifying everyone involved has signed the PSF contributor agreement (CLA).

CLA Missing

Our records indicate the following people have not signed the CLA:

@fxcoudert

For legal reasons we need all the people listed to sign the CLA before we can look at your contribution. Please follow the steps outlined in the CPython devguide to rectify this issue.

If you have recently signed the CLA, please wait at least one business day
before our records are updated.

You can check yourself to see if the CLA has been received.

Thanks again for the contribution, we look forward to reviewing it!

@fxcoudert
Copy link
Contributor Author

I have now signed the CLA

@lewis262626
Copy link

Looks good to me 👍

Copy link
Member

@ned-deily ned-deily left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the PR. There is more work to be done, though. With:

MACOSX_DEPLOYMENT_TARGET=11 ./configure

making this change in setup.py gets past the first error only to fail later in distutils/spawn.py:

  File "source/Lib/distutils/spawn.py", line 66, in spawn
    if _cfg_target_split > [int(x) for x in cur_target.split('.')]:
TypeError: '>' not supported between instances of 'NoneType' and 'list'

Are there other users of MACOSX_DEPLOYMENT_TARGET in the source that need to be changed as well?

@bedevere-bot
Copy link

A Python core developer has requested some changes be made to your pull request before we can consider merging it. If you could please address their requests along with any other requests in other reviews from core developers that would be appreciated.

Once you have made the requested changes, please leave a comment on this pull request containing the phrase I have made the requested changes; please review again. I will then notify any core developers who have left a review that you're ready for them to take another look at this pull request.

@ronaldoussoren
Copy link
Contributor

A nicer fix is to ensure that sysconfig.get_config_var('MACOSX_DEPLOYMENT_TARGET') evaluates to a string. I haven't checked how easy it would be to do this.

@fxcoudert
Copy link
Contributor Author

@ronaldoussoren the code at https://github.com/python/cpython/blob/3.9/Lib/sysconfig.py#L461 shows it's very deliberate that int-type values are returned as int

@fxcoudert
Copy link
Contributor Author

Two places I am not 100% sure what to do:

@fxcoudert
Copy link
Contributor Author

fxcoudert commented Nov 30, 2020

I have made the requested changes; please review again.
I have confirmed that this makes the formula build on 11.0 when setting MACOSX_DEPLOYMENT_TARGET=11 (https://github.com/Homebrew/homebrew-core/pull/65933/checks?check_run_id=1473199510)


Travis is telling me:

Fixing Python file whitespace ... 1 file:
  Lib/test/test_posix.py

but I haven't changed whitespace in this file, and it is not telling me what the issue actually is.

@bedevere-bot
Copy link

Thanks for making the requested changes!

@ned-deily: please review the changes made to this pull request.

Copy link
Member

@ned-deily ned-deily left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the changes. Running test_distutils:
./python(.exe) -m test -w test_distutils

gives a number of failing test cases, basically due to one of two problems.

  1. The missing str() at spawn.py:66

  2. Failures in test_build_ext.py:501:

File "source/Lib/distutils/tests/test_build_ext.py", line 501, in _try_compile_deployment_target
    target = '%02d%02d00' % target
TypeError: not enough arguments for format string

I don't think we need to make any changes to configure.ac or build_installer.py.

@@ -57,7 +57,7 @@ def spawn(cmd, search_path=1, verbose=0, dry_run=0):
_cfg_target = sysconfig.get_config_var(
'MACOSX_DEPLOYMENT_TARGET') or ''
if _cfg_target:
_cfg_target_split = [int(x) for x in _cfg_target.split('.')]
_cfg_target_split = [int(x) for x in str(_cfg_target).split('.')]
Copy link
Member

@ned-deily ned-deily Dec 1, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A similar change is needed below at line 66.

@bedevere-bot
Copy link

A Python core developer has requested some changes be made to your pull request before we can consider merging it. If you could please address their requests along with any other requests in other reviews from core developers that would be appreciated.

Once you have made the requested changes, please leave a comment on this pull request containing the phrase I have made the requested changes; please review again. I will then notify any core developers who have left a review that you're ready for them to take another look at this pull request.

@fxcoudert
Copy link
Contributor Author

@nilleb wait I see the problem you're referring to, we're passing that int as an environment variable. That's where it should be fixed, actually. If it's defined, _cfg_target should always be a string to begin with. Then things go smoothly.

@fxcoudert
Copy link
Contributor Author

This was tested with a full build of Python on macOS Big Sur (ARM), as well as building several python-based packages. Without the latest version of the patch, some failed in subprocess.py. Now all pass.

@nilleb
Copy link

nilleb commented Dec 2, 2020

hey @fxcoudert the problem comes from line https://github.com/python/cpython/pull/23556/files#diff-a06590fdcc4068035ba08a86c9c816cb70a78d80cb9ff0babfbb8dae85dd41d0L75
where we pass env=env to the subprocess call (this has nothing to do with _cfg_target)
Since the variable MACOSX_DEPLOYMENT_TARGET has a 11 (int) value
3 stack levels beneath, it will raise an exception.

you can reproduce it by

git clone https://github.com/nilleb/magpie
cd magpie
bin/setup

edit: the interesting part of the stack

      File "/opt/homebrew/Cellar/python@3.9/3.9.0_3/Frameworks/Python.framework/Versions/3.9/lib/python3.9/distutils/spawn.py", line 75, in spawn
        proc = subprocess.Popen(cmd, env=env)
      File "/opt/homebrew/Cellar/python@3.9/3.9.0_3/Frameworks/Python.framework/Versions/3.9/lib/python3.9/subprocess.py", line 947, in __init__
        self._execute_child(args, executable, preexec_fn, close_fds,
      File "/opt/homebrew/Cellar/python@3.9/3.9.0_3/Frameworks/Python.framework/Versions/3.9/lib/python3.9/subprocess.py", line 1740, in _execute_child
        val = os.fsencode(v)
      File "/opt/homebrew/Cellar/python@3.9/3.9.0_3/Frameworks/Python.framework/Versions/3.9/lib/python3.9/os.py", line 810, in fsencode
        filename = fspath(filename)  # Does type-checking of `filename`.
    TypeError: expected str, bytes or os.PathLike object, not int

@fxcoudert
Copy link
Contributor Author

@nilleb this is fixed in the latest version of this patch. The problem is we pass cur_target as MACOSX_DEPLOYMENT_TARGET, and cur_target defaults to _cfg_target in some cases, and _cfg_target could be an int. Now it's always a str, and there is no problem.

@guillochon
Copy link

@fxcoudert can you add the blurb using the blurb-it tool so that check will pass? https://blurb-it.herokuapp.com/

@guillochon
Copy link

@ned-deily mind taking a gander at this one again? It looks ready to go

Copy link
Member

@ned-deily ned-deily left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM now, thanks! No doubt we will find other implications of moving from 10.x to 1x release version but this should be a good start.

@ned-deily ned-deily merged commit 5291639 into python:master Dec 3, 2020
@ned-deily ned-deily added the needs backport to 3.9 only security fixes label Dec 3, 2020
@miss-islington
Copy link
Contributor

Thanks @fxcoudert for the PR, and @ned-deily for merging it 🌮🎉.. I'm working now to backport this PR to: 3.9.
🐍🍒⛏🤖

miss-islington pushed a commit to miss-islington/cpython that referenced this pull request Dec 3, 2020
macOS releases numbering has changed as of macOS 11 Big Sur.  Previously, major releases were of the form 10.x, 10.x+1, 10.x+2, etc; as of Big Sur, they are now x, x+1, etc, so, for example, 10.15, 10.15.1, ..., 10.15.7, 11, 11.0.1, 11.1, ..., 12, 12.1, etc. Allow Python to build with single-digit deployment target values. Patch provided by FX Coudert.
(cherry picked from commit 5291639)

Co-authored-by: FX Coudert <fxcoudert@gmail.com>
@bedevere-bot
Copy link

GH-23622 is a backport of this pull request to the 3.9 branch.

@bedevere-bot bedevere-bot removed the needs backport to 3.9 only security fixes label Dec 3, 2020
miss-islington added a commit that referenced this pull request Dec 3, 2020
macOS releases numbering has changed as of macOS 11 Big Sur.  Previously, major releases were of the form 10.x, 10.x+1, 10.x+2, etc; as of Big Sur, they are now x, x+1, etc, so, for example, 10.15, 10.15.1, ..., 10.15.7, 11, 11.0.1, 11.1, ..., 12, 12.1, etc. Allow Python to build with single-digit deployment target values. Patch provided by FX Coudert.
(cherry picked from commit 5291639)

Co-authored-by: FX Coudert <fxcoudert@gmail.com>
@fxcoudert fxcoudert deleted the patch-1 branch December 3, 2020 07:27
@fxcoudert
Copy link
Contributor Author

Related PR, with wheel: pypa/wheel#385

adorilson pushed a commit to adorilson/cpython that referenced this pull request Mar 13, 2021
macOS releases numbering has changed as of macOS 11 Big Sur.  Previously, major releases were of the form 10.x, 10.x+1, 10.x+2, etc; as of Big Sur, they are now x, x+1, etc, so, for example, 10.15, 10.15.1, ..., 10.15.7, 11, 11.0.1, 11.1, ..., 12, 12.1, etc. Allow Python to build with single-digit deployment target values. Patch provided by FX Coudert.
ned-deily pushed a commit to ned-deily/cpython that referenced this pull request Apr 29, 2021
macOS releases numbering has changed as of macOS 11 Big Sur.  Previously, major releases were of the form 10.x, 10.x+1, 10.x+2, etc; as of Big Sur, they are now x, x+1, etc, so, for example, 10.15, 10.15.1, ..., 10.15.7, 11, 11.0.1, 11.1, ..., 12, 12.1, etc. Allow Python to build with single-digit deployment target values. Patch provided by FX Coudert.
(cherry picked from commit 5291639)

Co-authored-by: FX Coudert <fxcoudert@gmail.com>
ambv pushed a commit that referenced this pull request May 2, 2021
)

* bpo-41100: Support macOS 11 and Apple Silicon on Python 3.8

This is a partial backport of bpo-41100 changes `e8b1c038b14b5fc8120aab62c9bf5fb840274cb6` and `96d906b144e6e6aa96c5ffebecbcc5d38034bbda` for Python 3.8. We introduce the ability to build Python from source for `arm64` on macOS, but we do not make a promise of support. This allows us to omit support for Universal2 binaries as well as weak-linking of symbols from the macOS SDK based on the deployment target, which are larger changes much more difficult to merge.

This also includes a backport of subsequent bpo-42688 change `7e729978fa08a360cbf936dc215ba7dd25a06a08` to fix build errors with external `libffi`.

* bpo-41116: Ensure system supplied libraries are found on macOS 11 (GH-23301) (GH-23455)

On macOS system provided libraries are in a shared library cache
and not at their usual location. This PR teaches distutils to search
in the SDK, even if there was no "-sysroot" argument in
the compiler flags.
(cherry picked from commit 404a719)

* bpo-42504: fix for MACOSX_DEPLOYMENT_TARGET=11 (GH-23556)

macOS releases numbering has changed as of macOS 11 Big Sur.  Previously, major releases were of the form 10.x, 10.x+1, 10.x+2, etc; as of Big Sur, they are now x, x+1, etc, so, for example, 10.15, 10.15.1, ..., 10.15.7, 11, 11.0.1, 11.1, ..., 12, 12.1, etc. Allow Python to build with single-digit deployment target values. Patch provided by FX Coudert.
(cherry picked from commit 5291639)

* bpo-42504: Ensure that get_config_var('MACOSX_DEPLOYMENT_TARGET') is a string (GH-24341) (GH-24410)

* bpo-42504: Ensure that get_config_var('MACOSX_DEPLOYMENT_TARGET') is a string
(cherry picked from commit 49926cf)

Co-authored-by: Ronald Oussoren <ronaldoussoren@mac.com>
Co-authored-by: FX Coudert <fxcoudert@gmail.com>
Co-authored-by: Max Bélanger <aeromax@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

9 participants