Skip to content

Install on Windows using pkg-config from conda #13016

Closed

Description

@rth

The current way of installing from sources on Windows involves running the build_alllocal.cmd script which manually copies libz and libpng to the right location. Such approach doesn't work with e.g.,

pip install https://<some-url>/matplotlib.zip

where matplotlib.zip is the source distribution, taken e.g. from an open PR.

As far as I understand, on Linux this is solved by using pkg-config. On Windows, pkg-config can also be installed from the msys2 channel which is now parts of the default channel, as,

conda install m2w64-pkg-config

see conda-forge/pkg-config-feedstock#11 (comment)
This might help to detect the libpng/freetype libraries (I'm not fully sure), however in any case, install fails while linking libpng,

[...]
  REQUIRED DEPENDENCIES AND EXTENSIONS
    install_requires: yes [handled by setuptools]
            freetype: yes [Using unknown version found on system.]
                 png: yes [Using unknown version found on system.]
[...]

C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\BIN\x86_amd64\link.exe /nologo /INCREMENTAL:NO /LTCG /DLL /MANIFEST:EMBED,ID=2 /MANIFESTUAC:NO /LIBPATH:C:\ProgramData\Miniconda3\envs\laserbeam-env\Library\lib /LIBPATH:C:\ProgramData\Miniconda3\envs\laserbeam-env\libs /LIBPATH:C:\ProgramData\Miniconda3\envs\laserbeam-env\PCbuild\amd64 "/LIBPATH:C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\LIB\amd64" "/LIBPATH:C:\Program Files (x86)\Windows Kits\10\lib\10.0.10240.0\ucrt\x64" "/LIBPATH:C:\Program Files (x86)\Windows Kits\8.1\lib\winv6.3\um\x64" png.lib z.lib /EXPORT:PyInit__png build\temp.win-amd64-3.7\Release\src/_png.obj build\temp.win-amd64-3.7\Release\src/mplutils.obj /OUT:build\lib.win-amd64-3.7\matplotlib\_png.cp37-win_amd64.pyd /IMPLIB:build\temp.win-amd64-3.7\Release\src\_png.cp37-win_amd64.lib
    LINK : fatal error LNK1181: cannot open input file 'png.lib'
    error: command 'C:\\Program Files (x86)\\Microsoft Visual Studio 14.0\\VC\\BIN\\x86_amd64\\link.exe' failed with exit status 1181

See detailed_log.txt for more details (this builds the #11577 PR)

I'm wondering if this has anything to do with the fact that PkgConfig.has_pkgconfig is hardcoded to False in setupext.py when on Windows.

Opening this issue to track the usage of pkg-config on windows.

Versions

  • Operating system: Windows Server 2016 Datacenter
  • Matplotlib version: master branch
  • Python version: 3.7

Related: #9693

Activity

  1. anntzer commented on Dec 29, 2018

    @anntzer
    Contributor

    Does un-hardcoding has_pkgconfig result in a working build?
    If so, we may as well do that.

  2. rth commented on Dec 29, 2018

    @rth
    ContributorAuthor

    I have not investigated too much (among other things because I'm not familiar with pkg-config even on Linux or how matplotlib build works in details). Also I don't have a Windows machine to try it on at the moment... Opened this issue in case someone finds the above information useful.

  3. anntzer commented on Dec 29, 2018

    @anntzer
    Contributor

    No worries, we can keep this around for now.

  4. anntzer commented on Dec 29, 2018

    @anntzer
    Contributor

    In the meantime, if you want to install from the github zip on Windows, your best bet is probably to create z.lib and png.lib somewhere, then set the LINK environment variable to point to them, as documented in https://github.com/matplotlib/matplotlib/pull/13064/files#diff-26dee18463b5da190f343abcc74cf708R185.

  5. anntzer commented on Jan 2, 2019

    @anntzer
    Contributor

    I looked a bit into it; it's actually not too hard to use pkg-config on Windows too once #13064 is merged (specifically, the "don't-try-to-parse-pkgconfig-output" part -- then we can just use pkg-config --msvc-syntax). However, there's also the issue that the libpng pkg-config files are actually invalid (conda-forge/libpng-feedstock#26), moreover they are only shipped by conda-forge and upstream libpng explicitly does not intend the pkg-config files to be used on Windows (conda-forge had to patch that) so I'm not sure how I feel about using them here.

  6. anntzer commented on Jan 3, 2019

    @anntzer
    Contributor

    Proposing to close this for the reasons above (there is no one distributing useful pkg-config files for libpng on Windows that I'm aware of and libpng does not intend these files to be used on Windows either).
    Also the general situation should already become better after #13077/#13064.

  7. anntzer commented on Jan 6, 2019

    @anntzer
    Contributor

    Closing per above; thanks for the suggestion @rth and feel free to further comment on Windows builds.

  8. rth commented on Jan 6, 2019

    @rth
    ContributorAuthor

    Thanks for investigating this possibility!

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions