Open zonca opened 12 years ago
You mean, should we support building Windows DLLs? As far as the C++ part is concerned, this should work pretty smoothly if the Cygwin package is installed.. I don't have any experience with Intel and Microsoft compilers on Windows.
ok, I don't have experience with Windows compilers either, let's see if somebody that does is willing to collaborate on this. We'd be happy to support the effort.
we might consider using conda
I have temporary access to a Windows box at work now. I got as far as @ARepp. However, I think that it is going to be very hard to build the bundled healpix-cxx and cfitsio sources because there is no easy way to use Anaconda with Cygwin or MSYS.
I think that if we want to support Windows, then we must go back to using setuptools itself to build the libraries instead of running ./configure && make && make install
. We could still use pkg-config/pykg-config to attempt to build and link against pre-build libraries.
A few questions:
Oh---another question. Does healpy really have to link against cfitsio, or can we get all of the FITS functionality we need through pyfits/astropy at the Python level?
Hi,
Only healpix_cxx needs to link against cfitsio.
Healpy uses healpix_data_io.h for read_pixwin() and read_weight_ring() functions (which read the window and weights data files), so if healpix_cxx is linked against cfitsio, it should be enough. The include file healpix_data_io.h also doesn’t includes fitsio.h itself.
read_map() and family are only using pyfits/astropy.
Cyrille.
Le 27 avr. 2015 à 17:58, Leo Singer notifications@github.com a écrit :
Oh---another question. Does healpy really have to link against cfitsio, or can we get all of the FITS functionality we need through pyfits/astropy at the Python level?
— Reply to this email directly or view it on GitHub https://github.com/healpy/healpy/issues/25#issuecomment-96722703.
I'd be really pleased to see Healpy running on Windows. Many planetariums run on Windows, and an API for python is becoming more common. If needed, I have a number of Windows XP or Windows 8 machines I can test on. --Mike
I wanna ask that does the bug (environment can only contain strings) in installing healpy on windows be fixed? I try install healpy1.9.1 on my windows pc, but it has error that environment can only contain strings. The version of my python is 2.7.11 Any help is appreciative.
Hi there—I was never able to get it to work, so I ended up using another computer. Thus I don’t know if it’s been fixed or not.
Thanks,
Andrew
From: astroOcean [mailto:notifications@github.com] Sent: Friday, April 29, 2016 5:06 PM To: healpy/healpy healpy@noreply.github.com Cc: Andrew Repp repp@ifa.hawaii.edu; Mention mention@noreply.github.com Subject: Re: [healpy/healpy] [help] build healpy on Windows (#25)
I wanna ask that does the bug (environment can only contain strings) in installing healpy on windows be fixed? I try install healpy1.9.1 on my windows pc, but it has error that environment can only contain strings. The version of my python is 2.7.11 Any help is appreciative.
— You are receiving this because you were mentioned. Reply to this email directly or view it on GitHub https://github.com/healpy/healpy/issues/25#issuecomment-215928213
Thanks for your reply. Anyway, I can use it on my Linux system.
------------------ Original ------------------ From: "Andrew Repp"; Date: 2016年5月1日(星期天) 凌晨5:26 To: "healpy/healpy"; Cc: "astroOcean"; "Comment"; Subject: Re: [healpy/healpy] [help] build healpy on Windows (#25)
Hi there—I was never able to get it to work, so I ended up using another computer. Thus I don’t know if it’s been fixed or not.
Thanks,
Andrew
From: astroOcean [mailto:notifications@github.com] Sent: Friday, April 29, 2016 5:06 PM To: healpy/healpy healpy@noreply.github.com Cc: Andrew Repp repp@ifa.hawaii.edu; Mention mention@noreply.github.com Subject: Re: [healpy/healpy] [help] build healpy on Windows (#25)
I wanna ask that does the bug (environment can only contain strings) in installing healpy on windows be fixed? I try install healpy1.9.1 on my windows pc, but it has error that environment can only contain strings. The version of my python is 2.7.11 Any help is appreciative.
— You are receiving this because you were mentioned. Reply to this email directly or view it on GitHub <" target="_blank">https://github.com/healpy/healpy/issues/25#issuecomment-215928213>
— You are receiving this because you commented. Reply to this email directly or view it on GitHub
Hello,
So I manage to build healpy in Windows 10 using msys2. I have not tested if it is fully functional, but as far as I am concerned it is working great for me, so I thought I should share how I did it.
I had to hack a few things, but perhaps I am over-complicating things and I would not be surprised if I am doing something awful or unnecessary in the middle. Some of the steps I did may be fixed from the setup.py, I think. But anyway, this is what I did:
pacman -S --needed mingw-w64-x86_64-toolchain git subversion mercurial mingw-w64-x86_64-cmake mingw-w64-x86_64-cfitsio
prefix=/mingw64
libdir=${prefix}/Healpix_3.31/src/cxx/generic_gcc/lib
bindir=${prefix}/Healpix_3.31/src/cxx/generic_gcc/bin
includedir=${prefix}/Healpix_3.31/src/cxx/generic_gcc/include
Name: healpix Description: HealPix Version: 3.31 Libs: -L${libdir} -lhealpix_cxx -lcxxsupport -lsharp -lfftpack -lc_utils -lcfitsio -fopenmp Libs.private: -lm -lz Cflags: -I${includedir}
6. Tell python to use the mingw compiler by creating the disutils.cfg file in Lib/disutils in the python main directory, and fill it with
[build] compiler=mingw32 [build_ext] compiler=mingw32
This is where it gets non ideal, since I modified essential files in python, so if you know of a better alternative please let me know!
7. There is a problem with using ::hypot in the cmath package when called from python. I fixed this by including math.h in inlcude/pyconfig.h in the third line. I think it is possible to solve this by adding the math package before calling python.h in healpy/src/_healpy_pixel_lib.cc, but I couldn't test this.
8. The next issue arises from sysconfig.get_config_var("CC"), which returns None. In this case it should return mingw32. Since I do not know how to fix it, I added a catch in unixcompiler.py to set the compiler to mingw32 when it fails to get it from sysconfig (search for the line that contain the sysconfig.get_config_var("CC")). Aditionally, mingw32 needs to be recongnized as a gcc compiler, so one also needs to add `or compiler_name=='mingw32` in the `_is_gcc` function in the same file. This is super ugly and I do not like it...
9. Next, there is an issue arising from python not recognizing the g++ call as a 64 bit one with compiling. The specific error is `undefined reference to __imp_Py_InitModule4` . To solve this, we need to tell g++ to use the Msys64 dependence when calling gcc. I did this by adding `-D MS_WIN64` in the set_sexecutables variable from the Mingw32CCompiler in the /lib/disutils/cygwincompiler.py python file, specifically in the compiler, compiler_so and compiler_cxx variables. I am fine with this modificiation, since I will only have x64 compiler in my system, but I think this very very far from ideal... I believe this ugly hack can be avoided by setting the -D MS_WIN64 in the healpy setup.py, but again I am not sure...
Well, that is it! next you can just run pip install healpy and it should work.
Disclaimer: I am no expert and I probably do not know what I am doing, so please let me know if something is wrong here! Just wanted to comment that one of the things that bugs me the most is that I link a x64 compiler to the mingw32 compiler variable in python. Although this is apparently the way it should be done according to the [wiki](https://wiki.python.org/moin/WindowsCompilers)
Hope this helps!
thanks @Grillard , it would be a great contribution to the project if you can package this into a conda recipe and make a Pull Request to our repository for creating conda packages at https://github.com/conda-forge/healpy-feedstock
This way a conda package for windows could be automatically built for healpy
.
I had some spare budget that could be used to pay someone a $300 incentive to get healpy conda-forge version working for Windows (but needs to be in the next two months).
Not sure how relevant this is for the task at hand, but I'm currently assembling a package that contains most of my C++ codes (support library, pocketfft, libsharp, healpix_cxx and more) which has the following characteristics:
arr
class).Current state is available at https://gitlab.mpcdf.mpg.de/mtr/cxxbase.
This may be a good back end for healpy
to use once it is finished, but of course it's still far from complete and healpy
will need quite a lot of internal adjustments. In the longer term I think it's the way to go, however.
[Edit: remove icpc from the list, it doesn't have sufficient C++17 support yet.]
Yes, this looks like a good option!
Due to the pandemic many of us have project students working from home on Windows machines on projects needing healpy. I was able to get it installed via the Windows Subsystem for Linux, and available in a jupyter notebook.
In case useful to others I've put instructions below.
Restart your computer, and follow the instructions (which appear before windows starts) to enter BIOS.
Usually this means pressing DEL or F2 just after powering on.
Find the option to enable virtualization (exact name will depend on your system, can google your machine brand name + "enable virtualization" for instructions)
Follow these instructions to install Windows Subsystem for Linux: https://docs.microsoft.com/en-us/windows/wsl/install-win10 Following the instructions for WSL version 2, and choosing Ubuntu from the store.
Restart machine
Open the newly installed Ubuntu application from the Start menu and follow the setup instructions.
When they are complete, run these commands:
sudo apt-get update sudo apt-get upgrade sudo apt-get install python3 python3-pip
pip3 install numpy jupyter matplotlib healpy ipython jupyter
Quit ubuntu again, restart it, and run: ipython notebook --no-browser
Copy and paste the line starting http://localhost:8888/?token= into your normal windows web browser.
thanks @joezuntz! this is very helpful, I added instructions to https://github.com/healpy/healpy/blob/master/INSTALL.rst
I would appreciate windows version of this. I can get it working in virtual environment, but I am struggling to use other components on virtual environment. :)
Hello, I want to ask you what you did after seeing Healpy in your browser? I did not find the Healpy folder in the browser according to the above steps, but I found it in other ways. I copy it directly to the corresponding directory of the python installed in Windows. But when import healpy, the int.py function will report an error.
Still hoping healpy that supports windows. There are so many astro-related packages that rely on healpy and I can't use them.
Also looking for a windows version - I tried the WSL instructions but they didn't work for me. I'll try downloading the source code and have a look.
Thanks for the info - I do need healpy though as it is a dependency of the package I need for a collaborative pipeline.
I also managed to build healpy on Windows 10 using latest MSYS2 in UCRT64 environment:
after I got MSYS2 up and running on Windows 10 (following MSYS2 docs), I installed requirements in UCRT64 environment:
pacman -S --needed base-devel mingw-w64-ucrt-x86_64-gcc mingw-w64-ucrt-x86_64-toolchain git subversion mercurial mingw-w64-ucrt-x86_64-cmake
pacman -S mingw-w64-ucrt-x86_64-cfitsio
pacman -S mingw-w64-ucrt-x86_64-python-scipy
git clone ...
pip install ...
or SETUPTOOLS_USE_DISTUTILS=stdlib pip3 install ...
.Then, I installed healpix 3.82 C++ version following docs, copied lib/ and include/ contents to /ucrt64/lib/ and /ucrt64/include/
And finally, I got healpy 1.16.6 installed: SETUPTOOLS_USE_DISTUTILS=stdlib pip3 install healpy
.
Non-trivial task, but manageable.
https://github.com/msys2/setup-msys2 might help to accomplish this in GitHub Actions.
vcpkg supports building autoconf/automake libraries. @dakota002, would you try that please?
I also managed to build healpy on Windows 10 using latest MSYS2 in UCRT64 environment:
after I got MSYS2 up and running on Windows 10 (following MSYS2 docs), I installed requirements in UCRT64 environment:
- build tools:
pacman -S --needed base-devel mingw-w64-ucrt-x86_64-gcc mingw-w64-ucrt-x86_64-toolchain git subversion mercurial mingw-w64-ucrt-x86_64-cmake
- cfitsio:
pacman -S mingw-w64-ucrt-x86_64-cfitsio
- scipy:
pacman -S mingw-w64-ucrt-x86_64-python-scipy
- astropy: build from source
git clone ...
- other dependent packages were installed via
pip install ...
orSETUPTOOLS_USE_DISTUTILS=stdlib pip3 install ...
.Then, I installed healpix 3.82 C++ version following docs, copied lib/ and include/ contents to /ucrt64/lib/ and /ucrt64/include/ And finally, I got healpy 1.16.6 installed:
SETUPTOOLS_USE_DISTUTILS=stdlib pip3 install healpy
.Non-trivial task, but manageable.
@Angrite , I saw your post, and was interested in trying to reproduce your build of healpy
for Windows 10. I've been able to follow everything up until building astropy
from source, where I started encountering issues. What version of astropy
did you use, and what commands did you run in MSYS2 in order to build it?
At present, I've tried using python -m pip install -ve . --no-build-isolation --config-settings editable-verbose=true
, which the astropy
docs recommended, but found that there were key errors and missing files while going through the build process.
should we make available an exe packages for Windows users? is anybody willing to help?