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

My attempt to make releases/pypi/gen.sh work again under python3 and … #1

Open
wants to merge 2 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
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
.DS_Store
__pycache__/
4 changes: 2 additions & 2 deletions bindings/python/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

include ../common/Makefile.common

BINDING_MODULE=$(if $(filter osx-%,$(PLATFORM)),ufal_udpipe.so,$(call dynlib,ufal_udpipe))
BINDING_MODULE=$(if $(filter osx-%,$(PLATFORM)),ufal/_udpipe.so,$(call dynlib,ufal/_udpipe))
BINDING_C_FLAGS+=$(if $(PYTHON_INCLUDE),,$(error PYTHON_INCLUDE must be set to the directory containing Python.h))
BINDING_C_FLAGS+=$(call include_dir,$(PYTHON_INCLUDE))
BINDING_C_FLAGS+=$(if $(filter %-gcc %-clang,$(PLATFORM)),-w)
Expand All @@ -23,7 +23,7 @@ $(BINDING_MODULE): $(call dynobj,udpipe_python) $(BINDING_UDPIPE_OBJECTS)
udpipe_python.cpp: udpipe_python.i ../common/udpipe.i
@$(call mkdir,ufal)
@$(call echo,>ufal/__init__.py)
swig $(SWIG_FLAGS) -python -outdir ufal -o $@ -interface ufal_udpipe -builtin $<
swig $(SWIG_FLAGS) -python -outdir ufal -o $@ -builtin $<

.PHONY: clean
clean:
Expand Down
6 changes: 5 additions & 1 deletion bindings/python/udpipe_python.i
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
%module udpipe
%module(package="ufal") udpipe

%begin %{
#ifdef _WIN32
Expand All @@ -12,4 +12,8 @@
#endif
%}

%pythonbegin %{
# __version__ =
%}

%include "../common/udpipe.i"
4 changes: 2 additions & 2 deletions doc/t2t_docsys/txt2tags.py
Original file line number Diff line number Diff line change
Expand Up @@ -2124,10 +2124,10 @@ def getRegexes():
bank['linkmark'] = re.compile(
r'\[(?P<label>%s|[^]]+) (?P<link>%s|%s|%s)\]'%(
patt_img, retxt_url, patt_email, retxt_url_local),
re.L+re.I)
re.I)

# Image
bank['img'] = re.compile(patt_img, re.L+re.I)
bank['img'] = re.compile(patt_img, re.I)

# Special things
bank['special'] = re.compile(r'^%!\s*')
Expand Down
3 changes: 2 additions & 1 deletion releases/pypi/.gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
ufal.udpipe
ufal.udpipe/
README
2 changes: 2 additions & 0 deletions releases/pypi/gen.sh
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ cp -a ../../bindings/python/ufal $dir

# Fill in version
sed "s/^\\( *version *= *'\\)[^']*'/\\1$1'/" setup.py >$dir/setup.py
sed "s/^# *__version__ *=.*$/__version__ = \"$1\"/" $dir/ufal/udpipe.py > $dir/ufal/udpipe.py.tmp
mv $dir/ufal/udpipe.py.tmp $dir/ufal/udpipe.py

# README file
./README.sh >$dir/README
Expand Down
7 changes: 5 additions & 2 deletions releases/pypi/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,11 @@
with open('README') as file:
readme = file.read()

extra_link_args = []
extra_compile_args = ['-std=c++11', '-fvisibility=hidden', '-w']
if platform == "darwin":
extra_compile_args += ['-stdlib=libc++']
extra_link_args += ['-stdlib=libc++']

