Fix setup.py encoding to be py2 and py3 compatible.

This commit is contained in:
Alexis M 2019-09-16 18:54:10 +02:00 committed by Alexis Metaireau
parent fabceefece
commit bef973d85e
2 changed files with 12 additions and 9 deletions

View file

@ -29,4 +29,5 @@ Contributing
Do you wish to contribute to IHateMoney? Fantastic! There's a lot of very Do you wish to contribute to IHateMoney? Fantastic! There's a lot of very
useful help on the official `contributing useful help on the official `contributing
<https://ihatemoney.readthedocs.io/en/latest/contributing.html>`_ page. <https://ihatemoney.readthedocs.io/en/latest/contributing.html>`_ page.

View file

@ -1,16 +1,13 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
import os import os
import sys
from io import open
from setuptools import setup, find_packages from setuptools import setup, find_packages
here = os.path.abspath(os.path.dirname(__file__)) here = os.path.abspath(os.path.dirname(__file__))
def read_file(filename):
"""Open a related file and return its content."""
with open(os.path.join(here, filename), "r") as f:
return f.read()
def parse_requirements(filename): def parse_requirements(filename):
""" load requirements from a pip requirements file """ """ load requirements from a pip requirements file """
with open(filename) as lines: with open(filename) as lines:
@ -18,7 +15,12 @@ def parse_requirements(filename):
return [line for line in lineiter if line and not line.startswith("#")] return [line for line in lineiter if line and not line.startswith("#")]
README = read_file('README.rst') README = open('README.rst', encoding='utf-8').read()
CHANGELOG = open('CHANGELOG.rst', encoding='utf-8').read()
description = u'\n'.join([README, CHANGELOG])
if sys.version_info.major < 3:
description = description.encode('utf-8')
ENTRY_POINTS = { ENTRY_POINTS = {
'paste.app_factory': [ 'paste.app_factory': [
@ -33,7 +35,7 @@ ENTRY_POINTS = {
setup(name='ihatemoney', setup(name='ihatemoney',
version='4.1', version='4.1',
description='A simple shared budget manager web application.', description='A simple shared budget manager web application.',
long_description=README, long_description=description,
license='Custom BSD Beerware', license='Custom BSD Beerware',
classifiers=[ classifiers=[
"Programming Language :: Python", "Programming Language :: Python",