Skip to content

Commit

Permalink
Merge pull request #15 from UIUCLibrary/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
henryborchers authored Jan 11, 2024
2 parents 60b6ec5 + cfaa687 commit ba19ba8
Show file tree
Hide file tree
Showing 16 changed files with 394 additions and 270 deletions.
3 changes: 3 additions & 0 deletions Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,9 @@ pipeline {
always {
junit 'reports/pytest.xml'
}
failure{
sh('pip list')
}
}
}
stage('Pylint'){
Expand Down
9 changes: 0 additions & 9 deletions ci/docker/linux/jenkins/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
ARG CONAN_USER_HOME=/conan
ARG PIP_DOWNLOAD_CACHE=/.cache/pip

FROM ubuntu:22.04
Expand All @@ -18,11 +17,3 @@ ARG PIP_INDEX_URL
COPY requirements/ /tmp/requirements/requirements/
COPY requirements-ci.txt /tmp/requirements/
RUN python3 -m pip install pip --upgrade && pip install -r /tmp/requirements/requirements-ci.txt

COPY ci/docker/linux/shared/update_conan_compiler.py /tmp/update_conan_compiler.py
ARG CONAN_USER_HOME
RUN conan config init && \
conan config set general.revisions_enabled=1 && \
conan profile update settings.compiler.version=$(cc -dumpfullversion -dumpversion | grep -oE "^([0-9]+(\.)?)([0-9]+?)") default && \
python3 /tmp/update_conan_compiler.py ${CONAN_USER_HOME}/.conan/settings.yml gcc $(cc -dumpfullversion -dumpversion | grep -oE "^([0-9]+(\.)?)([0-9]+?)")
ENV CONAN_USER_HOME=${CONAN_USER_HOME}
10 changes: 0 additions & 10 deletions ci/docker/linux/tox/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
ARG PIPX_HOME=/pipx
ARG CONAN_USER_HOME=/conan
ARG PIP_DOWNLOAD_CACHE=/.cache/pip
FROM ubuntu:22.04
COPY ci/docker/linux/tox/apt-packages.txt /tmp/
Expand All @@ -23,15 +22,6 @@ RUN mkdir -p ${PIP_DOWNLOAD_CACHE} && \
chmod -R 777 ${PIP_DOWNLOAD_CACHE}
ENV PIP_DOWNLOAD_CACHE=${PIP_DOWNLOAD_CACHE}

COPY ci/docker/linux/shared/update_conan_compiler.py /tmp/update_conan_compiler.py
ARG CONAN_USER_HOME
RUN conan config init && \
conan config set general.revisions_enabled=1 && \
conan profile update settings.compiler.version=$(cc -dumpfullversion -dumpversion | grep -oE "^([0-9]+(\.)?)([0-9]+?)") default && \
python3 /tmp/update_conan_compiler.py ${CONAN_USER_HOME}/.conan/settings.yml gcc $(cc -dumpfullversion -dumpversion | grep -oE "^([0-9]+(\.)?)([0-9]+?)")
ENV CONAN_USER_HOME=${CONAN_USER_HOME}


ARG PIPX_HOME
ENV PIPX_HOME=${PIPX_HOME}
ENV PIPX_BIN_DIR=${PIPX_HOME}/bin
Expand Down
75 changes: 38 additions & 37 deletions requirements/requirements-ci-freeze.txt
Original file line number Diff line number Diff line change
@@ -1,61 +1,62 @@
alabaster==0.7.13
astroid==3.0.0
Babel==2.13.0
bottle==0.12.25
cachetools==5.3.1
certifi==2023.7.22
astroid==3.0.2
Babel==2.14.0
cachetools==5.3.2
certifi==2023.11.17
chardet==5.2.0
charset-normalizer==3.3.0
charset-normalizer==3.3.2
colorama==0.4.6
conan==1.61.0
coverage==7.3.2
conan==2.0.17
coverage==7.4.0
dill==0.3.7
distlib==0.3.7
distlib==0.3.8
docutils==0.20.1
exceptiongroup==1.2.0
fasteners==0.19
filelock==3.12.4
flake8==6.1.0
idna==3.4
filelock==3.13.1
flake8==7.0.0
idna==3.6
imagesize==1.4.1
importlib-metadata==7.0.1
iniconfig==2.0.0
isort==5.12.0
Jinja2==3.1.2
lxml==4.9.3
isort==5.13.2
Jinja2==3.1.3
lxml==5.1.0
MarkupSafe==2.1.3
mccabe==0.7.0
mypy==1.6.0
mypy==1.8.0
mypy-extensions==1.0.0
node-semver==0.6.1
packaging==23.2
patch-ng==1.17.4
platformdirs==3.11.0
platformdirs==4.1.0
pluggy==1.3.0
pluginbase==1.0.1
pybind11==2.11.1
pycodestyle==2.11.0
pycodestyle==2.11.1
pydocstyle==6.3.0
pyflakes==3.1.0
Pygments==2.16.1
PyJWT==2.8.0
pylint==3.0.1
pyflakes==3.2.0
Pygments==2.17.2
pylint==3.0.3
pyproject-api==1.6.1
pytest==7.4.2
pytest==7.4.4
python-dateutil==2.8.2
pytz==2023.3.post1
PyYAML==6.0.1
requests==2.31.0
six==1.16.0
snowballstemmer==2.2.0
Sphinx==7.2.6
sphinxcontrib-applehelp==1.0.7
sphinxcontrib-devhelp==1.0.5
sphinxcontrib-htmlhelp==2.0.4
Sphinx==7.1.2
sphinxcontrib-applehelp==1.0.4
sphinxcontrib-devhelp==1.0.2
sphinxcontrib-htmlhelp==2.0.1
sphinxcontrib-jsmath==1.0.1
sphinxcontrib-qthelp==1.0.6
sphinxcontrib-serializinghtml==1.1.9
sphinxcontrib-qthelp==1.0.3
sphinxcontrib-serializinghtml==1.1.5
toml==0.10.2
tomlkit==0.12.1
tox==4.11.3
tqdm==4.66.1
typing_extensions==4.8.0
urllib3==1.26.17
virtualenv==20.24.5
tomli==2.0.1
tomlkit==0.12.3
tox==4.11.4
types-toml==0.10.8.7
typing_extensions==4.9.0
urllib3==1.26.18
virtualenv==20.25.0
zipp==3.17.0
3 changes: 2 additions & 1 deletion requirements/requirements-dev.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ coverage
flake8
lxml
mypy
types-toml
pytest
pylint
sphinx
pydocstyle
pydocstyle
2 changes: 1 addition & 1 deletion requirements/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
toml
conan<2.0
conan
pybind11
46 changes: 26 additions & 20 deletions uiucprescon/build/compiler_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,30 +17,32 @@ def get_compiler_name() -> str:
'^(GCC|Clang|MSVC|MSC)',
platform.python_compiler()
)
try:
if "Clang" in groups[1]:
if platform.system() == "Darwin":
return 'apple-clang'
elif "GCC" in groups[1]:
return 'gcc'
elif groups[1] in ['MSVC', 'MSC']:
return 'Visual Studio'
else:
return groups[1]
except TypeError:
print(
f"python compiler = {platform.python_compiler()}",
file=sys.stderr
)
raise
if groups is not None:
try:
if "Clang" in groups[1]:
if platform.system() == "Darwin":
return 'apple-clang'
elif "GCC" in groups[1]:
return 'gcc'
elif groups[1] in ['MSVC', 'MSC']:
return 'Visual Studio'
else:
return groups[1]
except TypeError:
print(
f"python compiler = {platform.python_compiler()}",
file=sys.stderr
)
raise
raise ValueError("Unable to locate compiler or unknown compiler")


