From d0f7ac994ae4f756045ed4ce5517296ff80ab638 Mon Sep 17 00:00:00 2001 From: Yuichi Motoyama Date: Tue, 19 Mar 2024 17:08:38 +0900 Subject: [PATCH] update install script for python tools (#44) * update CI envs * use latest action * update * update * specify python executable explicitly * check site-packages directory names * apt update --- .github/workflows/deploy_docs.yml | 8 ++++---- .github/workflows/main.yml | 20 +++++++++++++------- CMakeLists.txt | 1 - tool/CMakeLists.txt | 8 ++------ tool/cmake/dla_alg.in | 1 - tool/cmake/dla_hamgen.in | 1 - tool/cmake/dla_latgen.in | 1 - tool/cmake/dla_pgen.in | 1 - tool/cmake/dla_pre.in | 1 - tool/cmake/dla_wvgen.in | 1 - tool/cmake/install.sh.in | 22 ++++++++++++---------- tool/cmake/pmwa_pre.in | 1 - tool/pyproject.toml | 9 +++++---- 13 files changed, 36 insertions(+), 39 deletions(-) diff --git a/.github/workflows/deploy_docs.yml b/.github/workflows/deploy_docs.yml index 9bce0ea1..b413eb6a 100644 --- a/.github/workflows/deploy_docs.yml +++ b/.github/workflows/deploy_docs.yml @@ -11,24 +11,24 @@ on: jobs: deploy: - runs-on: ubuntu-20.04 + runs-on: ubuntu-22.04 steps: - name: Inject slug/short variables uses: rlespinasse/github-slug-action@v4.x - name: Checkout - uses: actions/checkout@v3 + uses: actions/checkout@v4 with: path: main - name: Checkout gh-pages - uses: actions/checkout@v3 + uses: actions/checkout@v4 with: ref: gh-pages path: gh-pages - name: Set up Python - uses: actions/setup-python@v4 + uses: actions/setup-python@v5 with: python-version: 3.8 diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 077ad23a..bb5e6bea 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -4,13 +4,18 @@ on: [push] jobs: build: - runs-on: ubuntu-20.04 + runs-on: ${{ matrix.os }} + + strategy: + matrix: + os: ['ubuntu-20.04', 'ubuntu-22.04'] + fail-fast: false steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: Setup Python - uses: actions/setup-python@v4 + uses: actions/setup-python@v5 with: python-version: 3.8 @@ -33,7 +38,7 @@ jobs: - name: cmake working-directory: ${{runner.workspace}}/build shell: bash - run: cmake -DCMAKE_INSTALL_PREFIX=${{runner.workspace}}/usr -DCMAKE_VERBOSE_MAKEFILE=1 $GITHUB_WORKSPACE + run: cmake -DPYTHON_EXECUTABLE=$(which python3) -DCMAKE_INSTALL_PREFIX=${{runner.workspace}}/usr -DCMAKE_VERBOSE_MAKEFILE=1 $GITHUB_WORKSPACE - name: build working-directory: ${{runner.workspace}}/build @@ -52,18 +57,19 @@ jobs: docs: - runs-on: ubuntu-20.04 + runs-on: ubuntu-22.04 steps: - name: Checkout - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Set up Python - uses: actions/setup-python@v4 + uses: actions/setup-python@v5 with: python-version: 3.8 - name: Prepare LaTeX env run: | + sudo apt update sudo apt install \ texlive-latex-recommended texlive-latex-extra \ texlive-lang-japanese texlive-fonts-recommended texlive-fonts-extra latexmk diff --git a/CMakeLists.txt b/CMakeLists.txt index 17ee0cfa..d835ec6e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -95,7 +95,6 @@ else() list(GET result 0 Python3_VERSION_MAJOR) list(GET result 1 Python3_VERSION_MINOR) list(GET result 2 Python3_VERSION_MICRO) - # message(STATUS "Python version: ${Python3_VERSION_MAJOR}.${Python3_VERSION_MINOR}.${Python3_VERSION_MICRO}") set(python_version_mm "${Python3_VERSION_MAJOR}.${Python3_VERSION_MINOR}") endif() diff --git a/tool/CMakeLists.txt b/tool/CMakeLists.txt index 75c20ec6..b108c3b4 100644 --- a/tool/CMakeLists.txt +++ b/tool/CMakeLists.txt @@ -1,7 +1,3 @@ -set(pythonpath_build "${CMAKE_CURRENT_BINARY_DIR}/pythonmodule") -set(pythonpath_path "${CMAKE_CURRENT_BINARY_DIR}/pythonmodule/lib/python${python_version_mm}/site-packages") -set(ENV{PYTHONPATH} "${pythonpath_build}:$ENV{PYTHONPATH}") - file(COPY dsqss DESTINATION ${CMAKE_CURRENT_BINARY_DIR}) set(dla_scripts @@ -24,7 +20,7 @@ configure_file(cmake/dsqssvars.sh.in ${CMAKE_CURRENT_BINARY_DIR}/dsqssvars-${DSQSS_VERSION}.sh @ONLY) configure_file(cmake/install.sh.in ${CMAKE_CURRENT_BINARY_DIR}/install.sh @ONLY) -install(FILES ${CMAKE_CURRENT_BINARY_DIR}/dsqssvars-${DSQSS_VERSION}.sh - DESTINATION share/dsqss) +# install(FILES ${CMAKE_CURRENT_BINARY_DIR}/dsqssvars-${DSQSS_VERSION}.sh +# DESTINATION share/dsqss) install( CODE "execute_process(COMMAND sh ${CMAKE_CURRENT_BINARY_DIR}/install.sh)") diff --git a/tool/cmake/dla_alg.in b/tool/cmake/dla_alg.in index 0dbaa77a..17ad5043 100755 --- a/tool/cmake/dla_alg.in +++ b/tool/cmake/dla_alg.in @@ -18,7 +18,6 @@ import sys sys.path.append('@CMAKE_CURRENT_BINARY_DIR@') -sys.path.append('@pythonpath_build@') from dsqss.dla_alg import main if __name__ == '__main__': main() diff --git a/tool/cmake/dla_hamgen.in b/tool/cmake/dla_hamgen.in index 69260d57..5ade7e62 100755 --- a/tool/cmake/dla_hamgen.in +++ b/tool/cmake/dla_hamgen.in @@ -18,7 +18,6 @@ import sys sys.path.append('@CMAKE_CURRENT_BINARY_DIR@') -sys.path.append('@pythonpath_build@') from dsqss.std_model import main if __name__ == '__main__': main() diff --git a/tool/cmake/dla_latgen.in b/tool/cmake/dla_latgen.in index e938cbb2..3346eac1 100755 --- a/tool/cmake/dla_latgen.in +++ b/tool/cmake/dla_latgen.in @@ -18,7 +18,6 @@ import sys sys.path.append('@CMAKE_CURRENT_BINARY_DIR@') -sys.path.append('@pythonpath_build@') from dsqss.std_lattice import main if __name__ == '__main__': main() diff --git a/tool/cmake/dla_pgen.in b/tool/cmake/dla_pgen.in index 6aacd40d..408ce8c2 100755 --- a/tool/cmake/dla_pgen.in +++ b/tool/cmake/dla_pgen.in @@ -18,7 +18,6 @@ import sys sys.path.append('@CMAKE_CURRENT_BINARY_DIR@') -sys.path.append('@pythonpath_build@') from dsqss.parameter import main if __name__ == '__main__' : main() diff --git a/tool/cmake/dla_pre.in b/tool/cmake/dla_pre.in index b360e402..551ff7e8 100755 --- a/tool/cmake/dla_pre.in +++ b/tool/cmake/dla_pre.in @@ -1,7 +1,6 @@ #!@PYTHON_EXECUTABLE@ import sys sys.path.append('@CMAKE_CURRENT_BINARY_DIR@') -sys.path.append('@pythonpath_build@') from dsqss.dla_pre import main if __name__ == '__main__' : main() diff --git a/tool/cmake/dla_wvgen.in b/tool/cmake/dla_wvgen.in index c39ad96f..2057582a 100755 --- a/tool/cmake/dla_wvgen.in +++ b/tool/cmake/dla_wvgen.in @@ -18,7 +18,6 @@ import sys sys.path.append('@CMAKE_CURRENT_BINARY_DIR@') -sys.path.append('@pythonpath_build@') from dsqss.wavevector import main if __name__ == '__main__': main() diff --git a/tool/cmake/install.sh.in b/tool/cmake/install.sh.in index dca64134..ed7905fa 100644 --- a/tool/cmake/install.sh.in +++ b/tool/cmake/install.sh.in @@ -1,16 +1,18 @@ -PYTHONPATH_BUILD=@pythonpath_build@ -export PYTHONPATH=@pythonpath_path@ PREFIX=@CMAKE_INSTALL_PREFIX@ -# export PIPX_HOME=@CMAKE_INSTALL_PREFIX@/pipx -# export PIPX_BIN_DIR=@CMAKE_INSTALL_PREFIX@/bin cd @CMAKE_CURRENT_BINARY_DIR@ -find @CMAKE_INSTALL_PREFIX@/bin -name 'dla_*' | xargs rm -f -rm -f @CMAKE_INSTALL_PREFIX@/bin/pmwa_pre -# echo "-- Installing poetry to $PYTHONPATH_BUILD" -# @PYTHON_EXECUTABLE@ -m pip install --prefix=$PYTHONPATH_BUILD poetry-core poetry echo "-- Installing dsqss tools to $PREFIX" -# echo "--- PYTHONPATH=$PYTHONPATH" -# PYTHONPATH=$PYTHONPATH @PYTHON_EXECUTABLE@ -c 'import poetry; print(poetry.__path__)' @PYTHON_EXECUTABLE@ -m pip install --prefix=$PREFIX --no-deps @CMAKE_CURRENT_SOURCE_DIR@ + +echo "export PATH=${PREFIX}/bin:\$PATH" > dsqssvars.sh + +# Some systems like Ubuntu 22.04 install python packages under ${PREFIX}/local instead of ${PREFIX} +if [ -d ${PREFIX}/local ]; then + echo "export PATH=${PREFIX}/local/bin:\$PATH" >> dsqssvars.sh +fi +DSQSS_PYTHONPATH=$(@PYTHON_EXECUTABLE@ @CMAKE_CURRENT_SOURCE_DIR@/cmake/get_site_packages.py $PREFIX) + +echo "export PYTHONPATH=${DSQSS_PYTHONPATH}:\$PYTHONPATH" >> dsqssvars.sh +mkdir -p ${PREFIX}/share/dsqss +cp dsqssvars.sh ${PREFIX}/share/dsqss/dsqssvars-@DSQSS_VERSION@.sh diff --git a/tool/cmake/pmwa_pre.in b/tool/cmake/pmwa_pre.in index daaf070f..006ea9ed 100755 --- a/tool/cmake/pmwa_pre.in +++ b/tool/cmake/pmwa_pre.in @@ -18,7 +18,6 @@ import sys sys.path.append('@CMAKE_CURRENT_BINARY_DIR@') -sys.path.append('@pythonpath_build@') from dsqss.pmwa_pre import main if __name__ == '__main__' : main() diff --git a/tool/pyproject.toml b/tool/pyproject.toml index e81ea961..39a95956 100644 --- a/tool/pyproject.toml +++ b/tool/pyproject.toml @@ -13,10 +13,11 @@ packages = [ [tool.poetry.dependencies] python = "^3.6" -numpy = "^1.17" -toml = ">= 0.10.0" -scipy = "^1" -typing-extensions = "^3.7.4" +# Users should install dependencies by themselves +# numpy = "^1.17" +# toml = ">= 0.10.0" +# scipy = "^1" +# typing-extensions = "^3.7.4" [tool.poetry.dev-dependencies]