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

070 python3 #71

Merged
merged 37 commits into from
Mar 7, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
efab756
run 2to3
nhoffman Apr 23, 2021
9d063bc
fix unit tests without external dependencies
nhoffman Apr 24, 2021
1c81a31
bin/bootstrap.py installs python3 environment
nhoffman Apr 24, 2021
f2a5f68
lots of fixes for python3
nhoffman Apr 24, 2021
2f11ce7
fix warning related to use of masked_array
nhoffman Apr 24, 2021
f543f9b
fix additional warnings about unclosed files
nhoffman Apr 24, 2021
2b67abc
modernize setup.py
nhoffman Apr 25, 2021
c31fc72
fix strange bug composing list of vars using locals()
nhoffman Apr 25, 2021
46a9616
open file in text mode
nhoffman Apr 25, 2021
b6664f4
uti.tempcopy uses shutil.copyfile to avoid encoding issue
nhoffman Apr 25, 2021
378d3ed
remove deprecated argument in logging setup
nhoffman Apr 25, 2021
7efd27b
fix python3-related errors for tests in search-select
nhoffman Apr 26, 2021
ebf9cc8
fix encoding issues in tests for fill-lonely
nhoffman Apr 26, 2021
23aee85
fix various encoding issues in tests for hrefpkg-build
nhoffman Apr 26, 2021
b3b9e26
esl_sfetch requires a binary mode output file
nhoffman Apr 26, 2021
6e22b20
don't run tests verbosely
nhoffman Apr 26, 2021
a66a3c0
import setuptools.Command directly
nhoffman Apr 26, 2021
ccc1313
Docker image builds and passes tests
nhoffman Apr 26, 2021
b88cb03
update travis config for python 3.8
nhoffman Apr 26, 2021
48fa1b8
use taxtastic 0.9.1
nhoffman May 4, 2021
8d3e687
fixing travis
crosenth Jul 8, 2021
4f37816
taxtastic==0.9.2
crosenth Jul 12, 2021
e93fe72
Fixing I/O buffering bug left over from py2 conversion
crosenth Jan 15, 2022
273b37d
required numpy update
crosenth Jan 15, 2022
0d8f841
Python 3.7 not compatible with numpy >= 1.22
crosenth Jan 15, 2022
91ffe61
enforcing Python>=3.8
crosenth Jan 15, 2022
c0f6e5b
trying some alternatives to deprecated future._traceback
crosenth Feb 26, 2022
64046a9
futures port not needed anymore
crosenth Feb 26, 2022
54eab9a
officially removing old traceback
crosenth Feb 28, 2022
567130c
Fixed bug where pandas was sniffing str for bit_sc column that should…
crosenth Mar 1, 2022
5841a94
WIP: Adding apt-get upgrade step to image and moving to Python 3.9-sl…
crosenth Mar 3, 2022
98b0d75
Removing Singularity file and updating Dockerfile to Python 3.9
crosenth Mar 3, 2022
29c1de6
0.3.0 release notes
crosenth Mar 3, 2022
65a0c67
Python 3 and Docker instructions
crosenth Mar 4, 2022
24ea44b
set is not allowed anymore
crosenth Mar 7, 2022
934eb34
More dependency upgrades
crosenth Mar 7, 2022
6f05940
Infernal 1.1.4
crosenth Mar 7, 2022
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
3 changes: 3 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,6 @@ tests/*/output/*
tests/*/temp.fasta
tests/hrefpkg-build/hrefpkg
*.ssi
*-env
deenurp.egg-info
build
14 changes: 4 additions & 10 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
sudo: false
language: python
python: 2.7
python:
- 3.8
- 3.9

cache:
# must specify pip dir
Expand All @@ -11,13 +12,6 @@ cache:

env:
global:
# These two environment variables could be set by Travis itself, or Travis
# could configure itself in /etc/, ~/, or inside of the virtual
# environments. In any case if these two values get configured then end
# users only need to enable the pip cache and manually run pip wheel before
# running pip install.
- PIP_WHEEL_DIR=$HOME/.cache/pip/wheels
- PIP_FIND_LINKS=file://$HOME/.cache/pip/wheels
- VIRTUAL_ENV=deenurp-env

addons:
Expand All @@ -32,7 +26,7 @@ install:
- "bin/bootstrap.sh $VIRTUAL_ENV"

script:
- python setup.py test
- python3 -m deenurp.test
- tests/run.sh

notifications:
Expand Down
5 changes: 5 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@
Changes for deenurp
=====================

0.3.0
=====

* Python 3 support and other dependency upgrades and bug fixes

0.2.7
=====

Expand Down
32 changes: 9 additions & 23 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,48 +1,34 @@
FROM ubuntu:18.04
MAINTAINER [email protected]
FROM python:3.9
LABEL org.opencontainers.image.authors="[email protected],[email protected],[email protected]"

