Rename TemplateProject -> TestProject & tidy some comments
This commit is contained in:
@@ -1,2 +0,0 @@
|
|||||||
from .base import TemplateProject # noqa
|
|
||||||
from .c import new_c_project # noqa
|
|
||||||
@@ -1,9 +1,9 @@
|
|||||||
import textwrap
|
import textwrap
|
||||||
import platform
|
import platform
|
||||||
from . import template_projects
|
from . import test_projects
|
||||||
from . import utils
|
from . import utils
|
||||||
|
|
||||||
basic_project = template_projects.new_c_project(
|
basic_project = test_projects.new_c_project(
|
||||||
setup_py_add=textwrap.dedent('''
|
setup_py_add=textwrap.dedent('''
|
||||||
import os
|
import os
|
||||||
|
|
||||||
|
|||||||
@@ -1,9 +1,9 @@
|
|||||||
import textwrap
|
import textwrap
|
||||||
|
|
||||||
from . import utils
|
from . import utils
|
||||||
from . import template_projects
|
from . import test_projects
|
||||||
|
|
||||||
project_with_before_build_asserts = template_projects.new_c_project(
|
project_with_before_build_asserts = test_projects.new_c_project(
|
||||||
setup_py_add=textwrap.dedent(r'''
|
setup_py_add=textwrap.dedent(r'''
|
||||||
import sys, os
|
import sys, os
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
from . import template_projects
|
from . import test_projects
|
||||||
from . import utils
|
from . import utils
|
||||||
|
|
||||||
before_test_project = template_projects.new_c_project()
|
before_test_project = test_projects.new_c_project()
|
||||||
before_test_project.files['test/spam_test.py'] = r'''
|
before_test_project.files['test/spam_test.py'] = r'''
|
||||||
import sys
|
import sys
|
||||||
import os
|
import os
|
||||||
|
|||||||
@@ -1,9 +1,9 @@
|
|||||||
import textwrap
|
import textwrap
|
||||||
|
|
||||||
from . import utils
|
from . import utils
|
||||||
from . import template_projects
|
from . import test_projects
|
||||||
|
|
||||||
project_with_skip_asserts = template_projects.new_c_project(
|
project_with_skip_asserts = test_projects.new_c_project(
|
||||||
setup_py_add=textwrap.dedent(r'''
|
setup_py_add=textwrap.dedent(r'''
|
||||||
# explode if run on Python 2.7 or Python 3.7 (these should be skipped)
|
# explode if run on Python 2.7 or Python 3.7 (these should be skipped)
|
||||||
if sys.version_info[0:2] == (2, 7):
|
if sys.version_info[0:2] == (2, 7):
|
||||||
|
|||||||
+12
-13
@@ -4,11 +4,11 @@ import jinja2
|
|||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
from . import utils
|
from . import utils
|
||||||
from .template_projects import TemplateProject
|
from .test_projects import TestProject
|
||||||
|
|
||||||
cpp_template_project = TemplateProject()
|
cpp_test_project = TestProject()
|
||||||
|
|
||||||
cpp_template_project.files['setup.py'] = jinja2.Template(r'''
|
cpp_test_project.files['setup.py'] = jinja2.Template(r'''
|
||||||
from setuptools import Extension, setup
|
from setuptools import Extension, setup
|
||||||
|
|
||||||
setup(
|
setup(
|
||||||
@@ -18,7 +18,7 @@ setup(
|
|||||||
)
|
)
|
||||||
''')
|
''')
|
||||||
|
|
||||||
cpp_template_project.files['spam.cpp'] = jinja2.Template(r'''
|
cpp_test_project.files['spam.cpp'] = jinja2.Template(r'''
|
||||||
#include <Python.h>
|
#include <Python.h>
|
||||||
|
|
||||||
{{ spam_cpp_top_level_add }}
|
{{ spam_cpp_top_level_add }}
|
||||||
@@ -72,7 +72,7 @@ MOD_INIT(spam)
|
|||||||
''')
|
''')
|
||||||
|
|
||||||
|
|
||||||
cpp11_project = cpp_template_project.copy()
|
cpp11_project = cpp_test_project.copy()
|
||||||
cpp11_project.template_context['extra_compile_args'] = (
|
cpp11_project.template_context['extra_compile_args'] = (
|
||||||
['/std:c++11'] if utils.platform == 'windows' else ['-std=c++11']
|
['/std:c++11'] if utils.platform == 'windows' else ['-std=c++11']
|
||||||
)
|
)
|
||||||
@@ -95,7 +95,7 @@ def test_cpp11(tmp_path):
|
|||||||
assert set(actual_wheels) == set(expected_wheels)
|
assert set(actual_wheels) == set(expected_wheels)
|
||||||
|
|
||||||
|
|
||||||
cpp14_project = cpp_template_project.copy()
|
cpp14_project = cpp_test_project.copy()
|
||||||
cpp14_project.template_context['extra_compile_args'] = (
|
cpp14_project.template_context['extra_compile_args'] = (
|
||||||
['/std:c++14'] if utils.platform == 'windows' else ['-std=c++14']
|
['/std:c++14'] if utils.platform == 'windows' else ['-std=c++14']
|
||||||
)
|
)
|
||||||
@@ -120,7 +120,10 @@ def test_cpp14(tmp_path):
|
|||||||
assert set(actual_wheels) == set(expected_wheels)
|
assert set(actual_wheels) == set(expected_wheels)
|
||||||
|
|
||||||
|
|
||||||
cpp17_project = cpp_template_project.copy()
|
cpp17_project = cpp_test_project.copy()
|
||||||
|
|
||||||
|
# Python and PyPy 2.7 headers use the `register` keyword, which is forbidden in
|
||||||
|
# the C++17 standard, so we need the -Wno-register or /wd5033 options
|
||||||
cpp17_project.template_context['extra_compile_args'] = (
|
cpp17_project.template_context['extra_compile_args'] = (
|
||||||
['/std:c++17', '/wd5033'] if utils.platform == 'windows' else ['-std=c++17', '-Wno-register']
|
['/std:c++17', '/wd5033'] if utils.platform == 'windows' else ['-std=c++17', '-Wno-register']
|
||||||
)
|
)
|
||||||
@@ -136,15 +139,11 @@ def test_cpp17(tmp_path):
|
|||||||
|
|
||||||
cpp17_project.generate(project_dir)
|
cpp17_project.generate(project_dir)
|
||||||
|
|
||||||
# - Python and PyPy 2.7 use the `register` keyword which is forbidden in
|
|
||||||
# the C++17 standard
|
|
||||||
# - The manylinux1 docker image does not have a compiler which supports
|
|
||||||
# C++11
|
|
||||||
# - Pypy's distutils sets the default compiler to 'msvc9compiler', which
|
|
||||||
# is too old to support cpp17.
|
|
||||||
if os.environ.get('APPVEYOR_BUILD_WORKER_IMAGE', '') == 'Visual Studio 2015':
|
if os.environ.get('APPVEYOR_BUILD_WORKER_IMAGE', '') == 'Visual Studio 2015':
|
||||||
pytest.skip('Visual Studio 2015 does not support C++17')
|
pytest.skip('Visual Studio 2015 does not support C++17')
|
||||||
|
|
||||||
|
# Pypy's distutils sets the default compiler to 'msvc9compiler', which
|
||||||
|
# is too old to support cpp17.
|
||||||
add_env = {'CIBW_SKIP': 'cp27-win* pp??-*'}
|
add_env = {'CIBW_SKIP': 'cp27-win* pp??-*'}
|
||||||
|
|
||||||
if utils.platform == 'macos':
|
if utils.platform == 'macos':
|
||||||
|
|||||||
@@ -5,10 +5,10 @@ import textwrap
|
|||||||
import cibuildwheel.util
|
import cibuildwheel.util
|
||||||
|
|
||||||
from . import utils
|
from . import utils
|
||||||
from . import template_projects
|
from . import test_projects
|
||||||
|
|
||||||
|
|
||||||
project_with_expected_version_checks = template_projects.new_c_project(
|
project_with_expected_version_checks = test_projects.new_c_project(
|
||||||
setup_py_add=textwrap.dedent(r'''
|
setup_py_add=textwrap.dedent(r'''
|
||||||
import subprocess
|
import subprocess
|
||||||
import os
|
import os
|
||||||
|
|||||||
@@ -4,9 +4,9 @@ import textwrap
|
|||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
from . import utils
|
from . import utils
|
||||||
from . import template_projects
|
from . import test_projects
|
||||||
|
|
||||||
dockcross_only_project = template_projects.new_c_project(
|
dockcross_only_project = test_projects.new_c_project(
|
||||||
setup_py_add=textwrap.dedent(r'''
|
setup_py_add=textwrap.dedent(r'''
|
||||||
import os, sys
|
import os, sys
|
||||||
|
|
||||||
|
|||||||
@@ -3,10 +3,10 @@ import pytest
|
|||||||
import subprocess
|
import subprocess
|
||||||
import textwrap
|
import textwrap
|
||||||
from . import utils
|
from . import utils
|
||||||
from . import template_projects
|
from . import test_projects
|
||||||
|
|
||||||
|
|
||||||
project_with_environment_asserts = template_projects.new_c_project(
|
project_with_environment_asserts = test_projects.new_c_project(
|
||||||
setup_py_add=textwrap.dedent(r'''
|
setup_py_add=textwrap.dedent(r'''
|
||||||
import os
|
import os
|
||||||
|
|
||||||
@@ -48,7 +48,7 @@ def test_overridden_path(tmp_path):
|
|||||||
project_dir = tmp_path / 'project'
|
project_dir = tmp_path / 'project'
|
||||||
output_dir = tmp_path / 'output'
|
output_dir = tmp_path / 'output'
|
||||||
|
|
||||||
project = template_projects.new_c_project()
|
project = test_projects.new_c_project()
|
||||||
project.generate(project_dir)
|
project.generate(project_dir)
|
||||||
output_dir.mkdir()
|
output_dir.mkdir()
|
||||||
|
|
||||||
|
|||||||
@@ -4,10 +4,10 @@ import textwrap
|
|||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
from . import utils
|
from . import utils
|
||||||
from . import template_projects
|
from . import test_projects
|
||||||
|
|
||||||
# TODO: specify these at runtime according to manylinux_image
|
# TODO: specify these at runtime according to manylinux_image
|
||||||
project_with_manylinux_symbols = template_projects.new_c_project(
|
project_with_manylinux_symbols = test_projects.new_c_project(
|
||||||
spam_c_top_level_add=textwrap.dedent(r'''
|
spam_c_top_level_add=textwrap.dedent(r'''
|
||||||
#include <malloc.h>
|
#include <malloc.h>
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,2 @@
|
|||||||
|
from .base import TestProject # noqa
|
||||||
|
from .c import new_c_project # noqa
|
||||||
@@ -7,8 +7,8 @@ import subprocess
|
|||||||
|
|
||||||
def main():
|
def main():
|
||||||
parser = ArgumentParser(
|
parser = ArgumentParser(
|
||||||
prog="python -m test.template_projects",
|
prog="python -m test.test_projects",
|
||||||
description='Generate a template project to check it out'
|
description='Generate a test project to check it out'
|
||||||
)
|
)
|
||||||
parser.add_argument('PROJECT', help='''
|
parser.add_argument('PROJECT', help='''
|
||||||
Python path to a project object. E.g. test.test_0_basic.basic_project
|
Python path to a project object. E.g. test.test_0_basic.basic_project
|
||||||
@@ -7,7 +7,13 @@ FilesDict = Dict[str, Union[str, jinja2.Template]]
|
|||||||
TemplateContext = Dict[str, Any]
|
TemplateContext = Dict[str, Any]
|
||||||
|
|
||||||
|
|
||||||
class TemplateProject:
|
class TestProject:
|
||||||
|
'''
|
||||||
|
An object that represents a project that can be built by cibuildwheel.
|
||||||
|
Can be manipulated in tests by changing `files` and `template_context`.
|
||||||
|
|
||||||
|
Write out to the filesystem using `generate`.
|
||||||
|
'''
|
||||||
files: FilesDict
|
files: FilesDict
|
||||||
template_context: TemplateContext
|
template_context: TemplateContext
|
||||||
|
|
||||||
@@ -27,7 +33,7 @@ class TemplateProject:
|
|||||||
f.write(content)
|
f.write(content)
|
||||||
|
|
||||||
def copy(self):
|
def copy(self):
|
||||||
other = TemplateProject()
|
other = TestProject()
|
||||||
other.files = self.files.copy()
|
other.files = self.files.copy()
|
||||||
other.template_context = self.template_context.copy()
|
other.template_context = self.template_context.copy()
|
||||||
return other
|
return other
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
import jinja2
|
import jinja2
|
||||||
from .base import TemplateProject
|
from .base import TestProject
|
||||||
|
|
||||||
|
|
||||||
SPAM_C_TEMPLATE = r'''
|
SPAM_C_TEMPLATE = r'''
|
||||||
@@ -81,7 +81,7 @@ version = 0.1.0
|
|||||||
|
|
||||||
def new_c_project(*, spam_c_top_level_add='', spam_c_function_add='', setup_py_add='',
|
def new_c_project(*, spam_c_top_level_add='', spam_c_function_add='', setup_py_add='',
|
||||||
setup_py_setup_args_add='', setup_cfg_add=''):
|
setup_py_setup_args_add='', setup_cfg_add=''):
|
||||||
project = TemplateProject()
|
project = TestProject()
|
||||||
|
|
||||||
project.files.update({
|
project.files.update({
|
||||||
'spam.c': jinja2.Template(SPAM_C_TEMPLATE),
|
'spam.c': jinja2.Template(SPAM_C_TEMPLATE),
|
||||||
+2
-2
@@ -1,9 +1,9 @@
|
|||||||
import textwrap
|
import textwrap
|
||||||
|
|
||||||
from . import utils
|
from . import utils
|
||||||
from . import template_projects
|
from . import test_projects
|
||||||
|
|
||||||
project_with_ssl_tests = template_projects.new_c_project(
|
project_with_ssl_tests = test_projects.new_c_project(
|
||||||
setup_py_add=textwrap.dedent(r'''
|
setup_py_add=textwrap.dedent(r'''
|
||||||
import ssl
|
import ssl
|
||||||
import sys
|
import sys
|
||||||
|
|||||||
@@ -3,10 +3,10 @@ import os
|
|||||||
import jinja2
|
import jinja2
|
||||||
|
|
||||||
from . import utils
|
from . import utils
|
||||||
from .template_projects import TemplateProject
|
from .test_projects import TestProject
|
||||||
from .template_projects.c import SPAM_C_TEMPLATE
|
from .test_projects.c import SPAM_C_TEMPLATE
|
||||||
|
|
||||||
subdir_package_project = TemplateProject()
|
subdir_package_project = TestProject()
|
||||||
|
|
||||||
subdir_package_project.files['src/spam/spam.c'] = jinja2.Template(SPAM_C_TEMPLATE)
|
subdir_package_project.files['src/spam/spam.c'] = jinja2.Template(SPAM_C_TEMPLATE)
|
||||||
subdir_package_project.template_context['spam_c_top_level_add'] = ''
|
subdir_package_project.template_context['spam_c_top_level_add'] = ''
|
||||||
|
|||||||
@@ -5,9 +5,9 @@ import textwrap
|
|||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
from . import utils
|
from . import utils
|
||||||
from . import template_projects
|
from . import test_projects
|
||||||
|
|
||||||
project_with_a_test = template_projects.new_c_project(
|
project_with_a_test = test_projects.new_c_project(
|
||||||
setup_cfg_add=textwrap.dedent(r'''
|
setup_cfg_add=textwrap.dedent(r'''
|
||||||
[options.extras_require]
|
[options.extras_require]
|
||||||
test = nose
|
test = nose
|
||||||
|
|||||||
Reference in New Issue
Block a user