diff options
| author | bolkedebruin <bolkedebruin@users.noreply.github.com> | 2018-03-25 03:48:47 +0200 |
|---|---|---|
| committer | Val Neekman <un33kvu@gmail.com> | 2018-03-24 21:48:47 -0400 |
| commit | 874fe140aa68ee1065e2170385f8c4ace5ac644a (patch) | |
| tree | 955640a1612c32b7c45673f3f011191c2e3ed307 | |
| parent | e14bde218d794869eba8d23949bf0a9de8611a46 (diff) | |
| download | python-slugify-874fe140aa68ee1065e2170385f8c4ace5ac644a.tar.gz | |
Use unidecode as an API and allow alternatives (#53)
This PR allows specifying WITH_TEXTUNIDECODE when
installing python-slugify. This allows using
text-unidecode instead of unidecode. It will default
to using unidecode.
Closes: #51
| -rw-r--r-- | .travis.yml | 6 | ||||
| -rw-r--r-- | README.rst | 16 | ||||
| -rw-r--r-- | alt_requirements.txt | 1 | ||||
| -rwxr-xr-x | setup.py | 5 | ||||
| -rw-r--r-- | slugify/slugify.py | 6 |
5 files changed, 30 insertions, 4 deletions
diff --git a/.travis.yml b/.travis.yml index d852b0a..737fa21 100644 --- a/.travis.yml +++ b/.travis.yml @@ -10,9 +10,13 @@ python: - "3.6" - pypy +env: + - WITH_TEXTUNIDECODE=yes + - WITH_UNIDECODE=yes # this is redundant but otherwise travis will only trigger one build type + install: - pip install pip -U - - pip install -q -r requirements.txt + - if [[ -z "${WITH_TEXTUNIDECODE}" ]]; then pip install -q -r requirements.txt; else pip install -q -r alt_requirements.txt; fi - pip install -e . - pip install pep8 - pip install coveralls @@ -211,3 +211,19 @@ X.Y.Z Version :target: https://pypi.python.org/pypi/python-slugify .. _MIT: https://github.com/un33k/python-slugify/blob/master/LICENSE + + +GPL +--- + +By default python-slugify depends on **unidecode** which is released under GPL. In case this is +a concern to you it is possible to install slugify with **text-unidecode** which is dual licensed +Perl Artistic and GPL. This can be done by: + +.. code:: bash + + $ export WITH_TEXTUNIDECODE=yes + +And then proceed with the normal installation instructions. Please note that this needs to be specified +for every upgrade. Also be aware that in case **unidecode* is present on the system python-slugify will +still default to using it. diff --git a/alt_requirements.txt b/alt_requirements.txt new file mode 100644 index 0000000..980e50a --- /dev/null +++ b/alt_requirements.txt @@ -0,0 +1 @@ +text-unidecode>=1.2
\ No newline at end of file @@ -15,7 +15,10 @@ url = 'https://github.com/un33k/python-slugify' author = 'Val Neekman' author_email = 'info@neekware.com' license = 'MIT' -install_requires = ['Unidecode>=0.04.16'] +if "WITH_TEXTUNIDECODE" in os.environ: + install_requires = ['text-unidecode>=1.2'] +else: + install_requires = ['Unidecode>=0.04.16'] classifiers = [ 'Development Status :: 5 - Production/Stable', 'Intended Audience :: Developers', diff --git a/slugify/slugify.py b/slugify/slugify.py index af0c609..8619184 100644 --- a/slugify/slugify.py +++ b/slugify/slugify.py @@ -13,8 +13,10 @@ except ImportError: _unicode_type = str unichr = chr -import unidecode - +try: + import unidecode +except ImportError: + import text_unidecode as unidecode __all__ = ['slugify', 'smart_truncate'] |
