Skip to content

Commit

Permalink
Fixed Windows Compilation: Switched to RelWithDebInfo Instead of Debug
Browse files Browse the repository at this point in the history
  • Loading branch information
Laky-64 committed Sep 9, 2023
1 parent ade0c38 commit c8521c0
Showing 1 changed file with 13 additions and 13 deletions.
26 changes: 13 additions & 13 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,14 @@

base_path = os.path.abspath(os.path.dirname(__file__))

with open(os.path.join(base_path, 'CMakeLists.txt'), 'r', encoding='utf-8') as f:
regex = re.compile(r'VERSION ([A-Za-z0-9.]+)', re.MULTILINE)
version = re.findall(regex, f.read())[1]

if version.count('.') == 3:
major, minor, path_, tweak = version.split('.')
version = f'{major}.{minor}.{path_}.dev{tweak}'


class CMakeExtension(Extension):
def __init__(self, name: str, sourcedir: str = "") -> None:
Expand Down Expand Up @@ -68,13 +76,12 @@ class CMakeBuild(build_ext):
def build_extension(self, ext: CMakeExtension) -> None:
ext_fullpath = Path.cwd() / self.get_ext_fullpath(ext.name)
extdir = ext_fullpath.parent.resolve()
dist_version = self.distribution.get_version()
cfg = "Debug" if "dev" in dist_version else "Release"
cfg = "RelWithDebInfo" if "dev" in version else "Release"
cmake_args = [
f"-DCMAKE_LIBRARY_OUTPUT_DIRECTORY={extdir}{os.sep}",
f"-DPYTHON_EXECUTABLE={sys.executable}",
f"-DCMAKE_BUILD_TYPE={cfg}",
f"-DPY_VERSION_INFO={dist_version}",
f"-DPY_VERSION_INFO={version}",
f"-DCMAKE_LIBRARY_OUTPUT_DIRECTORY_{cfg.upper()}={extdir}",
]
build_args = [
Expand Down Expand Up @@ -109,12 +116,13 @@ def finalize_options(self):

# noinspection PyMethodMayBeStatic
def run(self):
cfg = "RelWithDebInfo" if "dev" in version else "Release"
cmake_args = [
'-DCMAKE_BUILD_TYPE=Release',
f'-DCMAKE_BUILD_TYPE={cfg}',
]
cmake_args += get_os_cmake_args()
build_args = [
'--config', 'Release',
'--config', cfg,
f'-j{multiprocessing.cpu_count()}',
]
build_temp = Path('shared-build')
Expand Down Expand Up @@ -155,14 +163,6 @@ def run(self):
raise FileNotFoundError("No library files found")


with open(os.path.join(base_path, 'CMakeLists.txt'), 'r', encoding='utf-8') as f:
regex = re.compile(r'VERSION ([A-Za-z0-9.]+)', re.MULTILINE)
version = re.findall(regex, f.read())[1]

if version.count('.') == 3:
major, minor, path_, tweak = version.split('.')
version = f'{major}.{minor}.{path_}.dev{tweak}'

with open(os.path.join(base_path, 'README.md'), encoding='utf-8') as f:
readme = f.read()

Expand Down

0 comments on commit c8521c0

Please sign in to comment.