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 changes from MacPorts #368

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 2 additions & 2 deletions develop.py
Expand Up @@ -15,7 +15,7 @@
import shutil
import subprocess
import sys
from distutils.sysconfig import get_config_var
from setuptools._distutils.sysconfig import get_config_var
Copy link
Owner

Choose a reason for hiding this comment

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

This doesn't look correct, the new version of the code uses a private submodule of setuptools

Copy link
Owner

Choose a reason for hiding this comment

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

I won't use this bit, I've changed the script to use sysconfig.get_config_var.


TOPDIR = os.path.dirname(os.path.abspath(__file__))

Expand Down Expand Up @@ -122,7 +122,7 @@ def get_sdk_level():
assert sdkname.startswith("MacOSX")
assert sdkname.endswith(".sdk")

if sdkname == "MacOSX.sdk":
if sdkname == "MacOSX.sdk" or "." not in sdkname[6:-4]:
Copy link
Owner

Choose a reason for hiding this comment

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

Why is this needed?

Copy link

@Bo98 Bo98 Oct 24, 2021

Choose a reason for hiding this comment

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

Because MacOSX11.sdk exists as a valid option at /Library/Developer/CommandLineTools/SDKs. This particular one affects Homebrew as well.

Copy link
Owner

Choose a reason for hiding this comment

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

I'm working on a change that will turn the logic around: use SDKSettings.plist where it is available and only use the version in the base name of the SDK when there is no plist file. Both here and in the various setup files.

Copy link

@Bo98 Bo98 Oct 26, 2021

Choose a reason for hiding this comment

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

Sounds good to me. We also primarily use SDKSettings in Homebrew's SDK selection and it's worked well so it should work for PyObjC too. Just be aware you may need to strip the patch version like you do to the OS version (there was a 10.15.4 SDK).

Copy link
Owner

Choose a reason for hiding this comment

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

Stripping shouldn't be necessary, the code should work fine with more than 3 labels....

Copy link
Owner

Choose a reason for hiding this comment

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

db2cdc8 implements the new code.

