Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Loading Glyphs file failed: 'str' object has no attribute 'read' #1033

Open
atzlinux opened this issue Aug 29, 2023 · 5 comments
Open

Loading Glyphs file failed: 'str' object has no attribute 'read' #1033

atzlinux opened this issue Aug 29, 2023 · 5 comments

Comments

@atzlinux
Copy link

In Debian 12, when I build , test has many errors:

cd .pybuild/cpython3_3.11/build
python3.11 -m pytest tests

`
FAILED tests/test_main.py::test_main_export_custom_ufo_structure[package-False] - SystemExit: fontmake: Error: In 'tests/data/GlyphsUnitTestSans.glyphs': Loading Glyphs file failed: 'str' object has no attribute 'read'
FAILED tests/test_main.py::test_main_export_custom_ufo_structure[package-True] - SystemExit: fontmake: Error: In 'tests/data/GlyphsUnitTestSans.glyphs': Loading Glyphs file failed: 'str' object has no attribute 'read'
FAILED tests/test_main.py::test_main_export_custom_ufo_structure[zip-False] - SystemExit: fontmake: Error: In 'tests/data/GlyphsUnitTestSans.glyphs': Loading Glyphs file failed: 'str' object has no attribute 'read'
FAILED tests/test_main.py::test_main_export_custom_ufo_structure[zip-True] - SystemExit: fontmake: Error: In 'tests/data/GlyphsUnitTestSans.glyphs': Loading Glyphs file failed: 'str' object has no attribute 'read'
============================================== 39 failed, 38 passed, 6 skipped, 6 warnings in 8.39s ==============================================

`

@anthrotype
Copy link
Member

I suspect it might be related to these changes googlefonts/glyphsLib#932 released with glyphsLib 6.3.0. I'll take a look, thank you

@anthrotype
Copy link
Member

actually I tried this locally and all tests pass even with latest glyphsLib 6.3.0 so I don't think it's that.
Can you copy/paste the output of pip freeze to see what versions of depdencies have you got?

@anthrotype
Copy link
Member

also try use --verbose DEBUG to get the full traceback and see where exactly that exception is being thrown

@atzlinux
Copy link
Author

atzlinux commented Sep 4, 2023

In Debian 12, glyphslib is old version 6.0.6+ds1-1.
After I build and update to 6.3.0, this bug is not exist.

But there are other test not pass, I also think that it is caused by old software verison in Debian 12.


.....
            exclude_args(
                parser,
                args,
                [
                    "interpolate",
                    "variable_fonts",
                    "interpolate_binary_layout",
                    "round_instances",
                    "expand_features_to_instances",
                    "check_compatibility",
                ],
                inputs.format_name,
            )
            args.pop("ufo_structure", None)  # unused for UFO output
            args.pop("indent_json", None)
            project.run_from_ufos(
                inputs.ufo_paths, is_instance=args.pop("masters_as_instances"), **args
            )
        except FontmakeError as e:
            if PRINT_TRACEBACK:
                logging.exception(e)
                sys.exit(1)
>           sys.exit(f"fontmake: Error: {str(e)}")
E           SystemExit: fontmake: Error: In 'tests/data/GlyphsUnitTestSans.glyphs' -> 'master_ufo/GlyphsUnitTestSans.designspace': Generating fonts from Designspace failed: 'Font' object has no attribute 'tempLib'

fontmake/__main__.py:743: SystemExit
=============================== warnings summary ===============================
.pybuild/cpython3_3.11/build/tests/test_main.py::test_variable_otf
.pybuild/cpython3_3.11/build/tests/test_main.py::test_no_interpolation
.pybuild/cpython3_3.11/build/tests/test_main.py::test_no_interpolation
.pybuild/cpython3_3.11/build/tests/test_main.py::test_mti_sources
.pybuild/cpython3_3.11/build/tests/test_main.py::test_ufo_to_static_otf_cff2
.pybuild/cpython3_3.11/build/tests/test_main.py::test_ufoz_to_static_otf_cff2
.pybuild/cpython3_3.11/build/tests/test_main.py::test_static_otf_cffsubr_subroutinizer
  /usr/lib/python3/dist-packages/cffsubr/__init__.py:63: DeprecationWarning: path is deprecated. Use files() instead. Refer to https://importlib-resources.readthedocs.io/en/latest/using.html#migrating-from-legacy for migration advice.
    with path(__name__, TX_EXE) as tx_cli:

