From d0d2aa472ef49ebce33cde5e47f8788770fb869f Mon Sep 17 00:00:00 2001 From: Ludo Pulles Date: Fri, 20 Dec 2024 11:12:09 +0100 Subject: [PATCH] Update bootstrap.sh & setup.py - only append once all code to fpylll-env/bin/activate so deactivating is not necessary - pick up on return code of `make clean` in FPLLL, like G6K does. - fix DeprecationWarning in setup.py and docs/conf.py for getting `__version__` - depend on most recent cysignals (1.12.2) again as this one works again. - change return values of bootstrap.sh to make all errors have different ones Closes: #278 --- bootstrap.sh | 65 ++++++++++++++++++++++++------------------------ docs/conf.py | 3 +-- pyproject.toml | 4 +-- requirements.txt | 2 +- setup.py | 12 ++++----- 5 files changed, 42 insertions(+), 44 deletions(-) diff --git a/bootstrap.sh b/bootstrap.sh index fb0a5996..72d05b75 100755 --- a/bootstrap.sh +++ b/bootstrap.sh @@ -5,8 +5,6 @@ if [ "$1" = "-j" ]; then jobs="-j $2 " fi -# Create Virtual Environment - if [ "$PYTHON" = "" ]; then PYTHON=python; export PYTHON; fi PIP="$PYTHON -m pip" @@ -20,73 +18,76 @@ echo "Using python version: $PYVER" echo "Using $jobs" sleep 1 -rm -rf fpylll-env -$PYTHON -m virtualenv fpylll-env +# Create Virtual Environment +rm -rf fpylll-env activate +$PYTHON -m virtualenv fpylll-env if [ ! -d fpylll-env ]; then - echo "Failed to create virtual environment in 'fpylll-env' !" - echo "Is '$PYTHON -m virtualenv' working?" - echo "Try '$PYTHON -m pip install virtualenv' otherwise." - exit 1 + echo "Failed to create virtual environment in 'fpylll-env'!" + echo "Is '$PYTHON -m virtualenv' working?" + echo "Try '$PIP install virtualenv' otherwise." + exit 1 # 1 is the exit value if creating virtualenv fails fi cat <>fpylll-env/bin/activate + ### LD_LIBRARY_HACK _OLD_LD_LIBRARY_PATH="\$LD_LIBRARY_PATH" LD_LIBRARY_PATH="\$VIRTUAL_ENV/lib:\$LD_LIBRARY_PATH" export LD_LIBRARY_PATH ### END_LD_LIBRARY_HACK -EOF - -ln -s fpylll-env/bin/activate -source ./activate - -$PIP install -U pip -$PIP install Cython -$PIP install cysignals - -# Install FPLLL -cat <>fpylll-env/bin/activate CFLAGS="\$CFLAGS -O3 -march=native -Wp,-U_FORTIFY_SOURCE" CXXFLAGS="\$CXXFLAGS -O3 -march=native -Wp,-U_FORTIFY_SOURCE" export CFLAGS export CXXFLAGS EOF -deactivate +ln -s fpylll-env/bin/activate source ./activate +$PIP install -U pip -r requirements.txt -r suggestions.txt + +# Install FPLLL + git clone https://github.com/fplll/fplll fpylll-fplll cd fpylll-fplll || exit +git pull # Update if it was checked-out before ./autogen.sh ./configure --prefix="$VIRTUAL_ENV" $CONFIGURE_FLAGS -make clean -make $jobs -retval=$? -if [ $retval -ne 0 ]; then - echo "Making fplll failed." +if ! make clean; then + echo "Make clean failed in fplll. This is usually because there was an error with either autogen.sh or configure." echo "Check the logs above - they'll contain more information." - exit 2 # 2 is the exit value if building fplll fails as a result of make $jobs. + exit 2 # 2 is the exit value if building fplll fails via configure or autogen fi -make install +if ! make $jobs; then + echo "Making fplll failed." + echo "Check the logs above - they'll contain more information." + exit 3 # 3 is the exit value if building fplll fails as a result of make $jobs. +fi -if [ $retval -ne 0 ]; then +if ! make install; then echo "Make install failed for fplll." echo "Check the logs above - they'll contain more information." - exit 3 # 3 is the exit value if installing fplll failed. + exit 4 # 4 is the exit value if installing fplll failed. fi cd .. -$PIP install -r requirements.txt -$PIP install -r suggestions.txt +# Install FPyLLL $PYTHON setup.py clean -$PYTHON setup.py build $jobs || $PYTHON setup.py build_ext +if ! $PYTHON setup.py build $jobs || $PYTHON setup.py build_ext; then + echo "Failed to build FPyLLL!" + echo "Check the logs above - they'll contain more information." + exit 5 +fi $PYTHON setup.py install +# Fin + +echo " " echo "Don't forget to activate environment each time:" echo " source ./activate" diff --git a/docs/conf.py b/docs/conf.py index 5560fabb..1e0cbd17 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -14,7 +14,6 @@ import sys import os -import shlex try: from itertools import ifilter as filter @@ -24,7 +23,7 @@ from ast import parse with open(os.path.join('..', 'src', 'fpylll', '__init__.py')) as f: - __version__ = parse(next(filter(lambda line: line.startswith('__version__'), f))).body[0].value.s + __version__ = parse(next(filter(lambda line: line.startswith('__version__'), f))).body[0].value.value # If extensions (or modules to document with autodoc) are in another directory, diff --git a/pyproject.toml b/pyproject.toml index 61548ae2..13a7aef9 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,5 +1,5 @@ [build-system] requires = ["setuptools", - "Cython", - "cysignals<1.12.0"] + "Cython>=3.0", + "cysignals"] build-backend = "setuptools.build_meta" diff --git a/requirements.txt b/requirements.txt index 7da579ca..f591acff 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,5 +1,5 @@ setuptools Cython>=3.0 +cysignals pytest -cysignals<1.12.0 black diff --git a/setup.py b/setup.py index 9ac9b475..25912158 100755 --- a/setup.py +++ b/setup.py @@ -6,6 +6,8 @@ import subprocess import sys import io +from ast import parse +from copy import copy if "READTHEDOCS" in os.environ: # When building with readthedocs, install the dependencies too. @@ -19,9 +21,6 @@ except ImportError: pass # python 3 -from os import path -from ast import parse - try: from setuptools.command.build_ext import build_ext as _build_ext from setuptools.core import setup @@ -33,8 +32,6 @@ from distutils.extension import Extension as _Extension aux_setup_kwds = {} -from copy import copy - try: FileNotFoundError except NameError: @@ -221,10 +218,11 @@ def _get_have_long_double(self): # VERSION -with open(path.join("src", "fpylll", "__init__.py")) as f: +with open(os.path.join("src", "fpylll", "__init__.py")) as f: __version__ = ( - parse(next(filter(lambda line: line.startswith("__version__"), f))).body[0].value.s + parse(next(filter(lambda line: line.startswith("__version__"), f))).body[0].value.value ) + # FIRE