Skip to content

Commit 89eb76e

Browse files
authored
Merge pull request #475 from MongoEngine/setuptools
Added: Complete pyproject.toml configuration; Removed: Static version mentions in source code files
2 parents 8647a85 + 2803755 commit 89eb76e

File tree

12 files changed

+108
-121
lines changed

12 files changed

+108
-121
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,3 +20,4 @@ venv/
2020
.vscode
2121
htmlcov/
2222
coverage.xml
23+
_version.py

.readthedocs.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,3 +17,6 @@ python:
1717
- requirements: docs/requirements.txt
1818
- method: pip
1919
path: .
20+
extra_requirements:
21+
- wtf
22+
- toolbar

docs/conf.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,7 @@
1111

1212
import os
1313
import sys
14-
15-
import flask_mongoengine
14+
from importlib.metadata import version as v
1615

1716
# If extensions (or modules to document with autodoc) are in another directory,
1817
# add these directories to sys.path here. If the directory is relative to the
@@ -30,7 +29,7 @@
3029
"sphinx.ext.autodoc",
3130
"sphinx.ext.intersphinx",
3231
"myst_parser",
33-
# "sphinxcontrib.apidoc",
32+
"sphinx.ext.viewcode",
3433
"sphinx_autodoc_typehints",
3534
]
3635

@@ -59,9 +58,9 @@
5958
#
6059

6160
# The short X.Y version.
62-
version = flask_mongoengine.__version__
61+
version = v("flask_mongoengine")
6362
# The full version, including alpha/beta/rc tags.
64-
release = flask_mongoengine.__version__
63+
release = v("flask_mongoengine")
6564

6665
# The language for content autogenerated by Sphinx. Refer to documentation
6766
# for a list of supported languages.

docs/requirements.txt

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,3 @@ sphinx-autobuild>=2021.3.14
44
Sphinx>=4.5.0
55
sphinxcontrib-apidoc>=0.3.0
66
sphinx-autodoc-typehints>=1.18.2
7-
pymongo>=3.10.1,<4.0.0
8-
Flask-DebugToolbar>=0.13.1

example_app/compose/flask/Dockerfile

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,5 @@ ENV PYTHONUNBUFFERED 1
44
RUN groupadd -r flask && useradd -r -g flask flask
55
COPY --chown=flask . /flask_mongoengine
66
RUN pip install --upgrade pip \
7-
&& pip install -r /flask_mongoengine/requirements.txt \
8-
&& pip install -e /flask_mongoengine
7+
&& pip install -e /flask_mongoengine[toolbar,wtf]
98
WORKDIR /flask_mongoengine

flask_mongoengine/__init__.py

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -9,16 +9,6 @@
99
from flask_mongoengine.sessions import *
1010
from flask_mongoengine.wtf import db_fields
1111

12-
VERSION = (1, 0, 0)
13-
14-
15-
def get_version():
16-
"""Return the VERSION as a string."""
17-
return ".".join(map(str, VERSION))
18-
19-
20-
__version__ = get_version()
21-
2212

2313
def current_mongoengine_instance():
2414
"""Return a MongoEngine instance associated with current Flask app."""

noxfile.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,21 +13,20 @@
1313

1414
def base_install(session, flask, mongoengine):
1515
"""Create basic environment setup for tests and linting."""
16-
session.install("-r", "requirements-dev.txt")
1716
if flask == "==1.1.4":
1817
session.install(
1918
f"Flask{flask}",
2019
f"mongoengine{mongoengine}",
2120
"MarkupSafe==2.0.1",
2221
"-e",
23-
".",
22+
".[wtf,toolbar,legacy]",
2423
)
2524
else:
2625
session.install(
2726
f"Flask{flask}",
2827
f"mongoengine{mongoengine}",
2928
"-e",
30-
".",
29+
".[wtf,toolbar,dev]",
3130
)
3231
return session
3332

@@ -98,7 +97,7 @@ def docs(session, batch_run: bool = False):
9897
"""Build the documentation or serve documentation interactively."""
9998
shutil.rmtree(Path("docs").joinpath("_build"), ignore_errors=True)
10099
session.install("-r", "docs/requirements.txt")
101-
session.install("-e", ".")
100+
session.install("-e", ".[wtf,toolbar]")
102101
session.cd("docs")
103102
sphinx_args = ["-b", "html", "-W", ".", "_build/html"]
104103

