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

python3Packages.pyobjc-core: init at 10.3.1 #336801

Closed
wants to merge 1 commit into from

Conversation

ferrine
Copy link
Contributor

@ferrine ferrine commented Aug 23, 2024

Description of changes

Things done

  • Built on platform(s)
    • x86_64-linux
    • aarch64-linux
    • x86_64-darwin
    • aarch64-darwin
  • For non-Linux: Is sandboxing enabled in nix.conf? (See Nix manual)
    • sandbox = relaxed
    • sandbox = true
  • Tested, as applicable:
  • Tested compilation of all packages that depend on this change using nix-shell -p nixpkgs-review --run "nixpkgs-review rev HEAD". Note: all changes have to be committed, also see nixpkgs-review usage
  • Tested basic functionality of all binary files (usually in ./result/bin/)
  • 24.11 Release Notes (or backporting 23.11 and 24.05 Release notes)
    • (Package updates) Added a release notes entry if the change is major or breaking
    • (Module updates) Added a release notes entry if the change is significant
    • (Module addition) Added a release notes entry if adding a new NixOS module
  • Fits CONTRIBUTING.md.

Add a 👍 reaction to pull requests you find important.

@ferrine ferrine requested a review from natsukium as a code owner August 23, 2024 15:21
@ferrine ferrine force-pushed the new/pyobjc-core branch 4 times, most recently from e7490ab to c628cdb Compare August 24, 2024 13:51
@ofborg ofborg bot added 8.has: package (new) This PR adds a new package 10.rebuild-darwin: 1-10 10.rebuild-linux: 0 This PR does not cause any packages to rebuild on Linux labels Aug 24, 2024
@ferrine
Copy link
Contributor Author

ferrine commented Aug 24, 2024

Hi, can anyone please review?

@ferrine ferrine force-pushed the new/pyobjc-core branch 2 times, most recently from 3879755 to 8c5df9a Compare August 25, 2024 10:21
pkgs/development/python-modules/pyobjc-core/default.nix Outdated Show resolved Hide resolved
#
# ZZZ: Sorted out the issues with tests and put them in prePatch
checkPhase = ''
python3 setup.py test
Copy link
Member

Choose a reason for hiding this comment

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

That is deprecated and we removed already all usages of running tests like that. Please use pytest.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I did not manage to do that, looking into the actual code, the author of the package did some extra stuff to bootstrap unittest

Copy link
Member

Choose a reason for hiding this comment

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

Can we use pytestCheckHook and pytestFlagsArray = [ "PyObjCTest" ]?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

that's what I tried and it was failing with

ERROR PyObjCTest/test_voidpointer.py::TestCase - AttributeError: 'TestCase' object has no attribute 'runTest'. Did you mean:...
ERROR PyObjCTest/test_voidpointer.py::TestVoidPointer - AttributeError: 'TestVoidPointer' object has no attribute 'runTest'. Did yo...
ERROR PyObjCTest/test_weakref.py::TestCase - AttributeError: 'TestCase' object has no attribute 'runTest'. Did you mean:...
ERROR PyObjCTest/test_weakref.py::TestWeakrefs - AttributeError: 'TestWeakrefs' object has no attribute 'runTest'. Did you m...
ERROR PyObjCTest/test_weakref.py::TestObjCWeakRef - AttributeError: 'TestObjCWeakRef' object has no attribute 'runTest'. Did yo...
!!!!!!!!!!!!!!!!!! Interrupted: 438 errors during collection !!!!!!!!!!!!!!!!!!!
====================== 11 warnings, 438 errors in 20.36s =======================

unittestCheckHook is promising, trying to make it work as well

Copy link
Contributor Author

Choose a reason for hiding this comment

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

niether unittestCheckHook is easy to make working

Copy link
Contributor Author

Choose a reason for hiding this comment

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

With unittestCheck Hook errors are different and seem to be related to how tests are set up in the library

https://github.com/ronaldoussoren/pyobjc/blob/master/pyobjc-core/setup.py#L216-L329

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I've updated the PR with all the comments taken into account, but for running tests with all the guidelines.

pkgs/development/python-modules/pyobjc-core/default.nix Outdated Show resolved Hide resolved
pkgs/development/python-modules/pyobjc-core/default.nix Outdated Show resolved Hide resolved
pkgs/development/python-modules/pyobjc-core/default.nix Outdated Show resolved Hide resolved
pkgs/development/python-modules/pyobjc-core/default.nix Outdated Show resolved Hide resolved
pkgs/development/python-modules/pyobjc-core/default.nix Outdated Show resolved Hide resolved
@adrian-gierakowski
Copy link
Contributor

would be great to have this merged

@ferrine
Copy link
Contributor Author

ferrine commented Sep 12, 2024

Any more issues there?

