Merge branch 'master' into henryiii/pep517
This commit is contained in:
@@ -1,4 +1,3 @@
|
||||
import os
|
||||
import re
|
||||
import pytest
|
||||
import textwrap
|
||||
@@ -39,11 +38,9 @@ VERSION_REGEX = r'([\w-]+)==([^\s]+)'
|
||||
|
||||
|
||||
def get_versions_from_constraint_file(constraint_file):
|
||||
with open(constraint_file, encoding='utf8') as f:
|
||||
constraint_file_text = f.read()
|
||||
constraint_file_text = constraint_file.read_text(encoding='utf8')
|
||||
|
||||
versions = {}
|
||||
|
||||
for package, version in re.findall(VERSION_REGEX, constraint_file_text):
|
||||
versions[package] = version
|
||||
|
||||
@@ -73,7 +70,7 @@ def test_pinned_versions(tmp_path, python_version):
|
||||
constraint_filename = 'constraints.txt'
|
||||
build_pattern = '[cp]p38-*'
|
||||
|
||||
constraint_file = os.path.join(cibuildwheel.util.resources_dir, constraint_filename)
|
||||
constraint_file = cibuildwheel.util.resources_dir / constraint_filename
|
||||
constraint_versions = get_versions_from_constraint_file(constraint_file)
|
||||
|
||||
for package in ['pip', 'setuptools', 'wheel', 'virtualenv']:
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
import os
|
||||
from pathlib import Path
|
||||
|
||||
import jinja2
|
||||
|
||||
from typing import Union, Dict, Any
|
||||
|
||||
|
||||
@@ -14,6 +16,8 @@ class TestProject:
|
||||
|
||||
Write out to the filesystem using `generate`.
|
||||
'''
|
||||
__test__ = False # Have pytest ignore this class on `from .test_projects import TestProject`
|
||||
|
||||
files: FilesDict
|
||||
template_context: TemplateContext
|
||||
|
||||
@@ -21,12 +25,12 @@ class TestProject:
|
||||
self.files = {}
|
||||
self.template_context = {}
|
||||
|
||||
def generate(self, path: str):
|
||||
def generate(self, path: Path):
|
||||
for filename, content in self.files.items():
|
||||
file_path = os.path.join(path, filename)
|
||||
os.makedirs(os.path.dirname(file_path), exist_ok=True)
|
||||
file_path = path / filename
|
||||
file_path.parent.mkdir(parents=True, exist_ok=True)
|
||||
|
||||
with open(file_path, 'w', encoding='utf8') as f:
|
||||
with file_path.open('w', encoding='utf8') as f:
|
||||
if isinstance(content, jinja2.Template):
|
||||
content = content.render(self.template_context)
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import os
|
||||
from pathlib import Path
|
||||
|
||||
import jinja2
|
||||
|
||||
@@ -35,7 +35,7 @@ def test(capfd, tmp_path):
|
||||
project_dir = tmp_path / 'project'
|
||||
subdir_package_project.generate(project_dir)
|
||||
|
||||
package_dir = os.path.join(project_dir, 'src', 'spam')
|
||||
package_dir = Path('src', 'spam')
|
||||
# build the wheels
|
||||
actual_wheels = utils.cibuildwheel_run(project_dir, package_dir=package_dir, add_env={
|
||||
'CIBW_BEFORE_BUILD': 'python {project}/bin/before_build.py',
|
||||
|
||||
@@ -46,12 +46,15 @@ class TestSpam(TestCase):
|
||||
self.assertNotEqual(0, spam.system('python -c "exit(1)"'))
|
||||
|
||||
def test_virtualenv(self):
|
||||
virtualenv_path = os.environ.get("__CIBW_VIRTUALENV_PATH__")
|
||||
if not virtualenv_path:
|
||||
self.fail("No virtualenv path defined in environment variable __CIBW_VIRTUALENV_PATH__")
|
||||
# sys.prefix is different from sys.base_prefix when running a virtualenv
|
||||
# See https://docs.python.org/3/library/venv.html, which virtualenv seems
|
||||
# to honor in recent releases
|
||||
# Python 2 doesn't have sys.base_prefix by default
|
||||
if not hasattr(sys, 'base_prefix') or sys.prefix == sys.base_prefix:
|
||||
self.fail("Not running in a virtualenv")
|
||||
|
||||
self.assertTrue(path_contains(virtualenv_path, sys.executable))
|
||||
self.assertTrue(path_contains(virtualenv_path, spam.__file__))
|
||||
self.assertTrue(path_contains(sys.prefix, sys.executable))
|
||||
self.assertTrue(path_contains(sys.prefix, spam.__file__))
|
||||
|
||||
def test_uname(self):
|
||||
if platform.system() == "Windows":
|
||||
|
||||
+3
-2
@@ -10,9 +10,10 @@ import shutil
|
||||
import subprocess
|
||||
import sys
|
||||
from contextlib import contextmanager
|
||||
from pathlib import Path
|
||||
from tempfile import mkdtemp
|
||||
|
||||
IS_WINDOWS_RUNNING_ON_AZURE = os.path.exists('C:\\hostedtoolcache')
|
||||
IS_WINDOWS_RUNNING_ON_AZURE = Path('C:\\hostedtoolcache').exists()
|
||||
IS_WINDOWS_RUNNING_ON_TRAVIS = os.environ.get('TRAVIS_OS_NAME') == 'windows'
|
||||
|
||||
|
||||
@@ -66,7 +67,7 @@ def cibuildwheel_run(project_path, package_dir='.', env=None, add_env=None, outp
|
||||
|
||||
with TemporaryDirectoryIfNone(output_dir) as _output_dir:
|
||||
subprocess.check_call(
|
||||
[sys.executable, '-m', 'cibuildwheel', '--output-dir', str(_output_dir), package_dir],
|
||||
[sys.executable, '-m', 'cibuildwheel', '--output-dir', str(_output_dir), str(package_dir)],
|
||||
env=env,
|
||||
cwd=project_path,
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user