Skip to content

Commit 3e26924

Browse files
committed
revise compilation instructions for meson
1 parent 094f1ca commit 3e26924

File tree

3 files changed

+210
-39
lines changed

3 files changed

+210
-39
lines changed

webdocs/compile.rst

Lines changed: 209 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -64,82 +64,142 @@ Some older binary files with combinations of older Python and
6464
NumPy versions can be found in the older svn repository for GSAS-II:
6565
https://subversion.xray.aps.anl.gov/trac/pyGSAS/browser/Binaries
6666

67-
Compiling with meson
68-
---------------------------
67+
Compiling with meson for Linux/MacOS
68+
--------------------------------------------
6969

70-
Compiling GSAS-II binaries is quite simple. One needs to install the
70+
Compiling GSAS-II binaries is quite simple on Linux and MacOS and a
71+
bit more complex on Windows.
72+
One needs to install the
7173
Python meson and cython packages and a C compiler and the Gfortran
72-
compiler. On Linux it probably best to use compilers supplied with the
74+
compiler.
75+
76+
On Linux it probably best to use compilers supplied with the
7377
dist using a commands such as `apt-get` or `yum`,
74-
but these compilers can be installed via conda
75-
from conda-forge and the latter does not require admin privs.
76-
On windows and MacOS, the easist way to obtain them
77-
is via their conda packages.
78+
but it is also possible to install these compilers via conda
79+
from conda-forge. The conda route has the advantage of not requiring admin privs.
80+
For Linux, one can add the extra packages needed for compilation to
81+
the Python environment used by GSAS-II. Below it is assumed that the
82+
Python environment is managed with conda, but on Linux it is also
83+
possible to utilize the distribution-supplied packages and/or PyPi
84+
(pip). It is also possible to use separate environments for
85+
compilation and for running GSAS-II.
86+
87+
For Mac, while there are several ways to potentially install the tools
88+
needed for compilation (for example homebrew) and one can use separate
89+
environments for compilation and for running GSAS-II, below a single
90+
environment is used and all software is loaded via conda.
91+
92+
Note that if the gsas2full installer is used, this can replace
93+
steps (1) and (3), below. In that case use command::
94+
95+
source .../g2full/bin/activate
96+
97+
to activate Python/conda, where `.../g2full` is the location where gsas2full was
98+
installed. And in place of step (3) use command::
99+
100+
cd .../g2full/GSAS-II
101+
102+
where again `.../g2full` is the location where gsas2full was installed.
103+
104+
1. Install an initial, bare-bones Python environment can be installed
105+
using the miniforge installer from conda-forge at
106+
https://github.com/conda-forge/miniforge/releases/latest. Then
107+
activate Python/conda as instructed by the installer (or use command::
108+
109+
source ~/miniforge3/bin/activate
110+
where `~/miniforge3` is the location where miniforge was installed.)
111+
Then use the conda command to install the following packages to run GSAS-II:
112+
113+
python, numpy, matplotlib, scipy, wxpython, pyopengl, imageio, h5py,
114+
hdf5, pillow, requests, pycifrw, pybaselines, git, gitpython, conda
78115

79-
Windows::
116+
(see `the GUI requirement section of the Developers manual
117+
<https://gsas-ii.readthedocs.io/en/latest/packages.html#gui-requirements>`_.)
80118

81-
conda install meson cython gcc gfortran -c conda-forge
119+
2. Install the Python build routines and the compilers:
82120

83121
MacOS::
84122

85-
conda install meson cython clang compilers -c conda-forge
123+
conda install python numpy meson cython clang compilers git -c conda-forge
86124

87125
Linux::
88126

89-
sudo apt-get gcc gfortran # or use the yum command
90-
yum install gcc-gfortran
91-
conda install meson cython -c conda-forge
92-
93-
Once meson and the tools are installed, the following steps are needed
94-
to build the GSAS-II binaries.
127+
sudo apt-get gcc gfortran git # or use the yum command:
128+
yum install gcc-gfortran git
95129

96-
1. Download the GSAS-II sources (if not already done) and move to the directory::
130+
conda python numpy install meson cython -c conda-forge
131+
132+
Note that the GSAS-II binaries will be compiled to work with a
133+
specific version of Python and numpy, if you have more than one conda
134+
environment, and will use a different environment to compile vs. run
135+
GSAS-II, you may want to pin the Python and numpy versions above by
136+
specifying them in the conda command (such as using `python=3.13` and
137+
`numpy=2.2` in place of `python` and `numpy` above) to match the
138+
environment where GSAS-II will be run.
139+
140+
3. Download the GSAS-II sources (if not already done) and move to the directory::
97141

