Skip to content

Commit

Permalink
Replace most of setup.py with pyproject.toml (#1113)
Browse files Browse the repository at this point in the history
  • Loading branch information
bartfeenstra committed Dec 28, 2023
1 parent 586d948 commit 1111647
Show file tree
Hide file tree
Showing 4 changed files with 156 additions and 158 deletions.
12 changes: 0 additions & 12 deletions betty/_package/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
27 changes: 18 additions & 9 deletions betty/_package/pyinstaller/__init__.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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(
Expand Down
137 changes: 137 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -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 = '[email protected]'},
]
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__',
]
138 changes: 1 addition & 137 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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': '[email protected]',
'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()

0 comments on commit 1111647

Please sign in to comment.