Skip to content

Commit

Permalink
Make setup.py read metadata from a json file
Browse files Browse the repository at this point in the history
Signed-off-by: Lou Marvin Caraig <[email protected]>
  • Loading branch information
se7entyse7en committed Jun 27, 2020
1 parent 73fd3c1 commit 7a005f6
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 22 deletions.
9 changes: 9 additions & 0 deletions meta.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"title": "pydockenv",
"version": "0.5.0",
"author": "Lou Marvin Caraig",
"author_email": "[email protected]",
"description": "Python Virtualenv Powered by Docker",
"project_url": "https://github.com/se7entyse7en/pydockenv",
"copyright": "Copyright 2020 Lou Marvin Caraig"
}
27 changes: 5 additions & 22 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import re
from functools import partial
import json

import setuptools
from wheel.bdist_wheel import bdist_wheel as _bdist_wheel
Expand All @@ -22,28 +21,12 @@
'Topic :: Utilities',
]

with open('README.md', 'r') as fh:
long_description = fh.read()
with open('README.md', 'r') as fin:
long_description = fin.read()


def get_about():
regexes = {
'title': r"^__title__\s=\s(?P<quote>['])(?P<title>\w*)(?P=quote)$",
'version': r"^__version__\s=\s(?P<quote>['])(?P<version>[\w\.]*)(?P=quote)$",
'author': r"^__author__\s=\s(?P<quote>['])(?P<author>[\w\s]*)(?P=quote)$",
'author_email': r"^__author_email__\s=\s(?P<quote>['])(?P<author_email>.*)(?P=quote)$",
'description': r"^__description__\s=\s(?P<quote>['])(?P<description>.*)(?P=quote)$",
'project_url': r"^__project_url__\s=\s(?P<quote>['])(?P<project_url>.*)(?P=quote)$",
}

with open('./pydockenv/__init__.py') as f:
raw_about = f.read()

extract = partial(re.search, string=raw_about, flags=re.MULTILINE)
return {k: extract(v).group(k) for k, v in regexes.items()}


about = get_about()
with open('meta.json') as fin:
about = json.load(fin)


class bdist_wheel(_bdist_wheel):
Expand Down

0 comments on commit 7a005f6

Please sign in to comment.