diff --git a/.github/workflows/manylinux_build.sh b/.github/workflows/manylinux_build.sh new file mode 100644 index 0000000..f94f7db --- /dev/null +++ b/.github/workflows/manylinux_build.sh @@ -0,0 +1,8 @@ +cd /workdir +yum -y install centos-release-scl-rh +yum -y install llvm-toolset-7.0 +source scl_source enable llvm-toolset-7.0 +curl https://sh.rustup.rs -sSf | sh -s -- -y --profile minimal +curl --verbose -L "https://github.com/PyO3/maturin/releases/latest/download/maturin-%arch%-unknown-linux-musl.tar.gz" | tar -xz -C /usr/local/bin +export PATH="${PATH}:/root/.cargo/bin:/opt/python/cp37-cp37m/bin:/opt/python/cp38-cp38/bin:/opt/python/cp39-cp39/bin:/opt/python/cp310-cp310/bin" +maturin build --release -m python/Cargo.toml diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index e3b0043..68e7a55 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -7,40 +7,82 @@ on: jobs: - publish_lib_crate: +publish_pypi_linux: runs-on: ubuntu-latest + strategy: + matrix: + architecture: [ "x86_64", "aarch64" ] + continue-on-error: true steps: - uses: actions/checkout@v2 - - run: rustup update - - run: cargo login $CRATES_IO_TOKEN - env: - CRATES_IO_TOKEN: ${{ secrets.CRATES_IO_TOKEN }} - - run: cargo publish - publish_pypi_linux: - runs-on: ubuntu-latest - needs: publish_lib_crate - steps: - - uses: actions/checkout@v2 - - run: docker run --rm -v $(pwd):/io -e PYO3_PYTHON=python3.7 konstin2/maturin:latest publish --cargo-extra-args="--features python-library" -u "${{ secrets.PYPI_USER }}" -p "${{ secrets.PYPI_PASS }}" + with: + submodules: true + - uses: docker/setup-qemu-action@v1 + with: + platforms: linux/${{ matrix.architecture }} + if: matrix.architecture != 'x86_64' + - run: sed 's/%arch%/${{ matrix.architecture }}/g' .github/workflows/manylinux_build.sh > .github/workflows/manylinux_build_script.sh + - run: docker run -v "$(pwd)":/workdir --platform linux/${{ matrix.architecture }} quay.io/pypa/manylinux2014_${{ matrix.architecture }} /bin/bash /workdir/.github/workflows/manylinux_build_script.sh + - uses: pypa/gh-action-pypi-publish@release/v1 + with: + user: __token__ + password: ${{ secrets.PYPI_PASS }} + packages_dir: target/wheels + - uses: softprops/action-gh-release@v1 + with: + files: target/wheels/* + publish_pypi_mac: runs-on: macos-latest - needs: publish_lib_crate + env: + DEVELOPER_DIR: '/Applications/Xcode.app/Contents/Developer' + SDKROOT: '/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk' + MACOSX_DEPLOYMENT_TARGET: '10.14' steps: - uses: actions/checkout@v2 - - run: rustup update && rustup target add x86_64-apple-darwin && rustup target add aarch64-apple-darwin + with: + submodules: true - uses: actions/setup-python@v2 with: python-version: 3.7 - - run: pip install 'maturin>=0.13,<0.14' cffi - - run: maturin publish -F python-library --universal2 --no-sdist -u "${{ secrets.PYPI_USER }}" -p "${{ secrets.PYPI_PASS }}" + - run: rustup update && rustup target add aarch64-apple-darwin + - run: pip install maturin + - run: maturin publish --no-sdist --universal2 -m python/Cargo.toml -u __token__ -p ${{ secrets.PYPI_PASS }} + - run: maturin publish --no-sdist -m python/Cargo.toml -u __token__ -p ${{ secrets.PYPI_PASS }} + - uses: softprops/action-gh-release@v1 + with: + files: target/wheels/* + publish_pypi_windows: runs-on: windows-latest - needs: publish_lib_crate steps: - uses: actions/checkout@v2 - - run: rustup toolchain install stable-gnu + with: + submodules: true - uses: actions/setup-python@v2 with: python-version: 3.7 - - run: pip install 'maturin>=0.13,<0.14' cffi - - run: maturin publish -F python-library --no-sdist -u "${{ secrets.PYPI_USER }}" -p "${{ secrets.PYPI_PASS }}" + - run: rustup update + - run: pip install maturin + - run: Remove-Item -LiteralPath "C:\msys64\" -Force -Recurse + - run: maturin publish --no-sdist -m python/Cargo.toml -u __token__ -p ${{ secrets.PYPI_PASS }} + - uses: softprops/action-gh-release@v1 + with: + files: target/wheels/* + + publish_pypi_stdist: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + with: + submodules: true + - run: pip install maturin + - run: maturin sdist -m python/Cargo.toml + - uses: pypa/gh-action-pypi-publish@release/v1 + with: + user: __token__ + password: ${{ secrets.PYPI_PASS }} + packages_dir: target/wheels + - uses: softprops/action-gh-release@v1 + with: + files: target/wheels/* diff --git a/Cargo.toml b/Cargo.toml index 90dceb2..03bb17a 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "reasonable" -version = "0.1.60" +version = "0.1.61" authors = ["Gabe Fierro <gtfierro@mines.edu>"] repository = "https://github.com/gtfierro/reasonable" homepage = "https://brickschema.org/" diff --git a/poetry.lock b/poetry.lock index 6628fb8..3435a5f 100644 --- a/poetry.lock +++ b/poetry.lock @@ -37,6 +37,14 @@ python-versions = "*" [package.dependencies] six = "*" +[[package]] +name = "libclang" +version = "14.0.6" +description = "Clang Python Bindings, mirrored from the official LLVM repo: https://github.com/llvm/llvm-project/tree/main/clang/bindings/python, to make the installation process easier." +category = "main" +optional = false +python-versions = "*" + [[package]] name = "maturin" version = "0.13.1" @@ -131,7 +139,7 @@ testing = ["pytest (>=6)", "pytest-checkdocs (>=2.4)", "pytest-flake8", "pytest- [metadata] lock-version = "1.1" python-versions = "^3.7" -content-hash = "add3dffcb21d4f3ec87f1dff178b3f324a4ba96d1a1202bda489018d4451df27" +content-hash = "b7441385766e6e517a0ec8a7f0e05320c615af820e4d081f530dd09c1ecc2afc" [metadata.files] cffi = [] @@ -143,6 +151,7 @@ isodate = [ {file = "isodate-0.6.1-py2.py3-none-any.whl", hash = "sha256:0751eece944162659049d35f4f549ed815792b38793f07cf73381c1c87cbed96"}, {file = "isodate-0.6.1.tar.gz", hash = "sha256:48c5881de7e8b0a0d648cb024c8062dc84e7b840ed81e864c7614fd3c127bde9"}, ] +libclang = [] maturin = [] pycparser = [ {file = "pycparser-2.21-py2.py3-none-any.whl", hash = "sha256:8ee45429555515e1f6b185e78100aea234072576aa43ab53aefcae078162fca9"}, diff --git a/pyproject.toml b/pyproject.toml index 0ebb587..30a409e 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "reasonable" -version = "0.1.60" +version = "0.1.61" description = "Python interface to 'reasonable', a Datalog implementation of the OWL 2 RL profile" authors = ["Gabe Fierro <gtfierro@mines.edu>"] license = "bsd-3-clause" @@ -10,6 +10,7 @@ homepage = "https://github.com/gtfierro/reasonable" [tool.poetry.dependencies] python = "^3.7" cffi = "^1.15.1" +libclang = "^14.0.6" [tool.poetry.dev-dependencies] maturin = "^0.13" diff --git a/src/python.rs b/src/python.rs index 4f6915a..0410940 100644 --- a/src/python.rs +++ b/src/python.rs @@ -87,6 +87,9 @@ fn term_to_python<'a>(py: Python, rdflib: &'a PyModule, node: Term) -> PyResult< Term::BlankNode(id) => { rdflib.getattr("BNode")?.call1((id.clone().into_string(),))? } + _ => { + panic!("Should not be here"); + } }; Ok(res) }