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

Definitive docs for how to compile on Windows #1717

Closed
dhyams opened this issue Jan 29, 2013 · 26 comments
Closed

Definitive docs for how to compile on Windows #1717

dhyams opened this issue Jan 29, 2013 · 26 comments

Comments

@dhyams
Copy link
Contributor

dhyams commented Jan 29, 2013

I've managed to compile matplotlib under Windows 7, but it was a bit of a fight and I felt like a kludged one too many things. I've not been able to find a guide for building matplotlib on Windows, except for a smattering of newsgroup posts a long time ago (http://sourceforge.net/mailarchive/message.php?msg_id=27961105)

Really this info needs to be on the website before it becomes a lost art; apparently someone is doing it (Christophe probably?) because the Windows binary releases continue to show up ;)

@pelson
Copy link
Member

pelson commented Feb 4, 2013

As you say, @cgohlke is probably the best person for this. @dhyams - did you write up what you did so that it might reduce the total work that is needed to complete this issue?

Cheers,

@dhyams
Copy link
Contributor Author

dhyams commented Feb 7, 2013

No, I've not written anything up yet; I will do so as soon as I have the chance. I'm afraid that half of it is going to be bad practice though, and possibly a little embarrassing to me ;)

@pelson
Copy link
Member

pelson commented Feb 7, 2013

and possibly a little embarrassing to me

TBH I have tried in the past to build on Windows, and failed pretty miserably - I find that more embarrassing - and you never know, you might learn something! 😄

@dhyams
Copy link
Contributor Author

dhyams commented Feb 9, 2013

OK, here's something get the ball rolling. Comments welcome....this took a lot longer than I anticipated...dang windows ;)

https://www.dropbox.com/s/vdslb2mt1dju8ao/matplotlib_compile_win32_v1.html

https://www.dropbox.com/s/csusx7ykgtd0yom/How%20to%20compile%20Matplotlib%20under%20Windows.docx

@mdboom
Copy link
Member

mdboom commented Feb 11, 2013

Haven't had a chance to try these out yet, but just wanted to say thanks to all for working on this. This is very good stuff to have!

@dhyams
Copy link
Contributor Author

dhyams commented Feb 11, 2013

Thanks mdboom. In my guide, I made it a priority not to "cheat" and use cgohlke premade library binaries. Not that I think he cheated (obviously!), but part of the gist of my raising this issue was to enable everyone to build, even if something were to happen to whomever is building the windows binaries (cgholke I presume).

@cgohlke: You mention in your guide that this isn't the procedure you use to build the distribution binaries...so what's different? It is something trivial, or something important that others might need to know? Especially on Windows, the smallest detail can really throw a monkey wrench into things...

@dhyams
Copy link
Contributor Author

dhyams commented Feb 11, 2013

It seems that some of my comments were not taken well; that was not my intention. This issue report was born from my own struggles in getting matplotlib compiled under Windows, searching on the website and through newsgroups for the "right" way to do it, and not finding anything.

I never meant to imply that only one person had ever built on Windows. I put the word "definitive" in the title of this issue, because there's no telling what hacks or shortcuts were taken by these others; I know, because I'm one of the "others". Maybe they did it right, maybe not...but no one ever wrote it down until now.

I didn't want to use matplotlib-1.x-windows-link-libraries.zip because I figured that most people (including me) would have a distaste for downloading binaries from someone's personal website; I know that I can trust you, but the average person I would think (if they are prudent at all) would have serious pause. I looked at the existence of the link-libraries.zip as a convenience for the "quick and dirty" build, but not something that should be part of any official build instructions.

As it stands, I've wasted an entire evening and greater part of a Saturday morning putting together instructions that are bad (I didn't know that the GnuWin32 binaries were outdated, but after investigating, they certainly are), and have apparently rubbed one of the main devs the wrong way. So I'll bow out of this discussion, and the Powers That Be can decide what to do with the info enclosed herein.

@pelson
Copy link
Member

pelson commented Feb 12, 2013

and have apparently rubbed one of the main devs the wrong way. So I'll bow out of this discussion

There is room for everybody here - if we all agreed all of the time we would have a problem! 😄

@mdboom
Copy link
Member

mdboom commented Feb 12, 2013

@dhyams: I applaud you for taking the initiative on this. I, too, even as the lead developer of matplotlib, have found it hard to piece together current information about building on Windows -- it's been on my TODO list for a long time to document it well, but, like you, found it hard to piece together best practices from all of the available options -- so I was really pleased to see someone take this on. I'm hoping that some confluence of your work and the new information from @cgohlke can find its way into the official docs and be maintained.

jbmohler pushed a commit to jbmohler/matplotlib-winbuild that referenced this issue Dec 5, 2013
@jbmohler
Copy link
Contributor

jbmohler commented Dec 5, 2013

I took the liberty of lifting cgohlke's scripts from this page to a new repository (https://github.com/jbmohler/matplotlib-winbuild). I had to update a few of the versions for the dependencies. I'd welcome pull requests if other people want to improve those scripts.

@pelson
Copy link
Member

pelson commented Dec 9, 2013

Thanks @jbmohler. I think this issue has gone stale, partly as I don't believe there is a tangible outcome in the description. The contents of this issue are here for posterity, but I suggest we go ahead and close this issue. @mdboom?

@mdboom
Copy link
Member

mdboom commented Dec 10, 2013

Apologies for this going stale. I'd still like to see some of this information moved into the docs proper (or at least a link to some good canonical resource), and we have a good start for that here.

@JamesRamm
Copy link

BTW, I have had good luck using @cgohlke batch script to build the dependencies for python 2.7.

