icupy


Nameicupy JSON
Version 0.20.0 PyPI version JSON
download
home_pageNone
SummaryPython bindings for ICU4C
upload_time2024-10-27 06:10:26
maintainerNone
docs_urlNone
authorNone
requires_python>=3.9
licenseMIT License Copyright (c) 2021 Tetsuya Miura Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
keywords icu4c unicode binding
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # icupy

[![PyPI](https://img.shields.io/pypi/v/icupy)](https://pypi.org/project/icupy/)
[![PyPI - Python Version](https://img.shields.io/pypi/pyversions/icupy)](https://pypi.org/project/icupy/)
[![icu](https://img.shields.io/badge/icu-70%20%7C%2071%20%7C%2072%20%7C%2073%20%7C%2074%20%7C%2075%20%7C%2076-red)](https://icu.unicode.org/)
[![PyPI - License](https://img.shields.io/pypi/l/icupy)](https://pypi.org/project/icupy/)
[![pre-commit.ci status](https://results.pre-commit.ci/badge/github/miute/icupy/main.svg)](https://results.pre-commit.ci/latest/github/miute/icupy/main)
[![tests](https://github.com/miute/icupy/actions/workflows/tests.yml/badge.svg)](https://github.com/miute/icupy/actions/workflows/tests.yml)
[![build wheels](https://github.com/miute/icupy/actions/workflows/build.yml/badge.svg)](https://github.com/miute/icupy/actions/workflows/build.yml)
[![codecov](https://codecov.io/gh/miute/icupy/branch/main/graph/badge.svg?token=QCW3K19ARA)](https://codecov.io/gh/miute/icupy)

Python bindings for [ICU4C](https://unicode-org.github.io/icu-docs/apidoc/released/icu4c/index.html) using [pybind11](https://github.com/pybind/pybind11).

## Changes from ICU4C

- **Naming Conventions**

  Renamed functions, methods, and C++ enumerators to conform to [PEP 8](https://peps.python.org/pep-0008/#naming-conventions).

  - Function Names:
    Use `lower_case_with_underscores` style.
  - Method Names:
    Use `lower_case_with_underscores` style.
    Also, use one leading underscore only for protected methods.
  - C++ Enumerators: Use `UPPER_CASE_WITH_UNDERSCORES` style without a leading "k". (e.g., `kDateOffset` → `DATE_OFFSET`)
  - APIs that match Python reserved words: e.g.,
    - `with()` → `with_()`

- **Error Handling**
  - Unlike the C/C++ APIs, `icupy` raises the `icupy.icu.ICUError` exception if an error code indicates a failure instead of receiving an error code `UErrorCode`.

    You can access the [icu::ErrorCode](https://unicode-org.github.io/icu-docs/apidoc/released/icu4c/classicu_1_1ErrorCode.html) object from `ICUError.args[0]`.
    For example:

    ```python
    from icupy import icu
    try:
        ...
    except icu.ICUError as e:
        print(e.args[0])  # → icupy.icu.ErrorCode
        print(e.args[0].get())  # → icupy.icu.UErrorCode
    ```

## Examples

- [icu::UnicodeString](https://unicode-org.github.io/icu-docs/apidoc/released/icu4c/classicu_1_1UnicodeString.html) with
  [error callback](https://unicode-org.github.io/icu-docs/apidoc/released/icu4c/ucnv__err_8h.html)

  ```python
  from icupy import icu
  cnv = icu.ucnv_open('utf-8')
  action = icu.UCNV_TO_U_CALLBACK_ESCAPE
  context = icu.ConstVoidPtr(icu.UCNV_ESCAPE_C)
  icu.ucnv_set_to_ucall_back(cnv, action, context)
  utf8 = b'\x61\xfe\x62'  # Impossible bytes
  s = icu.UnicodeString(utf8, -1, cnv)
  str(s)  # → 'a\\xFEb'

  action = icu.UCNV_TO_U_CALLBACK_ESCAPE
  context = icu.ConstVoidPtr(icu.UCNV_ESCAPE_XML_DEC)
  icu.ucnv_set_to_ucall_back(cnv, action, context)
  s = icu.UnicodeString(utf8, -1, cnv)
  str(s)  # → 'aþb'
  ```

- [icu::UnicodeString](https://unicode-org.github.io/icu-docs/apidoc/released/icu4c/classicu_1_1UnicodeString.html) with
  [user callback](https://unicode-org.github.io/icu-docs/apidoc/released/icu4c/ucnv__cb_8h.html)

  ```python
  from icupy import icu
  def _to_callback(
      _context: object,
      _args: icu.UConverterToUnicodeArgs,
      _code_units: bytes,
      _length: int,
      _reason: icu.UConverterCallbackReason,
      _error_code: icu.UErrorCode,
  ) -> icu.UErrorCode:
      if _reason == icu.UCNV_ILLEGAL:
          _source = ''.join(['%{:02X}'.format(x) for x in _code_units])
          icu.ucnv_cb_to_uwrite_uchars(_args, _source, len(_source), 0)
          _error_code = icu.U_ZERO_ERROR
      return _error_code

  cnv = icu.ucnv_open('utf-8')
  action = icu.UConverterToUCallbackPtr(_to_callback)
  context = icu.ConstVoidPtr(None)
  icu.ucnv_set_to_ucall_back(cnv, action, context)
  utf8 = b'\x61\xfe\x62'  # Impossible bytes
  s = icu.UnicodeString(utf8, -1, cnv)
  str(s)  # → 'a%FEb'
  ```

- [icu::DateFormat](https://unicode-org.github.io/icu-docs/apidoc/released/icu4c/classicu_1_1DateFormat.html)

  ```python
  from icupy import icu
  tz = icu.TimeZone.create_time_zone('America/Los_Angeles')
  fmt = icu.DateFormat.create_instance_for_skeleton('yMMMMd', icu.Locale.get_english())
  fmt.set_time_zone(tz)
  dest = icu.UnicodeString()
  s = fmt.format(0, dest)
  str(s)  # → 'December 31, 1969'
  ```

- [icu::MessageFormat](https://unicode-org.github.io/icu-docs/apidoc/released/icu4c/classicu_1_1MessageFormat.html)

  ```python
  from icupy import icu
  fmt = icu.MessageFormat(
      "At {1,time,::jmm} on {1,date,::dMMMM}, "
      "there was {2} on planet {0,number}.",
      icu.Locale.get_us(),
  )
  tz = icu.TimeZone.get_gmt()
  subfmts = fmt.get_formats()
  subfmts[0].set_time_zone(tz)
  subfmts[1].set_time_zone(tz)
  date = 1637685775000.0  # 2021-11-23T16:42:55Z
  obj = icu.Formattable(
      [
          icu.Formattable(7),
          icu.Formattable(date, icu.Formattable.IS_DATE),
          icu.Formattable(icu.UnicodeString('a disturbance in the Force')),
      ]
  )
  dest = icu.UnicodeString()
  s = fmt.format(obj, dest)
  str(s)  # → 'At 4:42 PM on November 23, there was a disturbance in the Force on planet 7.'
  ```

- [icu::number::NumberFormatter](https://unicode-org.github.io/icu-docs/apidoc/released/icu4c/classicu_1_1number_1_1NumberFormatter.html)

  ```python
  from icupy import icu
  fmt = icu.number.NumberFormatter.with_().unit(icu.MeasureUnit.get_meter()).per_unit(icu.MeasureUnit.get_second())
  print(fmt.locale(icu.Locale.get_us()).format_double(3000).to_string())  # → '3,000 m/s'
  print(fmt.locale(icu.Locale.get_france()).format_double(3000).to_string())  # → '3 000 m/s'
  print(fmt.locale('ar').format_double(3000).to_string())  # → '٣٬٠٠٠ م/ث'
  ```

- [icu::BreakIterator](https://unicode-org.github.io/icu-docs/apidoc/released/icu4c/classicu_1_1BreakIterator.html)

  ```python
  from icupy import icu
  text = icu.UnicodeString('In the meantime Mr. Weston arrived with his small ship.')
  bi = icu.BreakIterator.create_sentence_instance(icu.Locale('en'))
  bi.set_text(text)
  list(bi)  # → [20, 55]
  # filter based on common English language abbreviations
  bi = icu.BreakIterator.create_sentence_instance(icu.Locale('en@ss=standard'))
  bi.set_text(text)
  list(bi)  # → [55]
  ```

- [icu::IDNA](https://unicode-org.github.io/icu-docs/apidoc/released/icu4c/classicu_1_1IDNA.html) (UTS #46)

  ```python
  from icupy import icu
  uts46 = icu.IDNA.create_uts46_instance(icu.UIDNA_NONTRANSITIONAL_TO_ASCII)
  dest = icu.UnicodeString()
  info = icu.IDNAInfo()
  uts46.name_to_ascii(icu.UnicodeString('faß.ExAmPlE'), dest, info)
  info.get_errors()  # → 0
  str(dest)  # → 'xn--fa-hia.example'
  ```

- For more examples, see [tests](https://github.com/miute/icupy/tree/main/tests).

## Installation

### Prerequisites

- [Python](https://www.python.org/) >=3.9
- [ICU4C](https://github.com/unicode-org/icu/releases) [(ICU - The International Components for Unicode)](https://icu.unicode.org/) (>=70 recommended)
- C++17 compatible compiler (see [supported compilers](https://github.com/pybind/pybind11#supported-compilers))
- [CMake](https://cmake.org/) >=3.7

### Installing prerequisites

- Windows

  Install the following dependencies.

  - [Python](https://www.python.org/downloads/) >=3.9
  - [Pre-built ICU4C binary package](https://github.com/unicode-org/icu/releases) (>=70 recommended)
  - Visual Studio 2015 Update 3 or newer. Visual Studio 2019 or newer recommended
  - [CMake](https://cmake.org/download/) >=3.7
    - *Note: Add CMake to the system PATH.*

- Linux

  To install dependencies, run the following command:

  - Ubuntu/Debian:

    ```bash
    sudo apt install g++ cmake libicu-dev python3-dev python3-pip
    ```

  - Fedora:

    ```bash
    sudo dnf install gcc-c++ cmake icu libicu-devel python3-devel
    ```

  If your system's ICU is out of date, consider
  [building ICU4C from source](https://unicode-org.github.io/icu/userguide/icu4c/build.html) or installing [pre-built
  ICU4C binary package](https://github.com/unicode-org/icu/releases).

### Building icupy from source

1. Configuring environment variables:

   - Windows:

     - Set the `ICU_ROOT` environment variable to the root of the ICU installation (default is `C:\icu`).
       For example, if the ICU is located in `C:\icu4c`:

       ```bat
       set ICU_ROOT=C:\icu4c
       ```

       or in PowerShell:

       ```powershell
       $env:ICU_ROOT = "C:\icu4c"
       ```

     - To verify settings using `icuinfo` (64-bit):

       ```bat
       %ICU_ROOT%\bin64\icuinfo
       ```

       or in PowerShell:

       ```powershell
       & $env:ICU_ROOT\bin64\icuinfo
       ```

   - Linux:

     - If the ICU is located in a non-regular place, set the `PKG_CONFIG_PATH` and `LD_LIBRARY_PATH` environment variables.
       For example, if the ICU is located in `/usr/local`:

       ```bash
       export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig:$PKG_CONFIG_PATH
       export LD_LIBRARY_PATH=/usr/local/lib:$LD_LIBRARY_PATH
       ```

     - To verify settings using `pkg-config`:

       ```bash
       $ pkg-config --cflags --libs icu-uc
       -I/usr/local/include -L/usr/local/lib -licuuc -licudata
       ```

2. Installing from PyPI:

   ```bash
   pip install icupy
   ```

   Optionally, CMake environment variables are available.
   For example, using the Ninja build system and Clang:

   ```bash
   CMAKE_GENERATOR=Ninja CXX=clang++ pip install icupy
   ```

   Alternatively, installing development version from the git repository:

   ```bash
   pip install git+https://github.com/miute/icupy.git
   ```

## Usage

1. Configuring environment variables:

   - Windows:

     - Set the `ICU_ROOT` environment variable to the root of the ICU installation (default is `C:\icu`).
       For example, if the ICU is located in `C:\icu4c`:

       ```bat
       set ICU_ROOT=C:\icu4c
       ```

       or in PowerShell:

       ```powershell
       $env:ICU_ROOT = "C:\icu4c"
       ```

   - Linux:

     - If the ICU is located in a non-regular place, set the `LD_LIBRARY_PATH` environment variables.
       For example, if the ICU is located in `/usr/local`:

       ```bash
       export LD_LIBRARY_PATH=/usr/local/lib:$LD_LIBRARY_PATH
       ```

2. Using `icupy`:

   ```python
   import icupy.icu as icu
   # or
   from icupy import icu
   ```

## License

This project is licensed under the [MIT License](https://github.com/miute/icupy/blob/main/LICENSE).

            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "icupy",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.9",
    "maintainer_email": null,
    "keywords": "icu4c, unicode, binding",
    "author": null,
    "author_email": "Tetsuya Miura <miute.dev@gmail.com>",
    "download_url": "https://files.pythonhosted.org/packages/9f/60/d0fe0379fe359ee41ca07555c5de1eaa1e0731b570e0f5f13528531bbc05/icupy-0.20.0.tar.gz",
    "platform": null,
    "description": "# icupy\n\n[![PyPI](https://img.shields.io/pypi/v/icupy)](https://pypi.org/project/icupy/)\n[![PyPI - Python Version](https://img.shields.io/pypi/pyversions/icupy)](https://pypi.org/project/icupy/)\n[![icu](https://img.shields.io/badge/icu-70%20%7C%2071%20%7C%2072%20%7C%2073%20%7C%2074%20%7C%2075%20%7C%2076-red)](https://icu.unicode.org/)\n[![PyPI - License](https://img.shields.io/pypi/l/icupy)](https://pypi.org/project/icupy/)\n[![pre-commit.ci status](https://results.pre-commit.ci/badge/github/miute/icupy/main.svg)](https://results.pre-commit.ci/latest/github/miute/icupy/main)\n[![tests](https://github.com/miute/icupy/actions/workflows/tests.yml/badge.svg)](https://github.com/miute/icupy/actions/workflows/tests.yml)\n[![build wheels](https://github.com/miute/icupy/actions/workflows/build.yml/badge.svg)](https://github.com/miute/icupy/actions/workflows/build.yml)\n[![codecov](https://codecov.io/gh/miute/icupy/branch/main/graph/badge.svg?token=QCW3K19ARA)](https://codecov.io/gh/miute/icupy)\n\nPython bindings for [ICU4C](https://unicode-org.github.io/icu-docs/apidoc/released/icu4c/index.html) using [pybind11](https://github.com/pybind/pybind11).\n\n## Changes from ICU4C\n\n- **Naming Conventions**\n\n  Renamed functions, methods, and C++ enumerators to conform to [PEP 8](https://peps.python.org/pep-0008/#naming-conventions).\n\n  - Function Names:\n    Use `lower_case_with_underscores` style.\n  - Method Names:\n    Use `lower_case_with_underscores` style.\n    Also, use one leading underscore only for protected methods.\n  - C++ Enumerators: Use `UPPER_CASE_WITH_UNDERSCORES` style without a leading \"k\". (e.g., `kDateOffset` \u2192 `DATE_OFFSET`)\n  - APIs that match Python reserved words: e.g.,\n    - `with()` \u2192 `with_()`\n\n- **Error Handling**\n  - Unlike the C/C++ APIs, `icupy` raises the `icupy.icu.ICUError` exception if an error code indicates a failure instead of receiving an error code `UErrorCode`.\n\n    You can access the [icu::ErrorCode](https://unicode-org.github.io/icu-docs/apidoc/released/icu4c/classicu_1_1ErrorCode.html) object from `ICUError.args[0]`.\n    For example:\n\n    ```python\n    from icupy import icu\n    try:\n        ...\n    except icu.ICUError as e:\n        print(e.args[0])  # \u2192 icupy.icu.ErrorCode\n        print(e.args[0].get())  # \u2192 icupy.icu.UErrorCode\n    ```\n\n## Examples\n\n- [icu::UnicodeString](https://unicode-org.github.io/icu-docs/apidoc/released/icu4c/classicu_1_1UnicodeString.html) with\n  [error callback](https://unicode-org.github.io/icu-docs/apidoc/released/icu4c/ucnv__err_8h.html)\n\n  ```python\n  from icupy import icu\n  cnv = icu.ucnv_open('utf-8')\n  action = icu.UCNV_TO_U_CALLBACK_ESCAPE\n  context = icu.ConstVoidPtr(icu.UCNV_ESCAPE_C)\n  icu.ucnv_set_to_ucall_back(cnv, action, context)\n  utf8 = b'\\x61\\xfe\\x62'  # Impossible bytes\n  s = icu.UnicodeString(utf8, -1, cnv)\n  str(s)  # \u2192 'a\\\\xFEb'\n\n  action = icu.UCNV_TO_U_CALLBACK_ESCAPE\n  context = icu.ConstVoidPtr(icu.UCNV_ESCAPE_XML_DEC)\n  icu.ucnv_set_to_ucall_back(cnv, action, context)\n  s = icu.UnicodeString(utf8, -1, cnv)\n  str(s)  # \u2192 'a&#254;b'\n  ```\n\n- [icu::UnicodeString](https://unicode-org.github.io/icu-docs/apidoc/released/icu4c/classicu_1_1UnicodeString.html) with\n  [user callback](https://unicode-org.github.io/icu-docs/apidoc/released/icu4c/ucnv__cb_8h.html)\n\n  ```python\n  from icupy import icu\n  def _to_callback(\n      _context: object,\n      _args: icu.UConverterToUnicodeArgs,\n      _code_units: bytes,\n      _length: int,\n      _reason: icu.UConverterCallbackReason,\n      _error_code: icu.UErrorCode,\n  ) -> icu.UErrorCode:\n      if _reason == icu.UCNV_ILLEGAL:\n          _source = ''.join(['%{:02X}'.format(x) for x in _code_units])\n          icu.ucnv_cb_to_uwrite_uchars(_args, _source, len(_source), 0)\n          _error_code = icu.U_ZERO_ERROR\n      return _error_code\n\n  cnv = icu.ucnv_open('utf-8')\n  action = icu.UConverterToUCallbackPtr(_to_callback)\n  context = icu.ConstVoidPtr(None)\n  icu.ucnv_set_to_ucall_back(cnv, action, context)\n  utf8 = b'\\x61\\xfe\\x62'  # Impossible bytes\n  s = icu.UnicodeString(utf8, -1, cnv)\n  str(s)  # \u2192 'a%FEb'\n  ```\n\n- [icu::DateFormat](https://unicode-org.github.io/icu-docs/apidoc/released/icu4c/classicu_1_1DateFormat.html)\n\n  ```python\n  from icupy import icu\n  tz = icu.TimeZone.create_time_zone('America/Los_Angeles')\n  fmt = icu.DateFormat.create_instance_for_skeleton('yMMMMd', icu.Locale.get_english())\n  fmt.set_time_zone(tz)\n  dest = icu.UnicodeString()\n  s = fmt.format(0, dest)\n  str(s)  # \u2192 'December 31, 1969'\n  ```\n\n- [icu::MessageFormat](https://unicode-org.github.io/icu-docs/apidoc/released/icu4c/classicu_1_1MessageFormat.html)\n\n  ```python\n  from icupy import icu\n  fmt = icu.MessageFormat(\n      \"At {1,time,::jmm} on {1,date,::dMMMM}, \"\n      \"there was {2} on planet {0,number}.\",\n      icu.Locale.get_us(),\n  )\n  tz = icu.TimeZone.get_gmt()\n  subfmts = fmt.get_formats()\n  subfmts[0].set_time_zone(tz)\n  subfmts[1].set_time_zone(tz)\n  date = 1637685775000.0  # 2021-11-23T16:42:55Z\n  obj = icu.Formattable(\n      [\n          icu.Formattable(7),\n          icu.Formattable(date, icu.Formattable.IS_DATE),\n          icu.Formattable(icu.UnicodeString('a disturbance in the Force')),\n      ]\n  )\n  dest = icu.UnicodeString()\n  s = fmt.format(obj, dest)\n  str(s)  # \u2192 'At 4:42 PM on November 23, there was a disturbance in the Force on planet 7.'\n  ```\n\n- [icu::number::NumberFormatter](https://unicode-org.github.io/icu-docs/apidoc/released/icu4c/classicu_1_1number_1_1NumberFormatter.html)\n\n  ```python\n  from icupy import icu\n  fmt = icu.number.NumberFormatter.with_().unit(icu.MeasureUnit.get_meter()).per_unit(icu.MeasureUnit.get_second())\n  print(fmt.locale(icu.Locale.get_us()).format_double(3000).to_string())  # \u2192 '3,000 m/s'\n  print(fmt.locale(icu.Locale.get_france()).format_double(3000).to_string())  # \u2192 '3\u202f000\u202fm/s'\n  print(fmt.locale('ar').format_double(3000).to_string())  # \u2192 '\u0663\u066c\u0660\u0660\u0660 \u0645/\u062b'\n  ```\n\n- [icu::BreakIterator](https://unicode-org.github.io/icu-docs/apidoc/released/icu4c/classicu_1_1BreakIterator.html)\n\n  ```python\n  from icupy import icu\n  text = icu.UnicodeString('In the meantime Mr. Weston arrived with his small ship.')\n  bi = icu.BreakIterator.create_sentence_instance(icu.Locale('en'))\n  bi.set_text(text)\n  list(bi)  # \u2192 [20, 55]\n  # filter based on common English language abbreviations\n  bi = icu.BreakIterator.create_sentence_instance(icu.Locale('en@ss=standard'))\n  bi.set_text(text)\n  list(bi)  # \u2192 [55]\n  ```\n\n- [icu::IDNA](https://unicode-org.github.io/icu-docs/apidoc/released/icu4c/classicu_1_1IDNA.html) (UTS #46)\n\n  ```python\n  from icupy import icu\n  uts46 = icu.IDNA.create_uts46_instance(icu.UIDNA_NONTRANSITIONAL_TO_ASCII)\n  dest = icu.UnicodeString()\n  info = icu.IDNAInfo()\n  uts46.name_to_ascii(icu.UnicodeString('fa\u00df.ExAmPlE'), dest, info)\n  info.get_errors()  # \u2192 0\n  str(dest)  # \u2192 'xn--fa-hia.example'\n  ```\n\n- For more examples, see [tests](https://github.com/miute/icupy/tree/main/tests).\n\n## Installation\n\n### Prerequisites\n\n- [Python](https://www.python.org/) >=3.9\n- [ICU4C](https://github.com/unicode-org/icu/releases) [(ICU - The International Components for Unicode)](https://icu.unicode.org/) (>=70 recommended)\n- C++17 compatible compiler (see [supported compilers](https://github.com/pybind/pybind11#supported-compilers))\n- [CMake](https://cmake.org/) >=3.7\n\n### Installing prerequisites\n\n- Windows\n\n  Install the following dependencies.\n\n  - [Python](https://www.python.org/downloads/) >=3.9\n  - [Pre-built ICU4C binary package](https://github.com/unicode-org/icu/releases) (>=70 recommended)\n  - Visual Studio 2015 Update 3 or newer. Visual Studio 2019 or newer recommended\n  - [CMake](https://cmake.org/download/) >=3.7\n    - *Note: Add CMake to the system PATH.*\n\n- Linux\n\n  To install dependencies, run the following command:\n\n  - Ubuntu/Debian:\n\n    ```bash\n    sudo apt install g++ cmake libicu-dev python3-dev python3-pip\n    ```\n\n  - Fedora:\n\n    ```bash\n    sudo dnf install gcc-c++ cmake icu libicu-devel python3-devel\n    ```\n\n  If your system's ICU is out of date, consider\n  [building ICU4C from source](https://unicode-org.github.io/icu/userguide/icu4c/build.html) or installing [pre-built\n  ICU4C binary package](https://github.com/unicode-org/icu/releases).\n\n### Building icupy from source\n\n1. Configuring environment variables:\n\n   - Windows:\n\n     - Set the `ICU_ROOT` environment variable to the root of the ICU installation (default is `C:\\icu`).\n       For example, if the ICU is located in `C:\\icu4c`:\n\n       ```bat\n       set ICU_ROOT=C:\\icu4c\n       ```\n\n       or in PowerShell:\n\n       ```powershell\n       $env:ICU_ROOT = \"C:\\icu4c\"\n       ```\n\n     - To verify settings using `icuinfo` (64-bit):\n\n       ```bat\n       %ICU_ROOT%\\bin64\\icuinfo\n       ```\n\n       or in PowerShell:\n\n       ```powershell\n       & $env:ICU_ROOT\\bin64\\icuinfo\n       ```\n\n   - Linux:\n\n     - If the ICU is located in a non-regular place, set the `PKG_CONFIG_PATH` and `LD_LIBRARY_PATH` environment variables.\n       For example, if the ICU is located in `/usr/local`:\n\n       ```bash\n       export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig:$PKG_CONFIG_PATH\n       export LD_LIBRARY_PATH=/usr/local/lib:$LD_LIBRARY_PATH\n       ```\n\n     - To verify settings using `pkg-config`:\n\n       ```bash\n       $ pkg-config --cflags --libs icu-uc\n       -I/usr/local/include -L/usr/local/lib -licuuc -licudata\n       ```\n\n2. Installing from PyPI:\n\n   ```bash\n   pip install icupy\n   ```\n\n   Optionally, CMake environment variables are available.\n   For example, using the Ninja build system and Clang:\n\n   ```bash\n   CMAKE_GENERATOR=Ninja CXX=clang++ pip install icupy\n   ```\n\n   Alternatively, installing development version from the git repository:\n\n   ```bash\n   pip install git+https://github.com/miute/icupy.git\n   ```\n\n## Usage\n\n1. Configuring environment variables:\n\n   - Windows:\n\n     - Set the `ICU_ROOT` environment variable to the root of the ICU installation (default is `C:\\icu`).\n       For example, if the ICU is located in `C:\\icu4c`:\n\n       ```bat\n       set ICU_ROOT=C:\\icu4c\n       ```\n\n       or in PowerShell:\n\n       ```powershell\n       $env:ICU_ROOT = \"C:\\icu4c\"\n       ```\n\n   - Linux:\n\n     - If the ICU is located in a non-regular place, set the `LD_LIBRARY_PATH` environment variables.\n       For example, if the ICU is located in `/usr/local`:\n\n       ```bash\n       export LD_LIBRARY_PATH=/usr/local/lib:$LD_LIBRARY_PATH\n       ```\n\n2. Using `icupy`:\n\n   ```python\n   import icupy.icu as icu\n   # or\n   from icupy import icu\n   ```\n\n## License\n\nThis project is licensed under the [MIT License](https://github.com/miute/icupy/blob/main/LICENSE).\n",
    "bugtrack_url": null,
    "license": "MIT License  Copyright (c) 2021 Tetsuya Miura  Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the \"Software\"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:  The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ",
    "summary": "Python bindings for ICU4C",
    "version": "0.20.0",
    "project_urls": {
        "Changelog": "https://github.com/miute/icupy/blob/main/CHANGELOG.md",
        "Download": "https://github.com/miute/icupy/releases",
        "ICU": "https://icu.unicode.org/home",
        "Repository": "https://github.com/miute/icupy"
    },
    "split_keywords": [
        "icu4c",
        " unicode",
        " binding"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "9f60d0fe0379fe359ee41ca07555c5de1eaa1e0731b570e0f5f13528531bbc05",
                "md5": "550489018d6562bf0143cd1e416505db",
                "sha256": "7726bf3d4d430076c84c8ecd31f4661d9a7ee6e8ebbb6d93dedc2af54793b8fd"
            },
            "downloads": -1,
            "filename": "icupy-0.20.0.tar.gz",
            "has_sig": false,
            "md5_digest": "550489018d6562bf0143cd1e416505db",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.9",
            "size": 566731,
            "upload_time": "2024-10-27T06:10:26",
            "upload_time_iso_8601": "2024-10-27T06:10:26.998557Z",
            "url": "https://files.pythonhosted.org/packages/9f/60/d0fe0379fe359ee41ca07555c5de1eaa1e0731b570e0f5f13528531bbc05/icupy-0.20.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-10-27 06:10:26",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "miute",
    "github_project": "icupy",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "tox": true,
    "lcname": "icupy"
}
        
Elapsed time: 2.34897s