Skip to content

Commit

Permalink
Merge pull request #475 from MongoEngine/setuptools
Browse files Browse the repository at this point in the history
Added: Complete pyproject.toml configuration; Removed: Static version mentions in source code files
  • Loading branch information
insspb committed Jul 8, 2022
2 parents 8647a85 + 2803755 commit 89eb76e
Show file tree
Hide file tree
Showing 12 changed files with 108 additions and 121 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,4 @@ venv/
.vscode
htmlcov/
coverage.xml
_version.py
3 changes: 3 additions & 0 deletions .readthedocs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,6 @@ python:
- requirements: docs/requirements.txt
- method: pip
path: .
extra_requirements:
- wtf
- toolbar
9 changes: 4 additions & 5 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,7 @@

import os
import sys

import flask_mongoengine
from importlib.metadata import version as v

# If extensions (or modules to document with autodoc) are in another directory,
# add these directories to sys.path here. If the directory is relative to the
Expand All @@ -30,7 +29,7 @@
"sphinx.ext.autodoc",
"sphinx.ext.intersphinx",
"myst_parser",
# "sphinxcontrib.apidoc",
"sphinx.ext.viewcode",
"sphinx_autodoc_typehints",
]

Expand Down Expand Up @@ -59,9 +58,9 @@
#

# The short X.Y version.
version = flask_mongoengine.__version__
version = v("flask_mongoengine")
# The full version, including alpha/beta/rc tags.
release = flask_mongoengine.__version__
release = v("flask_mongoengine")

# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.
Expand Down
2 changes: 0 additions & 2 deletions docs/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,3 @@ sphinx-autobuild>=2021.3.14
Sphinx>=4.5.0
sphinxcontrib-apidoc>=0.3.0
sphinx-autodoc-typehints>=1.18.2
pymongo>=3.10.1,<4.0.0
Flask-DebugToolbar>=0.13.1
3 changes: 1 addition & 2 deletions example_app/compose/flask/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,5 @@ ENV PYTHONUNBUFFERED 1
RUN groupadd -r flask && useradd -r -g flask flask
COPY --chown=flask . /flask_mongoengine
RUN pip install --upgrade pip \
&& pip install -r /flask_mongoengine/requirements.txt \
&& pip install -e /flask_mongoengine
&& pip install -e /flask_mongoengine[toolbar,wtf]
WORKDIR /flask_mongoengine
10 changes: 0 additions & 10 deletions flask_mongoengine/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,6 @@
from flask_mongoengine.sessions import *
from flask_mongoengine.wtf import db_fields

VERSION = (1, 0, 0)


def get_version():
"""Return the VERSION as a string."""
return ".".join(map(str, VERSION))


__version__ = get_version()


def current_mongoengine_instance():
"""Return a MongoEngine instance associated with current Flask app."""
Expand Down
7 changes: 3 additions & 4 deletions noxfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,21 +13,20 @@

def base_install(session, flask, mongoengine):
"""Create basic environment setup for tests and linting."""
session.install("-r", "requirements-dev.txt")
if flask == "==1.1.4":
session.install(
f"Flask{flask}",
f"mongoengine{mongoengine}",
"MarkupSafe==2.0.1",
"-e",
".",
".[wtf,toolbar,legacy]",
)
else:
session.install(
f"Flask{flask}",
f"mongoengine{mongoengine}",
"-e",
".",
".[wtf,toolbar,dev]",
)
return session

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

Expand Down
94 changes: 94 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,3 +1,93 @@
[project]
name = "flask-mongoengine"
description = "Flask extension that provides integration with MongoEngine and WTF model forms."
readme = "README.rst"
requires-python = ">=3.7"
license = {text = "BSD 3-Clause License"}
classifiers = [
"Development Status :: 4 - Beta",
"Environment :: Web Environment",
"Intended Audience :: Developers",
"License :: OSI Approved :: BSD License",
"Operating System :: OS Independent",
"Programming Language :: Python",
"Programming Language :: Python :: 3 :: Only",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.7",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: Implementation :: PyPy",
"Programming Language :: Python :: Implementation :: CPython",
"Topic :: Internet :: WWW/HTTP :: Dynamic Content",
"Topic :: Software Development :: Libraries :: Python Modules",
"Framework :: Flask",
]
dependencies = [
"Flask>=1.1.4",
"mongoengine>=0.21",
'importlib-metadata; python_version<"3.8"',
]
keywords = [
"flask",
"wtf",
"wtf-forms",
"forms",
"mongo",
"pymongo",
"mongoengine",
"extension"
]
authors = [
{name = "Ross Lawley", email = "ross.lawley@gmail.com"}
]
maintainers = [
{name = "Andrey Shpak", email = "ashpak@ashpak.ru"}
]
dynamic = ["version"]