.pybuild/cpython3_3.11/build/tests/test_main.py::test_ufo_interpolation
  /usr/lib/python3/dist-packages/glyphsLib/glyphdata.py:108: DeprecationWarning: open_binary is deprecated. Use files() instead. Refer to https://importlib-resources.readthedocs.io/en/latest/using.html#migrating-from-legacy for migration advice.
    with open_binary("glyphsLib.data", "GlyphData.xml") as f1:

.pybuild/cpython3_3.11/build/tests/test_main.py::test_ufo_interpolation
  /usr/lib/python3/dist-packages/glyphsLib/glyphdata.py:109: DeprecationWarning: open_binary is deprecated. Use files() instead. Refer to https://importlib-resources.readthedocs.io/en/latest/using.html#migrating-from-legacy for migration advice.
    with open_binary("glyphsLib.data", "GlyphData_Ideographs.xml") as f2:

-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html
=========================== short test summary info ============================
FAILED tests/test_compatibility.py::test_compatibility_cli - SystemExit: font...
FAILED tests/test_instantiator.py::test_strict_math_glyph - AssertionError: a...
FAILED tests/test_main.py::test_interpolation - SystemExit: fontmake: Error: ...
FAILED tests/test_main.py::test_interpolation_designspace_5 - SystemExit: fon...
FAILED tests/test_main.py::test_interpolation_and_masters_as_instances - Syst...
FAILED tests/test_main.py::test_masters_and_instances_ttf_interpolatable - Sy...
FAILED tests/test_main.py::test_variable_ttf - SystemExit: fontmake: Error: I...
FAILED tests/test_main.py::test_no_interpolation - SystemExit: fontmake: Erro...
FAILED tests/test_main.py::test_ufo_interpolation - SystemExit: fontmake: Err...
FAILED tests/test_main.py::test_ufo_interpolation_specific - SystemExit: font...
FAILED tests/test_main.py::test_subsetting[default] - SystemExit: fontmake: E...
FAILED tests/test_main.py::test_subsetting[no-write-skipexportglyphs] - Syste...
FAILED tests/test_main.py::test_keep_glyphs[default] - SystemExit: fontmake: ...
FAILED tests/test_main.py::test_keep_glyphs[no-write-skipexportglyphs] - Syst...
FAILED tests/test_main.py::test_shared_features_expansion - SystemExit: fontm...
FAILED tests/test_main.py::test_shared_features_ufo - SystemExit: fontmake: E...
FAILED tests/test_main.py::test_mti_sources - SystemExit: fontmake: Error: In...
FAILED tests/test_main.py::test_interpolate_layout - SystemExit: fontmake: Er...
FAILED tests/test_main.py::test_debug_feature_file - SystemExit: fontmake: Er...
FAILED tests/test_main.py::test_main_with_feature_writer_none - SystemExit: f...
FAILED tests/test_main.py::test_main_with_filter - SystemExit: fontmake: Erro...
FAILED tests/test_main.py::test_autohinting[autohint_options0] - SystemExit: ...
FAILED tests/test_main.py::test_autohinting[autohint_options1] - SystemExit: ...
FAILED tests/test_main.py::test_autohinting[autohint_options2] - SystemExit: ...
FAILED tests/test_main.py::test_autohinting[autohint_options3] - SystemExit: ...
FAILED tests/test_main.py::test_autohinting[autohint_options4] - SystemExit: ...
FAILED tests/test_main.py::test_main_designspace_v5_builds_STAT - SystemExit: 1
FAILED tests/test_main.py::test_main_designspace_v5_builds_all_vfs - SystemEx...
FAILED tests/test_main.py::test_main_designspace_v5_select_vfs_to_build - Sys...
FAILED tests/test_main.py::test_main_designspace_v5_can_use_output_path_with_1_vf
FAILED tests/test_main.py::test_main_designspace_v5_dont_interpolate_discrete_axis
FAILED tests/test_main.py::test_main_glyphspackage - SystemExit: fontmake: Er...
FAILED tests/test_main.py::test_timing_logger - subprocess.CalledProcessError...
FAILED tests/test_main.py::test_main_export_custom_ufo_structure[package-True]
FAILED tests/test_main.py::test_main_export_custom_ufo_structure[zip-True] - ...
============ 35 failed, 42 passed, 6 skipped, 9 warnings in 12.07s =============
E: pybuild pybuild:388: test: plugin distutils failed with: exit code=1: cd /home/atzlinux/devel/office/fontmake/.pybuild/cpython3_3.11/build; python3.11 -m pytest tests


@anthrotype
Copy link
Member

the minimum required versions of fontmake (as with any python project) at any given time are listed in its setup.py's install_requires parameter.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants