mirror of
https://github.com/NGSolve/netgen.git
synced 2024-12-25 21:40:33 +05:00
Check if pip package already available before building
This commit is contained in:
parent
a009825d83
commit
18ea280388
12
setup.py
12
setup.py
@ -42,16 +42,8 @@ def is_dev_build():
|
||||
return False
|
||||
return True
|
||||
|
||||
git_version = check_output(['git', 'describe', '--tags']).decode('utf-8').strip()
|
||||
version = git_version[1:].split('-')
|
||||
if len(version)>2:
|
||||
version = version[:2]
|
||||
if len(version)>1:
|
||||
version = '.post'.join(version)
|
||||
if is_dev_build():
|
||||
version += '.dev0'
|
||||
else:
|
||||
version = version[0]
|
||||
git_version = check_output([sys.executable, os.path.join('tests', 'utils.py'), '--get-git-version']).decode('utf-8').strip()
|
||||
version = check_output([sys.executable, os.path.join('tests', 'utils.py'), '--get-version']).decode('utf-8').strip()
|
||||
|
||||
py_install_dir = os.path.relpath(sysconfig.get_path('platlib'), sysconfig.get_path('data')).replace('\\','/')
|
||||
|
||||
|
@ -10,6 +10,11 @@ $env:NETGEN_ARCH = 'avx2'
|
||||
|
||||
$pydir=$args[0]
|
||||
& $pydir\python.exe --version
|
||||
& $pydir\python.exe -m pip install packaging
|
||||
& $pydir\python.exe tests\utils.py --check-pip
|
||||
if ($LASTEXITCODE -ne 0) {
|
||||
exit 0
|
||||
}
|
||||
& $pydir\python.exe -m pip install scikit-build wheel numpy twine pybind11-stubgen
|
||||
& $pydir\python.exe -m pip install --upgrade netgen-occt==7.8.1 netgen-occt-devel==7.8.1
|
||||
& $pydir\python setup.py bdist_wheel -G"Visual Studio 16 2019"
|
||||
|
@ -23,6 +23,8 @@ for pyversion in 312 311 310 39 38
|
||||
do
|
||||
export PYDIR="/opt/python/cp${pyversion}-cp${pyversion}/bin"
|
||||
echo $PYDIR
|
||||
$PYDIR/pip install requests packaging
|
||||
$PYDIR/python3 ./tests/utils.py --check-pip || continue
|
||||
$PYDIR/pip install -U pytest-check numpy wheel scikit-build pybind11-stubgen netgen-occt==7.8.1 netgen-occt-devel==7.8.1
|
||||
$PYDIR/pip install -i https://pypi.anaconda.org/mpi4py/simple/ --pre mpi4py
|
||||
|
||||
|
@ -7,6 +7,8 @@ export PATH=$PYDIR:/Applications/CMake.app/Contents/bin:$PATH
|
||||
export NETGEN_CCACHE=1
|
||||
|
||||
$PYDIR/python3 --version
|
||||
$PYDIR/python3 -m pip install packaging
|
||||
$PYDIR/python3 tests/utils.py --check-pip || exit 0
|
||||
$PYDIR/python3 -m pip install --user numpy twine scikit-build wheel pybind11-stubgen
|
||||
$PYDIR/python3 -m pip install --user -U netgen-occt==7.8.1 netgen-occt-devel==7.8.1
|
||||
|
||||
|
@ -1,15 +1,32 @@
|
||||
from subprocess import check_output
|
||||
import argparse
|
||||
import os
|
||||
import platform
|
||||
import requests
|
||||
import sys
|
||||
import argparse
|
||||
from subprocess import check_output
|
||||
from packaging import tags
|
||||
from packaging.utils import parse_wheel_filename
|
||||
|
||||
|
||||
_sys_tags = None
|
||||
|
||||
|
||||
def _is_wheel_compatible(wheel_filename: str):
|
||||
global _sys_tags
|
||||
try:
|
||||
if _sys_tags is None:
|
||||
_sys_tags = set(tags.sys_tags())
|
||||
|
||||
for tag in parse_wheel_filename(wheel_filename)[-1]:
|
||||
if tag in _sys_tags:
|
||||
return True
|
||||
|
||||
return False
|
||||
except Exception as e:
|
||||
print(f"Error parsing wheel file: {e}")
|
||||
return False
|
||||
|
||||
|
||||
def is_package_available(package_name, version):
|
||||
architecture = platform.machine()
|
||||
py_version = "cp" + "".join(platform.python_version_tuple()[:2])
|
||||
|
||||
url = f"https://pypi.org/pypi/{package_name}/{version}/json"
|
||||
|
||||
try:
|
||||
@ -21,7 +38,7 @@ def is_package_available(package_name, version):
|
||||
|
||||
for file_info in data["urls"]:
|
||||
name = file_info.get("filename", "")
|
||||
if name.endswith(".whl") and py_version in name and architecture in name:
|
||||
if _is_wheel_compatible(name):
|
||||
return True
|
||||
|
||||
return False
|
||||
@ -42,10 +59,12 @@ def is_dev_build():
|
||||
return True
|
||||
|
||||
|
||||
def get_git_version(cwd):
|
||||
return check_output(["git", "describe", "--tags"], cwd=cwd).decode("utf-8").strip()
|
||||
|
||||
|
||||
def get_version(cwd):
|
||||
git_version = (
|
||||
check_output(["git", "describe", "--tags"], cwd=cwd).decode("utf-8").strip()
|
||||
)
|
||||
git_version = get_git_version(cwd)
|
||||
|
||||
version = git_version[1:].split("-")
|
||||
if len(version) > 2:
|
||||
@ -53,7 +72,7 @@ def get_version(cwd):
|
||||
if len(version) > 1:
|
||||
version = ".post".join(version)
|
||||
if is_dev_build():
|
||||
version += ".dev0"
|
||||
version += ".dev2"
|
||||
else:
|
||||
version = version[0]
|
||||
|
||||
@ -67,6 +86,11 @@ def main():
|
||||
action="store_true",
|
||||
help="Check if package is on pypi already, fails with exit code 1 if available",
|
||||
)
|
||||
parser.add_argument(
|
||||
"--get-git-version",
|
||||
action="store_true",
|
||||
help="Generate the current package git version string",
|
||||
)
|
||||
parser.add_argument(
|
||||
"--get-version",
|
||||
action="store_true",
|
||||
@ -82,10 +106,12 @@ def main():
|
||||
|
||||
args = parser.parse_args()
|
||||
|
||||
version = get_version(args.dir)
|
||||
if args.get_version:
|
||||
print(version)
|
||||
if args.get_git_version:
|
||||
print(get_git_version(args.dir))
|
||||
elif args.get_version:
|
||||
print(get_version(args.dir))
|
||||
elif args.check_pip:
|
||||
version = get_version(args.dir)
|
||||
if is_package_available(args.package, version):
|
||||
print(f"{args.package}=={version} is already on pypi")
|
||||
sys.exit(1)
|
||||
|
Loading…
Reference in New Issue
Block a user