setup(
name = 'ufal.udpipe',
Expand All @@ -19,11 +21,12 @@
license = 'MPL 2.0',
py_modules = ['ufal.udpipe'],
ext_modules = [Extension(
'ufal_udpipe',
'ufal._udpipe',
['udpipe/udpipe.cpp', 'udpipe/udpipe_python.cpp'],
language = 'c++',
include_dirs = ['udpipe/include'],
extra_compile_args = extra_compile_args)],
extra_compile_args = extra_compile_args,
extra_link_args = extra_link_args)],
classifiers = [
'Development Status :: 5 - Production/Stable',
'License :: OSI Approved :: Mozilla Public License 2.0 (MPL 2.0)',
Expand Down
10 changes: 4 additions & 6 deletions src/mi/guesser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,8 @@
#include <boost/iterator/filter_iterator.hpp>


namespace institute
{
namespace mova
{
namespace ufal {
namespace udpipe {
///////////////////////////////////////////////////////////////////////////
void Guesser::analyze(vector<tagged_lemma>& o_lemmas, const char* i_form_bytes)
{
Expand Down Expand Up @@ -227,5 +225,5 @@ namespace institute
{
this->dictionary = dictionary;
}
}
}
} // namespace udpipe
} // namespace ufal
29 changes: 9 additions & 20 deletions src/mi/guesser.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@
// Created by Москалевський on 4/6/17.
//

#ifndef SRC_GUESSER_H
#define SRC_GUESSER_H

#include "utils/string_piece.h"
#include "morphodita/morpho/morpho_dictionary.h"
Expand All @@ -14,20 +12,14 @@
#include <iostream>
#include <regex>

namespace ufal {
namespace udpipe {
using ufal::udpipe::morphodita::generic_lemma_addinfo;
using ufal::udpipe::morphodita::morpho_dictionary;
using ufal::udpipe::morphodita::tagged_lemma;
using namespace ufal::udpipe::utils;

using ufal::udpipe::morphodita::generic_lemma_addinfo;
using ufal::udpipe::morphodita::morpho_dictionary;
using ufal::udpipe::morphodita::tagged_lemma;
using namespace ufal::udpipe::utils;



typedef morpho_dictionary<generic_lemma_addinfo> Dictionary;

namespace institute
{
namespace mova
{
typedef morpho_dictionary<generic_lemma_addinfo> Dictionary;
struct TaggedLemma
{
string tag;
Expand Down Expand Up @@ -64,8 +56,5 @@ namespace institute
private:

};
}
}


#endif //SRC_GUESSER_H
} // namespace udpipe
} // namespace ufal
13 changes: 6 additions & 7 deletions src/mi/static.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,12 @@
#include <map>
#include "static.h"

using std::wstring;

namespace institute
{
namespace mova
{
namespace ufal {
namespace udpipe {
using std::wstring;

// const wregex INTJ_RE{boost::join(INTJ_RE_STRS, L"|")};

}
}
} // namespace udpipe
} // namespace ufal
26 changes: 9 additions & 17 deletions src/mi/static.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,17 @@
// Created by Москалевський on 4/10/17.
//

#ifndef SRC_STATIC_H
#define SRC_STATIC_H

#include <regex>
#include <boost/algorithm/string/join.hpp>
#include <boost/algorithm/string.hpp>

using std::wstring;
using std::string;
using std::wregex;
using std::regex;
using std::vector;

namespace institute
{
namespace mova
{
namespace ufal {
namespace udpipe {
using std::wstring;
using std::string;
using std::wregex;
using std::regex;
using std::vector;

struct PrefixSpec
{
Expand Down Expand Up @@ -865,7 +859,5 @@ namespace institute
{L'0', L"двадцяти", L"двадцять", "~NUM~~Case=Loc|Number=Plur|NumType=Card"},
{L'0', L"двадцятьох", L"двадцять", "~NUM~~Case=Loc|Number=Plur|NumType=Card"},
};
}
}

#endif //SRC_STATIC_H
} // namespace udpipe
} // namespace ufal
2 changes: 1 addition & 1 deletion src/morphodita/morpho/generic_morpho.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ class generic_morpho : public morpho {
unsigned version;
morpho_dictionary<generic_lemma_addinfo> dictionary;
unique_ptr<morpho_statistical_guesser> statistical_guesser;
mutable institute::mova::Guesser mi_guesser;
mutable ufal::udpipe::Guesser mi_guesser;

string unknown_tag, number_tag, punctuation_tag, symbol_tag;
};
Expand Down