Skip to content

Commit 725eeb6

Browse files
committed
Getting pydecenttree to work on Windows 10.
1. Had to add zlib and build/zlib folders to the include paths in pydecenttree/setup.py (to avoid errors about not finding zlib.h). 2. Had to recognize _WIN32 and _WIN64 to avoid Python's preferred compiler (I wonder, is it 32 bit?!) trying to include <unistd.h>
1 parent e8110f6 commit 725eeb6

File tree

4 files changed

+44
-3
lines changed

4 files changed

+44
-3
lines changed

doco/Compilation_on_Windows.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,5 +25,7 @@ At present (October 2022), the version of CMake that MS Code uses (3.23 or 3.24)
2525
Builds may fail outright (with no error messages), due to missing DLLs (libisl-23.dll, for example) (the version number might vary). If you are installing GCC using MSYS2 and pacman you may find it necessary to copy files from c:\msys64\user\bin (where pacman puts them!) into c:\msys64\mingw64\bin (which is where pacman probably should put them, but might not).
2626
<br><br>
2727
<h4>Compiling with Microsoft Code and the Visual Studio Compiler</h4>
28-
[todo: this bit not written yet]
28+
On Windows 10 (and 11) workstations, decenttree will compile with Visual Studio 2017 through Visual Studio 2022.
29+
It's recommended that you compile 64 bit versions (using the - x86_amd64 rather than the - amd64_x86 compiler toolkit, if both choices are available).
30+
2931

doco/pydecenttree.md

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,3 +54,42 @@ rm -r dist
5454
pip install -e .
5555
python3.11 test_pydecenttree.py
5656
```
57+
58+
<h3>With Python 3.11, on Windows 10 (or 11)</h3>
59+
<i>These instructions are probably not the best (and are as yet incomplete).
60+
I've got as far as installing python and numpy, but I haven't figured out how
61+
to get pip to build (let alone install) the pydecenttree module itself</i> -James.
62+
63+
Download Python via the Windows download page
64+
65+
[https://www.python.org/downloads/windows](https://www.python.org/downloads/windows).
66+
67+
Run the Python 3.11 app, and execute the commands
68+
```
69+
import ensurepip
70+
ensurepip.bootstrap()
71+
```
72+
73+
Open the command prompt and navigate to the folder where you installed python (for me this was c:\Users\james\AppData\Local\Programs\Python\Python311). Execute the command (alernatively you could add your Python install directory to your %PATH% and then you could execute the following command from any folder - I didn't):
74+
75+
```
76+
python -m pip install numpy
77+
```
78+
79+
Navigate to the pydecenttree folder (for me this was c:\Users\james\Source\repos\decenttree\pydecenttree).
80+
Run a command <i>like</i> this (replace C:\Users\james\AppData\Local\Programs\Python\Python311 with the directory
81+
to which you installed Python):
82+
83+
```
84+
C:\Users\james\AppData\Local\Programs\Python\Python311\Scripts\pip install -e .
85+
```
86+
87+
(if you get an error message about it not being able to find zconf.h, you may need
88+
to run CMake in the build subfolder of the decenttree project folder, either
89+
directly, or via VS Code or Microsoft VIsual Studio, to create a
90+
build\zconf.h header file)
91+
92+
(this is building for me but I am getting a disturbing number of warnings)
93+
94+
95+

pydecenttree/setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
#python_include = get_paths()
88
#(but this doesn't seem necessary, so I've commented it out)
99

10-
dirs = [numpy_include, "..", "../build"]
10+
dirs = [numpy_include, "..", "../build", "../zlib-1.2.7", "../build/zlib-1.2.7"]
1111
flags = ['-std=c++11']
1212
link_flags = []
1313

utils/operatingsystem.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
#include "operatingsystem.h"
99
#include <string>
1010
#include <sstream>
11-
#if defined(WIN32) || defined(WIN64)
11+
#if defined(WIN32) || defined(WIN64) || defined(_WIN32) || defined(_WIN64)
1212
#include <io.h> //for _isatty
1313
#include <stdio.h> //for _fileno (explicit include needed for GCC 9.2 builds)
1414
#else

0 commit comments

Comments
 (0)