mirror of
https://github.com/drewcassidy/quicktex.git
synced 2024-09-13 06:37:34 +00:00
Add __version__
This commit is contained in:
parent
362c1c0715
commit
560acb20ea
@ -50,6 +50,7 @@ add_executable(test_quicktex
|
||||
target_link_libraries(test_quicktex PRIVATE pybind11::embed)
|
||||
|
||||
target_compile_definitions(test_quicktex PRIVATE -DCUSTOM_SYS_PATH="${CMAKE_HOME_DIRECTORY}/env/lib/python3.9/site-packages")
|
||||
target_compile_definitions(_quicktex PRIVATE VERSION_INFO=${QUICKTEX_VERSION_INFO})
|
||||
|
||||
# enable openMP if available
|
||||
if (OpenMP_CXX_FOUND)
|
||||
|
@ -1 +1,2 @@
|
||||
from _quicktex import *
|
||||
from _quicktex import *
|
||||
from _quicktex import __version__
|
||||
|
@ -27,6 +27,9 @@
|
||||
#include "Texture.h"
|
||||
#include "_bindings.h"
|
||||
|
||||
#define STRINGIFY(x) #x
|
||||
#define MACRO_STRINGIFY(x) STRINGIFY(x)
|
||||
|
||||
namespace py = pybind11;
|
||||
|
||||
namespace quicktex::bindings {
|
||||
@ -36,6 +39,12 @@ void InitS3TC(py::module_ &m);
|
||||
PYBIND11_MODULE(_quicktex, m) {
|
||||
m.doc() = "More Stuff";
|
||||
|
||||
#ifdef VERSION_INFO
|
||||
m.attr("__version__") = MACRO_STRINGIFY(VERSION_INFO);
|
||||
#else
|
||||
m.attr("__version__") = "dev";
|
||||
#endif
|
||||
|
||||
py::options options;
|
||||
|
||||
// Texture
|
||||
|
27
setup.py
27
setup.py
@ -1,4 +1,3 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
import os
|
||||
import sys
|
||||
import glob
|
||||
@ -7,13 +6,7 @@ import subprocess
|
||||
from setuptools import setup, Extension, find_packages
|
||||
from setuptools.command.build_ext import build_ext
|
||||
|
||||
# Convert distutils Windows platform specifiers to CMake -A arguments
|
||||
PLAT_TO_CMAKE = {
|
||||
"win32": "Win32",
|
||||
"win-amd64": "x64",
|
||||
"win-arm32": "ARM",
|
||||
"win-arm64": "ARM64",
|
||||
}
|
||||
__version__ = '0.0.1'
|
||||
|
||||
|
||||
# A CMakeExtension needs a sourcedir instead of a file list.
|
||||
@ -43,6 +36,7 @@ class CMakeBuild(build_ext):
|
||||
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 = []
|
||||
@ -64,11 +58,19 @@ class CMakeBuild(build_ext):
|
||||
# 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]]
|
||||
cmake_args += ["-A", plat_to_cmake[self.plat_name]]
|
||||
|
||||
# Multi-config generators have a different way to specify configs
|
||||
if not single_config:
|
||||
@ -104,19 +106,20 @@ stubs = [path.replace('quicktex/', '') for path in glob.glob('quicktex/**/*.pyi'
|
||||
# logic and declaration, and simpler if you include description/version in a file.
|
||||
setup(
|
||||
name="quicktex",
|
||||
version="0.0.1",
|
||||
version=__version__,
|
||||
author="Andrew Cassidy",
|
||||
author_email="drewcassidy@me.com",
|
||||
description="A fast block compression library for python",
|
||||
long_description="",
|
||||
python_requires=">=3.6",
|
||||
python_requires=">=3.7",
|
||||
ext_modules=[CMakeExtension("_quicktex")],
|
||||
cmdclass={"build_ext": CMakeBuild},
|
||||
packages=find_packages('.'),
|
||||
package_dir={'': '.'},
|
||||
package_data={'': ['py.typed'] + stubs},
|
||||
include_package_data=True,
|
||||
install_requires=["ninja", "Pillow", "click"],
|
||||
setup_requires=["ninja"],
|
||||
install_requires=["Pillow", "click"],
|
||||
extras_require={
|
||||
"tests": ["nose", "parameterized"],
|
||||
"docs": ["sphinx", "myst-parser", "sphinx-rtd-theme"],
|
||||
|
@ -1,18 +0,0 @@
|
||||
import unittest
|
||||
import os.path
|
||||
|
||||
tests_path = os.path.dirname(os.path.realpath(__file__))
|
||||
|
||||
|
||||
class TestInstall(unittest.TestCase):
|
||||
"""Test if everything is installed correctly"""
|
||||
|
||||
def test_images(self):
|
||||
"""Test for the images submodule"""
|
||||
|
||||
images_path = os.path.join(tests_path, 'images')
|
||||
|
||||
assert os.path.isdir(images_path), 'images directory/submodule not present'
|
||||
assert os.path.isfile(os.path.join(images_path, '__init__.py')), 'images __init__.py not present, is the submodule checked out?'
|
||||
bp_size = os.path.getsize(os.path.join(images_path, 'Boilerplate.png'))
|
||||
assert bp_size == 955989, 'Boilerplate.png is the wrong size, is the submodule checked out with LFS enabled?'
|
34
tests/test_install.py
Normal file
34
tests/test_install.py
Normal file
@ -0,0 +1,34 @@
|
||||
"""Test if everything is installed correctly"""
|
||||
|
||||
import unittest
|
||||
import os.path
|
||||
import quicktex
|
||||
import nose
|
||||
|
||||
tests_path = os.path.dirname(os.path.realpath(__file__))
|
||||
|
||||
|
||||
def test_images():
|
||||
"""Test for the images submodule"""
|
||||
|
||||
images_path = os.path.join(tests_path, 'images')
|
||||
|
||||
assert os.path.isdir(images_path), 'images directory/submodule not present'
|
||||
assert os.path.isfile(os.path.join(images_path, '__init__.py')), 'images __init__.py not present, is the submodule checked out?'
|
||||
bp_size = os.path.getsize(os.path.join(images_path, 'Boilerplate.png'))
|
||||
assert bp_size == 955989, 'Boilerplate.png is the wrong size, is the submodule checked out with LFS enabled?'
|
||||
|
||||
|
||||
def test_version():
|
||||
"""Test if the extension module version matches what setuptools returns"""
|
||||
try:
|
||||
from importlib import metadata
|
||||
except ImportError:
|
||||
# Python < 3.8, so we cant get the metadata, so just check if it exists
|
||||
assert quicktex.__version__
|
||||
print(f'Cannot check version in python < 3.8. __version__ is {quicktex.__version__}')
|
||||
return
|
||||
|
||||
version = metadata.version('quicktex')
|
||||
|
||||
assert version == quicktex.__version__, 'incorrect version string from extension module'
|
Loading…
Reference in New Issue
Block a user