From ffe3c8931384f0866b19d84a766fc6fe6b5d3c81 Mon Sep 17 00:00:00 2001 From: Rebecca Chen Date: Tue, 3 Nov 2020 19:57:43 -0800 Subject: [PATCH 1/2] Add pytype/typegraph/* to MANIFEST.in. I was getting errors about cfg_logging.h being missing when trying to test a new release; this change seems to fix the issue. I'm still seeing some odd dynamic import failure, but python3.7 on my machine also appears to be half-broken right now, so I have no idea if the issue is with the pytype code or my environment. --- MANIFEST.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/MANIFEST.in b/MANIFEST.in index c8d089301..c128c43bf 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -2,4 +2,4 @@ include LICENSE include pyproject.toml include pytype/pyi/* include pytype/test_data/* - +include pytype/typegraph/* From 5dd02dd239768595e32549be7cd26d869eb8e568 Mon Sep 17 00:00:00 2001 From: Rebecca Chen Date: Tue, 3 Nov 2020 20:24:23 -0800 Subject: [PATCH 2/2] Use plain setuptools.Extension for the parser extension. For reasons mysterious to me, using Pybind11Extension leads to the error "ImportError: dynamic module does not define module export function (PyInit_parser_ext)", even if I set include_pybind11=False. --- setup.py | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/setup.py b/setup.py index bed4fa168..c65878999 100644 --- a/setup.py +++ b/setup.py @@ -10,7 +10,7 @@ import shutil import sys -from setuptools import setup +from setuptools import setup, Extension # Path to directory containing setup.py here = os.path.abspath(os.path.dirname(__file__)) @@ -37,23 +37,27 @@ def get_parser_ext(): """Get the parser extension.""" - extra_compile_args = [] # We need some platform-dependent compile args for the C extensions. if sys.platform == 'win32': # windows does not have unistd.h; lex/yacc needs this define. - extra_compile_args.append('-DYY_NO_UNISTD_H') - - # This is a setuptools.Extension, with an added include for pybind11, a few - # flags, and a cxx_std setting. - return Pybind11Extension( + extra_compile_args = ['-DYY_NO_UNISTD_H'] + extra_link_args = [] + elif sys.platform == 'darwin': + # clang on darwin requires some extra flags, which gcc does not support + extra_compile_args = ['-std=c++11', '-stdlib=libc++'] + extra_link_args = ['-stdlib=libc++'] + else: + extra_compile_args = ['-std=c++11'] + extra_link_args = [] + return Extension( 'pytype.pyi.parser_ext', sources=[ 'pytype/pyi/parser_ext.cc', 'pytype/pyi/lexer.lex.cc', 'pytype/pyi/parser.tab.cc', ], - cxx_std=11, extra_compile_args=extra_compile_args, + extra_link_args=extra_link_args, )