Skip to content

Commit

Permalink
Copy-paste ufoLib2's infrastructure (#30)
Browse files Browse the repository at this point in the history
This modernizes the infrastructure.
  • Loading branch information
madig authored May 26, 2020
1 parent 83aa782 commit d2ddba0
Show file tree
Hide file tree
Showing 21 changed files with 237 additions and 96 deletions.
3 changes: 1 addition & 2 deletions .coveragerc
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@ source = vttLib
[paths]
source =
src/vttLib
.tox/*/lib/python*/site-packages/vttLib
.tox/*/Lib/site-packages/vttLib
*/site-packages/vttLib

[report]
# Regexes for lines to exclude from consideration
Expand Down
31 changes: 31 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# This workflows will upload a Python Package using Twine when a release is created
# For more information see: https://help.github.com/en/actions/language-and-framework-guides/using-python-with-github-actions#publishing-to-package-registries

name: Upload Python Package

on:
push:
# Sequence of patterns matched against refs/tags
tags:
- 'v*' # Push events to matching v*, i.e. v1.0, v20.15.10

jobs:
deploy:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- name: Set up Python
uses: actions/setup-python@v1
with:
python-version: '3.x'
- name: Install dependencies
run: |
pip install setuptools wheel twine
- name: Build and publish
env:
TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }}
TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
run: |
python setup.py sdist bdist_wheel
twine upload dist/*
40 changes: 40 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
name: Test

on:
push:
branches: [master]
pull_request:
branches: [master]

jobs:
lint:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- name: Set up Python
uses: actions/setup-python@v1
with:
python-version: '3.8'
- name: Lint
run: |
pip install tox
tox -e lint
build:
runs-on: ${{ matrix.platform }}
strategy:
matrix:
python-version: [3.6, 3.8]
platform: [ubuntu-latest, windows-latest]

steps:
- uses: actions/checkout@v2
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v1
with:
python-version: ${{ matrix.python-version }}
- name: Test with tox
run: |
pip install tox -r requirements-dev.txt
tox -e py-cov
22 changes: 0 additions & 22 deletions .pre-commit-config.yaml

This file was deleted.

14 changes: 0 additions & 14 deletions .travis.yml

This file was deleted.

35 changes: 35 additions & 0 deletions mypy.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
[mypy]
python_version = 3.6

# Untyped definitions and calls
disallow_incomplete_defs = True

# None and Optional handling
no_implicit_optional = True
strict_optional = True

# Configuring warnings
warn_no_return = True
warn_redundant_casts = True
warn_unreachable = True

# Miscellaneous strictness flags
strict_equality = True

[mypy-fontTools.*]
ignore_missing_imports = True

[mypy-pytest]
ignore_missing_imports = True

[mypy-py]
ignore_missing_imports = True

[mypy-setuptools]
ignore_missing_imports = True

[mypy-pyparsing]
ignore_missing_imports = True

[mypy-ufo2ft]
ignore_missing_imports = True
16 changes: 15 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,3 +1,17 @@
[build-system]
build-backend = "setuptools.build_meta"
requires = ["setuptools>=40.7", "wheel", "setuptools_scm"]
requires = ["setuptools>=42", "wheel", "setuptools_scm[toml]>=3.4"]

[tool.setuptools_scm]
write_to = "src/vttLib/_version.py"

[tool.black]
target-version = ["py36"]

[tool.isort]
multi_line_output = 3
include_trailing_comma = true
force_grid_wrap = 0
use_parentheses = true
line_length = 88
known_first_party = "vttLib"
7 changes: 7 additions & 0 deletions requirements-dev.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
black
coverage
flake8
isort[pyproject]
mypy
pytest
ufo2ft
45 changes: 45 additions & 0 deletions requirements-dev.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
#
# This file is autogenerated by pip-compile
# To update, run:
#
# pip-compile requirements-dev.in
#

appdirs==1.4.4 # via black, fs
atomicwrites==1.4.0 # via pytest
attrs==19.3.0 # via black, pytest
black==19.10b0 # via -r requirements-dev.in
booleanoperations==0.9.0 # via ufo2ft
click==7.1.2 # via black
colorama==0.4.3 # via pytest
compreffor==0.5.0 # via ufo2ft
coverage==5.1 # via -r requirements-dev.in
cu2qu==1.6.7 # via ufo2ft
flake8==3.8.2 # via -r requirements-dev.in
fonttools[ufo]==4.10.2 # via booleanoperations, compreffor, cu2qu, ufo2ft
fs==2.4.11 # via fonttools
isort[pyproject]==4.3.21 # via -r requirements-dev.in
mccabe==0.6.1 # via flake8
more-itertools==8.3.0 # via pytest
mypy-extensions==0.4.3 # via mypy
mypy==0.770 # via -r requirements-dev.in
packaging==20.4 # via pytest
pathspec==0.8.0 # via black
pluggy==0.13.1 # via pytest
py==1.8.1 # via pytest
pyclipper==1.1.0.post3 # via booleanoperations
pycodestyle==2.6.0 # via flake8
pyflakes==2.2.0 # via flake8
pyparsing==2.4.7 # via packaging
pytest==5.4.2 # via -r requirements-dev.in
pytz==2020.1 # via fs
regex==2020.5.14 # via black
six==1.15.0 # via fs, packaging
toml==0.10.1 # via black, isort
typed-ast==1.4.1 # via black, mypy
typing-extensions==3.7.4.2 # via mypy
ufo2ft==2.14.0 # via -r requirements-dev.in
wcwidth==0.1.9 # via pytest

# The following packages are considered to be unsafe in a requirements file:
# setuptools
20 changes: 11 additions & 9 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,14 @@
# pip-compile --output-file=requirements.txt setup.py
#

appdirs==1.4.3 # via fs
attrs==19.1.0 # via ufolib2
fonttools[lxml,ufo]==3.44.0
fs==2.4.10 # via fonttools
lxml==4.4.0 # via fonttools
pyparsing==2.4.2
pytz==2019.2 # via fs
six==1.12.0 # via fs
ufolib2==0.3.2.post2
appdirs==1.4.4 # via fs
attrs==19.3.0 # via ufolib2
fonttools[ufo]==4.10.2 # via ufolib2, vttLib (.\setup.py)
fs==2.4.11 # via fonttools
pyparsing==2.4.7 # via vttLib (.\setup.py)
pytz==2020.1 # via fs
six==1.15.0 # via fs
ufolib2==0.7.1 # via vttLib (.\setup.py)

# The following packages are considered to be unsafe in a requirements file:
# setuptools
18 changes: 5 additions & 13 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -12,23 +12,15 @@ packages = find:
package_dir =
=src
install_requires =
fonttools[ufo]>=3.44.0
pyparsing>=2.1.5
ufoLib2
fonttools[ufo]>=4.0.0
pyparsing>=2.1.5
ufoLib2>=0.7.1
setup_requires =
setuptools_scm
wheel
tests_require =
pytest
ufo2ft
setuptools_scm
wheel

[options.packages.find]
where=src

[sdist]
formats = zip

[tool:pytest]
filterwarnings =
ignore:fromstring:DeprecationWarning
ignore:tostring:DeprecationWarning
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
import setuptools

setuptools.setup(use_scm_version={"write_to": "src/vttLib/_version.py"})
setuptools.setup()
11 changes: 2 additions & 9 deletions src/vttLib/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,10 @@
import logging
import os
import re
import shutil
from collections import OrderedDict, defaultdict, deque, namedtuple

import ufoLib2
from fontTools.ttLib import (
TTFont,
TTLibError,
identifierToTag,
newTable,
tagToIdentifier,
)
from fontTools.ttLib import TTFont, TTLibError, newTable
from fontTools.ttLib.tables._g_l_y_f import (
ROUND_XY_TO_GRID,
SCALED_COMPONENT_OFFSET,
Expand All @@ -26,7 +19,7 @@
from vttLib.parser import AssemblyParser, ParseException

try:
from ._version import version as __version__
from ._version import version as __version__ # type: ignore
except ImportError:
__version__ = "0.0.0+unknown"

Expand Down
3 changes: 0 additions & 3 deletions src/vttLib/__main__.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
import logging
import os
import sys
from argparse import ArgumentParser

import fontTools.ttLib

import vttLib


Expand Down
3 changes: 2 additions & 1 deletion src/vttLib/transfer.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

import fontTools
import fontTools.ttLib
import ufoLib2

import vttLib

Expand Down Expand Up @@ -76,7 +77,7 @@ def merge_from_file(font: fontTools.ttLib.TTFont, path: os.PathLike) -> None:
setattr(font["maxp"], maxp_attr, getattr(ttx_dump["maxp"], maxp_attr))


def copy_from_ufo_data_to_file(ufo, path: os.PathLike) -> None:
def copy_from_ufo_data_to_file(ufo: ufoLib2.Font, path: os.PathLike) -> None:
"""Dump VTT data stored in a UFO's data/ structure into a file.
This is used to convert data from Legacy Projects to The New Way.
Expand Down
13 changes: 8 additions & 5 deletions tests/cli_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,10 @@ def test_move_ufo_data_to_file_and_roundtrip(tmp_path, test_ufo_UbuTestData):
vttLib.__main__.main(["mergefile", str(test_ttx_path), str(test_ttf_path)])
vttLib.__main__.main(["dumpfile", str(test_ttf_path), str(tmp_path / "test2.ttx")])

assert (
Path(tmp_path / "test.ttx").read_text()
== Path(tmp_path / "test2.ttx").read_text()
)
# Cut out the first two lines with version information for the comparison.
dump_before = Path(tmp_path / "test.ttx").read_text().split("\n", 2)[-1]
dump_after = Path(tmp_path / "test2.ttx").read_text().split("\n", 2)[-1]
assert dump_before == dump_after

vttLib.__main__.main(["compile", str(test_ttf_path), str(test_ttf_path), "--ship"])
ttf = fontTools.ttLib.TTFont(test_ttf_path)
Expand All @@ -76,7 +76,10 @@ def test_roundtrip_TSIC_cvar(tmp_path: Path, original_shared_datadir: Path) -> N
assert "cvar" in font

vttLib.__main__.main(["dumpfile", str(font_file_tmp), str(font_file_vtt_tmp)])
assert font_file_vtt.read_text() == font_file_vtt_tmp.read_text()
# Cut out the first two lines with version information for the comparison.
dump_before = font_file_vtt.read_text().split("\n", 2)[-1]
dump_after = font_file_vtt_tmp.read_text().split("\n", 2)[-1]
assert dump_before == dump_after

vttLib.__main__.main(["compile", str(font_file_tmp), str(font_file_tmp), "--ship"])
font = fontTools.ttLib.TTFont(font_file_tmp)
Expand Down
3 changes: 2 additions & 1 deletion tests/conftest.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
from pathlib import Path
from typing import Any

import pytest


@pytest.fixture
def original_shared_datadir(request) -> Path:
def original_shared_datadir(request: Any) -> Path:
return Path(request.fspath.dirname, "data")
2 changes: 1 addition & 1 deletion tests/data/NotoSans-MM-ASCII-VF.ttx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<ttFont sfntVersion="\x00\x01\x00\x00" ttLibVersion="3.44">
<ttFont sfntVersion="\x00\x01\x00\x00" ttLibVersion="4.4">

<TSI1>

Expand Down
2 changes: 1 addition & 1 deletion tests/data/NotoSans-MM-ASCII-VF_wrong_maxp.ttx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<ttFont sfntVersion="\x00\x01\x00\x00" ttLibVersion="3.44">
<ttFont sfntVersion="\x00\x01\x00\x00" ttLibVersion="4.4">

<TSI1>

Expand Down
Loading

0 comments on commit d2ddba0

Please sign in to comment.