Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ jobs:
python-version: ${{ matrix.python-version }}
allow-prereleases: true
cache: "pip"
cache-dependency-path: "**/setup.py"
cache-dependency-path: "**/pyproject.toml"
- name: Install dependencies
run: |
python -m pip install --upgrade pip setuptools wheel
Expand All @@ -76,7 +76,7 @@ jobs:
with:
python-version: "3.13"
cache: "pip"
cache-dependency-path: "**/setup.py"
cache-dependency-path: "**/pyproject.toml"
- run: pip install build -e .
- run: make import-cldr
- run: python -m build
Expand Down
11 changes: 0 additions & 11 deletions MANIFEST.in

This file was deleted.

13 changes: 7 additions & 6 deletions babel/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,12 +56,13 @@


def _raise_no_data_error():
raise RuntimeError('The babel data files are not available. '
'This usually happens because you are using '
'a source checkout from Babel and you did '
'not build the data files. Just make sure '
'to run "python setup.py import_cldr" before '
'installing the library.')
raise RuntimeError(
'The babel data files are not available. '
'This usually happens because you are using '
'a source checkout from Babel and you did '
'not build the data files. Please see the '
'README.rst file for more information.',
)


def get_global(key: _GLOBAL_KEY) -> Mapping[str, Any]:
Expand Down
1 change: 0 additions & 1 deletion conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

collect_ignore = [
'babel/messages/setuptools_frontend.py',
'setup.py',
'tests/messages/data',
]
babel_path = Path(__file__).parent / 'babel'
Expand Down
6 changes: 3 additions & 3 deletions docs/installation.rst
Original file line number Diff line number Diff line change
Expand Up @@ -83,17 +83,17 @@ Get the git checkout in a new virtualenv and run in development mode::
New python executable in venv/bin/python
Installing distribute............done.
$ . venv/bin/activate
$ python setup.py import_cldr
$ make import-cldr
$ pip install --editable .
...
Finished processing dependencies for Babel

Make sure to not forget about the ``import_cldr`` step because otherwise
Make sure to not forget about the CLDR import step because otherwise
you will be missing the locale data.
The custom setup command will download the most appropriate CLDR release from the
official website and convert it for Babel.

This will pull also in the dependencies and activate the git head as the
current version inside the virtualenv. Then all you have to do is run
``git pull origin`` to update to the latest version. If the CLDR data
changes you will have to re-run ``python setup.py import_cldr``.
changes you will have to re-run ``make import-cldr``.
33 changes: 33 additions & 0 deletions hatch_build.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import os
import tarfile
import zipfile

from hatchling.builders.hooks.plugin.interface import BuildHookInterface

DAT_MESSAGE = """
======
Package should contain multiple .dat files.
* Make sure you've imported the CLDR data; `make import-cldr`.
------
To skip this check, set the environment variable BABEL_NO_CHECK_BUILD=1
======
""".strip()


def check_babel_artifact(artifact_path: str):
if artifact_path.endswith(".whl"):
with zipfile.ZipFile(artifact_path) as whl:
filelist = whl.namelist()
elif artifact_path.endswith(".tar.gz"):
with tarfile.open(artifact_path) as tar:
filelist = tar.getnames()
if len([f.endswith(".dat") for f in filelist]) < 10:
raise ValueError(DAT_MESSAGE)


class CustomBuildHook(BuildHookInterface):
def finalize(self, version, build_data, artifact_path):
if version == "editable":
return
if not os.environ.get("BABEL_NO_CHECK_BUILD"):
check_babel_artifact(artifact_path)
113 changes: 113 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,3 +1,116 @@
[build-system]
requires = ["hatchling"]
build-backend = "hatchling.build"

[project]
name = "babel"
dynamic = ["version"]
description = "Internationalization utilities"
readme = "README.rst"
license = "BSD-3-Clause"
license-files = ["LICENSE"]
requires-python = ">=3.8"
authors = [
{ name = "Armin Ronacher", email = "[email protected]" },
]
maintainers = [
{ name = "Aarni Koskela", email = "[email protected]" },
]
classifiers = [
"Development Status :: 5 - Production/Stable",
"Environment :: Web Environment",
"Intended Audience :: Developers",
"License :: OSI Approved :: BSD License",
"Operating System :: OS Independent",
"Programming Language :: Python :: 3 :: Only",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"Programming Language :: Python :: 3.13",
"Programming Language :: Python :: Implementation :: CPython",
"Programming Language :: Python :: Implementation :: PyPy",
"Programming Language :: Python",
"Topic :: Software Development :: Internationalization",
"Topic :: Software Development :: Libraries :: Python Modules",
]

dependencies = [
# This version identifier is currently necessary as
# pytz otherwise does not install on pip 1.4 or higher.
# Python 3.9 and later include zoneinfo which replaces pytz.
'pytz>=2015.7; python_version<"3.9"',
]

[project.optional-dependencies]
# TODO: use a `dev` dependency group instead
dev = [
"backports.zoneinfo; python_version<\"3.9\"",
"freezegun~=1.0",
"jinja2>=3.0",
"pytest-cov",
"pytest>=6.0",
"pytz",
"setuptools",
"tzdata;sys_platform == 'win32'",
]

[project.urls]
Homepage = "https://babel.pocoo.org/"
Source = "https://github.com/python-babel/babel"

[tool.hatch.version]
path = "babel/__init__.py"

[tool.hatch.build.hooks.custom]

[tool.hatch.build.targets.sdist]
include = [
"/Makefile",
"/babel",
"/docs",
"/scripts",
"/tests",
"AUTHORS",
"CHANGES.rst",
"conftest.py",
"tox.ini",
]

[tool.hatch.build.targets.wheel]
include = [
"/babel",
]
artifacts = [
"**.dat",
]
exclude = [
"/babel/locale-data/.gitignore",
]

[project.scripts]
pybabel = "babel.messages.frontend:main"

[project.entry-points."distutils.commands"]
compile_catalog = "babel.messages.setuptools_frontend:compile_catalog"
extract_messages = "babel.messages.setuptools_frontend:extract_messages"
init_catalog = "babel.messages.setuptools_frontend:init_catalog"
update_catalog = "babel.messages.setuptools_frontend:update_catalog"

[project.entry-points."distutils.setup_keywords"]
message_extractors = "babel.messages.setuptools_frontend:check_message_extractors"

[project.entry-points."babel.checkers"]
num_plurals = "babel.messages.checkers:num_plurals"
python_format = "babel.messages.checkers:python_format"

[project.entry-points."babel.extractors"]
ignore = "babel.messages.extract:extract_nothing"
python = "babel.messages.extract:extract_python"
javascript = "babel.messages.extract:extract_javascript"

[tool.ruff]
target-version = "py38"
extend-exclude = [
Expand Down
2 changes: 0 additions & 2 deletions setup.cfg

This file was deleted.

112 changes: 0 additions & 112 deletions setup.py

This file was deleted.

Loading