Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update bootstrap.sh & setup.py #288

Merged
merged 2 commits into from
Dec 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
14 changes: 6 additions & 8 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 @@ -84,7 +81,7 @@ def finalize_options(self):
"libraries": ["gmp", "mpfr", "fplll"],
"extra_compile_args": ["-std=c++11"] + cxxflags,
"extra_link_args": ["-std=c++11"],
"define_macros": [("__PYX_EXTERN_C", 'extern "C++"')],
"define_macros": [("CYTHON_EXTERN_C", 'extern "C++"')],
}

if def_vars["HAVE_QD"]:
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
Loading