@ferrine ferrine force-pushed the new/pyobjc-core branch 2 times, most recently from 5931b48 to 986077d Compare September 13, 2024 15:02
@ofborg ofborg bot added the 11.by: package-maintainer This PR was created by the maintainer of the package it changes label Sep 13, 2024
@@ -0,0 +1,117 @@
# inpired by https://github.com/input-output-hk/lace/blob/0fd166666cc454171811b307050d0815452bea82/nix/lace-blockchain-services/internal/any-darwin.nix#L339
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
# inpired by https://github.com/input-output-hk/lace/blob/0fd166666cc454171811b307050d0815452bea82/nix/lace-blockchain-services/internal/any-darwin.nix#L339

done
# impurities:
( grep -RF '/usr/bin/xcrun' || true ; ) | cut -d: -f1 | while IFS= read -r file ; do
sed -r "s+/usr/bin/xcrun+$(${lib.getExe pkgs.which} xcrun)+g" -i "$file"
Copy link
Member

Choose a reason for hiding this comment

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

We want to use which instead of pkgs.which

checkPhase = ''
# TODO: This library does not follow standard testing with pytest
# and implemented its own test runner bootstrapping unittest
python3 setup.py test
Copy link
Member

Choose a reason for hiding this comment

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

That command is deprecated. Can we use pytest?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I tried, it just fails with internal errors, not running any tests. In the source code testing is managed by this code and has additional bootstrapping in setup.py

let
appleSDK = darwin.apple_sdk_11_0;
inherit (appleSDK) MacOSX-SDK objc4;
darwinFrameworks = appleSDK.frameworks;
Copy link
Member

Choose a reason for hiding this comment

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

Can we reduce the shorthands?

@frankplow
Copy link

frankplow commented Oct 23, 2024

It looks like the oustanding requested changes, with the exception of the checkPhase as explained by the contributor, were addressed in c0ea0f0. Is there anything else blocking this being merged?

@sarahec
Copy link
Contributor

sarahec commented Nov 6, 2024

@ferrine Are you on Matrix? I've been chatting with @emilazy about this PR there and there's now a much easier way to do it. Your work just fell into a crack between the old way and the new way.

There's a lot of interest in getting this done.

@ferrine
Copy link
Contributor Author

ferrine commented Nov 10, 2024

Not yet on matrix, let me join

@sarahec
Copy link
Contributor

sarahec commented Nov 10, 2024

This is about to become much simpler. A build of darwin.libffi is coming: #354108

The rest of the build becomes easier. You can remove the darwin import and all of the BuildInputs (and the xcodebuild reference); these are all provided automatically for Darwin builds now.

