Skip to content

Commit

Permalink
make the python scripts work in msys2 environments
Browse files Browse the repository at this point in the history
  • Loading branch information
hly1204 committed Jan 15, 2024
1 parent 983f01f commit 9d6208f
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ Source code of [https://judge.yosupo.jp](https://judge.yosupo.jp). You can get t

- Linux / OS X / Windows(MinGW-w64)
- python3.6+
- g++ / clang++ (Needs --std=c++14 and __int128_t)
- g++ / clang++ (Needs --std=c++17 and __int128_t)

## How to Use

Expand Down
10 changes: 8 additions & 2 deletions problem.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#!/usr/bin/env python3

import sys
import sysconfig
import argparse
import os
import platform
Expand Down Expand Up @@ -44,7 +45,11 @@ def param_to_str(key: str, value: object):

def compile(src: Path, rootdir: Path, opts: [str] = []):
if src.suffix == '.cpp':
cxx = getenv('CXX', 'g++')
# use clang for msys2 clang environment
if os.name == 'nt' and sysconfig.get_platform().startswith('mingw') and sysconfig.get_platform().endswith('clang'):
cxx = getenv('CXX', 'clang++')
else:
cxx = getenv('CXX', 'g++')
cxxflags_default = '-O2 -std=c++17 -Wall -Wextra -Werror -Wno-unused-result'
if platform.system() == 'Darwin':
cxxflags_default += ' -Wl,-stack_size,{}'.format(hex(STACK_SIZE))
Expand Down Expand Up @@ -81,7 +86,8 @@ def execcmd(src: Path, arg: List[str] = []) -> List[str]:
return cmd
elif src.suffix == '.in':
inpath = src.with_name(casename(src, int(arg[0])) + '.in')
if platform.system() == 'Windows':
# see https://www.msys2.org/docs/python/ for using msys2
if platform.system() == 'Windows' and not (os.name == 'nt' and sysconfig.get_platform().startswith("mingw")):
# Windows' built-in command
cmd = ['cmd', '/C', 'type', str(inpath)]
else:
Expand Down

0 comments on commit 9d6208f

Please sign in to comment.