Skip to content

Commit 0dde4ba

Browse files
benfultonBen Fultonpre-commit-ci[bot]
authored
Fixes #394: Update Python setup (#395)
* Fixes #394: Update Python setup Now using setuptools instead of distutils to do the install. Most of the Python code runs without installing, with a note in the manual that it has to be added to the PYTHONPATH to work correctly. But a user is likely to run "Make Install" instead which will install the files to the relevant site_packages folder without needing to change the PYTHONPATH. So to better replicate this, we'll add "make install" to the CI testing and simplify the Makefile by removing the Python-specific make recipes. We'll also modify the manual to mention that setting the PYTHONPATH is not necessary after running make install. --------- Co-authored-by: Ben Fulton <bfulton@imperial.ac.uk> Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
1 parent 468b3a2 commit 0dde4ba

10 files changed

Lines changed: 55 additions & 43 deletions

File tree

.gitignore

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -85,9 +85,6 @@ tests/tools.mk
8585
tools/lib
8686
tools/version-info
8787

88-
## Python
89-
python/setup.py
90-
9188
## Fortran files
9289
diagnostics/Diagnostic_Fields_New.F90
9390
preprocessor/check_options.F90

Makefile.in

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -213,26 +213,14 @@ fltools: fluidity_library
213213
manual:
214214
@cd manual; $(MAKE)
215215

216-
python_build:
217-
ifeq (@HAVE_PYTHON@,yes)
218-
@echo " MAKE python"
219-
@cd python; python3 setup.py build > build.log 2>&1
220-
@cd python/fluidity; find ../build/lib* -name '*.so' -exec ln -sf {} . \;
221-
endif
222-
223-
python_clean:
224-
@echo " CLEAN python"
225-
@cd python; rm -rf build
226-
@cd python/fluidity; find . -type l -name '*.so' -exec rm -f {} \;
227-
228216
.PHONY: scripts
229217

230218
scripts:
231219
@echo "INSTALL local scripts"
232220
@cd tools ; $(MAKE) scripts
233221

234222
fluidity_library: lib/lib$(FLUIDITY).a
235-
lib/lib$(FLUIDITY).a: $(OBJS) python_build sub_system scripts
223+
lib/lib$(FLUIDITY).a: $(OBJS) sub_system scripts
236224
@echo "BUILD libfluidity"
237225
@echo " MKDIR lib"
238226
@mkdir -p lib

configure

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17484,7 +17484,7 @@ printf "%s\n" "$ac_cv_path_GREP" >&6; }
1748417484

1748517485

1748617486

17487-
ac_config_files="$ac_config_files Makefile debug/Makefile bathymetry/Makefile ocean_forcing/Makefile ocean_forcing/tests/Makefile sediments/Makefile population_balance/Makefile hyperlight/Makefile femtools/Makefile femtools/tests/Makefile forward_interfaces/Makefile horizontal_adaptivity/Makefile horizontal_adaptivity/tests/Makefile preprocessor/Makefile error_measures/Makefile error_measures/tests/Makefile parameterisation/Makefile parameterisation/tests/Makefile fldecomp/Makefile assemble/Makefile assemble/tests/Makefile diagnostics/Makefile main/Makefile tools/Makefile tools/version-info python/setup.py climatology/Makefile libmba2d/Makefile libmba3d/Makefile libjudy/Makefile libjudy/src/Makefile libjudy/src/JudyCommon/Makefile libjudy/src/Judy1/Makefile libjudy/src/JudyL/Makefile libjudy/src/JudySL/Makefile libjudy/src/JudyHS/Makefile libwm/Makefile libvtkfortran/Makefile tests/tools.mk"
17487+
ac_config_files="$ac_config_files Makefile debug/Makefile bathymetry/Makefile ocean_forcing/Makefile ocean_forcing/tests/Makefile sediments/Makefile population_balance/Makefile hyperlight/Makefile femtools/Makefile femtools/tests/Makefile forward_interfaces/Makefile horizontal_adaptivity/Makefile horizontal_adaptivity/tests/Makefile preprocessor/Makefile error_measures/Makefile error_measures/tests/Makefile parameterisation/Makefile parameterisation/tests/Makefile fldecomp/Makefile assemble/Makefile assemble/tests/Makefile diagnostics/Makefile main/Makefile tools/Makefile tools/version-info climatology/Makefile libmba2d/Makefile libmba3d/Makefile libjudy/Makefile libjudy/src/Makefile libjudy/src/JudyCommon/Makefile libjudy/src/Judy1/Makefile libjudy/src/JudyL/Makefile libjudy/src/JudySL/Makefile libjudy/src/JudyHS/Makefile libwm/Makefile libvtkfortran/Makefile tests/tools.mk"
1748817488

