-
Notifications
You must be signed in to change notification settings - Fork 592
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
Python3 compatibility #319
base: master
Are you sure you want to change the base?
Changes from all commits
c4d3823
c62ebc1
51d908c
d5db950
77ceabe
90ac1ff
6bfa1ef
7aa8367
949588d
6651063
3ff4cd6
581e225
bb76524
7db9cbc
c773dd2
ac5f5f7
21b1aa8
89d982b
332ff6f
babbd42
3b424e8
8d9b990
d890047
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
version: 2 | ||
|
||
jobs: | ||
|
||
build-python27: &job-template | ||
docker: | ||
- image: python:2.7.13 | ||
working_directory: ~/ocropy-build | ||
steps: | ||
- checkout | ||
- restore_cache: | ||
keys: | ||
- default-model-{{ .Environment.CIRCLE_JOB }} | ||
- run: '(cd models && wget -nc http://www.tmbdev.net/en-default.pyrnn.gz)' | ||
- save_cache: | ||
key: default-model-{{ .Environment.CIRCLE_JOB }} | ||
paths: | ||
- models | ||
- run: pip install --user . | ||
- run: ./run-test-ci | ||
|
||
build-python34: | ||
<<: *job-template | ||
docker: | ||
- image: circleci/python:3.5 | ||
|
||
build-python35: | ||
<<: *job-template | ||
docker: | ||
- image: circleci/python:3.5 | ||
|
||
build-python36: | ||
<<: *job-template | ||
docker: | ||
- image: circleci/python:3.6 | ||
|
||
build-python37: | ||
<<: *job-template | ||
docker: | ||
- image: circleci/python:3.7 | ||
|
||
workflows: | ||
version: 2 | ||
build: | ||
jobs: | ||
- build-python27 | ||
- build-python35 | ||
- build-python36 | ||
- build-python37 | ||
Comment on lines
+46
to
+49
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. test |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,3 +15,6 @@ build/ | |
.~*.vue | ||
doc/.ipynb_checkpoints/ | ||
htmlcov/ | ||
dist | ||
*.egg-info | ||
linegen/ |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,49 +1,23 @@ | ||
language: python | ||
python: | ||
# This is not actually used. Because it would take an overly long time | ||
# to build scipy we cannot use the virtual env of travis. Instead, we | ||
# use miniconda. | ||
- "2.7" | ||
- "3.4" | ||
- "3.5" | ||
- "3.6" | ||
- "3.7-dev" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why does this work now without this whole miniconda stuff? This makes it much easier... There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It always worked without miniconda (see circle config and install instructions) but since @QuLogic went through the effort of setting it up with conda, we retained it in travis. I don't know enough about how to change the conda setup to test the various versions, so this seemed the simplest solution. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The conda environment is created with But originally, miniconda was only necessary because SciPy took forever to compile from source; I assume there are wheels now. Also, 3.7 is GA, you should use it and not 3.7-dev which is a very old snapshot. |
||
|
||
sudo: false | ||
|
||
cache: | ||
directories: | ||
- $HOME/.cache/matplotlib | ||
- $HOME/.cache/pip | ||
- models | ||
|
||
install: | ||
# Install miniconda | ||
# ----------------- | ||
- if [[ "$TRAVIS_PYTHON_VERSION" == 2* ]]; then | ||
wget http://repo.continuum.io/miniconda/Miniconda-latest-Linux-x86_64.sh -O miniconda.sh; | ||
else | ||
wget http://repo.continuum.io/miniconda/Miniconda3-latest-Linux-x86_64.sh -O miniconda.sh; | ||
fi | ||
- bash miniconda.sh -b -p $HOME/miniconda | ||
- export PATH="$HOME/miniconda/bin:$PATH" | ||
|
||
# Create the basic testing environment | ||
# ------------------------------------ | ||
- conda config --set always_yes yes --set changeps1 no --set show_channel_urls yes | ||
- conda update conda | ||
- conda create -n test-environment python=$TRAVIS_PYTHON_VERSION | ||
- source activate test-environment | ||
|
||
# Customise the testing environment | ||
# --------------------------------- | ||
- conda install --file requirements.txt | ||
|
||
# Conda debug | ||
#----------- | ||
- conda list | ||
|
||
# Install ocropy | ||
# -------------- | ||
- wget -O models/en-default.pyrnn.gz http://www.tmbdev.net/en-default.pyrnn.gz | ||
- python setup.py install | ||
- (cd models && wget -nc http://www.tmbdev.net/en-default.pyrnn.gz) | ||
- pip install . | ||
|
||
script: | ||
- mkdir ../test_folder | ||
- cd ../test_folder | ||
- ../ocropy/tests/run-unit | ||
- ../ocropy/run-test-ci | ||
- ./tests/run-unit | ||
- ./run-test-ci | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What happened with There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Will fix. Just an oversight. |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
python-scipy python-matplotlib python-lxml | ||
python-scipy python-matplotlib python-lxml python-six |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,7 +2,7 @@ ocropy | |
====== | ||
|
||
[![Build Status](https://travis-ci.org/tmbdev/ocropy.svg?branch=master)](https://travis-ci.org/tmbdev/ocropy) | ||
[![CircleCI](https://circleci.com/gh/UB-Mannheim/ocropy.png)](https://circleci.com/gh/UB-Mannheim/ocropy.png) | ||
[![CircleCI](https://circleci.com/gh/OCR-D/ocropy.png)](https://circleci.com/gh/OCR-D/ocropy.png) | ||
[![Docker Automated build](https://img.shields.io/docker/automated/ubma/ocropy.svg?maxAge=86400)](https://hub.docker.com/r/ubma/ocropy/) [![Docker Pulls](https://img.shields.io/docker/pulls/ubma/ocropy.svg?maxAge=86400)](https://hub.docker.com/r/ubma/ocropy/) | ||
[![license](https://img.shields.io/github/license/tmbdev/ocropy.svg)](https://github.com/tmbdev/ocropy/blob/master/LICENSE) | ||
[![Wiki](https://img.shields.io/badge/wiki-11%20pages-orange.svg)](https://github.com/tmbdev/ocropy/wiki) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It is mentioned in the README and done in the Dockerfile:
But then some warnings show up:
Should this be changed? As you already do it now with There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I tried to install the new version on Python 2.7 with There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The The best way to install IMHO is to create virtualenv with a specific python version, source it, update pip and do Otherwise it's always possible that either the python version, setuptools, pip or system-wide dependency requirements can mess up things. I would avoid system-wide There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Using |
||
|
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,12 @@ | ||
__all__ = [ | ||
"common", | ||
"hocr", | ||
"lang", | ||
"trace", | ||
"default", | ||
"lineest", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can these changes break possibly for someone who is relying on importing from There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If I understand this correctly, then the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This might indeed break stuff, because |
||
] | ||
|
||
################################################################ | ||
### top level imports | ||
################################################################ | ||
|
||
import default | ||
from common import * | ||
from default import traceback as trace | ||
from .default import traceback as trace | ||
from .common import * | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. For what are these import statements needed at all? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. See above. They are imported to be exported, so users can write from ocrolib import allsplitext instead of from ocrolib.common import allsplitext |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,22 @@ | ||
# -*- encoding: utf-8 -*- | ||
from __future__ import unicode_literals | ||
|
||
import re | ||
|
||
# common character sets | ||
|
||
digits = u"0123456789" | ||
letters = u"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz" | ||
symbols = ur"""!"#$%&'()*+,-./:;<=>?@[\]^_`{|}~""" | ||
ascii = digits+letters+symbols | ||
digits = "0123456789" | ||
letters = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz" | ||
symbols = """!"#$%&'()*+,-./:;<=>?@[\\]^_`{|}~""" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why is There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not sure I understood that. |
||
ascii = digits+letters+symbols # pylint: disable=redefined-builtin | ||
|
||
xsymbols = u"""€¢£»«›‹÷©®†‡°∙•◦‣¶§÷¡¿▪▫""" | ||
german = u"ÄäÖöÜüß" | ||
french = u"ÀàÂâÆæÇçÉéÈèÊêËëÎîÏïÔôŒœÙùÛûÜüŸÿ" | ||
turkish = u"ĞğŞşıſ" | ||
greek = u"ΑαΒβΓγΔδΕεΖζΗηΘθΙιΚκΛλΜμΝνΞξΟοΠπΡρΣσςΤτΥυΦφΧχΨψΩω" | ||
portuguese = u"ÁÃÌÍÒÓÕÚáãìíòóõú" | ||
telugu = u" ఁంఃఅఆఇఈఉఊఋఌఎఏఐఒఓఔకఖగఘఙచఛజఝఞటఠడఢణతథదధనపఫబభమయరఱలళవశషసహఽాిీుూృౄెేైొోౌ్ౘౙౠౡౢౣ౦౧౨౩౪౫౬౭౮౯" | ||
xsymbols = """€¢£»«›‹÷©®†‡°∙•◦‣¶§÷¡¿▪▫""" | ||
german = "ÄäÖöÜüß" | ||
french = "ÀàÂâÆæÇçÉéÈèÊêËëÎîÏïÔôŒœÙùÛûÜüŸÿ" | ||
turkish = "ĞğŞşıſ" | ||
greek = "ΑαΒβΓγΔδΕεΖζΗηΘθΙιΚκΛλΜμΝνΞξΟοΠπΡρΣσςΤτΥυΦφΧχΨψΩω" | ||
portuguese = "ÁÃÌÍÒÓÕÚáãìíòóõú" | ||
telugu = " ఁంఃఅఆఇఈఉఊఋఌఎఏఐఒఓఔకఖగఘఙచఛజఝఞటఠడఢణతథదధనపఫబభమయరఱలళవశషసహఽాిీుూృౄెేైొోౌ్ౘౙౠౡౢౣ౦౧౨౩౪౫౬౭౮౯" | ||
|
||
default = ascii+xsymbols+german+french+portuguese | ||
|
||
|
@@ -35,53 +36,53 @@ | |
# there seems to be left vs right leaning, and top-heavy vs bottom-heavy | ||
|
||
replacements = [ | ||
(u'[_~#]',u"~"), # OCR control characters | ||
(u'"',u"''"), # typewriter double quote | ||
(u"`",u"'"), # grave accent | ||
(u'[“”]',u"''"), # fancy quotes | ||
(u"´",u"'"), # acute accent | ||
(u"[‘’]",u"'"), # left single quotation mark | ||
(u"[“”]",u"''"), # right double quotation mark | ||
(u"“",u"''"), # German quotes | ||
(u"„",u",,"), # German quotes | ||
(u"…",u"..."), # ellipsis | ||
(u"′",u"'"), # prime | ||
(u"″",u"''"), # double prime | ||
(u"‴",u"'''"), # triple prime | ||
(u"〃",u"''"), # ditto mark | ||
(u"µ",u"μ"), # replace micro unit with greek character | ||
(u"[–—]",u"-"), # variant length hyphens | ||
(u"fl",u"fl"), # expand Unicode ligatures | ||
(u"fi",u"fi"), | ||
(u"ff",u"ff"), | ||
(u"ffi",u"ffi"), | ||
(u"ffl",u"ffl"), | ||
('[_~#]', "~"), # OCR control characters | ||
('"', "''"), # typewriter double quote | ||
("`", "'"), # grave accent | ||
('[“”]', "''"), # fancy quotes | ||
("´", "'"), # acute accent | ||
("[‘’]", "'"), # left single quotation mark | ||
("[“”]", "''"), # right double quotation mark | ||
("“", "''"), # German quotes | ||
("„", ",,"), # German quotes | ||
("…", "..."), # ellipsis | ||
("′", "'"), # prime | ||
("″", "''"), # double prime | ||
("‴", "'''"), # triple prime | ||
("〃", "''"), # ditto mark | ||
("µ", "μ"), # replace micro unit with greek character | ||
("[–—]", "-"), # variant length hyphens | ||
("fl", "fl"), # expand Unicode ligatures | ||
("fi", "fi"), | ||
("ff", "ff"), | ||
("ffi", "ffi"), | ||
("ffl", "ffl"), | ||
] | ||
|
||
|
||
def requote(s): | ||
s = unicode(s) | ||
s = re.sub(ur"''",u'"',s) | ||
s = re.sub("''", '"', s) | ||
return s | ||
|
||
def requote_fancy(s,germanic=0): | ||
s = unicode(s) | ||
|
||
def requote_fancy(s, germanic=0): | ||
if germanic: | ||
# germanic quoting style reverses the shapes | ||
# straight double quotes | ||
s = re.sub(ur"\s+''",u"”",s) | ||
s = re.sub(u"''\s+",u"“",s) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why is this There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. See above:
|
||
s = re.sub(ur"\s+,,",u"„",s) | ||
s = re.sub(r"\s+''", "”", s) | ||
s = re.sub(r"''\s+", "“", s) | ||
s = re.sub(r"\s+,,", "„", s) | ||
# straight single quotes | ||
s = re.sub(ur"\s+'",u"’",s) | ||
s = re.sub(ur"'\s+",u"‘",s) | ||
s = re.sub(ur"\s+,",u"‚",s) | ||
s = re.sub(r"\s+'", "’", s) | ||
s = re.sub(r"'\s+", "‘", s) | ||
s = re.sub(r"\s+,", "‚", s) | ||
else: | ||
# straight double quotes | ||
s = re.sub(ur"\s+''",u"“",s) | ||
s = re.sub(ur"''\s+",u"”",s) | ||
s = re.sub(ur"\s+,,",u"„",s) | ||
s = re.sub(r"\s+''", "“", s) | ||
s = re.sub(r"''\s+", "”", s) | ||
s = re.sub(r"\s+,,", "„", s) | ||
# straight single quotes | ||
s = re.sub(ur"\s+'",u"‘",s) | ||
s = re.sub(ur"'\s+",u"’",s) | ||
s = re.sub(ur"\s+,",u"‚",s) | ||
s = re.sub(r"\s+'", "‘", s) | ||
s = re.sub(r"'\s+", "’", s) | ||
s = re.sub(r"\s+,", "‚", s) | ||
return s |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This was previously
circleci.yml
. What caused the renaming? Unfortunatelygit
did not recognize this as a renaming...There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Circle CI switched from 1.0 to 2.0 in August last year which is very different (
.circle/config.yml
instead of.circleci.yml
, job/workflow based semantics, containers based directly on docker etc.)