98142
cd <...> # select where you wish to install GSAS-II
99-
git clone git@github.com:AdvancedPhotonSource/GSAS-II.git --depth 1 -b main G2
143+
git clone https://github.com/AdvancedPhotonSource/GSAS-II.git --depth 1 -b main G2
100144
cd G2
101145

102-
2. Create a scratch directory to compile GSAS-II into::
146+
4. Create a scratch directory to compile GSAS-II into::
103147
104148
meson setup /tmp/GSASIIc
105149

106-
Note that this command will fail if cython, gfortran and a c
107-
complier is not found. If the flang compiler is found, meson will
108-
use it, but the resulting binaries will not work properly.
150+
Note that this command will fail if cython, gfortran and a c
151+
complier is not found. If the flang compiler is found, meson will
152+
use it, but the resulting binaries will not work properly.
109153
110-
3. Move to the setup directory and compile::
154+
5. Move to the setup directory and compile::
111155
112156
cd /tmp/GSASIIc
113157
meson compile
114158

115-
4. (A) Install the GSAS-II binaries so they can be used by the current user::
159+
6. There are two choices for how to install the GSAS-II binaries to
160+
where they can be found by the software. If only one user will use
161+
GSAS-II, use option (A), which also allows multiple GSAS-II installations to share a
162+
single set of binaries (should a user wish to keep multiple
163+
versions available). When GSAS-II is installed on a server
164+
or possibly multiple versions of GSAS-II will be installed that
165+
need to have different versions of the binaries, use option (B) and
166+
the GSAS-II binaries will be placed with the GSAS-II source files.
167+
168+
(A) Install the GSAS-II binaries so they can be used by the current user::
116169

117-
meson compile local-install
170+
meson compile local-install
118171

119172
This command will copy the compiled files to `~/.GSASII/bin`, which
120173
is appropriate for when one user will access the GSAS-II
121174
program. It also allows multiple GSAS-II installations (should a
122175
user wish to keep multiple versions available).
123-
124-
4. (B) Or when GSAS-II is installed on a server, the GSAS-II binaries
125-
can be placed with the GSAS-II source files installed with the git
126-
command (into .../G2)::
127176

128-
meson compile system-install
177+
(B) Or when GSAS-II is installed on a server, the GSAS-II binaries
178+
can be placed with the GSAS-II source files installed with the
179+
git command (into .../G2)::
180+
181+
meson compile system-install
129182

130183
If the first command used was `cd ~/software` then GSAS-II was
131184
installed into `~/software/G2` and the binaries will be installed into
132185
`~/software/G2/GSASII/bin`.
133186

134-
5. Clean up:
187+
7. (Optional) Clean up:
135188

136-
rm -rf /tmp/GSASIIc
189+
rm -rf /tmp/GSASIIc
137190

138-
6. (Optional) Create shortcuts:
191+
8. (Optional) Run Self-tests::
139192

140-
Windows::
141-
142-
python .../G2/GSASII/install/makeBat.py
193+
conda activate base
194+
conda install pytest
195+
cd .../G2
196+
python -m pytest .../G2/tests
197+
198+
Note that `base` above may need to be replaced with the name of the
199+
environment that was used if not base and `.../G2` here and below will be the
200+
location used to install GSAS-II in step (2).
201+
202+
9. (Optional) Create shortcuts:
143203

144204
Linux::
145205
@@ -149,14 +209,125 @@ command (into .../G2)::
149209
150210
python .../G2/GSASII/install/makeMacApp.py
151211

