11 Commits

Author SHA1 Message Date
1aa08a0cda Attempt to port to scikit-build 2022-04-05 00:15:59 -07:00
421876ab0f Move more metadata to pyproject.toml 2022-04-03 20:41:02 -07:00
29590e0323 Move a good chunk of metadata to pyproject.toml 2022-04-03 16:22:47 -07:00
71379b7ae1 Revert to manylinux2014 2022-04-03 00:05:35 -07:00
d1346ca11d Enable macos cross-compiling in setup.py 2022-04-02 21:39:14 -07:00
e488dbcbff Fix builder version
and here I was thinking this was semver smh
2022-04-01 21:07:57 -07:00
1f7b45aa57 Compile for multiple architectures 2022-04-01 21:06:51 -07:00
70b7251eae Include build for python 3.10 (finally) 2022-04-01 20:27:00 -07:00
e8e0f4e29b Release 0.1.2
### Fixed

- Fixed sdist not including pybind
2022-03-27 14:29:57 -07:00
6d7f56476f Add manifest file 2022-03-27 14:28:17 -07:00
b4d2388615 Release 0.1.1
### Fixed

- Fixed alpha premultiplication when generating mipmaps
2021-09-28 20:42:13 -07:00
8 changed files with 107 additions and 157 deletions

View File