pyproject.toml

Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,93 @@
1+
[project]
2+
name = "flask-mongoengine"
3+
description = "Flask extension that provides integration with MongoEngine and WTF model forms."
4+
readme = "README.rst"
5+
requires-python = ">=3.7"
6+
license = {text = "BSD 3-Clause License"}
7+
classifiers = [
8+
"Development Status :: 4 - Beta",
9+
"Environment :: Web Environment",
10+
"Intended Audience :: Developers",
11+
"License :: OSI Approved :: BSD License",
12+
"Operating System :: OS Independent",
13+
"Programming Language :: Python",
14+
"Programming Language :: Python :: 3 :: Only",
15+
"Programming Language :: Python :: 3",
16+
"Programming Language :: Python :: 3.7",
17+
"Programming Language :: Python :: 3.8",
18+
"Programming Language :: Python :: 3.9",
19+
"Programming Language :: Python :: 3.10",
20+
"Programming Language :: Python :: Implementation :: PyPy",
21+
"Programming Language :: Python :: Implementation :: CPython",
22+
"Topic :: Internet :: WWW/HTTP :: Dynamic Content",
23+
"Topic :: Software Development :: Libraries :: Python Modules",
24+
"Framework :: Flask",
25+
]
26+
dependencies = [
27+
"Flask>=1.1.4",
28+
"mongoengine>=0.21",
29+
'importlib-metadata; python_version<"3.8"',
30+
]
31+
keywords = [
32+
"flask",
33+
"wtf",
34+
"wtf-forms",
35+
"forms",
36+
"mongo",
37+
"pymongo",
38+
"mongoengine",
39+
"extension"
40+
]
41+
authors = [
42+
{name = "Ross Lawley", email = "ross.lawley@gmail.com"}
43+
]
44+
maintainers = [
45+
{name = "Andrey Shpak", email = "ashpak@ashpak.ru"}
46+
]
47+
dynamic = ["version"]
48+
49+
[project.optional-dependencies]
50+
wtf = ["WTForms[email]>=2.3.1", "Flask-WTF>=0.14.3"]
51+
toolbar = ["Flask-DebugToolbar>=0.11.0"]
52+
dev = [
53+
"black==22.6.0",
54+
"pre-commit",
55+
"pytest",
56+
"pytest-cov",
57+
"pytest-mock",
58+
"nox",
59+
]
60+
legacy = [
61+
"pytest",
62+
"pytest-cov",
63+
"pytest-mock",
64+
]
65+
66+
[project.urls]
67+
Homepage = "https://github.com/MongoEngine/flask-mongoengine"
68+
Documentation = "http://docs.mongoengine.org/projects/flask-mongoengine/en/latest/"
69+
Repository = "https://github.com/MongoEngine/flask-mongoengine"
70+
Changelog = "https://github.com/MongoEngine/flask-mongoengine/releases"
71+
72+
[build-system]
73+
requires = [
74+
"setuptools>=45",
75+
"setuptools_scm[toml]>=6.3.1",
76+
"wheel"
77+
]
78+
build-backend = "setuptools.build_meta"
79+
80+
[tool.setuptools]
81+
zip-safe = false
82+
platforms = ["any"]
83+
packages=["flask_mongoengine", "flask_mongoengine.wtf"]
84+
85+
[tool.setuptools.dynamic]
86+
version = {attr = "flask_mongoengine._version.version"}
87+
88+
[tool.setuptools_scm]
89+
write_to = "flask_mongoengine/_version.py"
90+
191
[tool.black]
292
line-length = 88
393
target-version = ['py37']
@@ -23,3 +113,7 @@ multi_line_output = 3
23113
include_trailing_comma = true
24114
force_grid_wrap = 0
25115
use_parentheses = true
116+
117+
[tool.pytest.ini_options]
118+
addopts = "--cov=flask_mongoengine --cov-config=setup.cfg"
119+
testpaths = ["tests"]

requirements-dev.txt

Lines changed: 0 additions & 9 deletions
This file was deleted.

requirements.txt

Lines changed: 0 additions & 8 deletions
This file was deleted.

0 commit comments

Comments
 (0)