From 8c806fdf0f69a84fa21e5e9db6da8acc3faed6c7 Mon Sep 17 00:00:00 2001 From: Oleh Prypin Date: Tue, 10 Sep 2024 21:59:45 +0200 Subject: [PATCH] Fix Windows build --- .github/workflows/ci.yml | 13 +++++-------- build_scripts/build_utils.py | 3 +++ pytype/imports_map_loader_test.py | 3 +++ pytype/io_test.py | 11 ++++++----- pytype/tools/analyze_project/config_test.py | 4 ++-- 5 files changed, 19 insertions(+), 15 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index e80229a96..6de891941 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -2,7 +2,6 @@ name: CI on: push: - branches: [ main ] pull_request: branches: [ main ] workflow_dispatch: @@ -14,16 +13,10 @@ jobs: strategy: fail-fast: false matrix: - os: [ubuntu-20.04] - python-version: ['3.8', '3.9', '3.10', '3.11', '3.12'] - experimental: [false] include: - - os: macos-latest - python-version: '3.12' - experimental: false - os: windows-latest python-version: '3.12' - experimental: true + experimental: false # - os: ubuntu-20.04 # python-version: '3.13' # experimental: true @@ -42,6 +35,10 @@ jobs: run: | sudo apt-get install -y bison cmake flex g++ + - name: Setup Developer Command Prompt + if: runner.os == 'Windows' + uses: ilammy/msvc-dev-cmd@v1 + - name: Install Dependencies run: pip install -r requirements.txt diff --git a/build_scripts/build_utils.py b/build_scripts/build_utils.py index b9db3081e..784be9958 100644 --- a/build_scripts/build_utils.py +++ b/build_scripts/build_utils.py @@ -166,6 +166,9 @@ def run_cmake(force_clean=False, log_output=False, debug_build=False): ] if debug_build: cmd.append("-DCMAKE_BUILD_TYPE=Debug") + else: + if os.name == "nt": + cmd.append("-DCMAKE_BUILD_TYPE=Release") returncode, stdout = run_cmd(cmd, cwd=OUT_DIR) # Print the full CMake output to stdout. It is not a lot that it would # clutter the output, and also gives information about the Python version diff --git a/pytype/imports_map_loader_test.py b/pytype/imports_map_loader_test.py index 27c32f38f..37c71dd36 100644 --- a/pytype/imports_map_loader_test.py +++ b/pytype/imports_map_loader_test.py @@ -20,6 +20,8 @@ def __init__(self): class ImportMapLoaderTest(unittest.TestCase): """Tests for imports_map_loader.py.""" + maxDiff = None + @classmethod def setUpClass(cls): super().setUpClass() @@ -73,6 +75,7 @@ def test_build_imports_info(self): ("a/b/e", ["2/a/b/foo/#2.py~", "2/a/b/e1.py~", "2/a/b/e2.py~"]), ] f = file_utils.replace_separator + items = [(f(k), f(v)) for k, v in items] expected = [(f(k), list(map(f, v))) for k, v in expected] actual = self.builder._build_multimap(items).items() self.assertCountEqual(actual, expected) diff --git a/pytype/io_test.py b/pytype/io_test.py index 5cc0c4d2d..537ac129c 100644 --- a/pytype/io_test.py +++ b/pytype/io_test.py @@ -149,14 +149,12 @@ def test_unused_imports_info_files(self): d.create_file("aaa/other.pyi", "class Other: pass") imports_info = d.create_file( "imports_info", - textwrap.dedent( - """ + file_utils.replace_separator(textwrap.dedent(""" common/foo common/foo.pyi common/bar common/bar.pyi common/baz common/baz.pyi aaa/other aaa/other.pyi - """, - ), + """)), ) module = d.create_file("m.py", "from common import foo; print(foo.x)") unused_imports_info_files = path_utils.join(d.path, "unused_imports_info") @@ -173,7 +171,10 @@ def test_unused_imports_info_files(self): ) with options.open_function(unused_imports_info_files) as f: content = f.read() - self.assertEqual(content, "aaa/other.pyi\ncommon/baz.pyi\n") + self.assertEqual( + content, + file_utils.replace_separator("aaa/other.pyi\ncommon/baz.pyi\n"), + ) if __name__ == "__main__": diff --git a/pytype/tools/analyze_project/config_test.py b/pytype/tools/analyze_project/config_test.py index d6ab2b943..667072ec5 100644 --- a/pytype/tools/analyze_project/config_test.py +++ b/pytype/tools/analyze_project/config_test.py @@ -37,11 +37,11 @@ PYTYPE_TOML = f""" [tool.pytype] exclude = ['nonexistent.*'] - pythonpath = \"\"\" + pythonpath = ''' .{os.pathsep} {'C:' if sys.platform == 'win32' else ''}{os.path.sep}foo{os.path.sep}bar{os.pathsep} baz{os.path.sep}quux - \"\"\" + ''' python_version = '3.7' disable = ['import-error', 'module-attr'] """