# Install prerequisites
RUN apt-get update && apt-get install --assume-yes --no-install-recommends \
build-essential \
gfortran \
git \
liblapack-dev \
libopenblas-dev \
make \
python-dev \
python-pip \
python2.7 \
unzip \
wget
RUN apt-get update && \
apt-get upgrade --assume-yes && \
apt-get install --assume-yes --no-install-recommends git wget

# Add files
RUN mkdir /usr/local/share/deenurp/
ADD bin /usr/local/share/deenurp/bin
ADD tests /usr/local/share/deenurp/tests
ADD deenurp /usr/local/share/deenurp/deenurp
ADD deenurp.py setup.py requirements.txt MANIFEST.in /usr/local/share/deenurp/
ADD deenurp.py setup.py requirements.txt /usr/local/share/deenurp/

# Install deenurp and dependencies
RUN cd /usr/local/share/deenurp/ && \
PYTHON=/usr/bin/python2.7 \
PYTHON=/usr/local/bin/python3 \
DEENURP=/usr/local/share/deenurp/ \
bin/bootstrap.sh /usr/local/

# clean up sources apt packages
RUN rm -rf /var/lib/apt/lists/* && \
rm -rf /root/.cache/pip && \
rm -rf /usr/local/share/deenurp/src && \
apt-get purge -y --auto-remove \
build-essential \
unzip \
git \
python-dev \
make
apt-get purge -y --auto-remove git

# create some mount points
RUN mkdir -p /app /fh /mnt /run/shm

# Run tests
RUN python -m deenurp.test && \
RUN python3 -m deenurp.test && \
cd /usr/local/share/deenurp && \
tests/run.sh
4 changes: 0 additions & 4 deletions MANIFEST.in

This file was deleted.

18 changes: 14 additions & 4 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,13 @@ The Easy Way

* confirm availability of necessary libraries to compile dependencies
(on Ubuntu: ``sudo apt-get install gfortran libopenblas-dev liblapack-dev``)
* Install Python 2.7
* run `bin/bootstrap.sh`
* run `source bin-env/bin/activate`
* Install Python >= 3.8 or Python 3 Virtual Environment
::

% python3 -m venv bin-env
% source bin-env/bin/activate
% bin/bootstrap.sh


the `deenurp` executable should now be on your `$PATH`

Expand All @@ -25,7 +29,7 @@ See required system libraries above.

First, install binary dependencies:

* Python 2.7
* Python 3

- pip, for installing python dependencies (http://www.pip-installer.org/)
- Python packages:
Expand All @@ -46,6 +50,12 @@ Finally, install::

python setup.py install

The Docker Way
==============

Deenurp can be run from a Docker image which can be built locally from the Dockerfile
or pulled ``docker pull nghoffman/deenurp:v0.3.0``

De-novo reference set creation
==============================

Expand Down
41 changes: 0 additions & 41 deletions Singularity

This file was deleted.

81 changes: 13 additions & 68 deletions bin/bootstrap.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,23 +14,9 @@ set -e
# installs deenurp and dependencies to $VIRTUAL_ENV if defined;
# otherwise creates a virtualenv locally.

# Will attempt to install python packages from wheels if $PIP_FIND_LINKS is defined
# and pip --use-wheel is specified

# set $PIP_WHEEL_DIR and $PIP_FIND_LINKS in the parent environment if
# desired

# Will attempt to create wheels if $PIP_WHEEL_DIR is defined
# see https://pip.pypa.io/en/latest/user_guide.html#environment-variables


mkdir -p src
SRCDIR=$(readlink -f src)

if [[ -n "$PIP_WHEEL_DIR" ]]; then
mkdir -p "$PIP_WHEEL_DIR"
fi

srcdir(){
tar -tf $1 | head -1
}
Expand All @@ -44,7 +30,7 @@ else
fi

if [[ -z $PYTHON ]]; then
PYTHON=$(which python2)
PYTHON=$(which python3)
fi

# Defines the default source directory for deenurp as the parent of
Expand All @@ -55,65 +41,24 @@ fi

VENV_VERSION=15.1.0
PPLACER_BUILD=1.1.alpha19
INFERNAL_VERSION=1.1.2
INFERNAL_VERSION=1.1.4
RAXML_VERSION=8.0.5
MUSCLE_VERSION=3.8.31
VSEARCH_VERSION=2.6.2

check_version(){
# usage: check_version module version-string
"$PYTHON" <<EOF 2> /dev/null
import $1
from distutils.version import LooseVersion
assert LooseVersion($1.__version__) >= LooseVersion("$2")
EOF
}

# create virtualenv if necessary, downloading source if available
# version is not up to date.
VENV_URL="https://github.com/pypa/virtualenv/archive/${VENV_VERSION}"
# create virtualenv
if [[ ! -f "${venv:?}/bin/activate" ]]; then
# if the system virtualenv is up to date, use it
if check_version virtualenv $VENV_VERSION; then
echo "using $(which virtualenv) (version $(virtualenv --version))"
virtualenv "$venv"
else
echo "downloading virtualenv version $VENV_VERSION"
if [[ ! -f src/virtualenv-${VENV_VERSION}/virtualenv.py ]]; then
mkdir -p src
(cd src && \
wget --quiet -nc ${VENV_URL}.tar.gz && \
tar -xf ${VENV_VERSION}.tar.gz)
fi
"$PYTHON" src/virtualenv-${VENV_VERSION}/virtualenv.py "$venv"
fi
$PYTHON -m venv $venv
else
echo "virtualenv $venv already exists"
fi

source $venv/bin/activate

# full path; set by activate
venv=$VIRTUAL_ENV

# Preserve the order of installation. The requirements are sorted so
# that secondary (and higher-order) dependencies appear first. See
# bin/pipdeptree2requirements.py. We use --no-deps to prevent various
# packages from being repeatedly installed, uninstalled, reinstalled,
# etc. Also, enfoprcing the order of installation ensures that
# install-time dependencies are met (`pip install -r requirements.txt`
# fails due to a install-time dependency that cogent has for numpy)
pip2 install -U pip

# install pysqlite and updated sqlite3 libraries
wget --quiet -O - \
https://raw.githubusercontent.com/fhcrc/taxtastic/master/dev/install_pysqlite.sh | bash

while read pkg; do
pip2 install "$pkg" --no-deps --upgrade
done < <(/bin/grep -v -E '^#|^$' "$DEENURP/requirements.txt")

pip2 install "$DEENURP"
pip install -U pip wheel
pip install -r requirements.txt
pip install .

# install pplacer and accompanying python scripts
PPLACER_DIR=pplacer-Linux-v${PPLACER_BUILD}
Expand All @@ -128,11 +73,12 @@ if pplacer_is_installed; then
$venv/bin/pplacer --version
else
mkdir -p src && \
(cd src && \
wget -nc --quiet https://github.com/matsen/pplacer/releases/download/v$PPLACER_BUILD/$PPLACER_ZIP && \
unzip -o $PPLACER_ZIP && \
cp $PPLACER_DIR/{pplacer,guppy,rppr} $venv/bin && \
pip2 install -U $PPLACER_DIR/scripts)
(cd src \
&& wget -nc --quiet https://github.com/matsen/pplacer/releases/download/v$PPLACER_BUILD/$PPLACER_ZIP \
&& unzip -o $PPLACER_ZIP \
&& cp $PPLACER_DIR/{pplacer,guppy,rppr} $venv/bin \
# && pip2 install -U $PPLACER_DIR/scripts \
)
# confirm that we have installed the requested build
if ! pplacer_is_installed; then
echo -n "Error: you requested pplacer build $PPLACER_BUILD "
Expand Down Expand Up @@ -218,4 +164,3 @@ else
cd muscle${MUSCLE_VERSION}/src && \
./mk && cp muscle $venv/bin)
fi

2 changes: 1 addition & 1 deletion bin/pipdeptree2requirements.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,5 @@
deps = set()
for __, pkg in sorted(lines):
if pkg not in deps:
print pkg
print(pkg)
deps.add(pkg)
13 changes: 6 additions & 7 deletions deenurp/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
import os
import pkgutil
import sys
import util
from . import util

log = logging.getLogger(__name__)

Expand Down Expand Up @@ -89,9 +89,8 @@ def setup_logging(namespace):
'%(funcName)s %(lineno)s %(message)s')
datefmt = '%Y-%m-%d %H:%M:%S'

logging.basicConfig(stream=namespace.log, format=log_format,
level=loglevel, log_format=log_format,
datefmt=datefmt)
logging.basicConfig(
stream=namespace.log, format=log_format, level=loglevel, datefmt=datefmt)


def parse_version(parser):
Expand All @@ -105,7 +104,7 @@ def parse_args(parser):
parser.add_argument('-l', '--log',
metavar='FILE',
default=sys.stdout,
type=util.file_opener('a', buffering=0), # append
type=util.file_opener('a'), # append
help='Send logging to a file')

parser.add_argument('-v', '--verbose',
Expand All @@ -128,7 +127,7 @@ def parse_subcommands(parser, argv):
"""
Setup all sub-commands
"""
import subcommands
from . import subcommands

subparsers = parser.add_subparsers(dest='subparser_name')

Expand Down Expand Up @@ -158,7 +157,7 @@ def parse_subcommands(parser, argv):
try:
imp = '{}.{}'.format(subcommands.__name__, name)
mod = importlib.import_module(imp)
except Exception, e:
except Exception as e:
log.error('error importing subcommand {}'.format(name))
log.error(e)
continue
Expand Down
Loading