Skip to content

Commit

Permalink
setup.py uses pip and also installs editable requires like faup
Browse files Browse the repository at this point in the history
  • Loading branch information
fedelemantuano committed Dec 4, 2017
1 parent a7abaa2 commit e20e178
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 14 deletions.
30 changes: 18 additions & 12 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
---
sudo: required

services:
Expand All @@ -10,16 +11,22 @@ python:

env:
- TIKA_VER=1.15
TIKA_APP_JAR=/tmp/tika-app-${TIKA_VER}.jar
FAUP_PATH=/tmp/faup
ZEMANA_PATH=/tmp/zemana
DOCKER_ROOT_PATH=/tmp/docker-root
TIKA_APP_JAR=/tmp/tika-app-${TIKA_VER}.jar
FAUP_PATH=/tmp/faup
ZEMANA_PATH=/tmp/zemana
DOCKER_ROOT_PATH=/tmp/docker-root
DOCKER_ELASTICSEARCH_PATH=/tmp/docker-elasticsearch

before_install:
- sudo apt-get -qq update
- sudo apt-get install -y build-essential cmake libfuzzy-dev unrar spamassassin

- >
sudo apt-get install -y
build-essential
cmake
libfuzzy-dev
spamassassin
unrar
# Build latest images spamscope-root, spamscope-elasticsearch

# make images
Expand All @@ -31,7 +38,7 @@ before_install:
git clone -b $TRAVIS_BRANCH --single-branch https://github.com/SpamScope/spamscope-dockerfile-elasticsearch.git $DOCKER_ELASTICSEARCH_PATH &&
cd $DOCKER_ELASTICSEARCH_PATH && docker build -t $DOCKER_USERNAME/spamscope-elasticsearch . && cd -;
fi

- if [ "$TRAVIS_BRANCH" == "develop" ]; then
git clone -b $TRAVIS_BRANCH --single-branch https://github.com/SpamScope/spamscope-dockerfile-root.git $DOCKER_ROOT_PATH &&
cd $DOCKER_ROOT_PATH && docker build -t $DOCKER_USERNAME/spamscope-root:$TRAVIS_BRANCH . && cd - &&
Expand All @@ -42,18 +49,17 @@ before_install:
fi

# command to install dependencies
install:
- pip install -r requirements.txt && python setup.py install
install:
- python setup.py install
- git clone https://$BITBUCKET_USER:[email protected]/$BITBUCKET_USER/zemana-api.git $ZEMANA_PATH && cd $ZEMANA_PATH && python setup.py install && cd -
- src/cli/faup.sh
- cd ${FAUP_PATH}/src/lib/bindings/python && python setup.py install && cd -
- src/cli/faup.sh && cd -
- pip install coveralls

before_script:
- curl -o ${TIKA_APP_JAR} https://archive.apache.org/dist/tika/tika-app-${TIKA_VER}.jar

# command to run tests
script:
script:
# Unittests and coverage
- coverage run --include=src/modules/* --omit=src/modules/abstracts.py -m unittest discover -s tests -f -v
# - python -m unittest discover -s tests -f -v
Expand Down
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,4 @@ ssdeep==3.2
streamparse==3.11.0
tika-app==1.1.1
virustotal-api==1.1.2
-e "git+https://github.com/stricaud/faup.git#egg=pyfaup&subdirectory=src/lib/bindings/python"
1 change: 1 addition & 0 deletions requirements_editable.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
git+https://github.com/stricaud/faup.git#egg=pyfaup&subdirectory=src/lib/bindings/python
17 changes: 16 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import os
import runpy
from setuptools import setup, find_packages
from setuptools.command.install import install as SetupToolsInstall


current = os.path.realpath(os.path.dirname(__file__))
Expand All @@ -30,6 +31,19 @@
with open(os.path.join(current, 'requirements.txt')) as f:
requires = f.read().splitlines()

with open(os.path.join(current, 'requirements_editable.txt')) as f:
requirements_editable = f.read().splitlines()


class Install(SetupToolsInstall):
"""Customized setuptools install command which uses pip. """

def run(self, *args, **kwargs):
import pip
pip.main(["install", "-e"] + requirements_editable)
pip.main(['install', '.'])
SetupToolsInstall.run(self, *args, **kwargs)


setup(
name="SpamScope",
Expand All @@ -44,7 +58,8 @@
packages=find_packages(),
platforms=["Linux"],
keywords=["spam-analyzer", "email", "mail", "cli"],
# install_requires=requires,
install_requires=requires,
cmdclass={'install': Install},
classifiers=[
"License :: OSI Approved :: Apache Software License",
"Intended Audience :: Developers",
Expand Down
2 changes: 1 addition & 1 deletion src/modules/mails/spamassassin_analysis.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ def obj_report(s):
t = message.epilogue
t = t[t.index("pts rule name"):].strip()
except (ValueError, AttributeError):
return
return {}

details = convert_ascii2json(t)
spam_checker_version = message.get("X-Spam-Checker-Version")
Expand Down

0 comments on commit e20e178

Please sign in to comment.