Skip to content

Commit

Permalink
Build system fixes (#41)
Browse files Browse the repository at this point in the history
Build system fixes and modernization
  • Loading branch information
SylvanBrocard committed Oct 24, 2024
2 parents cde26fa + 059fb4d commit dceb94e
Show file tree
Hide file tree
Showing 38 changed files with 563 additions and 277 deletions.
1 change: 1 addition & 0 deletions .clang-format
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
BasedOnStyle: Google
62 changes: 62 additions & 0 deletions .clang-tidy
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
Checks: >
*,
-llvmlibc*,
-fuchsia*,
-altera*,
-android*,
CheckOptions:
- key: readability-identifier-naming.ClassCase
value: CamelCase
- key: readability-identifier-naming.ClassMemberCase
value: lower_case
- key: readability-identifier-naming.ConstexprVariableCase
value: CamelCase
- key: readability-identifier-naming.ConstexprVariablePrefix
value: k
- key: readability-identifier-naming.EnumCase
value: lower_case
- key: readability-identifier-naming.EnumPrefix
value: _
- key: readability-identifier-naming.EnumConstantCase
value: UPPER_CASE
- key: readability-identifier-naming.EnumConstantPrefix
value: ''
- key: readability-identifier-naming.FunctionCase
value: lower_case
- key: readability-identifier-naming.GlobalConstantCase
value: UPPER_CASE
- key: readability-identifier-naming.StaticConstantCase
value: CamelCase
- key: readability-identifier-naming.StaticConstantPrefix
value: k
- key: readability-identifier-naming.StaticVariableCase
value: lower_case
- key: readability-identifier-naming.MacroDefinitionCase
value: UPPER_CASE
- key: readability-identifier-naming.MacroDefinitionIgnoredRegexp
value: "(^[A-Z]+(_[A-Z]+)*_$|^_.*)"
- key: readability-identifier-naming.MemberCase
value: lower_case
- key: readability-identifier-naming.PrivateMemberSuffix
value: _
- key: readability-identifier-naming.PublicMemberSuffix
value: ""
- key: readability-identifier-naming.NamespaceCase
value: lower_case
- key: readability-identifier-naming.ParameterCase
value: lower_case
- key: readability-identifier-naming.TypeAliasCase
value: camelBack
- key: readability-identifier-naming.TypedefCase
value: lower_case
- key: readability-identifier-naming.TypeDefSuffix
value: _t
- key: readability-identifier-naming.VariableCase
value: lower_case
- key: readability-identifier-naming.IgnoreMainLikeFunctions
value: 1
- key: readability-identifier-naming.MethodCase
value: camelBack
- key: readability-identifier-naming.StructCase
value: lower_case
18 changes: 9 additions & 9 deletions .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
# See here for image contents: https://github.com/microsoft/vscode-dev-containers/tree/v0.194.3/containers/ubuntu/.devcontainer/base.Dockerfile
# See here for image contents: https://github.com/devcontainers/images/tree/main/src/base-ubuntu

# [Choice] Ubuntu version: hirsute, bionic, focal
ARG VARIANT="focal"
ARG VARIANT="jammy"
FROM mcr.microsoft.com/vscode/devcontainers/base:0-${VARIANT}

# [Optional] Uncomment this section to install additional OS packages.
# RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \
# && apt-get -y install --no-install-recommends <your-package-list-here>

RUN sudo apt update \
&& sudo apt -y install python-is-python3 pip build-essential cmake ninja-build cppcheck \
&& sudo apt full-upgrade -y
RUN sudo apt update \
&& wget http://sdk-releases.upmem.com/2021.3.0/ubuntu_20.04/upmem_2021.3.0_amd64.deb \
&& sudo apt install -y ./upmem_2021.3.0_amd64.deb
RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \
&& apt-get -y install build-essential ninja-build cppcheck nox pre-commit\
&& apt-get dist-upgrade -y
RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \
&& wget http://sdk-releases.upmem.com/2024.2.0/ubuntu_22.04/upmem_2024.2.0_amd64.deb \
&& apt-get install -y ./upmem_2024.2.0_amd64.deb \
&& rm upmem_2024.2.0_amd64.deb
72 changes: 35 additions & 37 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,53 +5,51 @@
"build": {
"dockerfile": "Dockerfile",
// Update 'VARIANT' to pick an Ubuntu version: hirsute, focal, bionic
"args": { "VARIANT": "focal" }
"args": {
"VARIANT": "jammy"
}
},
// "runArgs": [ "--init", "--cap-add=SYS_PTRACE", "--security-opt", "seccomp=unconfined"],

// Set *default* container specific settings.json values on container create.
"settings": {
"python.pythonPath": "/usr/bin/python",
"python.languageServer": "Pylance",
"python.linting.enabled": true,
"python.linting.pylintEnabled": true,
"python.formatting.autopep8Path": "/usr/local/py-utils/bin/autopep8",
"python.formatting.blackPath": "/usr/local/py-utils/bin/black",
"python.formatting.yapfPath": "/usr/local/py-utils/bin/yapf",
"python.formatting.provider": "black",
"python.linting.banditPath": "/usr/local/py-utils/bin/bandit",
"python.linting.flake8Path": "/usr/local/py-utils/bin/flake8",
"python.linting.mypyPath": "/usr/local/py-utils/bin/mypy",
"python.linting.pycodestylePath": "/usr/local/py-utils/bin/pycodestyle",
"python.linting.pydocstylePath": "/usr/local/py-utils/bin/pydocstyle",
"python.linting.pylintPath": "/usr/local/py-utils/bin/pylint",
"python.linting.pylintArgs": [
"--extension-pkg-whitelist=dpu_kmeans._core",
"--ignored-modules=dpu_kmeans._core"
],
"customizations": {
"vscode": {
// Set *default* container specific settings.json values on container create.
"settings": {
"python.pythonPath": "/usr/bin/python",
"python.languageServer": "Pylance",
"[python]": {
"editor.defaultFormatter": "charliermarsh.ruff"
},
"ruff.lint.select": [
"ALL"
]
},
// Add the IDs of extensions you want installed when the container is created.
"extensions": [
"llvm-vs-code-extensions.vscode-clangd",
"twxs.cmake",
"donjayamanne.githistory",
"ms-python.python",
"ms-python.vscode-pylance",
"cschlosser.doxdocgen",
"charliermarsh.ruff",
"mhutchie.git-graph",
"tamasfe.even-better-toml"
]
}
},

// Add the IDs of extensions you want installed when the container is created.
"extensions": [
"llvm-vs-code-extensions.vscode-clangd",
"twxs.cmake",
"donjayamanne.githistory",
"ms-python.python",
"ms-python.vscode-pylance",
"cschlosser.doxdocgen"
],

"features": {
"git": "os-provided",
"python": "os-provided"
"ghcr.io/devcontainers/features/git:1": {},
"ghcr.io/devcontainers/features/python:1": {
"installTools": false
}
},

// Use 'forwardPorts' to make a list of ports inside the container available locally.
// "forwardPorts": [],

// Use 'postCreateCommand' to run commands after the container is created.
"postCreateCommand": "pip install --upgrade pip nox pre-commit scikit-build pybind11[global] twine setuptools_scm hurry.filesize && pre-commit install && python setup.py clean && pip install --no-build-isolation -e .[test]",
"postCreateCommand": "pre-commit install && pip install -e .[test]",

// Comment out connect as root instead. More info: https://aka.ms/vscode-remote/containers/non-root.
"remoteUser": "vscode",
"remoteUser": "vscode"
}
3 changes: 3 additions & 0 deletions .git-blame-ignore-revs
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# ruff format

d13f4f15e3ee24b06ac2e98f8806c054f22488d2
37 changes: 37 additions & 0 deletions .github/workflows/documentation.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
name: documentation

on:
workflow_dispatch:
pull_request:
push:
branches:
- master

permissions:
contents: write

jobs:
docs:
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: 3.9
- name: Download SDK
run: wget http://sdk-releases.upmem.com/2024.2.0/ubuntu_22.04/upmem_2024.2.0_amd64.deb
- name: Install SDK
run: sudo apt install -y ./upmem_2024.2.0_amd64.deb
- name: Build and install
run: pip install --verbose .[doc]
- name: Sphinx build
run: |
sphinx-build docs _build
- name: Deploy to GitHub Pages
uses: peaceiris/actions-gh-pages@v3
if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/master' }}
with:
publish_branch: gh-pages
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: _build/
force_orphan: true
28 changes: 16 additions & 12 deletions .github/workflows/pip.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,23 +13,25 @@ jobs:
strategy:
fail-fast: false
matrix:
platform: [ubuntu-latest]
platform: [ubuntu-22.04]
python-version: ["3.7", "3.8", "3.9", "3.10"]

runs-on: ${{ matrix.platform }}

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
with:
fetch-depth: 0

- uses: actions/setup-python@v2
- uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}

