Skip to content

Commit

Permalink
update install script for python tools (#44)
Browse files Browse the repository at this point in the history
* update CI envs

* use latest action

* update

* update

* specify python executable explicitly

* check site-packages directory names

* apt update
  • Loading branch information
yomichi authored Mar 19, 2024
1 parent a7a0054 commit d0f7ac9
Show file tree
Hide file tree
Showing 13 changed files with 36 additions and 39 deletions.
8 changes: 4 additions & 4 deletions .github/workflows/deploy_docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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/[email protected]

- 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

Expand Down
20 changes: 13 additions & 7 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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
Expand All @@ -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
Expand Down
1 change: 0 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand Down
8 changes: 2 additions & 6 deletions tool/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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)")
1 change: 0 additions & 1 deletion tool/cmake/dla_alg.in
Original file line number Diff line number Diff line change
Expand Up @@ -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()
1 change: 0 additions & 1 deletion tool/cmake/dla_hamgen.in
Original file line number Diff line number Diff line change
Expand Up @@ -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()
1 change: 0 additions & 1 deletion tool/cmake/dla_latgen.in
Original file line number Diff line number Diff line change
Expand Up @@ -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()
1 change: 0 additions & 1 deletion tool/cmake/dla_pgen.in
Original file line number Diff line number Diff line change
Expand Up @@ -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()
1 change: 0 additions & 1 deletion tool/cmake/dla_pre.in
Original file line number Diff line number Diff line change
@@ -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()
1 change: 0 additions & 1 deletion tool/cmake/dla_wvgen.in
Original file line number Diff line number Diff line change
Expand Up @@ -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()
22 changes: 12 additions & 10 deletions tool/cmake/install.sh.in
Original file line number Diff line number Diff line change
@@ -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-@[email protected]
1 change: 0 additions & 1 deletion tool/cmake/pmwa_pre.in
Original file line number Diff line number Diff line change
Expand Up @@ -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()
9 changes: 5 additions & 4 deletions tool/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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]

Expand Down

0 comments on commit d0f7ac9

Please sign in to comment.