Skip to content

Commit

Permalink
Update bootstrap.sh & setup.py
Browse files Browse the repository at this point in the history
- 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
  • Loading branch information
ludopulles committed Dec 20, 2024
1 parent 5345e9b commit d0d2aa4
Show file tree
Hide file tree
Showing 5 changed files with 42 additions and 44 deletions.
65 changes: 33 additions & 32 deletions bootstrap.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand All @@ -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 <<EOF >>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 <<EOF >>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"
3 changes: 1 addition & 2 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@

import sys
import os
import shlex

try:
from itertools import ifilter as filter
Expand All @@ -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,
Expand Down
4 changes: 2 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[build-system]
requires = ["setuptools",
"Cython",
"cysignals<1.12.0"]
"Cython>=3.0",
"cysignals"]
build-backend = "setuptools.build_meta"
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
setuptools
Cython>=3.0
cysignals
pytest
cysignals<1.12.0
black
12 changes: 5 additions & 7 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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
Expand All @@ -33,8 +32,6 @@
from distutils.extension import Extension as _Extension
aux_setup_kwds = {}

from copy import copy

try:
FileNotFoundError
except NameError:
Expand Down Expand Up @@ -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


Expand Down

0 comments on commit d0d2aa4

Please sign in to comment.