Skip to content
This repository has been archived by the owner on Dec 25, 2019. It is now read-only.

Add python 2.7 compatibility and prepare release #1

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open
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
22 changes: 22 additions & 0 deletions .appveyor.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
environment:
matrix:
- PYTHON: C:\Python37-x64
- PYTHON: C:\Python36-x64
- PYTHON: C:\Python35-x64
- PYTHON: C:\Python34-x64
- PYTHON: C:\Python27-x64

init:
- SET PATH=%PYTHON%;%PATH%

install:
- python -m pip install -r requirements-dev.txt
- python setup.py develop

build: false

test_script:
- python -m pytest

cache:
- '%LOCALAPPDATA%\pip\Cache'
60 changes: 60 additions & 0 deletions .ci/test_servers.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
"""We want to ensure that users can run Texrrow through UWSGI without issues.
This script is ran by Travis and AppVeyor to ensure the compatibility.

This is a heavy test and incompatible test with pytest.
Thus we keep it separated from the rest of the tests."""
import os
import signal
import sys
import time

import mock
import requests
import requests.exceptions

from texrrow import __main__ as main

TEST_PORT = 12345


def _knock_url_and_wait(url, timeout_per_request=1, global_timeout=10):
status = None
end_time = time.time() + global_timeout
while status is None:
try:
response = requests.head(url, timeout=timeout_per_request)
status = response.status_code
except requests.exceptions.ConnectionError: # noqa
if time.time() > end_time:
raise
assert status == 200


def _run_and_test(to_run):
child_pid = os.fork()
if child_pid == 0:
to_run()
sys.exit(0)
try:
test_url = 'http://127.0.0.1:%d' % TEST_PORT
time.sleep(0.1)
pid, status = os.waitpid(child_pid, os.P_NOWAIT)

# ensure the process did not exit
assert not os.WEXITSTATUS(pid)

# try to ping uwsgi and get a HTTP 200
_knock_url_and_wait(test_url)
finally:
os.kill(child_pid, signal.SIGTERM)
os.wait()


@mock.patch.object(main, 'PORT', new=TEST_PORT)
def test_start_servers():
_run_and_test(main.start_uwsgi)
_run_and_test(main.start_flask)


if __name__ == '__main__':
test_start_servers()
23 changes: 9 additions & 14 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,19 @@ cache:
- node_modules
sudo: false
python:
- "2.7"
- "3.4"
- "3.5"
- "3.6"
- "pypy"
- "pypy3"
services:
- postgresql
env:
global:
- DATABASE_URL=postgres://postgres@localhost:5432/showcased
install:
- pip install codecov pytest-cov pipenv
- pip install codecov pytest-cov uwsgi
- pip install -r requirements-dev.txt
- nvm install 8
- npm i
- npm run build-assets --production
- python setup.py develop
matrix:
include:
- python: "3.7"
Expand All @@ -27,17 +27,12 @@ matrix:
sudo: required
dist: xenial
allow_failures:
- python: "pypy3"
- python: "nightly"
- python: "pypy"
- python: "pypy3"
fast_finish: true
before_script: # code coverage tool
- curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter
- chmod +x ./cc-test-reporter
- ./cc-test-reporter before-build
script:
- pipenv install
- pytest --cov --cov-report=
after_script:
- if [[ "$TRAVIS_PULL_REQUEST" == "false" && "$TRAVIS_PYTHON_VERSION" == "3.7" ]]; then ./cc-test-reporter after-build --exit-code $TRAVIS_TEST_RESULT; fi
- python .ci/test_servers.py
after_success:
- codecov
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2018 NyanKiyoshi

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
98 changes: 98 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
.PHONY: build

MODULE:=texrrow

all: ensure-pip dev style checks dists test

ensure-pip:
pip install --user --upgrade pipenv pip
pip --version
pipenv --version

ensure-pip-ci:
pip install --upgrade pipenv pip
pip --version
pipenv --version

dev:
pipenv install --dev
pipenv run pip install -e .

dev-ci:
pipenv install --dev --skip-lock
pipenv run pip install -e .

dev-py2:
pipenv install --dev --two
pipenv run pip install -e .

style: isort autopep8 yapf

isort:
pipenv run isort -y

autopep8:
pipenv run autopep8 --in-place --recursive setup.py $(MODULE)

yapf:
pipenv run yapf --style .yapf --recursive -i $(MODULE)

checks: flake8 pylint

flake8:
pipenv run python setup.py flake8

pylint:
pipenv run pylint --rcfile=.pylintrc --output-format=colorized $(MODULE)

sc: style checks
sct: style checks test

build: dists

test:
pipenv run pytest $(MODULE)

test-verbose:
pipenv run pytest -s $(MODULE)

test-coverage:
pipenv run py.test -v --cov $(MODULE) --cov-report term-missing

dists: sdist bdist wheels

sdist:
pipenv run python setup.py sdist

bdist:
pipenv run python setup.py bdist

wheels:
pipenv run python setup.py bdist_wheel

pypi-publish: build
pipenv run twine upload --repository pypi dist/*.whl

pypi-test-publish: build
pipenv run twine upload --repository testpypi dist/*.whl

update:
pipenv update

githook: style

push: githook
@git push origin --tags

clean:
pipenv --rm

# aliases to gracefully handle typos on poor dev's terminal
check: checks
devel: dev
develop: dev
dist: dists
install: install-system
pypi: pypi-publish
styles: style
wheel: wheels
21 changes: 0 additions & 21 deletions Pipfile

This file was deleted.

Loading