ronaldoussoren / pyobjc

The Python <-> Objective-C Bridge with bindings for macOS frameworks
https://pyobjc.readthedocs.io
546 stars 46 forks source link

gcc error attempting to install pyobjc in PyCharm venv on MacOS 10.15.7 #412

Open wheeled opened 2 years ago

wheeled commented 2 years ago

I migrated a script that has been working fine under the system Python (3.6.8) to a venv (also based on system Python 3.6.8 but with its own site packages). One of the requirements is pyobjc-framework-CoreLocation, which pip failed to install, producing the following gcc error:

Modules/objc/OC_PythonNumber.m:553:39: error: unused parameter 'zone'

I've searched for this error and can confirm that:

pip, setuptools and wheels are all upgraded to the current version gcc appears to be correctly installed (it successfully process all of the modules up to that point) xcode appears to be correctly installed:

% xcode-select -p
/Library/Developer/CommandLineTools

I had a thought that perhaps it can't install into a venv, although it doesn't look like that kind of error. The prior install has been working fine, but is almost certainly an earlier build. Any suggestions? I have attached the full printout of the pip error report.

gcc error message.txt

ronaldoussoren commented 2 years ago

Which macOS version (likely 10.15) and commandline tools version do you use? I've had earlier reports out compilation errors like this, but haven't been able to reproduce them myself.

The problem you're seeing is in pyobjc-core, and I see that I'm not providing a binary wheel for that package. That's something I'll fix for the next release, and I'll see if I can provide wheels for the current release as well.

That said, Python 3.6 has just moved out of the security support window for the core developers. More recent versions of Python contain many enhancement and are generally a better fit.

wheeled commented 2 years ago

Thanks for the quick response.

MacOS is 10.15.7 (19H1615) as for Command Line Tools is this what you're after?

% xcode-select -v
xcode-select version 2373.

I'm also keen for Apple to move beyond 3.6.8... I have 3.9 as well - would you like me to try to build my venv around that and see if the error appears? Alternatively is there an older build of pyobjc I could try - I didn't have this issue around 12 months ago when I first installed it.

wheeled commented 2 years ago

I notice that the code triggering the compilation error was added in https://github.com/ronaldoussoren/pyobjc/commit/355d385d083795cfd2220f673becb6a46c313f56 3 months ago

wheeled commented 2 years ago

Further update: I installed v7.3 without error. That will satisfy my requirements, but I noticed that pip attempted to use the cached v8.1 for pyobjc-core and pyobjc-framework-Cocoa prerequisites, which of course failed.

% pip3 install pyobjc-framework-CoreLocation==7.3
Collecting pyobjc-framework-CoreLocation==7.3
  Downloading pyobjc_framework_CoreLocation-7.3-cp36-abi3-macosx_10_9_x86_64.whl (9.2 kB)
Collecting pyobjc-framework-Cocoa>=7.3
  Using cached pyobjc_framework_Cocoa-8.1-cp36-cp36m-macosx_10_9_x86_64.whl
Collecting pyobjc-core>=7.3
  Using cached pyobjc-core-8.1.tar.gz (716 kB)

I'm not sure if that's an issue with pip or the setup.py for pyobjc-framework-CoreLocation but it meant I had to install the three packages separately:

% pip3 install pyobjc-core==7.3                  
Collecting pyobjc-core==7.3
  Downloading pyobjc-core-7.3.tar.gz (684 kB)
     |████████████████████████████████| 684 kB 525 kB/s            
  Preparing metadata (setup.py) ... done
Building wheels for collected packages: pyobjc-core
  Building wheel for pyobjc-core (setup.py) ... done
  Created wheel for pyobjc-core: filename=pyobjc_core-7.3-cp36-cp36m-macosx_10_9_x86_64.whl size=291839 sha256=d8fad7bd7303b0e5c8eb06e729b6faa93a6fa44df2252d3d9122654157a6d958
  Stored in directory: /Users/wheeled/Library/Caches/pip/wheels/44/2e/03/1ff2660f82a498f8ea08a74b824955ed32fbdd678b9ac75bcd
Successfully built pyobjc-core
Installing collected packages: pyobjc-core
Successfully installed pyobjc-core-7.3
(venv) wheeled@Davids-MBP bom_tools % pip3 install pyobjc_framework_Cocoa==7.3
Collecting pyobjc_framework_Cocoa==7.3
  Downloading pyobjc-framework-Cocoa-7.3.tar.gz (3.5 MB)
     |████████████████████████████████| 3.5 MB 679 kB/s            
  Preparing metadata (setup.py) ... done
Requirement already satisfied: pyobjc-core>=7.3 in ./venv/lib/python3.6/site-packages (from pyobjc_framework_Cocoa==7.3) (7.3)
Building wheels for collected packages: pyobjc-framework-Cocoa
  Building wheel for pyobjc-framework-Cocoa (setup.py) ... done
  Created wheel for pyobjc-framework-Cocoa: filename=pyobjc_framework_Cocoa-7.3-cp36-cp36m-macosx_10_9_x86_64.whl size=259477 sha256=25fbe366840a0ac28c7d2bdb4563902e128c80982fc4e1a3ffca275624f2f7fe
  Stored in directory: /Users/wheeled/Library/Caches/pip/wheels/71/f2/a1/0585b541ecca439a4ee463f6f71c2dc3561d1b592a3184a257
Successfully built pyobjc-framework-Cocoa
Installing collected packages: pyobjc-framework-Cocoa
Successfully installed pyobjc-framework-Cocoa-7.3
(venv) wheeled@Davids-MBP bom_tools % pip3 install pyobjc-framework-CoreLocation==7.3
Collecting pyobjc-framework-CoreLocation==7.3
  Using cached pyobjc_framework_CoreLocation-7.3-cp36-abi3-macosx_10_9_x86_64.whl (9.2 kB)
Requirement already satisfied: pyobjc-core>=7.3 in ./venv/lib/python3.6/site-packages (from pyobjc-framework-CoreLocation==7.3) (7.3)
Requirement already satisfied: pyobjc-framework-Cocoa>=7.3 in ./venv/lib/python3.6/site-packages (from pyobjc-framework-CoreLocation==7.3) (7.3)
Installing collected packages: pyobjc-framework-CoreLocation
Successfully installed pyobjc-framework-CoreLocation-7.3

So I suspect there is indeed an issue with that recent commit, and that possibly some more stringent version enforcement may be useful in setup.py to help other who may have stumbled onto this issue.

ronaldoussoren commented 2 years ago

Using 7.3 instead of 8.x is indeed a workaround.

I did some cleanup work in for 8.0, including changing to GCC attributes to annotate arguments as unused. Sadly that feature doesn't seem to work as expected with the compiler on 10.15.

The error should also go away when using a newer version of Python because you'll then use binary wheels and don't have to compile them yourself. But that's not very important, on 10.15 there's basically no functional difference between 7.x and 8.x.

ronaldoussoren commented 2 years ago

This issue is probably fixed in PyObjC 8.4.1