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

Modify setup.py to not import the whole module for package data #142

Merged
merged 3 commits into from
Feb 17, 2021
Merged
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
### Changed

- Type hinting fixed for Recipe "_model" parameter
- Modify `setup.py` to not import the whole module for package data, but get it from `__about__.py`

### Removed

Expand Down
5 changes: 5 additions & 0 deletions model_bakery/__about__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
__version__ = "1.2.1"
__author__ = "berinfontes"
__email__ = "bernardoxhc@gmail.com"
__url__ = "https://github.com/model-bakers/model_bakery"
__license__ = "Apache 2.0"
7 changes: 0 additions & 7 deletions model_bakery/__init__.py
Original file line number Diff line number Diff line change
@@ -1,8 +1 @@
"""Model Bakery module configuration."""
__version__ = "1.2.1"
__title__ = "model_bakery"
__author__ = "Vanderson Mota"
__license__ = "Apache 2.0"


from .utils import seq # NoQA
7 changes: 1 addition & 6 deletions model_bakery/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,7 @@
from types import ModuleType
from typing import Any, Callable, Optional, Union

try:
from django.apps import apps
except ModuleNotFoundError:
# probably we are importing this module from setup.py, before installing
# the requirements (and we don't need Django at this point)
apps = None
from django.apps import apps

from .timezone import tz_aware

Expand Down
19 changes: 11 additions & 8 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,19 +1,22 @@
from os.path import dirname, join
from os.path import abspath, dirname, join

import setuptools

import model_bakery
about: dict = {}
here = abspath(dirname(__file__))
with open(join(here, "model_bakery", "__about__.py")) as f: # type: ignore
exec(f.read(), about)

setuptools.setup(
name="model_bakery",
version=model_bakery.__version__,
version=about["__version__"],
author=about["__author__"],
author_email=about["__email__"],
url=about["__url__"],
license=about["__license__"],
packages=["model_bakery"],
include_package_data=True, # declarations in MANIFEST.in
install_requires=open(join(dirname(__file__), "requirements.txt")).readlines(),
author="berinfontes",
author_email="bernardoxhc@gmail.com",
url="http://github.com/model-bakers/model_bakery",
license="Apache 2.0",
install_requires=open(join(here, "requirements.txt")).readlines(),
description="Smart object creation facility for Django.",
long_description=open(join(dirname(__file__), "README.md")).read(),
long_description_content_type="text/markdown",
Expand Down
2 changes: 1 addition & 1 deletion tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -51,4 +51,4 @@ commands=black . --check
[testenv:mypy]
deps=mypy
basepython=python3
commands=python -m mypy .
commands=python -m mypy model_bakery