try:
with open(os.path.join(sdk, "SDKSettings.plist"), "rb") as fp:
pl = plistlib.load(fp)
Expand Down
2 changes: 1 addition & 1 deletion development-support/wheel-smoke-test.py
Expand Up @@ -6,7 +6,7 @@
"""

import platform
from distutils.version import LooseVersion
from setuptools._distutils.version import LooseVersion
Copy link
Owner

Choose a reason for hiding this comment

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

See above, private submodule of setuptools.

Copy link
Owner

Choose a reason for hiding this comment

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

changeset 12daa01 removes the dependency on distutils in this file.


import objc # noqa: F401
from AddressBook import * # noqa: F401, F403
Expand Down
2 changes: 1 addition & 1 deletion docs/core/intro.rst
Expand Up @@ -979,7 +979,7 @@ An example ``setup.py`` script:
.. sourcecode:: python
:linenos:

from distutils.core import setup
from setuptools import setup
import py2app

setup(
Expand Down
2 changes: 1 addition & 1 deletion docs/tutorials/embedded.rst
Expand Up @@ -69,7 +69,7 @@ Follow these steps:

.. sourcecode:: python

from distutils.core import setup
from setuptools import setup
import py2app

setup(
Expand Down
2 changes: 1 addition & 1 deletion docs/tutorials/firstapp.rst
Expand Up @@ -78,7 +78,7 @@ Testing the user interface
.. sourcecode:: python
:linenos:

from distutils.core import setup
from setuptools import setup
import py2app

setup(
Expand Down
17 changes: 5 additions & 12 deletions install.py
Expand Up @@ -15,7 +15,7 @@
import shutil
import subprocess
import sys
from distutils.sysconfig import get_config_var
from setuptools._distutils.sysconfig import get_config_var
Copy link
Owner

Choose a reason for hiding this comment

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

See above


TOPDIR = os.path.dirname(os.path.abspath(__file__))

Expand Down Expand Up @@ -122,7 +122,7 @@ def get_sdk_level():
assert sdkname.startswith("MacOSX")
assert sdkname.endswith(".sdk")

if sdkname == "MacOSX.sdk":
if sdkname == "MacOSX.sdk" or "." not in sdkname[6:-4]:
Copy link
Owner

Choose a reason for hiding this comment

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

See above

try:
with open(os.path.join(sdk, "SDKSettings.plist"), "rb") as fp:
pl = plistlib.load(fp)
Expand Down Expand Up @@ -221,16 +221,10 @@ def build_project(project, extra_args):
shutil.rmtree(os.path.join(proj_dir, "build"))

print("Installing {!r} using {!r}".format(project, sys.executable))
status = subprocess.call(
subprocess.check_call(
Copy link
Owner

Choose a reason for hiding this comment

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

I don't like this change, the old code nicely prints which subproject fails to install and the new one doesn't.

[sys.executable, "setup.py", "install"] + extra_args, cwd=proj_dir
)

if status != 0:
print("Installing {!r} failed (status {})".format(project, status))
return False

return True


def version_key(version):
return tuple(int(x) for x in version.split("."))
Expand All @@ -242,9 +236,8 @@ def main():
sys.exit(1)

for project in ["pyobjc-core"] + sorted_framework_wrappers():
ok = build_project(project, sys.argv[1:])
if not ok:
break
print(f"\nBuilding {project}...\n")
build_project(project, sys.argv[1:])
Copy link
Owner

Choose a reason for hiding this comment

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

Not ok. The old code is intentional, the code in framework wrappers should either build correctly or be skipped entirely (that is, bindings for frameworks introduced in macOS 11 will be skipped automatically on macOS 10.15 or earlier).



if __name__ == "__main__":
Expand Down
2 changes: 1 addition & 1 deletion pyobjc-core/Lib/PyObjCTools/TestSupport.py
Expand Up @@ -15,7 +15,7 @@
import sys as _sys
import unittest as _unittest
import subprocess as _subprocess
from distutils.sysconfig import get_config_var as _get_config_var
from setuptools._distutils.sysconfig import get_config_var as _get_config_var

import objc

Expand Down
2 changes: 1 addition & 1 deletion pyobjc-core/PyObjCTest/test_bridgesupport.py
Expand Up @@ -1861,7 +1861,7 @@ def _updatingMetadata(flag):
},
)

from distutils.sysconfig import get_config_var
from setuptools._distutils.sysconfig import get_config_var

self.assertNotIn("protocols", module_globals)
self.assertEqual(
Expand Down
2 changes: 1 addition & 1 deletion pyobjc-core/PyObjCTest/test_objc.py
Expand Up @@ -104,7 +104,7 @@ def test_resolve_name(self):

v = resolve("distutils.command.sdist.show_formats")

from distutils.command.sdist import show_formats
from setuptools.command.sdist import show_formats

self.assertIs(v, show_formats)

Expand Down
11 changes: 4 additions & 7 deletions pyobjc-core/Tools/pyobjc_setup.py
Expand Up @@ -28,9 +28,9 @@
from setuptools import setup as _setup
from setuptools.command import build_ext, build_py, develop, egg_info, install_lib, test

from distutils import log
from distutils.errors import DistutilsError, DistutilsPlatformError
from distutils.command import build, install
from setuptools._distutils import log
from setuptools._distutils.errors import DistutilsError, DistutilsPlatformError
from setuptools.command import build, install


class oc_build_py(build_py.build_py):
Expand Down Expand Up @@ -238,7 +238,7 @@ def get_sdk_level():
sdkname = os.path.basename(sdk)
assert sdkname.startswith("MacOSX")
assert sdkname.endswith(".sdk")
if sdkname == "MacOSX.sdk":
if sdkname == "MacOSX.sdk" or "." not in sdkname[6:-4]:
try:
with open(os.path.join(sdk, "SDKSettings.plist"), "rb") as fp:
pl = plistlib.load(fp)
Expand Down Expand Up @@ -467,9 +467,6 @@ def Extension(*args, **kwds):
if os_level == "10.4":
cflags.append("-DNO_OBJC2_RUNTIME")

if "-Werror" not in cflags:
cflags.append("-Werror")

if "extra_compile_args" in kwds:
kwds["extra_compile_args"] = kwds["extra_compile_args"] + cflags
else:
Expand Down
17 changes: 10 additions & 7 deletions pyobjc-core/setup.py
Expand Up @@ -9,10 +9,14 @@
import warnings
from setuptools import Extension, setup
from setuptools.command import build_ext, build_py, egg_info, install_lib, test
from distutils import log
from distutils.errors import DistutilsError, DistutilsPlatformError, DistutilsSetupError
from distutils.sysconfig import get_config_var as _get_config_var
from distutils.sysconfig import get_config_vars
from setuptools._distutils import log
Copy link
Owner

Choose a reason for hiding this comment

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

once again imports from a private submodule.

from setuptools._distutils.errors import (
DistutilsError,
DistutilsPlatformError,
DistutilsSetupError,
)
from setuptools._distutils.sysconfig import get_config_var as _get_config_var
from setuptools._distutils.sysconfig import get_config_vars

from pkg_resources import add_activation_listener, normalize_path, require, working_set

Expand Down Expand Up @@ -50,7 +54,7 @@ def get_sdk_level(sdk):
sdkname = os.path.basename(sdk)
assert sdkname.startswith("MacOSX")
assert sdkname.endswith(".sdk")
if sdkname == "MacOSX.sdk":
if sdkname == "MacOSX.sdk" or "." not in sdkname[6:-4]:
try:
with open(os.path.join(sdk, "SDKSettings.plist"), "rb") as fp:
pl = plistlib.load(fp)
Expand Down Expand Up @@ -80,7 +84,6 @@ def get_sdk_level(sdk):
"-Wshorten-64-to-32",
# "-fsanitize=address", "-fsanitize=undefined", "-fno-sanitize=vptr",
# "--analyze",
"-Werror",
"-I/usr/include/ffi",
# "-fvisibility=hidden",
# "-O3", "-flto",
Expand Down Expand Up @@ -487,7 +490,7 @@ def _fixup_compiler(use_ccache):


class oc_build_ext(build_ext.build_ext):
user_options = [
user_options = build_ext.build_ext.user_options + [
(
"deployment-target=",
None,
Expand Down
11 changes: 4 additions & 7 deletions pyobjc-framework-AVFoundation/pyobjc_setup.py
Expand Up @@ -28,9 +28,9 @@
from setuptools import setup as _setup
from setuptools.command import build_ext, build_py, develop, egg_info, install_lib, test

from distutils import log
from distutils.errors import DistutilsError, DistutilsPlatformError
from distutils.command import build, install
from setuptools._distutils import log
from setuptools._distutils.errors import DistutilsError, DistutilsPlatformError
from setuptools.command import build, install


class oc_build_py(build_py.build_py):
Expand Down Expand Up @@ -238,7 +238,7 @@ def get_sdk_level():
sdkname = os.path.basename(sdk)
assert sdkname.startswith("MacOSX")
assert sdkname.endswith(".sdk")
if sdkname == "MacOSX.sdk":
if sdkname == "MacOSX.sdk" or "." not in sdkname[6:-4]:
try:
with open(os.path.join(sdk, "SDKSettings.plist"), "rb") as fp:
pl = plistlib.load(fp)
Expand Down Expand Up @@ -467,9 +467,6 @@ def Extension(*args, **kwds):
if os_level == "10.4":
cflags.append("-DNO_OBJC2_RUNTIME")

if "-Werror" not in cflags:
cflags.append("-Werror")

if "extra_compile_args" in kwds:
kwds["extra_compile_args"] = kwds["extra_compile_args"] + cflags
else:
Expand Down
11 changes: 4 additions & 7 deletions pyobjc-framework-AVKit/pyobjc_setup.py
Expand Up @@ -28,9 +28,9 @@
from setuptools import setup as _setup
from setuptools.command import build_ext, build_py, develop, egg_info, install_lib, test

from distutils import log
from distutils.errors import DistutilsError, DistutilsPlatformError
from distutils.command import build, install
from setuptools._distutils import log
from setuptools._distutils.errors import DistutilsError, DistutilsPlatformError
from setuptools.command import build, install


class oc_build_py(build_py.build_py):
Expand Down Expand Up @@ -238,7 +238,7 @@ def get_sdk_level():
sdkname = os.path.basename(sdk)
assert sdkname.startswith("MacOSX")
assert sdkname.endswith(".sdk")
if sdkname == "MacOSX.sdk":
if sdkname == "MacOSX.sdk" or "." not in sdkname[6:-4]:
try:
with open(os.path.join(sdk, "SDKSettings.plist"), "rb") as fp:
pl = plistlib.load(fp)
Expand Down Expand Up @@ -467,9 +467,6 @@ def Extension(*args, **kwds):
if os_level == "10.4":
cflags.append("-DNO_OBJC2_RUNTIME")

if "-Werror" not in cflags:
cflags.append("-Werror")

if "extra_compile_args" in kwds:
kwds["extra_compile_args"] = kwds["extra_compile_args"] + cflags
else:
Expand Down
11 changes: 4 additions & 7 deletions pyobjc-framework-Accessibility/pyobjc_setup.py
Expand Up @@ -28,9 +28,9 @@
from setuptools import setup as _setup
from setuptools.command import build_ext, build_py, develop, egg_info, install_lib, test

from distutils import log
from distutils.errors import DistutilsError, DistutilsPlatformError
from distutils.command import build, install
from setuptools._distutils import log
from setuptools._distutils.errors import DistutilsError, DistutilsPlatformError
from setuptools.command import build, install


class oc_build_py(build_py.build_py):
Expand Down Expand Up @@ -238,7 +238,7 @@ def get_sdk_level():
sdkname = os.path.basename(sdk)
assert sdkname.startswith("MacOSX")
assert sdkname.endswith(".sdk")
if sdkname == "MacOSX.sdk":
if sdkname == "MacOSX.sdk" or "." not in sdkname[6:-4]:
try:
with open(os.path.join(sdk, "SDKSettings.plist"), "rb") as fp:
pl = plistlib.load(fp)
Expand Down Expand Up @@ -467,9 +467,6 @@ def Extension(*args, **kwds):
if os_level == "10.4":
cflags.append("-DNO_OBJC2_RUNTIME")

if "-Werror" not in cflags:
cflags.append("-Werror")

if "extra_compile_args" in kwds:
kwds["extra_compile_args"] = kwds["extra_compile_args"] + cflags
else:
Expand Down
11 changes: 4 additions & 7 deletions pyobjc-framework-Accounts/pyobjc_setup.py
Expand Up @@ -28,9 +28,9 @@
from setuptools import setup as _setup
from setuptools.command import build_ext, build_py, develop, egg_info, install_lib, test

from distutils import log
from distutils.errors import DistutilsError, DistutilsPlatformError
from distutils.command import build, install
from setuptools._distutils import log
from setuptools._distutils.errors import DistutilsError, DistutilsPlatformError
from setuptools.command import build, install


class oc_build_py(build_py.build_py):
Expand Down Expand Up @@ -238,7 +238,7 @@ def get_sdk_level():
sdkname = os.path.basename(sdk)
assert sdkname.startswith("MacOSX")
assert sdkname.endswith(".sdk")
if sdkname == "MacOSX.sdk":
if sdkname == "MacOSX.sdk" or "." not in sdkname[6:-4]:
try:
with open(os.path.join(sdk, "SDKSettings.plist"), "rb") as fp:
pl = plistlib.load(fp)
Expand Down Expand Up @@ -467,9 +467,6 @@ def Extension(*args, **kwds):
if os_level == "10.4":
cflags.append("-DNO_OBJC2_RUNTIME")

if "-Werror" not in cflags:
cflags.append("-Werror")

if "extra_compile_args" in kwds:
kwds["extra_compile_args"] = kwds["extra_compile_args"] + cflags
else:
Expand Down
11 changes: 4 additions & 7 deletions pyobjc-framework-AdServices/pyobjc_setup.py
Expand Up @@ -28,9 +28,9 @@
from setuptools import setup as _setup
from setuptools.command import build_ext, build_py, develop, egg_info, install_lib, test

from distutils import log
from distutils.errors import DistutilsError, DistutilsPlatformError
from distutils.command import build, install
from setuptools._distutils import log
from setuptools._distutils.errors import DistutilsError, DistutilsPlatformError
from setuptools.command import build, install


class oc_build_py(build_py.build_py):
Expand Down Expand Up @@ -238,7 +238,7 @@ def get_sdk_level():
sdkname = os.path.basename(sdk)
assert sdkname.startswith("MacOSX")
assert sdkname.endswith(".sdk")
if sdkname == "MacOSX.sdk":
if sdkname == "MacOSX.sdk" or "." not in sdkname[6:-4]:
try:
with open(os.path.join(sdk, "SDKSettings.plist"), "rb") as fp:
pl = plistlib.load(fp)
Expand Down Expand Up @@ -467,9 +467,6 @@ def Extension(*args, **kwds):
if os_level == "10.4":
cflags.append("-DNO_OBJC2_RUNTIME")

if "-Werror" not in cflags:
cflags.append("-Werror")

if "extra_compile_args" in kwds:
kwds["extra_compile_args"] = kwds["extra_compile_args"] + cflags
else:
Expand Down
11 changes: 4 additions & 7 deletions pyobjc-framework-AdSupport/pyobjc_setup.py
Expand Up @@ -28,9 +28,9 @@
from setuptools import setup as _setup
from setuptools.command import build_ext, build_py, develop, egg_info, install_lib, test

from distutils import log
from distutils.errors import DistutilsError, DistutilsPlatformError
from distutils.command import build, install
from setuptools._distutils import log
from setuptools._distutils.errors import DistutilsError, DistutilsPlatformError
from setuptools.command import build, install


class oc_build_py(build_py.build_py):
Expand Down Expand Up @@ -238,7 +238,7 @@ def get_sdk_level():
sdkname = os.path.basename(sdk)
assert sdkname.startswith("MacOSX")
assert sdkname.endswith(".sdk")
if sdkname == "MacOSX.sdk":
if sdkname == "MacOSX.sdk" or "." not in sdkname[6:-4]:
try:
with open(os.path.join(sdk, "SDKSettings.plist"), "rb") as fp:
pl = plistlib.load(fp)
Expand Down Expand Up @@ -467,9 +467,6 @@ def Extension(*args, **kwds):
if os_level == "10.4":
cflags.append("-DNO_OBJC2_RUNTIME")

if "-Werror" not in cflags:
cflags.append("-Werror")

if "extra_compile_args" in kwds:
kwds["extra_compile_args"] = kwds["extra_compile_args"] + cflags
else:
Expand Down