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 QGIS and dependencies on darwin #36902

Merged
merged 10 commits into from Mar 21, 2018
Merged

Conversation

mpickering
Copy link
Contributor

Motivation for this change

QGIS didn't build on darwin but now it does. I have only tested these patches on OSX. I'm not sure the original QGIS derivation worked properly on nixos anyway, is anyone using it?

It would be good to test the following attributes using @GrahamcOfBorg

grass qgis

The rest should be dependencies of qgis.

cc @viric

Things done
  • Tested using sandboxing (nix.useSandbox on NixOS, or option build-use-sandbox in nix.conf on non-NixOS)
  • Built on platform(s)
    • NixOS
    • macOS
    • other Linux distributions
  • Tested via one or more NixOS test(s) if existing and applicable for the change (look inside nixos/tests)
  • Tested compilation of all pkgs that depend on this change using nix-shell -p nox --run "nox-review wip"
  • Tested execution of all binary files (usually in ./result/bin/)
  • Fits CONTRIBUTING.md.

@GrahamcOfBorg GrahamcOfBorg added the 6.topic: darwin Running or building packages on Darwin label Mar 13, 2018
ifneq ($(findstring darwin,$(ARCH)),)
@# enable OSX Help Viewer
- @/bin/ln -sfh "$(INST_DIR)/docs/html" /Library/Documentation/Help/GRASS-$(GRASS_VERSION_MAJOR).$(GRASS_VERSION_MINOR)
+ #@/bin/ln -sfh "$(INST_DIR)/docs/html" /Library/Documentation/Help/GRASS-$(GRASS_VERSION_MAJOR).$(GRASS_VERSION_MINOR)
Copy link
Member

Choose a reason for hiding this comment

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

Is this commenting it out? If so, maybe prefer just removing it completely.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes it is commented out. I can remove it completely as well, I was just trying to make the least change possible.

Copy link
Member

Choose a reason for hiding this comment

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

I would just remove it, that makes it much easier to read the diff.

fcgi libspatialindex libspatialite postgresql qjson qca2 txt2tags ] ++
fcgi libspatialindex libspatialite postgresql qjson qca2 txt2tags pkgconfig
(stdenv.lib.optional stdenv.isDarwin darwin.apple_sdk.frameworks.IOKit)
(stdenv.lib.optional stdenv.isDarwin darwin.apple_sdk.frameworks.ApplicationServices)
Copy link
Member

Choose a reason for hiding this comment

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

Maybe append lib.optionals stdenv.isDarwin (with darwin.apple_sdk.frameworks; [IOKit ApplicationServices]) instead of having these individual entries

Copy link
Member

Choose a reason for hiding this comment

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

Extending the callPackage scope in all-packages.nix with frameworks is the most common approach.

++ stdenv.lib.optional stdenv.isDarwin
(["-DCMAKE_FIND_FRAMEWORK=never"]
++ ["-DQGIS_MACAPP_BUNDLE=0"]);
# ++ ["-DCMAKE_BUILD_TYPE=RelWithDebInfo"];
Copy link
Member

Choose a reason for hiding this comment

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

Was this left in intentionally?

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 was unsure whether to leave it in or not as it's very useful to see the terminal output when running the application. Like I said, the derivation is currently not perfect but much better than what is currently in the repo.

Copy link
Member

Choose a reason for hiding this comment

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

The release type affects the terminal output? 🤦‍♂️ ah well, maybe add a comment clarifying how it's useful then

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Well it's a graphical application. Building with debug info makes the terminal output very verbose as you use the gui.

Copy link
Member

Choose a reason for hiding this comment

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

No, the actual thing that debug info refers to is the debugging symbols that map the machine code sections back to source code. Terminal output should not usually be affected, but it's up to the application developer whether that's actually the case.

@@ -68,7 +68,7 @@ stdenv.mkDerivation rec {
wrapPythonPrograms
'';

enableParallelBuilding = true;
enableParallelBuilding = false;
Copy link
Member

Choose a reason for hiding this comment

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

Why?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

There were files missing in the installation before I set it to false.

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 worth documenting in a comment and/or the commit message.

wrapProgram $out/bin/qgis \
--prefix PYTHONPATH : $PYTHONPATH \
--prefix LD_LIBRARY_PATH : ${stdenv.lib.makeLibraryPath [ openssl ]}
'') ++
Copy link
Member

Choose a reason for hiding this comment

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

Currently evaluation fails as shown by our dear GrahamcOfBorg — strings are concatenated with +, not ++. Once this is fixed I can get ofborg to try building it :)

@lheckemann
Copy link
Member

@GrahamcOfBorg build grass qgis

@GrahamcOfBorg
Copy link

Failure on x86_64-darwin (full log)

Attempted: grass, qgis

Partial log (click to expand)