- name: Download SDK
run: wget http://sdk-releases.upmem.com/2021.2.0/ubuntu_20.04/upmem_2021.2.0_amd64.deb
run: wget http://sdk-releases.upmem.com/2024.2.0/ubuntu_22.04/upmem_2024.2.0_amd64.deb

- name: Install SDK
run: sudo apt install -y ./upmem_2021.2.0_amd64.deb
run: sudo apt install -y ./upmem_2024.2.0_amd64.deb

- name: Build and install
run: pip install --verbose .[test]
Expand All @@ -42,30 +44,32 @@ jobs:
strategy:
fail-fast: false
matrix:
platform: [ubuntu-latest]
platform: [ubuntu-22.04]
python-version: ["3.7", "3.8", "3.9", "3.10"]

runs-on: ${{ matrix.platform }}

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
with:
fetch-depth: 0

- uses: actions/setup-python@v2
- uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}

- name: Download SDK
run: wget http://sdk-releases.upmem.com/2021.2.0/ubuntu_20.04/upmem-2021.2.0-Linux-x86_64.tar.gz
run: wget http://sdk-releases.upmem.com/2024.2.0/ubuntu_22.04/upmem-2024.2.0-Linux-x86_64.tar.gz

- name: Untar SDK
run: tar -zxvf upmem-2021.2.0-Linux-x86_64.tar.gz
run: tar -zxvf upmem-2024.2.0-Linux-x86_64.tar.gz

