diff --git a/betty/_package/__init__.py b/betty/_package/__init__.py index 53962efcf..bbdfde5a9 100644 --- a/betty/_package/__init__.py +++ b/betty/_package/__init__.py @@ -4,21 +4,9 @@ from pathlib import Path from typing import Iterator -from setuptools import find_packages as find_packages_setuptools - from betty import _ROOT_DIRECTORY_PATH as ROOT_DIRECTORY_PATH -def find_packages() -> list[str]: - return find_packages_setuptools( - '.', - exclude=[ - 'betty.tests', - 'betty.tests.*', - ], - ) - - def is_data_file(file_path: Path) -> bool: if not (ROOT_DIRECTORY_PATH / 'betty' / file_path).is_file(): return False diff --git a/betty/_package/pyinstaller/__init__.py b/betty/_package/pyinstaller/__init__.py index 09d08f83a..0d3eb9f3c 100644 --- a/betty/_package/pyinstaller/__init__.py +++ b/betty/_package/pyinstaller/__init__.py @@ -1,12 +1,11 @@ -import inspect import sys -from importlib import import_module +from glob import glob from pathlib import Path from PyInstaller.building.api import PYZ, EXE, COLLECT from PyInstaller.building.build_main import Analysis +from setuptools import find_packages -from betty._package import get_data_paths, find_packages from betty._package.pyinstaller.hooks import HOOKS_DIRECTORY_PATH from betty.app import App from betty.app.extension import discover_extension_types, Extension @@ -46,15 +45,25 @@ async def a_pyz_exe_coll() -> tuple[Analysis, PYZ, EXE, COLLECT]: raise RuntimeError(f'Unsupported platform {sys.platform}.') await _build_assets() - root = Path(__file__).parents[3] block_cipher = None datas = [] - for module_name, file_paths in get_data_paths().items(): - for file_path in file_paths: - data_file_path = (Path(inspect.getfile(import_module(module_name))).parent / file_path).relative_to(root) - datas.append((str(data_file_path), str(data_file_path.parent))) + data_file_path_patterns = [ + 'betty/assets/**', + 'betty/extension/*/assets/**', + ] + for data_file_path_pattern in data_file_path_patterns: + for data_file_path_str in glob(data_file_path_pattern, recursive=True, root_dir=ROOT_DIRECTORY_PATH): + data_file_path = Path(data_file_path_str) + if data_file_path.is_file(): + datas.append((data_file_path_str, str(data_file_path.parent))) hiddenimports = [ - *find_packages(), + *find_packages( + '.', + exclude=[ + 'betty.tests', + 'betty.tests.*', + ], + ), 'babel.numbers' ] a = Analysis( diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 000000000..5aa57ec80 --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,137 @@ +[build-system] +requires = [ + 'setuptools ~= 68.2, >= 68.2.2', +] +build-backend = 'setuptools.build_meta' + +[project] +dynamic = [ + 'version', +] +name = 'betty' +description = 'Betty helps you visualize and publish your family history by building interactive genealogy websites out of your Gramps and GECOM family trees' +readme = 'README.md' +license = {file = 'LICENSE.txt'} +authors = [ + {name = 'Bart Feenstra', email = 'bar@bartfeenstra.com'}, +] +requires-python = '~= 3.11' +dependencies = [ + 'aiofiles ~= 23.2, >= 23.2.1', + 'aiohttp ~= 3.9', + 'babel ~= 2.12, >= 2.12.0', + 'click ~= 8.1, >= 8.1.2', + 'dill ~= 0.3, >= 0.3.6', + 'docker ~= 7.0, >= 7.0.0', + 'geopy ~= 2.3, >= 2.3.0', + 'jinja2 ~= 3.1, >= 3.1.1', + 'jsonschema ~= 4.17, >= 4.17.0', + 'langcodes ~= 3.3, >= 3.3.0', + 'markupsafe ~= 2.1, >= 2.1.1', + 'ordered-set ~= 4.1.0', + 'pdf2image ~= 1.16, >= 1.16.0', + 'polib ~= 1.2, >= 1.2.0', + 'Pillow ~= 10.1, >= 10.1.0', + 'PyQt6 ~= 6.5, >= 6.5.0', + 'pyyaml ~= 6.0, >= 6.0.0', + 'reactives ~= 0.5, >= 0.5.1', +] +classifiers = [ + 'License :: OSI Approved :: GNU General Public License v3 (GPLv3)', + 'Programming Language :: JavaScript', + 'Programming Language :: Python :: 3.11', + 'Programming Language :: Python :: 3.12', + 'Programming Language :: JavaScript', + 'Operating System :: MacOS :: MacOS X', + 'Operating System :: POSIX :: Linux', + 'Operating System :: Microsoft :: Windows', + 'Topic :: Internet', + 'Topic :: Scientific/Engineering :: Visualization', + 'Topic :: Sociology :: Genealogy', + 'Topic :: Software Development :: Code Generators', + 'Natural Language :: Dutch', + 'Natural Language :: English', + 'Natural Language :: French', + 'Natural Language :: Ukrainian', + 'Typing :: Typed ', +] + +[project.urls] +Homepage = 'https://github.com/bartfeenstra/betty' +Github = 'https://github.com/bartfeenstra/betty' +Twitter = 'https://twitter.com/BettyProject' +X = 'https://twitter.com/BettyProject' + +[project.entry-points.'console_scripts'] +betty = 'betty.cli:main' + +[project.entry-points.'betty.extensions'] +'betty.extension.CottonCandy' = 'betty.extension.CottonCandy' +'betty.extension.Demo' = 'betty.extension.Demo' +'betty.extension.Deriver' = 'betty.extension.Deriver' +'betty.extension.Gramps' = 'betty.extension.Gramps' +'betty.extension.Maps' = 'betty.extension.Maps' +'betty.extension.Privatizer' = 'betty.extension.Privatizer' +'betty.extension.HttpApiDoc' = 'betty.extension.HttpApiDoc' +'betty.extension.Trees' = 'betty.extension.Trees' +'betty.extension.Wikipedia' = 'betty.extension.Wikipedia' + +[project.optional-dependencies] +pyinstaller = [ + 'pyinstaller ~= 6.1, >= 6.1.0', +] +setuptools = [ + 'setuptools ~= 68.2, >= 68.2.2', + 'twine ~= 4.0, >= 4.0.0', + 'wheel ~= 0.40, >= 0.40.0', +] +development = [ + 'aioresponses ~= 0.7, >= 0.7.6', + 'autopep8 ~= 2.0, >= 2.0.2', + 'basedmypy ~= 2.0, >= 2.2.1', + 'codecov ~= 2.1, >= 2.1.12', + 'coverage ~= 7.2, >= 7.2.4', + 'flake8 ~= 6.0, >= 6.0.0', + 'html5lib ~= 1.1', + 'lxml ~= 4.9, >= 4.9.1; sys.platform != "win32"', + 'pip-licenses ~= 4.3, >= 4.3.0', + 'pytest ~= 7.3, >= 7.3.1', + 'pytest-aioresponses ~= 0.2, >= 0.2.0 ', + 'pytest-asyncio ~= 0.21, >= 0.21.0 ', + 'pytest-cov ~= 4.0, >= 4.0.0', + 'pytest-mock ~= 3.10, >= 3.10.0', + 'pytest-qt ~= 4.2, >= 4.2.0', + 'pytest-repeat ~= 0.9, >= 0.9.1', + 'pytest-xvfb ~= 3.0, >= 3.0.0', + 'types-aiofiles ~= 23.2, >= 23.2.0.0', + 'types-click ~= 7.1, >= 7.1.8', + 'types-mock ~= 5.0, >= 5.0.0.6', + 'types-polib ~= 1.2, >= 1.2.0.0', + 'types-pyyaml ~= 6.0, >= 6.0.6', + 'types-requests ~= 2.29, >= 2.29.0.0', + 'types-setuptools ~= 68.2, >= 68.2.0.0', + 'betty[pyinstaller]', + 'betty[setuptools]', +] + +[tool.setuptools.dynamic] +version = {file = ['betty/assets/VERSION']} + +[tool.setuptools.packages.find] +where = ['.'] +exclude = [ + 'betty.tests', + 'betty.tests.*', +] + +[tool.setuptools.package-data] +betty = [ + 'py.typed', + 'assets/**', + 'extension/*/assets/**', +] + +[tool.setuptools.exclude-package-data] +betty = [ + '__pycache__', +] diff --git a/setup.py b/setup.py index c7559cd53..1569535b6 100644 --- a/setup.py +++ b/setup.py @@ -2,141 +2,5 @@ from setuptools import setup -from betty import _ROOT_DIRECTORY_PATH as ROOT_DIRECTORY_PATH -from betty._package import get_data_paths, find_packages - -with open(ROOT_DIRECTORY_PATH / 'betty' / 'assets' / 'VERSION', encoding='utf-8') as f: - VERSION = f.read() - -with open(ROOT_DIRECTORY_PATH / 'README.md', encoding='utf-8') as f: - long_description = f.read() - - -extras_require_pyinstaller = [ - 'pyinstaller ~= 6.1, >= 6.1.0', -] - - -extras_require_setuptools = [ - 'setuptools ~= 68.2, >= 68.2.2', - 'twine ~= 4.0, >= 4.0.0', - 'wheel ~= 0.40, >= 0.40.0', -] - - -extras_require_development = [ - 'aioresponses ~= 0.7, >= 0.7.6', - 'autopep8 ~= 2.0, >= 2.0.2', - 'basedmypy ~= 2.0, >= 2.2.1', - 'codecov ~= 2.1, >= 2.1.12', - 'coverage ~= 7.2, >= 7.2.4', - 'flake8 ~= 6.0, >= 6.0.0', - 'html5lib ~= 1.1', - 'lxml ~= 4.9, >= 4.9.1; sys.platform != "win32"', - 'pip-licenses ~= 4.3, >= 4.3.0', - 'pytest ~= 7.3, >= 7.3.1', - 'pytest-aioresponses ~= 0.2, >= 0.2.0 ', - 'pytest-asyncio ~= 0.21, >= 0.21.0 ', - 'pytest-cov ~= 4.0, >= 4.0.0', - 'pytest-mock ~= 3.10, >= 3.10.0', - 'pytest-qt ~= 4.2, >= 4.2.0', - 'pytest-repeat ~= 0.9, >= 0.9.1', - 'pytest-xvfb ~= 3.0, >= 3.0.0', - 'types-aiofiles ~= 23.2, >= 23.2.0.0', - 'types-click ~= 7.1, >= 7.1.8', - 'types-mock ~= 5.0, >= 5.0.0.6', - 'types-polib ~= 1.2, >= 1.2.0.0', - 'types-pyyaml ~= 6.0, >= 6.0.6', - 'types-requests ~= 2.29, >= 2.29.0.0', - 'types-setuptools ~= 68.2, >= 68.2.0.0', - *extras_require_pyinstaller, - *extras_require_setuptools, -] - - -SETUP = { - 'name': 'betty', - 'description': 'Betty helps you visualize and publish your family history by building interactive genealogy websites out of your Gramps and GECOM family trees', - 'long_description': long_description, - 'long_description_content_type': 'text/markdown', - 'version': VERSION, - 'license': 'GPLv3', - 'author': 'Bart Feenstra & contributors', - 'author_email': 'bart@mynameisbart.com', - 'url': 'https://github.com/bartfeenstra/betty', - 'project_urls': { - 'Github': 'https://github.com/bartfeenstra/betty', - 'Twitter': 'https://twitter.com/BettyProject', - 'X': 'https://twitter.com/BettyProject', - }, - 'classifiers': [ - 'License :: OSI Approved :: GNU General Public License v3 (GPLv3)', - 'Programming Language :: JavaScript', - 'Programming Language :: Python :: 3.11', - 'Programming Language :: Python :: 3.12', - 'Programming Language :: JavaScript', - 'Operating System :: MacOS :: MacOS X', - 'Operating System :: POSIX :: Linux', - 'Operating System :: Microsoft :: Windows', - 'Topic :: Internet', - 'Topic :: Scientific/Engineering :: Visualization', - 'Topic :: Sociology :: Genealogy', - 'Topic :: Software Development :: Code Generators', - 'Natural Language :: Dutch', - 'Natural Language :: English', - 'Natural Language :: French', - 'Natural Language :: Ukrainian', - 'Typing :: Typed ', - ], - 'python_requires': '~= 3.11', - 'install_requires': [ - 'aiofiles ~= 23.2, >= 23.2.1', - 'aiohttp ~= 3.9', - 'babel ~= 2.12, >= 2.12.0', - 'click ~= 8.1, >= 8.1.2', - 'dill ~= 0.3, >= 0.3.6', - 'docker ~= 7.0, >= 7.0.0', - 'geopy ~= 2.3, >= 2.3.0', - 'jinja2 ~= 3.1, >= 3.1.1', - 'jsonschema ~= 4.17, >= 4.17.0', - 'langcodes ~= 3.3, >= 3.3.0', - 'markupsafe ~= 2.1, >= 2.1.1', - 'ordered-set ~= 4.1.0', - 'pdf2image ~= 1.16, >= 1.16.0', - 'polib ~= 1.2, >= 1.2.0', - 'Pillow ~= 10.1, >= 10.1.0', - 'PyQt6 ~= 6.5, >= 6.5.0', - 'pyyaml ~= 6.0, >= 6.0.0', - 'reactives ~= 0.5, >= 0.5.1', - ], - 'extras_require': { - 'development': extras_require_development, - 'pyinstaller': extras_require_pyinstaller, - 'setuptools': extras_require_setuptools, - }, - 'entry_points': { - 'console_scripts': [ - 'betty=betty.cli:main', - ], - 'betty.extensions': [ - 'betty.extension.CottonCandy=betty.extension.CottonCandy', - 'betty.extension.Demo=betty.extension.Demo', - 'betty.extension.Deriver=betty.extension.Deriver', - 'betty.extension.Gramps=betty.extension.Gramps', - 'betty.extension.Maps=betty.extension.Maps', - 'betty.extension.Privatizer=betty.extension.Privatizer', - 'betty.extension.HttpApiDoc=betty.extension.HttpApiDoc', - 'betty.extension.Trees=betty.extension.Trees', - 'betty.extension.Wikipedia=betty.extension.Wikipedia', - ], - }, - 'packages': find_packages(), - 'package_data': { - 'betty': list(map(str, data_file_paths)) - for package, data_file_paths - in get_data_paths().items() - }, -} - if __name__ == '__main__': - setup(**SETUP) + setup()