1 warning generated.
[ 49%] Building CXX object src/providers/wms/CMakeFiles/wmsprovider_a.dir/qgswmtsdimensions.cpp.o
[ 49%] Building CXX object src/providers/wms/CMakeFiles/wmsprovider_a.dir/qgsxyzconnection.cpp.o
[ 49%] Building CXX object src/providers/wms/CMakeFiles/wmsprovider_a.dir/moc_qgswmscapabilities.cxx.o
[ 49%] Building CXX object src/providers/wms/CMakeFiles/wmsprovider_a.dir/moc_qgswmsprovider.cxx.o
[ 49%] Building CXX object src/providers/wms/CMakeFiles/wmsprovider_a.dir/moc_qgswmssourceselect.cxx.o
[ 49%] Building CXX object src/providers/wms/CMakeFiles/wmsprovider_a.dir/moc_qgswmsconnection.cxx.o
[ 49%] Building CXX object src/providers/wms/CMakeFiles/wmsprovider_a.dir/moc_qgswmsdataitems.cxx.o
building of '/nix/store/gm535ymqawka4hsxpf7n95zc4p2ljwc9-qgis-2.18.16.drv' timed out after 1800 seconds
error: build of '/nix/store/gm535ymqawka4hsxpf7n95zc4p2ljwc9-qgis-2.18.16.drv' failed

@mpickering
Copy link
Contributor Author

The build takes over an hour locally on my machine so that time out seems expected.

@GrahamcOfBorg
Copy link

Failure on aarch64-linux (full log)

Attempted: grass, qgis

Partial log (click to expand)

                  ^~~~~
                  int
/build/hdf-4.2.12/hdf/src/tbbt.h:289:11: error: unknown type name 'VOID'
 HDFLIBAPI VOID        tbbtfree
           ^~~~
building of '/nix/store/6bmyb5w02zcghk85w67qb6v9wm1pambi-hdf-4.2.12.drv' timed out after 3600 seconds
cannot build derivation '/nix/store/4b809mcnfnhvilnm6rcm6zlw6bzcky20-gdal-2.2.3.drv': 1 dependencies couldn't be built
cannot build derivation '/nix/store/6qr0r6pfmsvn8xacnvkhi946r4cl6p4w-grass-7.2.2.drv': 1 dependencies couldn't be built
cannot build derivation '/nix/store/gbji5bk9lrfmnrzn3349i17i0axxfinr-qgis-2.18.16.drv': 2 dependencies couldn't be built
�[31;1merror:�[0m build of '/nix/store/6qr0r6pfmsvn8xacnvkhi946r4cl6p4w-grass-7.2.2.drv', '/nix/store/gbji5bk9lrfmnrzn3349i17i0axxfinr-qgis-2.18.16.drv' failed

@GrahamcOfBorg
Copy link

Failure on x86_64-linux (full log)

Attempted: grass, qgis

Partial log (click to expand)

/tmp/nix-build-qgis-2.18.16.drv-0/qgis-2.18.16/src/gui/../core/qgis.h:507:32: warning: extra ';' [-Wpedantic]
   _Pragma("GCC diagnostic pop");
                                ^
/tmp/nix-build-qgis-2.18.16.drv-0/qgis-2.18.16/src/gui/../core/qgsexpression.h:1602:1: note: in expansion of macro 'Q_NOWARN_DEPRECATED_POP'
 Q_NOWARN_DEPRECATED_POP
 ^~~~~~~~~~~~~~~~~~~~~~~
[ 42%] Building CXX object src/gui/CMakeFiles/qgis_gui.dir/moc_qgsowssourceselect.cxx.o
[ 42%] Building CXX object src/gui/CMakeFiles/qgis_gui.dir/moc_qgssourceselectdialog.cxx.o
building of ‘/nix/store/3vbhhzwg370dcg9vgv11i3mlhribyncg-qgis-2.18.16.drv’ timed out after 3600 seconds
error: build of ‘/nix/store/3vbhhzwg370dcg9vgv11i3mlhribyncg-qgis-2.18.16.drv’ failed

@mpickering
Copy link
Contributor Author

I rebased and applied the changes from the suggestions. I'm rebuilding now locally to verify that they work correctly.

postInstall =
(stdenv.lib.optionalString stdenv.isLinux ''
wrapProgram $out/bin/qgis \
--prefix PYTHONPATH : $PYTHONPATH \
Copy link
Member

Choose a reason for hiding this comment

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

use of prefix allows leaking in PTYTHONPATH. Typically it is better to use set

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It was like this before? Was it wrong before?

nativeBuildInputs = [ unzip ] ++ (if withQt5 then [ qmake ] else [ qmake4Hook ]);

# Fix Xcode 8 compilation problem
xcodePatch = fetchurl { url = "https://raw.githubusercontent.com/Homebrew/formula-patches/a651d71/qscintilla2/xcode-8.patch";
Copy link
Member

Choose a reason for hiding this comment

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

either add this directly in the patches list, or put it in a let in expression.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good idea.

@mpickering
Copy link
Contributor Author

I made the two changes @FRidh suggested.

@mpickering
Copy link
Contributor Author

I rebased onto staging. Thanks @copumpkin

@copumpkin
Copy link
Member

@grahamc I think borg got confused about the base branch switch somehow 😄or at least I hope this thing doesn't affect the stdenv!

@mpickering thanks!

@copumpkin copumpkin merged commit c7b3373 into NixOS:staging Mar 21, 2018
@mpickering
Copy link
Contributor Author

@copumpkin I am returning to this issue now looking at what is causing Syntax error at '__attribute__', have you got any ideas?

@mpickering
Copy link
Contributor Author

The source seems to be when compiling in the lib/python/ctypes folder if anyone runs into this later. I'm stopping my chase now as I found my files elsewhere.

@copumpkin
Copy link
Member

No real ideas, sorry!

@copumpkin
Copy link
Member

@mpickering actually needed qgis on Darwin today and it worked flawlessly, thanks again for fixing this!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

Successfully merging this pull request may close these issues.

None yet

7 participants