diff --git a/.github/workflows/run_tests.yml b/.github/workflows/run_tests.yml index 67209c2..6e95c36 100644 --- a/.github/workflows/run_tests.yml +++ b/.github/workflows/run_tests.yml @@ -19,6 +19,8 @@ jobs: steps: - uses: actions/checkout@v4 + with: + fetch-depth: 0 # Fetch full history for setuptools_scm - name: Log reason (manual run only) if: github.event_name == 'workflow_dispatch' @@ -28,23 +30,33 @@ jobs: - name: Set up Python uses: actions/setup-python@v5 with: - python-version: 3.11 + python-version: 3.13 + + - name: Install system dependencies + run: | + sudo apt-get update + sudo apt-get install -y build-essential pkg-config zlib1g-dev libtool autotools-dev - name: Install dependencies run: | python -m pip install --upgrade pip python -m pip install setuptools>=61.0 python -m pip install -r requirements.txt + python -m pip install opentype-sanitizer + + - name: Download OTS source + run: | + python setup.py download --version=9.2.0 --sha256=1a1e50cd7ecea27c4ef04c5b1491c21e75555f35bf91e27103ede04ddd11e053 - name: Lint with flake8 run: flake8 . --show-source --statistics - name: Lint with cpplint - run: cpplint --filter=-build/includesubdir,-readability/casting,-build/include --recursive . + run: cpplint --filter=-build/includesubdir,-readability/casting,-build/include --recursive src/_pyots/ - name: Build and install run: | - python setup.py install + python -m pip install -v . - name: Test with pytest run: | diff --git a/pyproject.toml b/pyproject.toml index ddc46f2..2a86497 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,5 +1,41 @@ [build-system] requires = ["setuptools>=61", "wheel", "setuptools_scm[toml]>=3.4", "ninja", "meson"] +build-backend = "setuptools.build_meta" + +[project] +name = "pyots" +description = "Python wrapper for ot-sanitizer" +readme = "README.md" +license = "BSD-3-Clause" +authors = [ + {name = "Adobe Type team & friends", email = "afdko@adobe.com"} +] +classifiers = [ + "Development Status :: 4 - Beta", + "Intended Audience :: Developers", + "Topic :: Software Development :: Testing", + "Programming Language :: Python :: 3.9", + "Programming Language :: Python :: 3.10", + "Programming Language :: Python :: 3.11", + "Programming Language :: Python :: 3.12", + "Programming Language :: Python :: 3.13", + "Operating System :: MacOS :: MacOS X", + "Operating System :: POSIX :: Linux", +] +requires-python = ">=3.9" +dynamic = ["version"] + +[project.urls] +Homepage = "https://github.com/adobe-type-tools/pyots" + +[tool.setuptools] +package-dir = {"" = "src"} +zip-safe = false + +[tool.setuptools.packages.find] +where = ["src"] + +[tool.setuptools_scm] [tool.pytest.ini_options] testpaths = [ diff --git a/setup.py b/setup.py index dd9a9ab..abde01f 100644 --- a/setup.py +++ b/setup.py @@ -1,10 +1,10 @@ -from build import SRC_DIR, OTS_SRC_DIR from distutils.dir_util import mkpath, remove_tree from distutils import log import io import os import re -from setuptools import setup, find_packages, Extension, Command +from pathlib import Path +from setuptools import setup, Extension, Command from setuptools.command import build_py from setuptools.command.egg_info import egg_info import subprocess @@ -12,6 +12,15 @@ PY = sys.executable +# Define paths (previously imported from build.py) +try: + ROOT = Path(__file__).parent.resolve() +except NameError: + # Fallback for when __file__ is not defined + ROOT = Path.cwd() +SRC_DIR = ROOT / "src" +OTS_SRC_DIR = SRC_DIR / "ots" + BUILD_DIR = OTS_SRC_DIR / "build" / "meson" BUILD_SUB_DIR = BUILD_DIR / "subprojects" SRC_SUB_DIR = OTS_SRC_DIR / "subprojects" @@ -47,7 +56,7 @@ def _get_extra_objects(): # xo.append(BUILD_SUB_DIR / f"woff2-{WOFF2_TAG}" / "libwoff2_decoder.a") # xo.append(BUILD_SUB_DIR / f"woff2-{WOFF2_TAG}" / "libwoff2_common.a") - return [str(p) for p in xo] + return [str(p.relative_to(ROOT)) for p in xo] def _get_include_dirs(): @@ -69,7 +78,7 @@ def _get_include_dirs(): # woff2 ip.append(SRC_SUB_DIR / f"woff2-{WOFF2_TAG}" / "include") - return [str(p) for p in ip] + return [str(p.relative_to(ROOT)) for p in ip] def _get_sources(): @@ -87,7 +96,7 @@ def _get_sources(): sp.append(SRC_SUB_DIR / f"woff2-{WOFF2_TAG}" / "src" / "woff2_dec.cc") sp.append(SRC_SUB_DIR / f"woff2-{WOFF2_TAG}" / "src" / "woff2_out.cc") - return [str(p) for p in sp] + return [str(p.relative_to(ROOT)) for p in sp] class BuildStaticLibs(Command): @@ -271,37 +280,7 @@ def run(self): sources=_get_sources(), ) -with io.open("README.md", encoding="utf-8") as readme: - long_description = readme.read() - -classifiers = [ - 'Development Status :: 4 - Beta', - 'Intended Audience :: Developers', - 'Topic :: Software Development :: Testing', - 'License :: OSI Approved :: BSD License', - 'Programming Language :: Python :: 3.9', - 'Programming Language :: Python :: 3.10', - 'Programming Language :: Python :: 3.11', - 'Programming Language :: Python :: 3.12', - 'Operating System :: MacOS :: MacOS X', - 'Operating System :: POSIX :: Linux', -] - setup( - author='Adobe Type team & friends', - author_email='afdko@adobe.com', cmdclass=custom_commands, - classifiers=classifiers, - description='Python wrapper for ot-sanitizer', ext_modules=[pyots_mod], - long_description_content_type='text/markdown', - long_description=long_description, - name='pyots', - packages=find_packages('src'), - package_dir={'': 'src'}, - python_requires='>=3.9', - url='https://github.com/adobe-type-tools/pyots', - use_scm_version=True, - setup_requires=['setuptools_scm'], - zip_safe=False, )