Skip to content

Commit

Permalink
Fix Python Docker image
Browse files Browse the repository at this point in the history
  • Loading branch information
hombit committed Jan 3, 2022
1 parent 11c4e2c commit 284b5b3
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 5 deletions.
11 changes: 10 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,16 @@ function(CREATE_PY_EXT)
find_package(PythonExtensions REQUIRED)
find_package(NumPy REQUIRED)

find_package(Boost COMPONENTS python numpy filesystem REQUIRED)
set(PYTHON_EXE "${PYTHON_PREFIX}/bin/python")
set(PYTHON_VERSION_SCRIPT "import sys; vi = sys.version_info; print(f'{vi.major}{vi.minor}')")
execute_process(
COMMAND
${PYTHON_EXE} -c "${PYTHON_VERSION_SCRIPT}"
OUTPUT_STRIP_TRAILING_WHITESPACE
OUTPUT_VARIABLE PYTHON_VERSION
)

find_package(Boost REQUIRED COMPONENTS python${PYTHON_VERSION} numpy${PYTHON_VERSION} filesystem)

add_library(${TARGET} MODULE ${MIN_SRC} ${NS_MIN_SRC} ${PYWRAP_SRC})
target_include_directories(${TARGET} PUBLIC ${Boost_INCLUDE_DIRS} ${NumPy_INCLUDE_DIRS})
Expand Down
12 changes: 8 additions & 4 deletions Dockerfile.python
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ RUN curl -LO https://boostorg.jfrog.io/artifactory/main/release/${BOOST_VERSION}
&& rm /boost_${BOOST_VERSION_}.tar.gz \
&& cd /boost_${BOOST_VERSION_} \
&& sh ./bootstrap.sh \
&& echo "using python : 3.7 : /opt/python/cp37-cp37m/bin/python : /opt/python/cp37-cp37m/include/python3.7m : /opt/python/cp37-cp37m/lib ;" >> tools/build/src/user-config.jam \
&& echo "using python : 3.8 : /opt/python/cp38-cp38/bin/python : /opt/python/cp38-cp38/include/python3.8 : /opt/python/cp38-cp38/lib ;" >> tools/build/src/user-config.jam \
&& echo "using python : 3.9 : /opt/python/cp39-cp39/bin/python : /opt/python/cp39-cp39/include/python3.9 : /opt/python/cp39-cp39/lib ;" >> tools/build/src/user-config.jam \
&& echo "using python : 3.7 : /opt/python/cp37-cp37m/bin/python : /opt/python/cp37-cp37m/include/python3.7m : /opt/python/cp37-cp37m/lib ;" >> tools/build/src/user-config.jam \
&& echo "using python : 3.8 : /opt/python/cp38-cp38/bin/python : /opt/python/cp38-cp38/include/python3.8 : /opt/python/cp38-cp38/lib ;" >> tools/build/src/user-config.jam \
&& echo "using python : 3.9 : /opt/python/cp39-cp39/bin/python : /opt/python/cp39-cp39/include/python3.9 : /opt/python/cp39-cp39/lib ;" >> tools/build/src/user-config.jam \
&& echo "using python : 3.10 : /opt/python/cp310-cp310/bin/python : /opt/python/cp310-cp310/include/python3.10 : /opt/python/cp310-cp310/lib ;" >> tools/build/src/user-config.jam \
&& ./b2 -d+2 python=3.7,3.8,3.9,3.10 link=static cflags="-fPIC" cxxflags="-fPIC" install \
&& cd / \
Expand All @@ -35,7 +35,11 @@ COPY python ${SOURCE}/python
WORKDIR ${SOURCE}
RUN python3.7 setup.py sdist -d${DIST}
RUN python3.7 setup.py bdist_wheel -DSTATIC_LINKING=TRUE -d${BUILD} \
&& rm -r _skbuild \
&& python3.8 setup.py bdist_wheel -DSTATIC_LINKING=TRUE -d${BUILD} \
&& rm -r _skbuild \
&& python3.9 setup.py bdist_wheel -DSTATIC_LINKING=TRUE -d${BUILD} \
&& python3.10 setup.py bdist_wheel -DSTATIC_LINKING=TRUE -d${BUILD}
&& rm -r _skbuild \
&& python3.10 setup.py bdist_wheel -DSTATIC_LINKING=TRUE -d${BUILD} \
&& rm -r _skbuild
RUN ls ${BUILD}/*.whl | xargs -iZZZ python3.7 -m auditwheel repair --wheel-dir=${DIST} ZZZ

0 comments on commit 284b5b3

Please sign in to comment.