I can take a look at the unusual test setup and see if I can fit it into the standard model. The same for replacing the substitutions with patches (it's much clearer to read then).

@reckenrode
Copy link
Contributor

reckenrode commented Nov 11, 2024

I was waiting on the checks to finish before merging #354108. It’s merged now, so you should be able to use it for pyobjc.

@sarahec
Copy link
Contributor

sarahec commented Nov 17, 2024

@ferrine could you rebase this over master, please? It's the one thing I can't do for you directly.

@ferrine
Copy link
Contributor Author

ferrine commented Nov 19, 2024

@ferrine could you rebase this over master, please? It's the one thing I can't do for you directly.

Did that today and got two errors in tests, will push soon

@ferrine
Copy link
Contributor Author

ferrine commented Nov 19, 2024

These new errors appeared

error: builder for '/nix/store/vp41w5311igaw6rjz98qriwk3nadfzda-python3.12-pyobjc-core-10.3.1.drv' failed with exit code 1;
       last 25 log lines:
       > test_cannot_create (PyObjCTest.test_varlist.TestVarlistVarious.test_cannot_create) ... ok
       >
       > ======================================================================
       > FAIL: testSignatureCount (PyObjCTest.test_splitsig.SplitSignatureTest.testSignatureCount) (cls='NSObject', sel=b'_ns:setObservationTrackingDictionary:')
       > ----------------------------------------------------------------------
       > Traceback (most recent call last):
       >   File "/private/tmp/nix-build-python3.12-pyobjc-core-10.3.1.drv-0/pyobjc_core-10.3.1/PyObjCTest/test_splitsig.py", line 174, in testSignatureCount
       >     self.assertEqual(
       > AssertionError: 1 != 2 : _ns:setObservationTrackingDictionary: [1:2] (b'v', b'@', b':', b'@') <objective-c class NSObject at 0x1f93a0330>
       >
       > ======================================================================
       > FAIL: testSignatureCount (PyObjCTest.test_splitsig.SplitSignatureTest.testSignatureCount) (cls='NSObject', sel=b'isNSURL::')
       > ----------------------------------------------------------------------
       > Traceback (most recent call last):
       >   File "/private/tmp/nix-build-python3.12-pyobjc-core-10.3.1.drv-0/pyobjc_core-10.3.1/PyObjCTest/test_splitsig.py", line 174, in testSignatureCount
       >     self.assertEqual(
       > AssertionError: 0 != 2 : isNSURL:: [0:2] (b'B', b'@', b':') <objective-c class NSObject at 0x1f93a0330>
       >
       > ----------------------------------------------------------------------
       > Ran 3786 tests in 475.284s
       >
       > FAILED (failures=2, skipped=4, expected failures=3)
       > SUMMARY: {'count': 3786, 'fails': 2, 'errors': 0, 'xfails': 3, 'xpass': 0, 'skip': 4}
       > error: some tests failed
       > hello
       For full logs, run 'nix log /nix/store/vp41w5311igaw6rjz98qriwk3nadfzda-python3.12-pyobjc-core-10.3.1.drv'.

Comment on lines +35 to +46
# TODO: Make patch for setup.py
# ignore the manual include flag for ffi, appears that it needs a very specific ffi from sdk (needs confirmation)
substituteInPlace setup.py --replace-fail '"-I/usr/include/ffi"' '#"-I/usr/include/ffi"'
# make os.path.exists that can spoil objc4 return True
substituteInPlace setup.py --replace-fail 'os.path.join(self.sdk_root, "usr/include/objc/runtime.h")' '"/"'

# Turn off clang’s Link Time Optimization, or else we can’t recognize (and link) Objective C .o’s:
sed -r 's/"-flto=[^"]+",//g' -i setup.py
# Fix some test code:
grep -RF '"sw_vers"' | cut -d: -f1 | while IFS= read -r file ; do
sed -r "s+"sw_vers"+"/usr/bin/sw_vers"+g" -i "$file"
done
Copy link
Member

Choose a reason for hiding this comment

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

Not sure about the test failures, but all of this should now be unnecessary.

Copy link
Contributor

@reckenrode reckenrode Nov 20, 2024

Choose a reason for hiding this comment

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

I agree the SDK and LTO stuff should be unnecessary. LTO was fixed with the ld64 update in #307880.

The sw_vers stuff might still be?

Comment on lines +62 to +71
# Fixes impurities in the package and fixes darwin min version
# TODO: Propose a patch that fixes it in a better way
# Force it to target our ‘darwinMinVersion’, it’s not recognized correctly:
grep -RF -- '-DPyObjC_BUILD_RELEASE=%02d%02d' | cut -d: -f1 | while IFS= read -r file ; do
sed -r '/-DPyObjC_BUILD_RELEASE=%02d%02d/{s/%02d%02d/${
lib.concatMapStrings (lib.fixedWidthString 2 "0") (
lib.splitString "." stdenv.targetPlatform.darwinMinVersion
)
}/;n;d;}' -i "$file"
done
Copy link
Member

Choose a reason for hiding this comment

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

This is also likely unnecessary.

Copy link
Contributor

Choose a reason for hiding this comment

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

darwinMinVersion probably shouldn’t be used even if it were. Build scripts should get the minimum version from MACOSX_DEPLOYMENT_TARGET.

@domenkozar
Copy link
Member

This is one of the last things to merge cachix/devenv-nixpkgs#9, how can I help?

@emilazy
Copy link
Member

emilazy commented Nov 20, 2024

I believe @sarahec was working on this. I’ll ask if there’s anything I can do to help the process, since this blocks a lot of things.

Edit: Though looking at the current state of the PR it seems like it should probably be good to merge with a little clean‐up and figuring out what to do with the failing tests (maybe just disable them if we’re already disabling a bunch?)

@sarahec
Copy link
Contributor

sarahec commented Nov 20, 2024

I believe @sarahec was working on this

Apologies. I spent yesterday getting an updated ID and passport and have been away from the keyboard.

@sarahec
Copy link
Contributor

sarahec commented Nov 20, 2024

I have this working and just need to figure out how to send the changes

@sarahec
Copy link
Contributor

sarahec commented Nov 21, 2024

Ugh. There's a bunch of patches missing. I may have to open a fresh PR and link back to this one.

@ferrine
Copy link
Contributor Author

ferrine commented Nov 21, 2024

I'm happy if you help with this

@sarahec
Copy link
Contributor

sarahec commented Nov 22, 2024

I finished the patch. Unfortunately, I had to open a new PR (#358063)

It couldn't be done here in suggestions, nor could I push code to this PR.

@domenkozar domenkozar closed this Nov 22, 2024
@ferrine
Copy link
Contributor Author

ferrine commented Nov 29, 2024

No problems, the progress you did is huge step forward anyway

@ferrine ferrine deleted the new/pyobjc-core branch November 29, 2024 18:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
6.topic: python 8.has: package (new) This PR adds a new package 10.rebuild-darwin: 1-10 10.rebuild-linux: 0 This PR does not cause any packages to rebuild on Linux 11.by: package-maintainer This PR was created by the maintainer of the package it changes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

9 participants