From 4c20237ed006e123708e352afd79f17744cb6d92 Mon Sep 17 00:00:00 2001 From: Amy He Date: Fri, 6 Sep 2024 17:59:54 -0700 Subject: [PATCH] 1. for compile binaries: edit Makefile BASE to find boost installed by apt-get (Linux) and homebrew (intel, Apple Silicon); 2. for newer boost versions: replace boost/filesystem/*.hpp by boost/filesystem.hpp in source; 3. explictly check for PEP 440 compliance of version: include packaging as build dependency, only return compliant version from setup.py --- build/linux/release/Makefile | 2 +- build/mac/release/Makefile | 2 +- build/python/pyproject.toml | 2 +- build/python/setup.py | 19 ++++++++++++++++--- src/lib/vina.h | 4 +--- src/split/split.cpp | 4 +--- 6 files changed, 21 insertions(+), 12 deletions(-) diff --git a/build/linux/release/Makefile b/build/linux/release/Makefile index eb23376b..6bbd6def 100644 --- a/build/linux/release/Makefile +++ b/build/linux/release/Makefile @@ -1,4 +1,4 @@ -BASE=/usr/local +BASE=/usr BOOST_VERSION= BOOST_INCLUDE = $(BASE)/include C_PLATFORM=-static -pthread diff --git a/build/mac/release/Makefile b/build/mac/release/Makefile index 6433c332..c55df31e 100644 --- a/build/mac/release/Makefile +++ b/build/mac/release/Makefile @@ -1,4 +1,4 @@ -BASE=/usr/local +BASE=$(shell brew --prefix) BOOST_VERSION= BOOST_INCLUDE = $(BASE)/include C_PLATFORM=-pthread diff --git a/build/python/pyproject.toml b/build/python/pyproject.toml index 34a99cce..cbb00f93 100644 --- a/build/python/pyproject.toml +++ b/build/python/pyproject.toml @@ -1,3 +1,3 @@ [build-system] -requires = ["setuptools>=50.3", "wheel"] +requires = ["setuptools>=50.3", "wheel", "packaging"] build-backend = "setuptools.build_meta" diff --git a/build/python/setup.py b/build/python/setup.py index 6d1c6a7d..37ad08df 100644 --- a/build/python/setup.py +++ b/build/python/setup.py @@ -19,7 +19,7 @@ from distutils.util import convert_path from distutils.sysconfig import customize_compiler from distutils.ccompiler import show_compilers - +from packaging.version import Version, InvalidVersion # Path to the directory that contains this setup.py file. base_dir = os.path.abspath(os.path.dirname(__file__)) @@ -53,13 +53,25 @@ def find_version(): 3. __init__.py (as failback) """ + + def is_compliant(version_str): + try: + # Attempt to parse the version string using packaging's Version class + Version(version_str) + return True + except InvalidVersion: + # If parsing fails, the version is not PEP 440 compliant + print(f"{version_str} is not PEP 440 compliant") + return False + version_file = os.path.join(base_dir, 'vina', 'version.py') if os.path.isfile(version_file): with open(version_file) as f: version = f.read().strip() print('Version found: %s (from version.py)' % version) - return version + if is_compliant(version): + return version try: git_output = subprocess.check_output(['git', 'describe', '--abbrev=7', '--dirty=@mod', '--always', '--tags']) @@ -70,7 +82,8 @@ def find_version(): version = git_output.replace('-', '.dev', 1).replace('@', '-', 1).replace('-', '+', 1).replace('-','') print('Version found %s (from git describe)' % version) - return version + if is_compliant(version): + return version except: pass diff --git a/src/lib/vina.h b/src/lib/vina.h index a44cf9b3..0379601b 100644 --- a/src/lib/vina.h +++ b/src/lib/vina.h @@ -33,9 +33,7 @@ #include #include #include -#include -#include -#include // filesystem::basename +#include #include // hardware_concurrency // FIXME rm ? #include //#include diff --git a/src/split/split.cpp b/src/split/split.cpp index b42e78aa..b6234dbf 100644 --- a/src/split/split.cpp +++ b/src/split/split.cpp @@ -28,9 +28,7 @@ #include // getline? #include // for ceila #include -#include -#include -#include // filesystem::basename +#include #include "file.h" #include "parse_error.h"