212+
Compiling with meson for Windows
213+
--------------------------------------------
214+
215+
Compiling GSAS-II binaries is bit more complex on Windows because
216+
separate Python environments *must* be used for compilation and
217+
running GSAS-II (it appears that inclusion of git and gfortran in the
218+
same installation causes problems with accessing libraries needed by the compiler).
219+
There are other ways potentially to install the tools
220+
needed for compilation, but use of conda will be much simpler, but
221+
will require use of command-line commands (in a cmd.exe window, the
222+
commands have not been worked out if they will done with PowerShell).
223+
224+
Note that if the gsas2full installer is used, this can replace
225+
steps (1) and (2), below. In that case, use command::
226+
227+
...\g2full\Scripts\activate
228+
229+
to activate Python/conda, where `...\g2full` is the location where gsas2full was
230+
installed. And in place of step (3) use command::
231+
232+
cd ...\g2full\GSAS-II
233+
234+
where again `...\g2full` is the location where gsas2full was installed.
235+
236+
1. Install miniforge
237+
238+
An initial, bare-bones Python environment can be installed
239+
using the miniforge installer from conda-forge at
240+
https://github.com/conda-forge/miniforge/releases/latest. Run the
241+
downloaded `.exe` file. Once that has completed use command::
242+
243+
...\miniforge3\Scripts\activate
244+
245+
where `...\miniforge3` is the location where miniforge was
246+
installed to enable the Python/conda environment. Or in the start
247+
menu use the "Start miniforge prompt" command which does the same
248+
thing.
249+
250+
Use this command to install the following packages to run GSAS-II:::
251+
252+
conda install python numpy matplotlib wxpython pyopengl scipy git gitpython PyCifRW pillow conda requests hdf5 h5py imageio zarr xmltodict pybaselines seekpath pywin32 -c conda-forge -y
253+
254+
(see `the GUI requirement section of the Developers manual
255+
<https://gsas-ii.readthedocs.io/en/latest/packages.html#gui-requirements>`_
256+
for more info.)
257+
258+
2. Download the GSAS-II sources (if not already done) and move to the directory::
259+
260+
cd <...> # select where you wish to install GSAS-II
261+
git clone https://github.com/AdvancedPhotonSource/GSAS-II.git --depth 1 -b main G2
262+
cd G2
263+
264+
3. Install the Python build routines and the compilers. Note that this
265+
is done in separate environment that is located in directory
266+
`..\compile` relative to GSAS-II::
267+
268+
conda create -p ..\compile meson cython gcc gfortran python numpy -c conda-forge -y
269+
270+
4. Create a scratch directory to compile GSAS-II into::
271+
272+
conda activate ..\compile
273+
meson setup ..\tmp
274+
275+
5. Move to the setup directory and compile::
276+
277+
cd ..\tmp
278+
meson compile
279+
280+
6. There are two choices for how to install the GSAS-II binaries to
281+
where they can be found by the software. If only one user will use
282+
GSAS-II, use option (A), which also allows multiple GSAS-II installations to share a
283+
single set of binaries (should a user wish to keep multiple
284+
versions available). When GSAS-II is installed on a server
285+
or possibly multiple versions of GSAS-II will be installed that
286+
need to have different versions of the binaries, use option (B) and
287+
the GSAS-II binaries will be placed with the GSAS-II source files.
288+
289+
(A) Install the GSAS-II binaries so they can be used by the current user::
290+
291+
meson compile local-install
292+
293+
This command will copy the compiled files to `.GSASII\bin` in the
294+
Home directory (usually `c:\Users\<your name>`), which
295+
is appropriate for when one user will access the GSAS-II
296+
program.
152297
298+
(B) Or when GSAS-II is installed on a server, the GSAS-II binaries
299+
can be placed with the GSAS-II source files::
300+
301+
meson compile system-install
302+
303+
If the first command used was `cd software` then GSAS-II was
304+
installed into `software\G2` and the binaries will be installed into
305+
`software\G2\GSASII\bin`.
306+
307+
7. Clean up::
308+
309+
cd ..
310+
rmdir /s tmp
311+
rmdir /s compile
312+
313+
8. Create shortcuts:
314+
315+
python G2\GSASII\install\makeBat.py
316+
317+
9. (Optional) Run Self-tests::
318+
319+
conda activate base
320+
conda install pytest
321+
python -m pytest G2\tests
322+
323+
153324
Compiling with Scons
154325
---------------------------
155326

156327
Compilation with scons (as opposed to meson, as discussed above) is not
157328
recommended and will be removed from GSAS-II in the future. It will
158329
work only with Python 3.11 or older and only with the `master`
159-
branch. GSAS-II will fail with Python earlier than 3.7 and may have
330+
branch. Do not use GSAS-II will fail with Python earlier than 3.7 and may have
160331
some errors even with Python 3.8.
161332

162333
The compilation process requires installation of the gcc and gfortran

webdocs/index.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ well as extensive visualization capabilities.
3232
help.rst
3333
developers.rst
3434
misc.rst
35+
compile.rst
3536

3637
.. tip::
3738
Please help us by citing:

webdocs/install.rst

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,6 @@ installation details are discussed in the topics below.
142142
.. toctree::
143143
:maxdepth: 3
144144

145-
compile.rst
146145
install-pip.rst
147146
proxy.rst
148147

0 commit comments

Comments
 (0)