Skip to content

Commit

Permalink
Merge pull request #1747 from bennibbelink/python3
Browse files Browse the repository at this point in the history
  • Loading branch information
gonuke committed May 8, 2024
2 parents ac33833 + c8a8196 commit 7768ed9
Show file tree
Hide file tree
Showing 19 changed files with 42 additions and 45 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.rst
Expand Up @@ -10,6 +10,7 @@ Since last release
**Changed:**

* Changed README.rst installation instructions, tested on fresh Ubuntu-22.04 system with Python3.11 (#1744)
* Rely on `python3` in environment instead of `python` (#1747)

**Removed:**

Expand Down
6 changes: 3 additions & 3 deletions INSTALL.rst
Expand Up @@ -31,7 +31,7 @@ Run the install script:

.. code-block:: bash
python install.py
python3 install.py
If you successfully followed the instruction above, the cyclus binary has been
generated and placed in the ``~/.local/`` in your home directory.
Expand All @@ -47,7 +47,7 @@ On MacOSX you also need to add ~/.local/lib/pythonX.Y/site-packages to your

.. code-block:: bash
echo "export PYTHONPATH=\"\$HOME/.local/lib/python`python -c 'import sys; \
echo "export PYTHONPATH=\"\$HOME/.local/lib/python`python3 -c 'import sys; \
print(".".join(map(str, sys.version_info[:2])))'`/site-packages:\$PYTHONPATH\"" >> ~/.bashrc
source ~/.bashrc
Expand Down Expand Up @@ -128,7 +128,7 @@ installation flag. The otherwise identical process would look like:

.. code-block:: bash
.../cyclus$ python install.py --coin_root=path/to/coin
.../cyclus$ python3 install.py --coin_root=path/to/coin
CMake Cyclus Installation
Expand Down
2 changes: 1 addition & 1 deletion README.rst
Expand Up @@ -134,7 +134,7 @@ simulations, first download Cycamore
https://github.com/cyclus/cycamore.git``,

- Install in the same location you installed Cyclus (eg. in ``~/.local/``):
``python install.py`` from the ``cycamore`` folder.
``python3 install.py`` from the ``cycamore`` folder.


**************
Expand Down
2 changes: 1 addition & 1 deletion cli/cycpp.py
@@ -1,4 +1,4 @@
#!/usr/bin/env python
#!/usr/bin/env python3
"""The cyclus preprocessor.
cycpp is a 3-pass preprocessor which adds reflection-like semantics to cyclus
Expand Down
2 changes: 1 addition & 1 deletion cli/cycstub
@@ -1,4 +1,4 @@
#!/usr/bin/env python
#!/usr/bin/env python3

from __future__ import print_function

Expand Down
2 changes: 1 addition & 1 deletion cli/post-process-cython.py
@@ -1,4 +1,4 @@
#!/usr/bin/env python
#!/usr/bin/env python3
from __future__ import print_function, unicode_literals
import re

Expand Down
4 changes: 2 additions & 2 deletions cmake/UseCython.cmake
Expand Up @@ -284,7 +284,7 @@ function( cython_add_standalone_executable _name )
set( other_module_sources "" )
set( main_module "" )
cmake_parse_arguments( cython_arguments "" "MAIN_MODULE" "" ${ARGN} )
include_directories( ${PYTHON_INCLUDE_DIRS} )
include_directories( ${Python3_INCLUDE_DIRS} )
foreach( _file ${cython_arguments_UNPARSED_ARGUMENTS} )
if( ${_file} MATCHES ".*\\.py[x]?$" )
get_filename_component( _file_we ${_file} NAME_WE )
Expand All @@ -310,5 +310,5 @@ function( cython_add_standalone_executable _name )
set( CYTHON_FLAGS ${CYTHON_FLAGS} --embed )
compile_pyx( "${main_module_we}_static" generated_file ${main_module} )
add_executable( ${_name} ${generated_file} ${pyx_module_sources} ${other_module_sources} )
target_link_libraries( ${_name} ${PYTHON_LIBRARIES} ${pyx_module_libs} )
target_link_libraries( ${_name} ${Python3_LIBRARIES} ${pyx_module_libs} )
endfunction()
2 changes: 1 addition & 1 deletion cyclus/CMakeLists.txt
Expand Up @@ -8,7 +8,7 @@ INCLUDE_DIRECTORIES(${CYCLUS_CORE_INCLUDE_DIRS})
# First things first, code-generation
#
message(STATUS "Generating Type System API for Python")
EXECUTE_PROCESS(COMMAND python ${CMAKE_CURRENT_SOURCE_DIR}/gentypesystem.py
EXECUTE_PROCESS(COMMAND ${Python3_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/gentypesystem.py
"--src-dir=${CMAKE_CURRENT_SOURCE_DIR}"
"--data-model-version=${DATA_MODEL_VERSION}"
"--verbose"
Expand Down
2 changes: 1 addition & 1 deletion cyclus/gentypesystem.py
@@ -1,4 +1,4 @@
#!/usr/bin/env python
#!/usr/bin/env python3
"""Generates Cyclus Type System bindings.
Module history:
Expand Down
6 changes: 3 additions & 3 deletions cyclus/server.py
Expand Up @@ -175,18 +175,18 @@
======================
You may launch the cyclus server by running::
$ python -m cyclus.server input.xml
$ python3 -m cyclus.server input.xml
Most of the arguments are relatively self-explanatory. However, the CLI here
also allows you to load initial and repeating actions. The syntax for this
is an event name followed by parameter tokens (which must contain an equals
sign)::
$ python -m cyclus.server input.xml --repeating-actions sleep n=1
$ python3 -m cyclus.server input.xml --repeating-actions sleep n=1
You may load many actions by repeating the name-params pattern:
$ python -m cyclus.server input.xml --repeating-actions \
$ python3 -m cyclus.server input.xml --repeating-actions \
sleep n=1 \
table_data table="TimeSeriesPower"
Expand Down
13 changes: 6 additions & 7 deletions docker/Dockerfile
Expand Up @@ -37,8 +37,7 @@ RUN apt update -y && apt install -y \
RUN apt install -y python3-pprintpp; exit 0
RUN apt clean -y all

RUN update-alternatives --install /usr/bin/python python /usr/bin/python3 10
RUN mkdir -p `python -m site --user-site`
RUN mkdir -p `python3 -m site --user-site`

FROM common-base as conda-deps

Expand Down Expand Up @@ -91,7 +90,7 @@ RUN conda update -y --all && \
&& \
mamba install -y --force-reinstall libsqlite && \
conda clean -y --all
RUN mkdir -p `python -m site --user-site`
RUN mkdir -p `python3 -m site --user-site`
ENV CC /opt/conda/bin/x86_64-conda_cos6-linux-gnu-gcc
ENV CXX /opt/conda/bin/x86_64-conda_cos6-linux-gnu-g++
ENV CPP /opt/conda/bin/x86_64-conda_cos6-linux-gnu-cpp
Expand All @@ -110,12 +109,12 @@ ARG make_cores=2
COPY . /cyclus
WORKDIR /cyclus

RUN python install.py -j ${make_cores} --allow-milps --code_coverage
RUN python3 install.py -j ${make_cores} --allow-milps --code_coverage
ENV PATH /root/.local/bin:$PATH
ENV LD_LIBRARY_PATH /root/.local/lib:/root/.local/lib/cyclus
RUN lcov -c -d /cyclus -o initial_coverage.info --gcov-tool ${GCOV} --initial --no-external && \
cyclus_unit_tests && \
cd tests && python -m pytest && cd .. && \
cd tests && python3 -m pytest && cd .. && \
lcov -c -d /cyclus -o test_coverage.info --gcov-tool ${GCOV} --no-external && \
lcov --add-tracefile initial_coverage.info --add-tracefile test_coverage.info -o total_coverage.info && \
mkdir -p html && genhtml total_coverage.info --output-directory html
Expand All @@ -135,7 +134,7 @@ WORKDIR /cyclus

# You may add the option "--cmake-debug" to the following command
# for further CMake debugging.
RUN python install.py -j ${make_cores} --allow-milps
RUN python3 install.py -j ${make_cores} --allow-milps
ENV PATH /root/.local/bin:$PATH

FROM cyclus as deb-generation
Expand All @@ -151,4 +150,4 @@ RUN cyclus_unit_tests

FROM cyclus-test as cyclus-pytest

RUN cd tests && python -m pytest
RUN cd tests && python3 -m pytest
14 changes: 6 additions & 8 deletions docker/Rocky.dockerfile
Expand Up @@ -8,13 +8,11 @@ RUN dnf update -y && \
dnf install -y python3.11 epel-release

FROM common-base as rocky-8-config
RUN alternatives --set python /usr/bin/python3.11 && \
alternatives --set python3 /usr/bin/python3.11 && \
RUN alternatives --set python3 /usr/bin/python3.11 && \
dnf config-manager --set-enabled powertools

FROM common-base as rocky-9-config
RUN alternatives --install /usr/bin/python python /bin/python3.11 10 && \
alternatives --install /usr/bin/python3 python3 /bin/python3.11 10 && \
RUN alternatives --install /usr/bin/python3 python3 /bin/python3.11 10 && \
dnf config-manager --set-enabled crb

FROM rocky-${rocky_version}-config as dnf-deps
Expand All @@ -37,11 +35,11 @@ RUN dnf update -y && dnf install -y \
python3.11-pytest \
&& dnf clean all

RUN mkdir -p $(python -m site --user-site) && python -m pip install pandas tables cython jinja2
RUN mkdir -p $(python3 -m site --user-site) && python3 -m pip install pandas tables cython jinja2

FROM dnf-deps as libxmlpp
RUN dnf update -y && dnf install -y wget m4 doxygen perl-open perl-XML-Parser diffutils pcre-cpp pcre-devel && \
python -m pip install meson ninja packaging && \
python3 -m pip install meson ninja packaging && \
wget https://github.com/libxmlplusplus/libxmlplusplus/releases/download/4.0.3/libxml++-4.0.3.tar.xz && \
tar xf libxml++-4.0.3.tar.xz && \
cd libxml++-4.0.3 && \
Expand Down Expand Up @@ -72,7 +70,7 @@ WORKDIR /cyclus

# You may add the option "--cmake-debug" to the following command
# for further CMake debugging.
RUN python install.py -j ${make_cores} -D Python3_EXECUTABLE=/usr/bin/python3.11
RUN python3 install.py -j ${make_cores} -D Python3_EXECUTABLE=/usr/bin/python3.11
ENV PATH /root/.local/bin:$PATH
ENV LD_LIBRARY_PATH /root/.local/lib:/root/.local/lib/cyclus

Expand All @@ -82,5 +80,5 @@ RUN cyclus_unit_tests

FROM cyclus-test as cyclus-pytest

RUN cd tests && python -m pytest
RUN cd tests && python3 -m pytest

3 changes: 1 addition & 2 deletions setup.py
Expand Up @@ -57,8 +57,7 @@ def run_setup(ver):
url='http://fuelcycle.org',
platforms=['posix'],
classifiers=['Operating System :: POSIX',
'Programming Language :: Python :: 3',
'Programming Language :: Python :: 2'],
'Programming Language :: Python :: 3'],
packages=['cyclus'],
package_dir={'cyclus': 'cyclus'},
package_data={'cyclus': ['*.pxd', '*.so', '*.dylib']},
Expand Down
2 changes: 1 addition & 1 deletion share/CMakeLists.txt
Expand Up @@ -20,7 +20,7 @@ CONFIGURE_FILE(
COPYONLY
)

EXECUTE_PROCESS(COMMAND python ${CMAKE_CURRENT_SOURCE_DIR}/dbtypes_gen.py ${DATA_MODEL_VERSION} OUTPUT_VARIABLE DBTYPES_JSON_ENTRIES RESULT_VARIABLE res_var)
EXECUTE_PROCESS(COMMAND ${Python3_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/dbtypes_gen.py ${DATA_MODEL_VERSION} OUTPUT_VARIABLE DBTYPES_JSON_ENTRIES RESULT_VARIABLE res_var)
IF(NOT "${res_var}" STREQUAL "0")
message(FATAL_ERROR "Process dbtypes_gen.py failed, res_var = '${res_var}'")
ENDIF()
Expand Down
2 changes: 1 addition & 1 deletion share/dbtypes_gen.py
@@ -1,4 +1,4 @@
#!/usr/bin/env python
#!/usr/bin/env python3
from __future__ import print_function
import os
import re
Expand Down
16 changes: 8 additions & 8 deletions src/CMakeLists.txt
Expand Up @@ -33,7 +33,7 @@ CONFIGURE_FILE(
@ONLY
)

EXECUTE_PROCESS(COMMAND python ${CMAKE_CURRENT_SOURCE_DIR}/hdf5_back_gen.py "VAL_TO_BUF_H" OUTPUT_VARIABLE HDF5_BACK_CC_VAL_TO_BUF_H RESULT_VARIABLE res_var_h)
EXECUTE_PROCESS(COMMAND ${Python3_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/hdf5_back_gen.py "VAL_TO_BUF_H" OUTPUT_VARIABLE HDF5_BACK_CC_VAL_TO_BUF_H RESULT_VARIABLE res_var_h)
IF(NOT "${res_var_h}" STREQUAL "0")
message(FATAL_ERROR "Process hdf5_back_gen.py 'VAL_TO_BUF_H' failed, result = '${res_var_h}'")
ENDIF()
Expand All @@ -48,37 +48,37 @@ copy_when_diff(
"${CMAKE_CURRENT_SOURCE_DIR}/hdf5_back.h"
)

EXECUTE_PROCESS(COMMAND python ${CMAKE_CURRENT_SOURCE_DIR}/hdf5_back_gen.py "QUERY" OUTPUT_VARIABLE HDF5_BACK_CC_QUERY RESULT_VARIABLE res_var_q)
EXECUTE_PROCESS(COMMAND ${Python3_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/hdf5_back_gen.py "QUERY" OUTPUT_VARIABLE HDF5_BACK_CC_QUERY RESULT_VARIABLE res_var_q)
IF(NOT "${res_var_q}" STREQUAL "0")
message(FATAL_ERROR "Process hdf5_back_gen.py 'QUERY' failed, result = '${res_var_q}'")
ENDIF()

EXECUTE_PROCESS(COMMAND python ${CMAKE_CURRENT_SOURCE_DIR}/hdf5_back_gen.py "CREATE" OUTPUT_VARIABLE HDF5_BACK_CC_CREATE RESULT_VARIABLE res_var_c)
EXECUTE_PROCESS(COMMAND ${Python3_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/hdf5_back_gen.py "CREATE" OUTPUT_VARIABLE HDF5_BACK_CC_CREATE RESULT_VARIABLE res_var_c)
IF(NOT "${res_var_c}" STREQUAL "0")
message(FATAL_ERROR "Process hdf5_back_gen.py 'CREATE' failed, result = '${res_var_c}'")
ENDIF()

EXECUTE_PROCESS(COMMAND python ${CMAKE_CURRENT_SOURCE_DIR}/hdf5_back_gen.py "VL_DATASET" OUTPUT_VARIABLE HDF5_BACK_CC_VL_DATASET RESULT_VARIABLE res_var_v)
EXECUTE_PROCESS(COMMAND ${Python3_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/hdf5_back_gen.py "VL_DATASET" OUTPUT_VARIABLE HDF5_BACK_CC_VL_DATASET RESULT_VARIABLE res_var_v)
IF(NOT "${res_var_v}" STREQUAL "0")
message(FATAL_ERROR "Process hdf5_back_gen.py 'VL_DATASET' failed, result = '${res_var_v}'")
ENDIF()

EXECUTE_PROCESS(COMMAND python ${CMAKE_CURRENT_SOURCE_DIR}/hdf5_back_gen.py "FILL_BUF" OUTPUT_VARIABLE HDF5_BACK_CC_FILL_BUF RESULT_VARIABLE res_var_f)
EXECUTE_PROCESS(COMMAND ${Python3_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/hdf5_back_gen.py "FILL_BUF" OUTPUT_VARIABLE HDF5_BACK_CC_FILL_BUF RESULT_VARIABLE res_var_f)
IF(NOT "${res_var_f}" STREQUAL "0")
message(FATAL_ERROR "Process hdf5_back_gen.py 'FILL_BUF' failed, result = '${res_var_f}'")
ENDIF()

EXECUTE_PROCESS(COMMAND python ${CMAKE_CURRENT_SOURCE_DIR}/hdf5_back_gen.py "WRITE" OUTPUT_VARIABLE HDF5_BACK_CC_WRITE RESULT_VARIABLE res_var_w)
EXECUTE_PROCESS(COMMAND ${Python3_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/hdf5_back_gen.py "WRITE" OUTPUT_VARIABLE HDF5_BACK_CC_WRITE RESULT_VARIABLE res_var_w)
IF(NOT "${res_var_w}" STREQUAL "0")
message(FATAL_ERROR "Process hdf5_back_gen.py 'WRITE' failed, result = '${res_var_w}'")
ENDIF()

EXECUTE_PROCESS(COMMAND python ${CMAKE_CURRENT_SOURCE_DIR}/hdf5_back_gen.py "VAL_TO_BUF" OUTPUT_VARIABLE HDF5_BACK_CC_VAL_TO_BUF RESULT_VARIABLE res_var_vb)
EXECUTE_PROCESS(COMMAND ${Python3_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/hdf5_back_gen.py "VAL_TO_BUF" OUTPUT_VARIABLE HDF5_BACK_CC_VAL_TO_BUF RESULT_VARIABLE res_var_vb)
IF(NOT "${res_var_vb}" STREQUAL "0")
message(FATAL_ERROR "Process hdf5_back_gen.py 'VAL_TO_BUF' failed, result = '${res_var_vb}'")
ENDIF()

EXECUTE_PROCESS(COMMAND python ${CMAKE_CURRENT_SOURCE_DIR}/hdf5_back_gen.py "BUF_TO_VAL" OUTPUT_VARIABLE HDF5_BACK_CC_BUF_TO_VAL RESULT_VARIABLE res_var_bv)
EXECUTE_PROCESS(COMMAND ${Python3_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/hdf5_back_gen.py "BUF_TO_VAL" OUTPUT_VARIABLE HDF5_BACK_CC_BUF_TO_VAL RESULT_VARIABLE res_var_bv)
IF(NOT "${res_var_bv}" STREQUAL "0")
message(FATAL_ERROR "Process hdf5_back_gen.py 'BUF_TO_VAL' failed, result = '${res_var_bv}'")
ENDIF()
Expand Down
4 changes: 2 additions & 2 deletions src/hdf5_back_gen.py
@@ -1,4 +1,4 @@
#!/usr/bin/env python
#!/usr/bin/env python3
"""This module generates HDF5 backend code found in src/hdf5_back.cc
There are 8 distinct code generation options, one of which must be passed
Expand All @@ -14,7 +14,7 @@
-------
To generate the code found in src/hdf5_back.cc::Query, use
$ python hdf5_back_gen.py QUERY
$ python3 hdf5_back_gen.py QUERY
"""
import os
Expand Down
2 changes: 1 addition & 1 deletion tests/CMakeLists.txt
Expand Up @@ -95,7 +95,7 @@ set(tgt "cyclus_unit_tests")
add_custom_target(
${tgt}-post-build
DEPENDS ${tgt}
COMMAND python "${CMAKE_CURRENT_SOURCE_DIR}/generate_gtest_macros.py"
COMMAND ${Python3_EXECUTABLE} "${CMAKE_CURRENT_SOURCE_DIR}/generate_gtest_macros.py"
"--executable=${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/${tgt}"
"--output=${CYCLUS_BINARY_DIR}/CTestTestfile.cmake"
COMMENT "adding tests from ${tgt}"
Expand Down
2 changes: 1 addition & 1 deletion tests/test_stubs.py
Expand Up @@ -28,7 +28,7 @@ def test_stubs():
inst = os.path.join(d, 'baz')

stub_cmd = 'cycstub --type {0} {1}:{1}:{2}'
inst_cmd = 'python install.py --build_dir {0} --prefix {1}'
inst_cmd = 'python3 install.py --build_dir {0} --prefix {1}'
tst_cmd = './bin/{}_unit_tests'

log = 'stub_test.log'
Expand Down

0 comments on commit 7768ed9

Please sign in to comment.