@ -45,11 +45,18 @@ jobs:
path: dist/*.tar.gz
build-wheels:
name: Build Wheels for ${{ matrix.os }}
name: Build Wheels for ${{ matrix.os }}-${{ matrix.arch }}
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ macos-latest, windows-latest, ubuntu-latest ]
arch: [ x86_64 ]
include:
- arch: arm64
os: macos-latest
- arch: aarch64
os: ubuntu-latest
qemu: true
steps:
- uses: actions/checkout@v2
@ -63,18 +70,29 @@ jobs:
# openMP isnt part of core apple clang for some reason?
run: brew install libomp
- name: Install QEMU
# install QEMU if building for arm linux
uses: docker/setup-qemu-action@v1
if: matrix.qemu
with:
platforms: arm64
- name: Install test images
run: git clone https://git.pileof.rocks/drewcassidy/quicktex-test-images.git tests/images
- name: Build wheels
uses: joerick/cibuildwheel@v1.11.0
uses: joerick/cibuildwheel@v2.3.1
env:
MACOSX_DEPLOYMENT_TARGET: "10.15"
CIBW_BUILD: "cp{37,38,39}-*"
CIBW_SKIP: "*-win32 *-manylinux_i686"
CIBW_BUILD: "cp{37,38,39,310}-*"
CIBW_ARCHS_MACOS: ${{ matrix.arch }}
CIBW_ARCHS_LINUX: ${{ matrix.arch }}
CIBW_ARCHS_WINDOWS: "auto64"
CIBW_MANYLINUX_X86_64_IMAGE: "manylinux2014"
CIBW_MANYLINUX_AARCH64_IMAGE: "manylinux2014"
CIBW_TEST_EXTRAS: "tests"
CIBW_TEST_COMMAND: nosetests {project}/tests -d
CIBW_TEST_SKIP: "*-macosx_arm64"
- name: Upload Wheels
uses: actions/upload-artifact@v2

1
.gitignore vendored
View File

@ -34,3 +34,4 @@ compile_commands.json
CTestTestfile.cmake
_deps
cmake-build-*
_skbuild

View File

@ -2,7 +2,14 @@
All notable changes to this project will be documented in this file
## Unreleased
## 0.1.2 - 2022-03-27
### Fixed
- Fixed sdist not including pybind
## 0.1.1 - 2021-09-29
### Fixed

View File

@ -4,10 +4,22 @@ include(tools/CompilerWarnings.cmake)
project(quicktex)
if (SKBUILD)
# Scikit-Build does not add your site-packages to the search path
# automatically, so we need to add it _or_ the pybind11 specific directory
# here.
execute_process(
COMMAND "${PYTHON_EXECUTABLE}" -c
"import pybind11; print(pybind11.get_cmake_dir())"
OUTPUT_VARIABLE _tmp_dir
OUTPUT_STRIP_TRAILING_WHITESPACE COMMAND_ECHO STDOUT)
list(APPEND CMAKE_PREFIX_PATH "${_tmp_dir}")
endif ()
# Find dependencies
find_package(Python COMPONENTS Interpreter Development)
find_package(pybind11 CONFIG REQUIRED)
find_package(OpenMP)
add_subdirectory(extern/pybind11)
# Collect source files
file(GLOB SOURCE_FILES
@ -73,3 +85,5 @@ if (CMAKE_CXX_COMPILER_ID MATCHES ".*Clang")
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -stdlib=libc++ -fsanitize=undefined")
set(PROJECT_WARNINGS ${CLANG_WARNINGS})
endif ()
install(TARGETS _quicktex LIBRARY DESTINATION quicktex)

1
MANIFEST.in Normal file
View File

@ -0,0 +1 @@
graft extern

1
extern/pybind11 vendored

Submodule extern/pybind11 deleted from 8de7772cc7

View File

@ -1,11 +1,58 @@
[build-system]
requires = [
"setuptools>=42",
"setuptools>=61",
"setuptools_scm>=6.2",
"wheel",
"pybind11>=2.9.0",
"cmake>=3.22",
"scikit-build>0.13",
"ninja; sys_platform != 'win32'",
"cmake>=3.12",
"setuptools_scm[toml]>=3.4"
]
build-backend = "setuptools.build_meta"
[project]
name = "quicktex"
description = "A fast block compression library for python"
readme = "README.md"
license = { file = "LICENSE.md" }
authors = [{ name = "Andrew Cassidy", email = "drewcassidy@me.com" }]
classifiers = [
"Development Status :: 3 - Alpha",
"Intended Audience :: Developers",
"License :: OSI Approved :: GNU Lesser General Public License v3 (LGPLv3)",
"Operating System :: OS Independent",
"Programming Language :: Python :: 3 :: Only",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.7",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Topic :: Multimedia :: Graphics :: Graphics Conversion",
"Programming Language :: Python :: Implementation :: CPython",
"Programming Language :: C++",
]
requires-python = ">=3.7"
dependencies = ["Pillow", "click"]
dynamic = ["version"]
[project.optional-dependencies]
tests = ["nose", "parameterized"]
docs = ["sphinx", "myst-parser", "sphinx-rtd-theme"]
stubs = ["pybind11-stubgen"]
[project.urls]
repository = "https://github.com/drewcassidy/quicktex"
changelog = "https://github.com/drewcassidy/quicktex/blob/main/CHANGELOG.md"
[project.scripts]
quicktex = "quicktex.__main__:main"
[tool.setuptools]
zip-safe = false
packages = { find = { include = ["quicktex*"] } } # only include quicktex and not tests
package-data = { '*' = ['py.typed', '*.pyi'] } # include stubs
package-dir = { '' = '.' } # without this line, C++ source files get included in the bdist
[tool.setuptools_scm]

157
setup.py
View File

@ -1,152 +1,15 @@
import os
import sys
import glob
import subprocess
from setuptools import setup, Extension, find_packages
from setuptools.command.build_ext import build_ext
try:
from skbuild import setup
except ImportError:
print(
"Please update pip, you need pip 10 or greater,\n"
" or you need to install the PEP 518 requirements in pyproject.toml yourself",
file=sys.stderr,
)
raise
project_path = os.path.dirname(os.path.realpath(__file__))
with open(os.path.join(project_path, 'README.md')) as f:
readme = f.read()
# A CMakeExtension needs a sourcedir instead of a file list.
# The name must be the _single_ output extension from the CMake build.
# If you need multiple extensions, see scikit-build.
class CMakeExtension(Extension):
def __init__(self, name, sourcedir=""):
Extension.__init__(self, name, sources=[])
self.sourcedir = os.path.abspath(sourcedir)
class CMakeBuild(build_ext):
def build_extension(self, ext):
from setuptools_scm import get_version
version = get_version(root='.', relative_to=__file__)
extdir = os.path.abspath(os.path.dirname(self.get_ext_fullpath(ext.name)))
# required for auto-detection of auxiliary "native" libs
if not extdir.endswith(os.path.sep):
extdir += os.path.sep
cfg = "Debug" if self.debug else "Release"
# CMake lets you override the generator - we need to check this.
# Can be set with Conda-Build, for example.
cmake_generator = os.environ.get("CMAKE_GENERATOR", "")
# Set Python_EXECUTABLE instead if you use PYBIND11_FINDPYTHON
cmake_args = [
"-DCMAKE_LIBRARY_OUTPUT_DIRECTORY={}".format(extdir),
"-DPython_EXECUTABLE={}".format(sys.executable),
"-DQUICKTEX_VERSION_INFO={}".format(version),
"-DCMAKE_BUILD_TYPE={}".format(cfg), # not used on MSVC, but no harm
]
build_args = []
if self.compiler.compiler_type != "msvc":
# Using Ninja-build since it a) is available as a wheel and b)
# multithreads automatically. MSVC would require all variables be
# exported for Ninja to pick it up, which is a little tricky to do.
# Users can override the generator with CMAKE_GENERATOR in CMake
# 3.15+.
if not cmake_generator:
cmake_args += ["-GNinja"]
else:
# Single config generators are handled "normally"
single_config = any(x in cmake_generator for x in {"NMake", "Ninja"})
# CMake allows an arch-in-generator style for backward compatibility
contains_arch = any(x in cmake_generator for x in {"ARM", "Win64"})
# Convert distutils Windows platform specifiers to CMake -A arguments
plat_to_cmake = {
"win32": "Win32",
"win-amd64": "x64",
"win-arm32": "ARM",
"win-arm64": "ARM64",
}
# Specify the arch if using MSVC generator, but only if it doesn't
# contain a backward-compatibility arch spec already in the
# generator name.
if not single_config and not contains_arch:
cmake_args += ["-A", plat_to_cmake[self.plat_name]]
# Multi-config generators have a different way to specify configs
if not single_config:
cmake_args += [
"-DCMAKE_LIBRARY_OUTPUT_DIRECTORY_{}={}".format(cfg.upper(), extdir)
]
build_args += ["--config", cfg]
# Set CMAKE_BUILD_PARALLEL_LEVEL to control the parallel build level
# across all generators.
if "CMAKE_BUILD_PARALLEL_LEVEL" not in os.environ:
# self.parallel is a Python 3 only way to set parallel jobs by hand
# using -j in the build_ext call, not supported by pip or PyPA-build.
if hasattr(self, "parallel") and self.parallel:
# CMake 3.12+ only.
build_args += ["-j{}".format(self.parallel)]
if not os.path.exists(self.build_temp):
os.makedirs(self.build_temp)
subprocess.check_call(
["cmake", ext.sourcedir] + cmake_args, cwd=self.build_temp
)
subprocess.check_call(
["cmake", "--build", ".", "--target", ext.name] + build_args, cwd=self.build_temp
)
# Find stub files
stubs = [path.replace('quicktex/', '') for path in glob.glob('quicktex/**/*.pyi', recursive=True)]
# The information here can also be placed in setup.cfg - better separation of
# logic and declaration, and simpler if you include description/version in a file.
setup(
name="quicktex",
use_scm_version=True,
author="Andrew Cassidy",
author_email="drewcassidy@me.com",
description="A fast block compression library for python",
url='https://github.com/drewcassidy/quicktex',
long_description=readme,
long_description_content_type='text/markdown',
python_requires=">=3.7",
ext_modules=[CMakeExtension("_quicktex")],
cmdclass={"build_ext": CMakeBuild},
packages=find_packages(where='.', include=['quicktex*']),
package_dir={'': '.'},
package_data={'': ['py.typed'] + stubs},
include_package_data=True,
install_requires=["Pillow", "click"],
extras_require={
"tests": ["nose", "parameterized"],
"docs": ["sphinx", "myst-parser", "sphinx-rtd-theme"],
"stubs": ["pybind11-stubgen"],
},
entry_points={
'console_scripts': ['quicktex = quicktex.__main__:main']
},
zip_safe=False,
classifiers=[
'Development Status :: 3 - Alpha',
'Intended Audience :: Developers',
'License :: OSI Approved :: GNU Lesser General Public License v3 (LGPLv3)',
'Operating System :: OS Independent',
'Programming Language :: Python :: 3 :: Only',
'Programming Language :: Python :: 3',
'Programming Language :: Python :: 3.7',
'Programming Language :: Python :: 3.8',
'Programming Language :: Python :: 3.9',
"Topic :: Multimedia :: Graphics :: Graphics Conversion",
'Programming Language :: Python :: Implementation :: CPython',
'Programming Language :: C++'
],
cmake_install_dir='.'
)