Most of us building probably only want to build for 1 version of python and already have python installed with python.exe on our PATH

If you meet that criteria and are using python 2.7 only (I think this will count for the majority still?), you will need to make these edits to the batch file:

replace py -3 with python

and replace

echo import sys, os, urllib.parse, urllib.request > fetch.py
echo name = urllib.parse.urlsplit(sys.argv[1])[2].split('/')[-1] >> fetch.py
echo if not os.path.exists(name): >> fetch.py
echo     print("Fetching", sys.argv[1]) >> fetch.py
echo     content = urllib.request.urlopen(sys.argv[1]).read() >> fetch.py
echo     with open(name, 'wb') as fd: >> fetch.py
echo         fd.write(content) >> fetch.py

with

echo import sys, os, urllib, urlparse > fetch.py
echo name = urlparse.urlsplit(sys.argv[1])[2].split('/')[-1] >> fetch.py
echo if not os.path.exists(name): >> fetch.py
echo     print("Fetching", sys.argv[1]) >> fetch.py
echo     content = urllib.urlopen(sys.argv[1]).read() >> fetch.py
echo     with open(name, 'wb') as fd: >> fetch.py
echo         fd.write(content) >> fetch.py

Also, the file assumes that nmake is on your system PATH. I don't think this is usually the case when installing the windows SDK? At least not on my machine...

In this case, you need to use the SET command at the top to set the path to nmake, which is usually something like:
This is usually something like C:\program files (x86)\Microsoft Visual Studio 12.0\VC\bin\nmake.exe

then replace all calls to nmake with %NMAKE%

You are also going to want to remove the sections of the script where there are irrelevant builds.
I.E I only wanted to build for python 27, 64 bit, so I only kept the 'build' section that began with:
rem Build for VC 2008 64 bit

The URL for the zlib download also needs updating (best to always check the URLS).

@cgohlke
Copy link
Contributor

cgohlke commented Jul 26, 2014

Also, the file assumes that nmake is on your system PATH. I don't think this is usually the case when installing the windows SDK?

Calling SetEnv.Cmd takes care of that.

@JamesRamm
Copy link

I'm finding that my build of MPL 1.4.xrc2 has extremely poor performance. It is definetly something to do with my build as I have tried using the installer @cgohlke just released and there is no discernible difference.

In my build, load time and resize events in particular (of what I've tested so far) are extremely sluggish.

I'm wondering if anyone else has come across this and has any tips to improve? I imagine it must be related to compilation of linked libraries?

EDIT: I noted that my fork of MPL was about 2-3 weeks out of date. Updating the fork and using the ext. library versions given by @cgohlke (i.e. not the latest versions) seems to have cleared it up.

@tacaswell tacaswell added the doc label Aug 17, 2014
@tacaswell tacaswell added this to the v1.4.0 milestone Aug 17, 2014
@tacaswell
Copy link
Member

If the text if this issue is not in the docs, it should be.

@tacaswell
Copy link
Member

@jbmohler @Tillsten Can one or both of you work on this? I see that the long set of directions from @cgohlke is for 1.2 and might be out of date. I don't have the expertise to sort that out.

Could you also add the links to @jbmohler 's build scripts discussed in #3388.

This should go in the tree near https://tacaswell.github.io/matplotlib/users/installing.html

I have labeled this as not-a-blocker as it should be done, but I intend to tag 1.4.0 this weekend with or with out it.

@jbmohler
Copy link
Contributor

I am working on a PR with the documentation to point to my build scripts & also get an e-mail out to -dev offering that repo.

@tacaswell
Copy link
Member

@jbmohler Please be aware of #3397 so we don't cause massive impossible to merge prose conflicts.

@tacaswell
Copy link
Member

closed by #3401

@WJTey
Copy link

WJTey commented Jul 18, 2016

Thank you for providing the matplotlib. Now I 'm working on a small research project with Python 2.7 and installed Microsoft VS 2012 on my laptop. And this make me unable to run python matplotlib-winbuild\buildall.py. Do you have other alternatives to solve this?

@QuLogic
Copy link
Member

QuLogic commented Jul 19, 2016

Firstly, this bug was closed almost two years ago, and secondly, it is only a change in documentation. Please open a new issue with a full description of the problem. Comments on really old issues are just going to get lost.

@efiring
Copy link
Member

efiring commented Jul 19, 2016

@WJTey I think your question might better be directed to the matplotlib-users@python.org or other mailing list; it is a "how do I manage MS compilers for compiling python extensions" question, not a matplotlib issue.

@tacaswell
Copy link
Member

If you want to build c-extensions from windows, you can not use VS2012 (it must be VS2008 for compatibility reasons). It seems that https://www.microsoft.com/en-us/download/details.aspx?id=44266 is now the recommended compiler to use for python 2.7 extensions on windows.

If you go to python 3.5+ building on windows is decoupled from an exact version of VS and will be much easier to maintain going forward.

@smaudet
Copy link

smaudet commented Nov 5, 2016

"If you go to python 3.5+ building on windows is decoupled from an exact version of VS and will be much easier to maintain going forward."

How I wish that were true.

This build is still kind of a kludge - doesn't seem to want to build well, and there's a lot of needing of specific versions/instructions missing. The only reasons I'm sticking with this, is that I want to update/increase my knowledge of the C++/C and python build systems...

Otherwise I'd say the build is garbage, on windows anyways.

@smaudet
Copy link

smaudet commented Nov 6, 2016

Frightful problems I have encountered:

Mismatched C RT libraries
Hard-coded dependence on msvc 2010
Mysterious segfaults
Contradictory build instructions
Undocumented dependencies on empty files being present in the filesystem

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

No branches or pull requests