[project.optional-dependencies]
wtf = ["WTForms[email]>=2.3.1", "Flask-WTF>=0.14.3"]
toolbar = ["Flask-DebugToolbar>=0.11.0"]
dev = [
"black==22.6.0",
"pre-commit",
"pytest",
"pytest-cov",
"pytest-mock",
"nox",
]
legacy = [
"pytest",
"pytest-cov",
"pytest-mock",
]

[project.urls]
Homepage = "https://github.com/MongoEngine/flask-mongoengine"
Documentation = "http://docs.mongoengine.org/projects/flask-mongoengine/en/latest/"
Repository = "https://github.com/MongoEngine/flask-mongoengine"
Changelog = "https://github.com/MongoEngine/flask-mongoengine/releases"

[build-system]
requires = [
"setuptools>=45",
"setuptools_scm[toml]>=6.3.1",
"wheel"
]
build-backend = "setuptools.build_meta"

[tool.setuptools]
zip-safe = false
platforms = ["any"]
packages=["flask_mongoengine", "flask_mongoengine.wtf"]

[tool.setuptools.dynamic]
version = {attr = "flask_mongoengine._version.version"}

[tool.setuptools_scm]
write_to = "flask_mongoengine/_version.py"

[tool.black]
line-length = 88
target-version = ['py37']
Expand All @@ -23,3 +113,7 @@ multi_line_output = 3
include_trailing_comma = true
force_grid_wrap = 0
use_parentheses = true

[tool.pytest.ini_options]
addopts = "--cov=flask_mongoengine --cov-config=setup.cfg"
testpaths = ["tests"]
9 changes: 0 additions & 9 deletions requirements-dev.txt

This file was deleted.

8 changes: 0 additions & 8 deletions requirements.txt

This file was deleted.

4 changes: 0 additions & 4 deletions setup.cfg
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
[tool:pytest]
addopts = --cov=flask_mongoengine --cov-config=setup.cfg
testpaths = tests

[flake8]
ignore=E501,F403,F405,I201,W503,E203
max-line-length=90
Expand Down
79 changes: 2 additions & 77 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,79 +1,4 @@
import os

"""Setup file for backward compatibility with setuptools, not supported PEP 660."""
from setuptools import setup

description = (
"Flask-MongoEngine is a Flask extension "
"that provides integration with MongoEngine and WTF model forms."
)

# Load index.rst as long_description
doc_path = os.path.join(os.path.dirname(__file__), "docs", "index.rst")
long_description = open(doc_path, encoding="utf-8").read()
long_description_content_type = "text/x-rst"

# Stops exit traceback on tests
try:
import multiprocessing # noqa
except ImportError:
pass


def get_version(version_tuple):
"""Return the version tuple as a string, e.g. for (0, 10, 7),
return '0.10.7'.
"""
return ".".join(map(str, version_tuple))


# Dirty hack to get version number from flask_monogengine/__init__.py - we
# can't import it as it depends on PyMongo and PyMongo isn't installed until
# this file is read
init = os.path.join(os.path.dirname(__file__), "flask_mongoengine", "__init__.py")
version_line = list(filter(lambda l: l.startswith("VERSION"), open(init)))[0]
version = get_version(eval(version_line.split("=")[-1]))

test_requirements = ["coverage", "pytest", "pytest-cov"]

setup(
name="flask-mongoengine",
version=version,
url="https://github.com/mongoengine/flask-mongoengine",
license="BSD",
author="Ross Lawley",
author_email="ross.lawley@gmail.com",
zip_safe=False,
platforms="any",
python_requires=">=3.7",
install_requires=[
"Flask>=1.1.4",
"WTForms[email]>=2.3.1",
"Flask-WTF>=0.14.3",
"mongoengine>=0.21",
"Flask-DebugToolbar>=0.11.0",
],
packages=["flask_mongoengine", "flask_mongoengine.wtf"],
include_package_data=True,
tests_require=test_requirements,
description=description,
long_description=long_description,
classifiers=[
"Development Status :: 4 - Beta",
"Environment :: Web Environment",
"Intended Audience :: Developers",
"License :: OSI Approved :: BSD License",
"Operating System :: OS Independent",
"Programming Language :: Python",
"Programming Language :: Python :: 3 :: Only",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.7",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: Implementation :: PyPy",
"Programming Language :: Python :: Implementation :: CPython",
"Topic :: Internet :: WWW/HTTP :: Dynamic Content",
"Topic :: Software Development :: Libraries :: Python Modules",
"Framework :: Flask",
],
)
setup()

0 comments on commit 89eb76e

Please sign in to comment.