Warwick-Plasma / epoch

Particle-in-cell code for plasma physics simulations
https://epochpic.github.io
GNU General Public License v3.0
176 stars 56 forks source link

SDF python install is deprecated #588

Open NSmith-99 opened 10 months ago

NSmith-99 commented 10 months ago

The install method for the SDF utilities is deprecated as of 2021, so on systems using more recent versions of python and its utility modules the make sdfutils method from the EPOCH Makefile's will not work. The build file in SDF/utilities makes use of a direct call of setup.py, resulting in an error message informing the user this method is deprecated, as shown below.

$ make sdfutils 
make[1]: Entering directory '/USER/epoch/SDF/C'
gcc -c -Iinclude -Isrc -I../extension/include -fPIC -g -O3 -o obj_gcc/sdf_control.o src/sdf_control.c
rm -f lib/libsdfc.a
ar -rsu lib/libsdfc.a obj_gcc/sdf_control.o obj_gcc/sdf_derived.o obj_gcc/sdf_extension_util.o obj_gcc/sdf_helper.o obj_gcc/sdf_input.o obj_gcc/sdf_input_cartesian.o obj_gcc/sdf_input_point.o obj_gcc/sdf_input_station.o obj_gcc/sdf_modify.o obj_gcc/sdf_output.o obj_gcc/sdf_util.o obj_gcc/stack_allocator.o
ar: creating lib/libsdfc.a
ranlib lib/libsdfc.a
make[1]: Leaving directory '/USER/epoch/SDF/C'
/USER/.conda/envs/venv/lib/python3.12/site-packages/setuptools/_distutils/cmd.py:66: SetuptoolsDeprecationWarning: setup.py install is deprecated.
!!

        ********************************************************************************
        Please avoid running ``setup.py`` directly.
        Instead, use pypa/build, pypa/installer or other
        standards-based tools.

        See https://blog.ganssle.io/articles/2021/10/setup-py-deprecated.html for details.
        ********************************************************************************

!!

This can be circumvented manually by using the command pip install ./ from the utilities folder, however since this creates its own file named build, the original build file must be renamed. If install is done manually, including the C/include/ folder in the include path is also necessary so the c files can compile correctly, usually performed automatically by the build file.

jthistle commented 1 month ago

+1, I also have this issue.

yuedongning commented 1 month ago

Me either, I also have this issue. I wonder it is because the version of python is much higher. But I cannot prove it. Is there anybody who can solve this issue?

yuedongning commented 1 month ago

Good news! I figure out how to solve this problem. Do not use anaconda environment!!! Just install python by commond "sudo apt install python3 python3-pip" and "sudo pip install numpy matplotlib -i URLs"

jthistle commented 1 month ago

@yuedongning Although this works for you, it is not a good enough solution.

The error occurs when using newer versions of Python and hence newer versions of setuptools, which deprecate running setup.py directly. The last version of setuptools to not show this error is 58.2.0 (source). I suspect that you are using Ubuntu 20.04 or a similarly old release, which means that when you run sudo apt install python3 you are installing an older version of Python---and with it a version of setuptools older than 58.2.0. Anaconda, however, comes with the latest version of Python and setuptools, which, I guess, is why you have jumped to the solution "don't use Anaconda". I'm afraid this isn't it.

A hacky (but universal) solution I have found is (with bash in the utilities/ directory):

mv build build.tmp
cp ../C/include/* ../C/src
pip install ./

This works with Anaconda and should work with older Python versions.

keithbennett commented 1 month ago

The build system needs reworking. I am on holiday until the 29th but will take a proper look when I return to work.

yuedongning commented 1 month ago

I think jthistle is very right about this problem. I tried to update the default python editor to the latest version, but there is always SSL build error. So, I failed. Then I tried jthistle codes mv build build.tmp cp ../C/include/* ../C/src pip install ./ It successes and looks like that we also need to run make sdfutils first.

yuedongning commented 1 month ago

@jthistle I thank you for your help very much!

keithbennett commented 4 weeks ago

This has now been fixed upstream with PR Warwick-Plasma/SDF_utilities#13 I will raise a PR for updating the SDF repository later today.