Skip to content

Commit

Permalink
build: move build requirements to setup.py
Browse files Browse the repository at this point in the history
  • Loading branch information
Artanias committed Feb 25, 2024
1 parent 267198a commit ee3b59a
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 6 deletions.
3 changes: 2 additions & 1 deletion .github/workflows/check_n_push_image.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,9 @@ jobs:
run: |
make substitute-sources
pip install $(python3 setup.py --install-requirements)
pip install $(python3 setup.py --build-requirements)
pip install --requirement docs/notebooks/requirements.txt
pip install pre-commit==3.4.0 Cython==3.0.8
pip install pre-commit==3.4.0
make pre-commit
docker-build-test-autotest:
Expand Down
2 changes: 2 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ DOCKER_SUB_FILES := docker/base_ubuntu2004.dockerfile \
docker/ubuntu2004.dockerfile

PYTHON_REQUIRED_LIBS := $(shell python3 setup.py --install-requirements)
PYTHON_BUILD_LIBS := $(shell python3 setup.py --build-requirements)


ifeq ($(IS_DEVELOPED), 1)
Expand All @@ -45,6 +46,7 @@ substitute = @sed \
-e "s|@CODEPLAG_LOG_PATH@|${CODEPLAG_LOG_PATH}|g" \
-e "s|@DEVEL_SUFFIX@|${DEVEL_SUFFIX}|g" \
-e "s|@PYTHON_REQUIRED_LIBS@|${PYTHON_REQUIRED_LIBS}|g" \
-e "s|@PYTHON_BUILD_LIBS@|${PYTHON_BUILD_LIBS}|g" \
-e "s|@LOGS_PATH@|${LOGS_PATH}|g" \
-e "s|@LIB_PATH@|${LIB_PATH}|g" \
-e "s|@CONFIG_PATH@|${CONFIG_PATH}|g" \
Expand Down
2 changes: 1 addition & 1 deletion docker/test_ubuntu2004.dockerfile.in
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ FROM @BASE_DOCKER_TAG@
ENV DEBIAN_FRONTEND=noninteractive

RUN apt-get install -y debhelper
RUN pip3 install argparse-manpage==3 pytest==7.4.0 pytest-mock==3.11.1 Cython==3.0.8
RUN pip3 install pytest==7.4.0 pytest-mock==3.11.1 @PYTHON_BUILD_LIBS@
RUN mkdir -p @LOGS_PATH@

# TODO: Move to middle docker file or make another solution
Expand Down
23 changes: 19 additions & 4 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
import os
import sys
from pathlib import Path
from typing import Tuple

from Cython.Build import cythonize
from setuptools import Extension, find_packages, setup

INSTALL_REQUIREMENTS = [
BUILD_REQUIREMENTS: Tuple[str, ...] = (
"argparse-manpage==3",
"Cython~=3.0.8",
)
INSTALL_REQUIREMENTS: Tuple[str, ...] = (
"argcomplete~=2.0.0",
"numpy~=1.23.5",
"pandas~=1.4.3",
Expand All @@ -20,17 +24,28 @@
"Jinja2~=3.1.2",
"cachetools==5.3.1",
"gidgethub~=5.3.0",
]
)
UTIL_NAME = os.getenv("UTIL_NAME")
UTIL_VERSION = os.getenv("UTIL_VERSION")


if "--install-requirements" in sys.argv:
if "--build-requirements" in sys.argv:
print(" ".join(BUILD_REQUIREMENTS))
sys.exit(0)
elif "--install-requirements" in sys.argv:
print(" ".join(INSTALL_REQUIREMENTS))
sys.exit(0)
elif UTIL_NAME is None or UTIL_VERSION is None:
print("Please provide UTIL_NAME and UTIL_VERSION environment variables.")
sys.exit(1)
try:
from Cython.Build import cythonize
except ModuleNotFoundError:
print(
"For the correct build install required build dependencies: "
f"'{' '.join(BUILD_REQUIREMENTS)}'."
)
sys.exit(1)


setup(
Expand Down

0 comments on commit ee3b59a

Please sign in to comment.