Skip to content

Commit

Permalink
Merge pull request #1565 from wger-project/fix/pyproject
Browse files Browse the repository at this point in the history
Move to pyproject.toml
  • Loading branch information
rolandgeider authored Jan 27, 2024
2 parents aa3595e + 71de644 commit 2e60846
Show file tree
Hide file tree
Showing 364 changed files with 2,996 additions and 3,702 deletions.
10 changes: 6 additions & 4 deletions .github/workflows/formatter.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,14 @@ jobs:
uses: actions/checkout@v4

- name: Get dependencies
run: pip install yapf isort
run: pip install ruff isort

- name: Format the code with yapf
run: yapf --recursive --in-place wger
- name: Format the code
run: ruff format

- name: Sort the imports with isort
# While ruff can also do some sorting, isort can still be configured to do more,
# like grouping imports, etc.
- name: Sort the imports
run: isort .

- name: Push a commit with the changed files
Expand Down
2 changes: 1 addition & 1 deletion extras/docker/demo/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ RUN python3 -m venv /home/wger/venv
RUN . /home/wger/venv/bin/activate \
&& pip install --upgrade pip \
&& pip install --no-cache /wheels/* \
&& python setup.py develop \
&& pip install -e . \
&& wger create-settings --database-path /home/wger/db/database.sqlite \
&& wger bootstrap \
&& wger load-online-fixtures \
Expand Down
20 changes: 16 additions & 4 deletions extras/scripts/filter-fixtures.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,11 +62,23 @@ def filter_dump(model_list, filename):
filter_dump(('exercises.muscle',), 'muscles.json')
filter_dump(('exercises.exercisecategory',), 'categories.json')
filter_dump(('exercises.exerciseimage',), 'exercise-images.json')
filter_dump(('exercises.exercisebase', 'exercises.variation',), 'exercise-base-data.json')
filter_dump(
('exercises.exercise', 'exercises.exercisecomment', 'exercises.alias'),
'translations.json')
filter_dump(('exercises.equipment', 'exercises.equipment',), 'equipment.json')
(
'exercises.exercisebase',
'exercises.variation',
),
'exercise-base-data.json',
)
filter_dump(
('exercises.exercise', 'exercises.exercisecomment', 'exercises.alias'), 'translations.json'
)
filter_dump(
(
'exercises.equipment',
'exercises.equipment',
),
'equipment.json',
)

#
# Gym
Expand Down
3 changes: 1 addition & 2 deletions manage.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,7 @@
)


if __name__ == "__main__":

if __name__ == '__main__':
# If user passed the settings flag ignore the default wger settings
if not any('--settings' in s for s in sys.argv):
setup_django_environment(get_path('settings.py'))
Expand Down
154 changes: 154 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,154 @@
[build-system]
requires = ["setuptools>=61.2"]
build-backend = "setuptools.build_meta"

[project]
name = "wger"
version = "2.3.0a1"
dynamic = ["dependencies"]
authors = [
{ name = "Roland Geider", email = "roland@geider.net" },
]
description = "FLOSS workout, fitness and weight manager/tracker"
readme = "README.md"
requires-python = ">=3.9"
classifiers = [
# http://pypi.python.org/pypi?%3Aaction=list_classifiers
'Development Status :: 5 - Production/Stable',
'Environment :: Web Environment',
'Intended Audience :: Other Audience',
'Framework :: Django',
'License :: OSI Approved :: GNU Affero General Public License v3 or later (AGPLv3+)',
'Operating System :: OS Independent',
'Programming Language :: Python :: 3',
'Programming Language :: Python :: 3.9',
'Programming Language :: Python :: 3.10',
'Programming Language :: Python :: 3.11',
'Programming Language :: Python :: 3.12',
]

[project.urls]
Homepage = "https://wger.de/"
Documentation = "https://wger.readthedocs.io/en/latest/"
Repository = "https://github.com/wger-project/wger"
Issues = "https://github.com/wger-project/wger/issues"
Changelog = "https://wger.readthedocs.io/en/latest/changelog.html"

[project.scripts]
wger = "wger.__main__:main"

[tool.setuptools]
include-package-data = false
packages = ["wger"]

[tool.setuptools.dynamic]
dependencies = { file = ["requirements.txt"] }

[tool.distutils.bdist_wheel]
universal = 1


[tool.ruff]
# Exclude a variety of commonly ignored directories.
exclude = [
".bzr",
".direnv",
".eggs",
".git",
".git-rewrite",
".hg",
".ipynb_checkpoints",
".mypy_cache",
".nox",
".pants.d",
".pyenv",
".pytest_cache",
".pytype",
".ruff_cache",
".svn",
".tox",
".venv",
".vscode",
"__pypackages__",
"_build",
"buck-out",
"build",
"dist",
"node_modules",
"site-packages",
"venv",
]
line-length = 100
indent-width = 4
src = ["wger", "extras"]

[tool.ruff.lint]
select = [
"F", # Pyflakes
"E", # Pycodestyle
"W",
]

[tool.ruff.format]
quote-style = "single"
indent-style = "space"
skip-magic-trailing-comma = false # Like Black, respect magic trailing commas.
line-ending = "auto"

[tool.isort]
src_paths = ["wger", "extras"]

sections = ["FUTURE", "STDLIB", "DJANGO", "THIRDPARTY", "FIRSTPARTY", "LOCALFOLDER"]
skip = ["extras", "build", "dist", "node_modules", "migrations", "docs", "settings.py", "apps.py"]
# If set to true - ensures that if a star import is present, nothing else is
# imported from that namespace.
combine_star = false
# If set to true - imports will be sorted by their length instead of
# alphabetically.
length_sort = false
# An integer that represents the longest line-length you want a single import to
# take. Defaults to 80.
line_length = 119
# A comment to consistently place directly above future imports.
import_heading_future = "Future"
# A comment to consistently place directly above django imports.
import_heading_django = "Django"
# A comment to consistently place directly above imports from the standard library.
import_heading_stdlib = "Standard Library"
# A comment to consistently place directly above third-party imports.
import_heading_thirdparty = "Third Party"
# A comment to consistently place directly above wger imports.
import_heading_firstparty = "wger"
# A comment to consistently place directly above imports that start with '.'.
import_heading_localfolder = "Local"
# An integer that represents the number of spaces you would like to indent by or
# Tab to indent by a single tab.
indent = "' '"
# A list of imports that will be forced to display within the first party
# category.
known_first_party = ["wger"]
known_django = ["django"]
# An integer that represents how you want imports to be displayed if they're long
# enough to span multiple lines. A full definition of all possible modes can be
# found in isort's README.
multi_line_output = 3
force_grid_wrap = 2
# If set to true - isort will create separate sections within "from" imports
# for CONSTANTS, Classes, and modules/functions.
order_by_type = true
# Forces a certain number of lines after the imports and before the first line
# of functional code. By default, this is 2 lines if the first line of code is a
# class or function. Otherwise, it's 1.
lines_after_imports = 2

# If set to true - isort will combine as imports on the same line within for
# import statements. By default, isort forces all as imports to display on their
# own lines.
combine_as_imports = true

# If set to true - isort will add imports even if the file specified is
# currently completely empty.
force_adds = false
# Include a trailing comma after the imports. This ensures that yapf doesn't
# reformat the code
include_trailing_comma = true
1 change: 1 addition & 0 deletions requirements_dev.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,5 @@ faker==22.5.1
coverage==7.4.1
django-debug-toolbar==4.2.0
tblib==3.0.0
ruff==0.1.13
isort==5.13.2
83 changes: 0 additions & 83 deletions setup.cfg

This file was deleted.

58 changes: 0 additions & 58 deletions setup.py

This file was deleted.

4 changes: 2 additions & 2 deletions wger/celery_configuration.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@
from celery import Celery


os.environ.setdefault("DJANGO_SETTINGS_MODULE", "settings")
app = Celery("wger")
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'settings')
app = Celery('wger')

# read config from Django settings, the CELERY namespace would make celery
# config keys has `CELERY` prefix
Expand Down
2 changes: 1 addition & 1 deletion wger/config/apps.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

class ConfigConfig(AppConfig):
name = 'wger.config'
verbose_name = "Config"
verbose_name = 'Config'

def ready(self):
import wger.config.signals
Loading

0 comments on commit 2e60846

Please sign in to comment.