1748917489
cat >confcache <<\_ACEOF
1749017490
# This file is a shell script that caches the results of configure

configure.in

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1859,7 +1859,6 @@ AC_CONFIG_FILES([Makefile
18591859
main/Makefile
18601860
tools/Makefile
18611861
tools/version-info
1862-
python/setup.py
18631862
climatology/Makefile
18641863
libmba2d/Makefile
18651864
libmba3d/Makefile

docker/actions/Dockerfile.actions.noble

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ RUN test -z "$(git status --porcelain */Makefile.dependencies)"
3232
RUN make
3333
RUN make fltools
3434
RUN make manual
35+
RUN sudo make install
3536

3637
# Python module 'assess' is required for some longtests
3738
RUN python3 -m pip install --break-system-packages assess

manual/examples.tex

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,8 @@ \subsection{Results}
175175

176176
Alternatively the results can be plotted using python. An example python script using pylab and the
177177
vtktools python module, is provided with this example. The vtktools module is located in
178-
\texttt{\fluiditysourcepath/python/}; this path needs to be added to the \texttt{PYTHONPATH} environment
178+
\texttt{\fluiditysourcepath/python/}. It will be available in the default Python installation after
179+
fluidity is installed; alternatively, this path can be added to the \texttt{PYTHONPATH} environment
179180
variable.
180181

181182
As can be seen in the numerical result using the CG method leads, to over and

manual/python.tex

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,10 @@ \section{System requirements}
3333
\lstinline[language=Bash]+python-numpy+ package.
3434

3535
\fluidity\ also requires access to its own Python modules which are stored in
36-
the python directory in the \fluidity\ source tree. To ensure that these are
37-
visible to \fluidity\ at runtime, users should add this directory to the
38-
\lstinline[language=Bash]+PYTHONPATH+ environment variable. For example:\
36+
the python directory in the \fluidity\ source tree. These will be installed
37+
to the default Python installation along with Fluidity, but users can add this
38+
directory to the \lstinline[language=Bash]+PYTHONPATH+ environment variable.
39+
For example:\
3940
\begin{lstlisting}[language=Bash]
4041
export PYTHONPATH=<my_fluidity>/python/:$PYTHONPATH
4142
\end{lstlisting}%$

python/pyproject.toml

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
[build-system]
2+
requires = ["setuptools>=61.0", "wheel"]
3+
build-backend = "setuptools.build_meta"
4+
5+
[project]
6+
name = "fluidity"
7+
version = "0.2"
8+
description = "Fluidity python files"
9+
requires-python = ">=3.8"
10+
authors = [
11+
{name = "Patrick Farrell"},
12+
{name = "Stephan Kramer"}
13+
]
14+
maintainers = [
15+
{name = "Ben Fulton"},
16+
]
17+
license = {text = "See LICENSE file"}
18+
classifiers = [
19+
"Development Status :: 5 - Production",
20+
"Intended Audience :: Science/Research",
21+
"License :: Other/Proprietary License",
22+
"Operating System :: OS Independent",
23+
"Programming Language :: Python :: 3",
24+
"Programming Language :: Python :: 3.8",
25+
"Programming Language :: Python :: 3.9",
26+
"Programming Language :: Python :: 3.10",
27+
"Programming Language :: Python :: 3.11",
28+
"Programming Language :: Python :: 3.12",
29+
"Topic :: Scientific/Engineering",
30+
]
31+
32+
[project.urls]
33+
Homepage = "https://fluidity-project.org"
34+
Documentation = "https://figshare.com/articles/journal_contribution/Fluidity_Manual/1387713?file=2031637"
35+
Repository = "https://github.com/FluidityProject/fluidity"
36+
Issues = "https://github.com/FluidityProject/fluidity/issues"
37+
38+
[tool.setuptools]
39+
packages = ["fluidity", "fluidity.diagnostics"]
40+
py-modules = ["fluidity_tools", "vtktools"]
41+
42+
[tool.setuptools.package-dir]
43+
fluidity = "fluidity"

python/setup.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
from setuptools import setup
2+
3+
setup()

python/setup.py.in

Lines changed: 0 additions & 21 deletions
This file was deleted.

0 commit comments

Comments
 (0)