- name: Build and install
run: |
source upmem-2021.2.0-Linux-x86_64/upmem_env.sh
source upmem-2024.2.0-Linux-x86_64/upmem_env.sh
pip install --verbose .[test]
- name: Test
run: |
source upmem-2021.2.0-Linux-x86_64/upmem_env.sh
source upmem-2024.2.0-Linux-x86_64/upmem_env.sh
pytest
6 changes: 3 additions & 3 deletions .github/workflows/wheels.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,17 +18,17 @@ env:
jobs:
build_sdist:
name: Build SDist
runs-on: ubuntu-latest
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v2
with:
submodules: true

- name: Download SDK
run: wget http://sdk-releases.upmem.com/2021.2.0/ubuntu_20.04/upmem_2021.2.0_amd64.deb
run: wget http://sdk-releases.upmem.com/2024.2.0/ubuntu_22.04/upmem_2024.2.0_amd64.deb

- name: Install SDK
run: sudo apt install -y ./upmem_2021.2.0_amd64.deb
run: sudo apt install -y ./upmem_2024.2.0_amd64.deb

- name: Build SDist
run: pipx run build --sdist
Expand Down
2 changes: 2 additions & 0 deletions .mailmap
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# All emails used by Sylvan Brocard
SylvanBrocard <[email protected]> <[email protected]>
27 changes: 10 additions & 17 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,12 @@
#
# See https://github.com/pre-commit/pre-commit

exclude: '(_core.pyi|_kmeans_w_perf.py)'

repos:
# Standard hooks
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.2.0
rev: v4.6.0
hooks:
- id: check-added-large-files
- id: check-case-conflict
Expand All @@ -27,29 +29,20 @@ repos:
- id: mixed-line-ending
- id: requirements-txt-fixer
- id: trailing-whitespace
- id: fix-encoding-pragma

# isort
- repo: https://github.com/PyCQA/isort
rev: 5.10.1
hooks:
- id: isort
name: isort (python)
args: ["--profile", "black", "--filter-files"]

# Black, the code formatter, natively supports pre-commit
- repo: https://github.com/psf/black
rev: 22.3.0
# format with Ruff
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.4.2
hooks:
- id: black
exclude: ^(docs)
- id: ruff-format
exclude: ^(docs)

# C/C++ files code formatting
# C/C++ files code formatting and linting
- repo: https://github.com/pocc/pre-commit-hooks
rev: v1.3.5
hooks:
- id: clang-format
args: ["--style=Google", "-i"]
args: ["-i"]
- id: cppcheck

# Changes tabs to spaces
Expand Down
12 changes: 0 additions & 12 deletions .pylintrc

This file was deleted.

Loading

0 comments on commit dceb94e

Please sign in to comment.