if sys.platform == 'darwin':
_cfg_target = None
_cfg_target_split = None


def get_visual_studio_version():
def get_visual_studio_version() -> str:
import winreg
possible_versions = [
"8.0", "9.0", "10.0", "11.0", "12.0", "14.0", "15.0", "16.0"
Expand All @@ -64,7 +66,7 @@ def get_visual_studio_version():
return sorted_values[-1].split(".")[0]


def get_clang_version():
def get_clang_version() -> str:
cmd = ['cc', '--version']

env = None
Expand Down Expand Up @@ -101,6 +103,8 @@ def get_clang_version():
exitcode = proc.returncode
clang_version_regex = re.compile(
r'(?<=Apple clang version )((\d+[.]){1,2}\d+)')
if proc.stdout is None:
raise ValueError("unable to read standard out of process")
compiler_response = proc.stdout.read().decode('utf-8')
try:
env_version = clang_version_regex.search(
Expand All @@ -121,12 +125,14 @@ def get_clang_version():
raise ExecError("command %r failed: %s" % (cmd, exc.args[-1])) from exc


def get_gcc_version():
def get_gcc_version() -> str:
cmd = ['cc', '-dumpfullversion', '-dumpversion']
try:
proc = subprocess.Popen(cmd, stdout=subprocess.PIPE)
proc.wait()
exitcode = proc.returncode
if proc.stdout is None:
raise ValueError("unable to read standard out of process")
compiler_response = proc.stdout.read().decode('utf-8')
if exitcode:
raise ExecError(f"command {cmd} failed with exit code {exitcode}")
Expand All @@ -140,7 +146,7 @@ def get_gcc_version():
raise ExecError("command %r failed: %s" % (cmd, exc.args[-1])) from exc


def get_compiler_version():
def get_compiler_version() -> str:
"""
Examples of compiler data:
GCC 10.2.1 20210110
Expand Down
2 changes: 1 addition & 1 deletion uiucprescon/build/conan/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@
if _version('conan')[0] == "2":
from . import v2 as conan_api
else:
from . import v1 as conan_api
from . import v1 as conan_api # type: ignore[no-redef]

__all__ = ['conan_api']
45 changes: 29 additions & 16 deletions uiucprescon/build/conan/files.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
from typing import List, Dict, TypedDict, Iterable, Any
import io
from typing import List, Dict, TypedDict, Iterable, Optional
import abc


import warnings
from uiucprescon.build.utils import locate_file
class ConanBuildInfoParser:
def __init__(self, fp):
def __init__(self, fp: io.TextIOWrapper) -> None:
self._fp = fp

def parse(self) -> Dict[str, List[str]]:
Expand All @@ -14,13 +15,13 @@ def parse(self) -> Dict[str, List[str]]:
data[subject_title] = subject_chunk[1:]
return data

def iter_subject_chunk(self) -> Iterable[Any]:
buffer = []
def iter_subject_chunk(self) -> Iterable[List[str]]:
buffer: List[str] = []
for line in self._fp:
line = line.strip()
if len(line) == 0:
continue
if line.startswith("[") and line.endswith("]") and len(buffer) > 0:
if line.startswith("[") and line.endswith("]") and buffer:
yield buffer
buffer.clear()
buffer.append(line)
Expand All @@ -46,18 +47,12 @@ class ConanLibraryMetadata(TypedDict):
frameworks: List[str]
frameworkdirs: List[str]
rootpath: List[str]
name: List[str]
version: List[str]
name: str
version: Optional[str]
generatornames: List[str]
generatorfilenames: List[str]


class AbsConanBuildInfo(abc.ABC):
@abc.abstractmethod
def parse(self, filename: str) -> Dict[str, str]:
pass


class ConanBuildInfo(TypedDict):
definitions: List[str]
include_paths: List[str]
Expand All @@ -67,10 +62,15 @@ class ConanBuildInfo(TypedDict):
metadata: Dict[str, ConanLibraryMetadata]


class AbsConanBuildInfo(abc.ABC):
@abc.abstractmethod
def parse(self, filename: str) -> ConanBuildInfo:
pass


class ConanBuildInfoTXT(AbsConanBuildInfo):

def parse(self, filename: str) -> ConanBuildInfo:
# def parse(self, filename: str) -> Dict[str, Union[str, List[str]]]:
with open(filename, "r", encoding="utf-8") as f:
parser = ConanBuildInfoParser(f)
data = parser.parse()
Expand Down Expand Up @@ -130,3 +130,16 @@ def parse(self, filename: str) -> ConanBuildInfo:
"metadata": libsmetadata

}
def locate_conanbuildinfo(search_locations: List[str]) -> Optional[str]:
warnings.warn(
message="use uiucprescon.build.utils.locate_file() instead",
category=DeprecationWarning
)
return locate_file("conanbuildinfo.txt", search_locations)

def locate_conanbuildinfo_json(search_locations: List[str]) -> Optional[str]:
warnings.warn(
message="use uiucprescon.build.utils.locate_file() instead",
category=DeprecationWarning
)
return locate_file("conanbuildinfo.json", search_locations)
Loading

0 comments on commit ba19ba8

Please sign in to comment.