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

kicad: python2 -> python3 #72813

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from 3 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
47 changes: 22 additions & 25 deletions pkgs/applications/science/electronics/kicad/default.nix
@@ -1,11 +1,11 @@
{ wxGTK, lib, stdenv, fetchurl, fetchFromGitHub, cmake, libGLU_combined, zlib
{ lib, stdenv, fetchurl, fetchFromGitHub, cmake, libGLU_combined, zlib
, libX11, gettext, glew, glm, cairo, curl, openssl, boost, pkgconfig
, doxygen, pcre, libpthreadstubs, libXdmcp
, wrapGAppsHook
, makeWrapper, hicolor-icon-theme, gsettings-desktop-schemas
, swig, lndir
, oceSupport ? true, opencascade
, ngspiceSupport ? true, libngspice
, swig, python, pythonPackages
, lndir
, wxGTK, python, pythonPackages, wxPython # defined in all-packages.nix
}:

assert ngspiceSupport -> libngspice != null;
Expand Down Expand Up @@ -35,43 +35,34 @@ in stdenv.mkDerivation rec {
sha256 = "1r60dgh6aalbpq1wsmpyxkz0nn4ck8ydfdjcrblpl69k5rks5k2j";
};

postPatch = ''
substituteInPlace CMakeModules/KiCadVersion.cmake \
--replace no-vcs-found ${version}
'';

cmakeFlags = [
"-DKICAD_SCRIPTING=ON"
"-DKICAD_SCRIPTING_PYTHON3=ON"
"-DKICAD_SCRIPTING_MODULES=ON"
"-DKICAD_SCRIPTING_WXPYTHON=ON"
# nix installs wxPython headers in wxPython package, not in wxwidget
# as assumed. We explicitely set the header location.
"-DCMAKE_CXX_FLAGS=-I${pythonPackages.wxPython}/include/wx-3.0"
"-DwxPYTHON_INCLUDE_DIRS=${pythonPackages.wxPython}/include/wx-3.0"
"-DKICAD_SCRIPTING_WXPYTHON_PHOENIX=ON"
] ++ optionals (oceSupport) [ "-DKICAD_USE_OCE=ON" "-DOCE_DIR=${opencascade}" ]
++ optional (ngspiceSupport) "-DKICAD_SPICE=ON";

nativeBuildInputs = [
cmake
doxygen
pkgconfig
wrapGAppsHook
pythonPackages.wrapPython
lndir
];
pythonPath = [ pythonPackages.wxPython ];
propagatedBuildInputs = [ pythonPackages.wxPython ];

pythonPath = [ wxPython ];
propagatedBuildInputs = [
wxPython
pythonPackages.six
];

buildInputs = [
libGLU_combined zlib libX11 wxGTK pcre libXdmcp glew glm libpthreadstubs
cairo curl openssl boost
swig (python.withPackages (ps: with ps; [ wxPython ]))
libGLU_combined zlib libX11 pcre libXdmcp glew glm libpthreadstubs
cairo curl openssl boost wxGTK swig wxPython
] ++ optional (oceSupport) opencascade
++ optional (ngspiceSupport) libngspice;

# this breaks other applications in kicad
dontWrapGApps = true;

passthru = {
i18n = mkLib version "i18n" "1dk7wis4cncmihl8fnic3jyhqcdzpifchzsp7hmf214h0vp199zr" {
buildInputs = [
Expand Down Expand Up @@ -103,11 +94,17 @@ in stdenv.mkDerivation rec {
done
'';

# GSETTINGS_SCHEMAS_PATH includes gtk twice, so wrapProgram with ${wxGTK.gtk} is used instead of wrapGApp
# since wrapGApp needs most of these set explicitly anyway (with dontWrapGApps = true;), lets not depend on it
preFixup = ''
buildPythonPath "$out $pythonPath"
gappsWrapperArgs+=(--set PYTHONPATH "$program_PYTHONPATH")
Copy link
Member

@evils evils Nov 10, 2019

Choose a reason for hiding this comment

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

doh, this line (101) isn't used anymore, the --set should either be added to wrapProgram
or it's not needed, you found scripting to work?

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 haven't given it thorough testing, but yes it appears to work.

Copy link
Member

Choose a reason for hiding this comment

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

i can't launch the python shell from pcbnew, got something working, just cleaning up the commit

Copy link
Member

Choose a reason for hiding this comment

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

ok, fixed here
also had to wrap pcbnew, otherwise python doesn't work if you run it directly

Copy link
Contributor Author

Choose a reason for hiding this comment

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

looks good to me. i've included it in the pr


wrapGApp "$out/bin/kicad" --prefix LD_LIBRARY_PATH : "${libngspice}/lib"
wrapProgram "$out/bin/kicad" \
--prefix LD_LIBRARY_PATH : "${libngspice}/lib" \
--prefix XDG_DATA_DIRS : "${wxGTK.gtk}/share/gsettings-schemas/${wxGTK.gtk.name}" \
--prefix XDG_DATA_DIRS : ""${gsettings-desktop-schemas}/share/gsettings-schemas/${gsettings-desktop-schemas.name} \
--prefix XDG_DATA_DIRS : "${hicolor-icon-theme}/share" \
--prefix XDG_DATA_DIRS : "$out/share"
'';

meta = {
Expand Down
6 changes: 4 additions & 2 deletions pkgs/top-level/all-packages.nix
Expand Up @@ -23817,8 +23817,10 @@ in
fped = callPackage ../applications/science/electronics/fped { };

kicad = callPackage ../applications/science/electronics/kicad {
wxGTK = wxGTK30;
boost = boost160;
wxGTK = wxGTK30.override { withGtk2 = false; };
Copy link
Member

Choose a reason for hiding this comment

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

If #73145 gets merged before this, the override part of this can be removed.

pythonPackages = python3Packages;
python = python3;
wxPython = python3Packages.wxPython_4_0;
};
kicad-with-packages3d = kicad.overrideAttrs (old: { modules = old.modules ++ [ old.passthru.packages3d ]; });

Expand Down