-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #29 from paullinnerud/main
Python extension interface
- Loading branch information
Showing
42 changed files
with
20,413 additions
and
19,560 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
name: Python Extension | ||
|
||
on: | ||
# Triggers the workflow on push or pull request events but only for the main branch | ||
push: | ||
branches: [ main ] | ||
tags: ["v*.*.*"] | ||
pull_request: | ||
branches: [ main ] | ||
|
||
# A workflow run is made up of one or more jobs that can run sequentially or in parallel | ||
jobs: | ||
|
||
build: | ||
# The type of runner that the job will run on | ||
runs-on: ${{ matrix.os }} | ||
defaults: | ||
run: | ||
shell: bash | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
os: [ubuntu-latest, macos-latest, windows-latest] | ||
|
||
# Steps represent a sequence of tasks that will be executed as part of the job | ||
steps: | ||
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it | ||
- uses: actions/checkout@v2 | ||
|
||
- name: Set up Python | ||
uses: actions/setup-python@v2 | ||
with: | ||
python-version: "3.x" | ||
|
||
- name: Install dependencies | ||
run: | | ||
python -m pip install --upgrade pip | ||
pip install cibuildwheel | ||
pip install cython | ||
- name: Build Wheels | ||
run: python -m cibuildwheel --output-dir wheelhouse | ||
|
||
- name: Upload Wheels | ||
uses: actions/upload-artifact@v2 | ||
with: | ||
name: vttcompilepy-${{ matrix.os }} | ||
path: ./wheelhouse/*.whl | ||
|
||
- name: Build Source Distribution | ||
run: python setup.py sdist | ||
|
||
- name: Upload Source Distribution | ||
uses: actions/upload-artifact@v2 | ||
with: | ||
path: ./dist/*.zip | ||
|
||
deploy: | ||
|
||
needs: [build] | ||
# only run if the commit is tagged... | ||
if: startsWith(github.ref, 'refs/tags/v') | ||
# ... and all build jobs completed successfully | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v2 | ||
with: | ||
submodules: recursive | ||
- name: Set up Python | ||
uses: actions/setup-python@v2 | ||
with: | ||
python-version: "3.x" | ||
- name: Install dependencies | ||
run: | | ||
python -m pip install --upgrade pip | ||
pip install --upgrade setuptools cython wheel twine | ||
- name: Download artifacts from build jobs | ||
uses: actions/download-artifact@v2 | ||
with: | ||
path: dist/ | ||
|
||
- uses: pypa/gh-action-pypi-publish@master | ||
with: | ||
user: __token__ | ||
password: ${{ secrets.pypi_password }} | ||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
# Project | ||
|
||
VTTCompilePy is a Python extension built using Cython. It provides streamlined bindings for | ||
various compilers from Visual TrueType. | ||
|
||
VTTCompilePy was developed to support a Python based font development environment. In addition to the Python interface, | ||
a command line interface is also installed. Usage is available with "vttcompilepy --help". | ||
|
||
### Example | ||
|
||
```python | ||
import sys | ||
from pathlib import Path | ||
import vttcompilepy as vtt | ||
|
||
TESTDATA = Path(__file__).parent / "data" | ||
IN_PATH = TESTDATA / "selawik-variable.ttf" | ||
OUT_PATH = TESTDATA / "out.ttf" | ||
|
||
print(bytes(IN_PATH)) | ||
|
||
print('VTTCompilePy Test Client') | ||
|
||
compiler = vtt.Compiler(IN_PATH) | ||
|
||
compiler.compile_all() | ||
|
||
compiler.save_font(OUT_PATH, vtt.StripLevel.STRIP_NOTHING) | ||
|
||
``` | ||
|
||
## Trademarks | ||
|
||
This project may contain trademarks or logos for projects, products, or services. Authorized use of Microsoft | ||
trademarks or logos is subject to and must follow | ||
[Microsoft's Trademark & Brand Guidelines](https://www.microsoft.com/en-us/legal/intellectualproperty/trademarks/usage/general). | ||
Use of Microsoft trademarks or logos in modified versions of this project must not cause confusion or imply Microsoft sponsorship. | ||
Any use of third-party trademarks or logos are subject to those third-party's policies. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
[build-system] | ||
requires = [ | ||
"setuptools", | ||
"wheel", | ||
"cython", | ||
] | ||
build-backend = "setuptools.build_meta" | ||
|
||
[tool.cibuildwheel] | ||
skip = ["*-manylinux_i686", "pp*"] | ||
|
||
test-requires = ["pytest", "fonttools"] | ||
test-command = "pytest {project}/tests" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
cython>=0.29.1 | ||
|
||
wheel>=0.31 | ||
|
||
pytest | ||
|
||
fonttools | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
[sdist] | ||
formats = zip | ||
|
||
[metadata] | ||
license_files = | ||
LICENSE.txt |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
# -*- coding: utf-8 -*- | ||
from io import open | ||
import os | ||
import sys | ||
import platform | ||
from setuptools import Extension, setup | ||
from Cython.Build import cythonize | ||
|
||
here = os.path.abspath(os.path.dirname(__file__)) | ||
|
||
# Get the long description from the pypi.md file | ||
with open(os.path.join(here, 'pypi.md'), encoding='utf-8') as f: | ||
long_description = f.read() | ||
|
||
define_macros = [('UNICODE', 1), ('_UNICODE', 1)] | ||
linetrace = False | ||
if int(os.environ.get('CYTHON_LINETRACE', '0')): | ||
linetrace = True | ||
define_macros.append(('CYTHON_TRACE_NOGIL', '1')) | ||
|
||
extra_compile_args = [] | ||
|
||
if platform.system() != 'Windows': | ||
extra_compile_args.append('-std=c++14') | ||
|
||
if platform.system() == 'Windows': | ||
extra_compile_args.append('-sdl') | ||
|
||
extension = Extension( | ||
'vttcompilepy.vttcompilepy', | ||
define_macros=define_macros, | ||
include_dirs=[".","src"], | ||
sources=['vttcompilepy/vttcompilepy.pyx','src/application.cpp','src/CvtManager.cpp','src/File.cpp','src/List.cpp', 'src/MathUtils.cpp', 'src/Memory.cpp','src/Platform.cpp','src/TextBuffer.cpp', 'src/TMTParser.cpp', 'src/TTAssembler.cpp', 'src/TTEngine.cpp', 'src/TTFont.cpp', 'src/TTGenerator.cpp', 'src/Variation.cpp', 'src/VariationInstance.cpp', 'src/VariationModels.cpp' ], | ||
language='c++', | ||
extra_compile_args=extra_compile_args, | ||
) | ||
|
||
setup( | ||
name="vttcompilepy", | ||
version= '0.0.1.2', | ||
description="Python extension for Visual TrueType font compile. ", | ||
long_description=long_description, | ||
long_description_content_type='text/markdown', | ||
author="Paul Linnerud", | ||
author_email="[email protected]", | ||
url="https://github.com/microsoft/VisualTrueType", | ||
license="MIT", | ||
classifiers=[ | ||
"Programming Language :: Python :: 3", | ||
"License :: OSI Approved :: MIT License", | ||
], | ||
package_dir={"": "."}, | ||
packages=["vttcompilepy"], | ||
zip_safe=False, | ||
python_requires=">=3.7", | ||
ext_modules = cythonize( | ||
extension, | ||
annotate=bool(int(os.environ.get('CYTHON_ANNOTATE', '0'))), | ||
compiler_directives={"linetrace": linetrace}, | ||
), | ||
entry_points={ | ||
'console_scripts': [ "vttcompilepy = vttcompilepy.__main__:main" ] | ||
} | ||
) |
Oops, something went wrong.