From bad1b6a4209f7dd6c6c604db517db5fb66382457 Mon Sep 17 00:00:00 2001 From: Martijn Govers Date: Fri, 13 Dec 2024 11:43:31 +0100 Subject: [PATCH] initial commit Signed-off-by: Martijn Govers --- .github/dco.yml | 4 + .github/dependabot.yml | 6 + .github/workflows/main.yml | 75 +++++++++++++ .gitignore | 135 +++++++++++++++++++++++ .pre-commit-config.yaml | 5 + LICENSE | 23 ++++ README.md | 16 +++ pyproject.toml | 52 +++++++++ src/libboost_headers/__init__.py | 7 ++ src/libboost_headers/include/__init__.py | 0 tests/test_msgpack_header.py | 8 ++ 11 files changed, 331 insertions(+) create mode 100644 .github/dco.yml create mode 100644 .github/dependabot.yml create mode 100644 .github/workflows/main.yml create mode 100644 .gitignore create mode 100644 .pre-commit-config.yaml create mode 100644 LICENSE create mode 100644 README.md create mode 100644 pyproject.toml create mode 100644 src/libboost_headers/__init__.py create mode 100644 src/libboost_headers/include/__init__.py create mode 100644 tests/test_msgpack_header.py diff --git a/.github/dco.yml b/.github/dco.yml new file mode 100644 index 0000000..98b97db --- /dev/null +++ b/.github/dco.yml @@ -0,0 +1,4 @@ +allowRemediationCommits: + individual: true + thirdParty: true + diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 0000000..5ace460 --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,6 @@ +version: 2 +updates: + - package-ecosystem: "github-actions" + directory: "/" + schedule: + interval: "weekly" diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml new file mode 100644 index 0000000..106a500 --- /dev/null +++ b/.github/workflows/main.yml @@ -0,0 +1,75 @@ +name: Upload libboost-headers to PyPI + +on: + pull_request: + workflow_dispatch: + +jobs: + + get-versions: + name: "Upload latest libboost-headers version to PyPI" + runs-on: ubuntu-latest + permissions: + contents: read + env: + TWINE_USERNAME: ${{ secrets.PYPI_USER }} + TWINE_PASSWORD: ${{ secrets.PYPI_PASS }} + + steps: + - uses: actions/checkout@v4 + + - name: Setup python + uses: actions/setup-python@v4 + with: + python-version: "3.11" + architecture: x64 + + - name: Install dependencies + run: pip install build + + - name: Enable brew + run: echo "/home/linuxbrew/.linuxbrew/bin:/home/linuxbrew/.linuxbrew/sbin" >> $GITHUB_PATH + + - name: Download boost + run: brew install boost + + - name: Get latest version + id: version + run: echo "latest=$(brew list --version boost | sed -e 's/boost\s//' | sed -e 's/_\w*//')" >> $GITHUB_OUTPUT + + - name: List version + run: echo "latest=${{ steps.version.outputs.latest }}" + + - name: Get the libboost-headers contents + run: cp -r /home/linuxbrew/.linuxbrew/Cellar/boost/${{ steps.version.outputs.latest }}/include/* src/libboost_headers/include + + - name: Set PyPI Version + run: echo "${{ steps.version.outputs.latest }}" >> PYPI_VERSION + + - name: Show contents + run: ls -ahl src/libboost_headers/include + + - name: Build wheel + run: python -m build --wheel --outdir wheelhouse . + + - name: Test wheel + run: | + pip install wheelhouse/* + pip install pytest + pytest + + - name: Keep Wheel file + uses: actions/upload-artifact@v3 + with: + name: wheelhouse + path: ./wheelhouse/*.whl + + - name: List assets + run: ls ./wheelhouse/ -al + + # - name: Upload wheels + # if: github.event_name == 'workflow_dispatch' + # run: | + # pip install twine + # echo "Publish to PyPI..." + # twine upload --verbose wheelhouse/* diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..d006a8f --- /dev/null +++ b/.gitignore @@ -0,0 +1,135 @@ +# Byte-compiled / optimized / DLL files +__pycache__/ +*.py[cod] +*$py.class + +# C extensions +*.so + +# Distribution / packaging +.Python +build/ +develop-eggs/ +dist/ +downloads/ +eggs/ +.eggs/ +lib/ +lib64/ +parts/ +sdist/ +var/ +wheels/ +pip-wheel-metadata/ +share/python-wheels/ +*.egg-info/ +.installed.cfg +*.egg +MANIFEST + +# PyInstaller +# Usually these files are written by a python script from a template +# before PyInstaller builds the exe, so as to inject date/other infos into it. +*.manifest +*.spec + +# Installer logs +pip-log.txt +pip-delete-this-directory.txt + +# Unit test / coverage reports +htmlcov/ +.tox/ +.nox/ +.coverage +.coverage.* +.cache +nosetests.xml +coverage.xml +*.cover +*.py,cover +.hypothesis/ +.pytest_cache/ + +# Translations +*.mo +*.pot + +# Django stuff: +*.log +local_settings.py +db.sqlite3 +db.sqlite3-journal + +# Flask stuff: +instance/ +.webassets-cache + +# Scrapy stuff: +.scrapy + +# Sphinx documentation +docs/_build/ + +# PyBuilder +target/ + +# Jupyter Notebook +.ipynb_checkpoints + +# IPython +profile_default/ +ipython_config.py + +# pyenv +.python-version + +# pipenv +# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control. +# However, in case of collaboration, if having platform-specific dependencies or dependencies +# having no cross-platform support, pipenv may install dependencies that don't work, or not +# install all needed dependencies. +#Pipfile.lock + +# PEP 582; used by e.g. github.com/David-OConnor/pyflow +__pypackages__/ + +# Celery stuff +celerybeat-schedule +celerybeat.pid + +# SageMath parsed files +*.sage.py + +# Environments +.env +.venv +env/ +venv/ +ENV/ +env.bak/ +venv.bak/ + +# Spyder project settings +.spyderproject +.spyproject + +# Rope project settings +.ropeproject + +# mkdocs documentation +/site + +# mypy +.mypy_cache/ +.dmypy.json +dmypy.json + +# Pyre type checker +.pyre/ + + +.vscode +PYPI_VERSION + +.idea/ diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 0000000..517039f --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,5 @@ +repos: + - repo: https://github.com/fsfe/reuse-tool + rev: v1.0.0 + hooks: + - id: reuse diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..36b7cd9 --- /dev/null +++ b/LICENSE @@ -0,0 +1,23 @@ +Boost Software License - Version 1.0 - August 17th, 2003 + +Permission is hereby granted, free of charge, to any person or organization +obtaining a copy of the software and accompanying documentation covered by +this license (the "Software") to use, reproduce, display, distribute, +execute, and transmit the Software, and to prepare derivative works of the +Software, and to permit third-parties to whom the Software is furnished to +do so, all subject to the following: + +The copyright notices in the Software and this entire statement, including +the above license grant, this restriction and the following disclaimer, +must be included in all copies of the Software, in whole or in part, and +all derivative works of the Software, unless such copies or derivative +works are solely in the form of machine-executable object code generated by +a source language processor. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT +SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE +FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE, +ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +DEALINGS IN THE SOFTWARE. diff --git a/README.md b/README.md new file mode 100644 index 0000000..df2175a --- /dev/null +++ b/README.md @@ -0,0 +1,16 @@ +# Boost PyPI + +This repo contains automation for [Boost](https://github.com/boostorg/boost). + +It creates, packages and pushes the header-only library `libboost-headers` to PyPI. +This repo is the equivalent of the [Anaconda libboost-headers](https://anaconda.org/conda-forge/libboost-headers) package. + +**NOTE:** Packages created by this repo only contain the raw source code and not a Python package. + +Credits go to the maintainers of the [Boost](https://github.com/boostorg/boost) package. + +## License + +The files in this repository are licensed under the Boost Software License - Version 1.0. + +The distributed boost package is a redistribution of [Boost](https://github.com/boostorg/boost) and therefore falls under the [Boost license model](https://github.com/boostorg/boost/blob/master/LICENSE_1_0.txt) as described in the [LICENCE_1_0.txt file in the Boost repository](https://github.com/boostorg/boost/blob/master/LICENSE_1_0.txt). diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 0000000..b0c4414 --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,52 @@ +[build-system] +requires = [ + "setuptools", + "wheel", +] +build-backend = "setuptools.build_meta" + +[project] +name = "libboost-headers" +authors = [ + { name = "Contributors to the Power Grid Model project", email = "powergridmodel@lfenergy.org" } +] +description = "Repackaging of libboost-headers distributed via PyPI" +readme = "README.md" +license = { text = "BSL-1.0" } +classifiers = [ + "Programming Language :: C++", + "Development Status :: 5 - Production/Stable", + "Intended Audience :: Developers", + "License :: OSI Approved :: Boost Software License 1.0 (BSL-1.0)", + "Operating System :: Microsoft :: Windows", + "Operating System :: POSIX :: Linux", + "Operating System :: MacOS", + "Topic :: File Formats", + "Topic :: Software Development :: Libraries", +] +dependencies = [ + "importlib-resources" +] +dynamic = [ + "version" +] + +[project.optional-dependencies] +dev = [ + "pytest" +] + +[project.urls] +Home-page = "http://www.boost.org/" +GitHub = "https://github.com/boostorg/boost" +Documentation = "https://www.boost.org/doc/" + +[tool.setuptools.packages.find] +where = ["src"] +namespaces = true + +[tool.setuptools.dynamic] +version = {file = "PYPI_VERSION"} + +[tool.setuptools.package-data] +libboost_headers = ["include/**/*"] diff --git a/src/libboost_headers/__init__.py b/src/libboost_headers/__init__.py new file mode 100644 index 0000000..dd6769e --- /dev/null +++ b/src/libboost_headers/__init__.py @@ -0,0 +1,7 @@ +from pathlib import Path + +from importlib_resources import files + + +def get_include() -> Path: + return files("boost.include") diff --git a/src/libboost_headers/include/__init__.py b/src/libboost_headers/include/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/tests/test_msgpack_header.py b/tests/test_msgpack_header.py new file mode 100644 index 0000000..15c1fe0 --- /dev/null +++ b/tests/test_msgpack_header.py @@ -0,0 +1,8 @@ +from pathlib import Path + +from libboost_headers import get_include + + +def test_header(): + include_path: Path = get_include() + assert (include_path / "version.hpp").exists()