Skip to content

Commit

Permalink
generate wheels (#84)
Browse files Browse the repository at this point in the history
* less chatty download progress

* fix version to 0.1.0

* add missing includes

* disable constexpr mutex constructor

* switch to slang linux build for glibc 2.17

* fix setup.py

* require python 3.9

* remove toolset spec

* update wheels workflow

* rename pypi package to nv-sgl
  • Loading branch information
skallweitNV authored Aug 20, 2024
1 parent dc056db commit 7d03836
Show file tree
Hide file tree
Showing 12 changed files with 81 additions and 23 deletions.
60 changes: 58 additions & 2 deletions .github/workflows/wheels.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,18 @@ on:
required: true
default: '0'

env:
CIBW_BUILD_VERBOSITY: 1
CIBW_SKIP: "*-musllinux* pp*"
CIBW_MANYLINUX_X86_64_IMAGE: manylinux_2_28
CIBW_ARCHS_WINDOWS: auto64
CIBW_ARCHS_LINUX: auto64
CIBW_TEST_COMMAND: "python -c \"import sgl\""
# zip required for vcpkg, rest for glfw
CIBW_BEFORE_ALL_LINUX: yum install -y zip wayland-devel libxkbcommon-devel libXcursor-devel libXi-devel libXinerama-devel libXrandr-devel

jobs:
build_wheels:
wheels:
runs-on: ${{ matrix.runs-on }}
strategy:
matrix:
Expand All @@ -26,9 +36,55 @@ jobs:

steps:
- uses: actions/checkout@v4
with:
submodules: recursive
lfs: true

# Used to host cibuildwheel
# Used to host cibuildwheel.
- uses: actions/setup-python@v5
with:
python-version: "3.10"

# Install cibuildwheel.
- name: Install cibuildwheel
run: python -m pip install cibuildwheel==2.20.0

# Setup MSVC.
- name: Setup MSVC
uses: ilammy/msvc-dev-cmd@v1
with:
arch: x64

# Build wheels.
- name: Build wheels
env:
CIBW_BUILD: ${{ matrix.python }}-*
run: |
python -m cibuildwheel --output-dir wheelhouse
# Copy wheels to artifact.
- name: Copy wheels to artifact
# Version v4 fails to copy files from same folder for multiple builds.
uses: actions/upload-artifact@v3
with:
name: wheels
path: ./wheelhouse/*.whl


upload_pypi:
name: Upload wheels to PyPI
runs-on: ubuntu-latest
if: ${{ github.event.inputs.upload == '1'}}
needs: [wheels]
environment: pypi

steps:
- uses: actions/download-artifact@v2
with:
name: wheels
path: dist

- uses: pypa/[email protected]
with:
user: __token__
password: ${{ secrets.PYPI_TOKEN }}
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ message(STATUS "Platform: ${SGL_PLATFORM}")
# Python
# -----------------------------------------------------------------------------

find_package(Python 3.8 COMPONENTS Interpreter Development.Module REQUIRED)
find_package(Python 3.9 COMPONENTS Interpreter Development.Module REQUIRED)

# -----------------------------------------------------------------------------
# CUDA
Expand Down
8 changes: 0 additions & 8 deletions CMakePresets.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,6 @@
"architecture": {
"value": "x64",
"strategy": "set"
},
"toolset": {
"value": "host=x86",
"strategy": "set"
}
},
{
Expand All @@ -61,10 +57,6 @@
"value": "x64",
"strategy": "external"
},
"toolset": {
"value": "host=x86,version=14.3",
"strategy": "external"
},
"cacheVariables": {
"CMAKE_MAKE_PROGRAM": "${sourceDir}/tools/host/ninja/ninja.exe",
"CMAKE_C_COMPILER": "cl",
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ If you use sgl in a research project leading to a publication, please cite the p
title = {Slang Graphics Library},
author = {Simon Kallweit and Chris Cummings},
note = {https://github.com/shader-slang/sgl},
version = {0.0.1},
version = {0.1.0},
year = 2024
}
```
2 changes: 1 addition & 1 deletion docs/changelog.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ Changelog

sgl uses a `semantic versioning <http://semver.org>`__ policy for its API.

Version 0.0.1 (TBA)
Version 0.1.0 (TBA)
----------------------------

* Initial release
2 changes: 1 addition & 1 deletion docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ If you use ``sgl`` in a research project leading to a publication, please cite t
title = {Slang Graphics Library},
author = {Simon Kallweit and Chris Cummings},
note = {https://github.com/shader-slang/sgl},
version = {0.0.1},
version = {0.1.0},
year = 2024
}
Expand Down
4 changes: 2 additions & 2 deletions external/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ set(SLANG_URL_BASE "https://github.com/shader-slang/slang/releases/download/v${S
if(SGL_WINDOWS)
set(SLANG_URL "${SLANG_URL_BASE}/slang-${SLANG_VERSION}-windows-x86_64.zip")
elseif(SGL_LINUX)
set(SLANG_URL "${SLANG_URL_BASE}/slang-${SLANG_VERSION}-linux-x86_64.tar.gz")
set(SLANG_URL "${SLANG_URL_BASE}/slang-${SLANG_VERSION}-linux-x86_64-glibc-2.17.tar.gz")
elseif(SGL_MACOS)
if(CMAKE_APPLE_SILICON_PROCESSOR MATCHES "x86_64")
set(SLANG_URL "${SLANG_URL_BASE}/slang-${SLANG_VERSION}-macos-x86_64.zip")
Expand Down Expand Up @@ -78,7 +78,7 @@ elseif(SGL_LINUX)
)
sgl_copy_binary(${SLANG_DIR}/lib/libslang.so .)
sgl_copy_binary(${SLANG_DIR}/lib/libslang-glslang.so .)
sgl_copy_binary(${SLANG_DIR}/lib/libslang-llvm.so .)
# sgl_copy_binary(${SLANG_DIR}/lib/libslang-llvm.so .)
elseif(SGL_MACOS)
add_library(slang::slang SHARED IMPORTED GLOBAL)
set_target_properties(slang::slang PROPERTIES
Expand Down
9 changes: 7 additions & 2 deletions setup-tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,12 +54,17 @@ def download_file(url: str, path: Path):
Download a file from the given URL to the given path.
"""

last_percent = -1

def progress_hook(count, block_size, total_size):
nonlocal last_percent
if total_size <= 0:
return
percent = int(count * block_size * 100 / total_size)
sys.stdout.write(f"\r{percent}%")
sys.stdout.flush()
if percent != last_percent:
sys.stdout.write(f"\r{percent}%")
sys.stdout.flush()
last_percent = percent

try:
urlretrieve(url, path, reporthook=progress_hook)
Expand Down
10 changes: 6 additions & 4 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,8 @@ def build_extension(self, ext: CMakeExtension) -> None:
"-B",
build_dir,
"-DCMAKE_DEFAULT_BUILD_TYPE=Release",
f"-DPython_ROOT_DIR:PATH={sys.prefix}",
f"-DPython_FIND_REGISTRY:STRING=NEVER",
f"-DCMAKE_INSTALL_PREFIX={extdir}",
f"-DCMAKE_INSTALL_LIBDIR=sgl",
f"-DCMAKE_INSTALL_BINDIR=sgl",
Expand Down Expand Up @@ -106,20 +108,20 @@ def build_extension(self, ext: CMakeExtension) -> None:
version = "{MAJOR}.{MINOR}.{PATCH}".format(**matches)
print(f"version={version}")

long_description = """sgl."""
long_description = """TBD"""

setup(
name="sgl",
name="nv-sgl",
version=version,
author="Simon Kallweit",
author_email="[email protected]",
description="A research rendering framework",
description="Slang Graphics Library",
url="https://github.com/shader-slang/sgl",
license="Apache-2.0",
long_description=long_description,
long_description_content_type="text/markdown",
ext_modules=[CMakeExtension("sgl")],
cmdclass={"build_ext": CMakeBuild},
zip_safe=False,
python_requires=">=3.8",
python_requires=">=3.9",
)
1 change: 1 addition & 0 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -293,6 +293,7 @@ target_compile_definitions(sgl
$<$<PLATFORM_ID:Windows>:UNICODE> # force character map to unicode
# MSVC C++ library.
$<$<CXX_COMPILER_ID:MSVC>:_USE_MATH_DEFINES>
$<$<CXX_COMPILER_ID:MSVC>:_DISABLE_CONSTEXPR_MUTEX_CONSTRUCTOR>
# $<$<CXX_COMPILER_ID:MSVC>:_SCL_SECURE_NO_WARNINGS>
# $<$<CXX_COMPILER_ID:MSVC>:_CRT_SECURE_NO_WARNINGS>
# $<$<CXX_COMPILER_ID:MSVC>:_SILENCE_CXX17_CODECVT_HEADER_DEPRECATION_WARNING>
Expand Down
2 changes: 2 additions & 0 deletions src/sgl/core/platform_linux.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
#include <signal.h>
#include <sys/types.h>
#include <pwd.h>
#include <unistd.h>
#include <linux/limits.h>

#include <regex>
#include <iostream>
Expand Down
2 changes: 1 addition & 1 deletion vcpkg.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "sgl",
"version-string": "0.0.1",
"version-string": "0.1.0",
"dependencies": [
"doctest",
"fmt",
Expand Down

0 comments on commit 7d03836

Please sign in to comment.