Metadata-Version: 2.4
Name: python-alpm
Version: 0.3.0
Classifier: Intended Audience :: Developers
Classifier: Operating System :: POSIX :: Linux
Classifier: Programming Language :: Python :: Implementation :: CPython
Classifier: Programming Language :: Python :: Implementation :: PyPy
Classifier: Programming Language :: Rust
Summary: Python bindings for the Rust-based ALPM project
Keywords: alpm,archlinux,packaging,srcinfo
Home-Page: https://alpm.archlinux.page
License-Expression: Apache-2.0 OR MIT
Requires-Python: >=3.10
Description-Content-Type: text/markdown; charset=UTF-8; variant=GFM
Project-URL: Changelog, https://alpm.archlinux.page/python-alpm/CHANGELOG.html
Project-URL: Documentation, https://alpm.archlinux.page/pdoc/
Project-URL: Homepage, https://alpm.archlinux.page/python-alpm/
Project-URL: Issues, https://gitlab.archlinux.org/archlinux/alpm/alpm/-/issues
Project-URL: Repository, https://gitlab.archlinux.org/archlinux/alpm/alpm

# python-alpm

Python bindings for the **A**rch **L**inux **P**ackage **M**anagement (ALPM) project.

We are currently awaiting decision from PyPI maintainers to allow us to publish this package under the name `alpm`.
Until then, we are using the name `python-alpm`.
You can view the support ticket [here](https://github.com/pypi/support/issues/7813).

## Documentation

Latest documentation is available at <https://alpm.archlinux.page/pdoc>.

## Installation

```sh
pip install python-alpm
```

## Examples

### Validating and comparing versions

```pycon
>>> from alpm.alpm_types import PackageVersion, PackageRelease, FullVersion, SchemaVersion

>>> full_version = FullVersion(pkgver=PackageVersion('0.1.0alpha'), pkgrel=PackageRelease(minor=1))
>>> full_version
FullVersion(pkgver=PackageVersion('0.1.0alpha'), pkgrel=PackageRelease(major=0, minor=1))

>>> PackageVersion('1.0.1') > full_version.pkgver
True

>>> version_one = SchemaVersion.from_str('1.0.0')
>>> version_one
SchemaVersion(major=1, minor=0, patch=0, pre='', build='')

>>> version_one == SchemaVersion(major=1)
True

```

### Parsing .SRCINFO

```pycon
>>> from alpm.alpm_srcinfo import SourceInfoV1
>>> from alpm.alpm_types import Architecture

>>> srcinfo = SourceInfoV1.from_file("../alpm-srcinfo/tests/correct/all_overrides.srcinfo")

>>> srcinfo.base
PackageBase(name='example', version=FullVersion(pkgver=PackageVersion('0.1.0'), pkgrel=PackageRelease(major=1), epoch=1))

>>> srcinfo.base.architectures
Architectures([Architecture('x86_64'), Architecture('aarch64')])

>>> srcinfo.packages
[Package(name='example')]

>>> srcinfo.packages_for_architecture(Architecture('aarch64'))
[MergedPackage(architecture=Architecture('aarch64'), name='example', version=FullVersion(pkgver=PackageVersion('0.1.0'), pkgrel=PackageRelease(major=1), epoch=1))]

```

### Working with package metadata

```pycon
>>> from alpm.alpm_srcinfo.source_info.v1.package import Package, Override
>>> from alpm.alpm_types import License

>>> pkg = Package("testpkg")

>>> pkg.description = Override("A test package")
>>> pkg.description
Override(value='A test package')

>>> pkg.licenses = Override([License("MIT"), License("custom-license")])
>>> pkg.licenses
Override(value=[License('MIT'), License('custom-license')])

>>> {str(lic): lic.is_spdx for lic in pkg.licenses.value}
{'MIT': True, 'custom-license': False}

```

## Contributing

Please refer to the [contribution guidelines] to learn how to contribute to this project.

## License

This project can be used under the terms of the [Apache-2.0] or [MIT].
Contributions to this project, unless noted otherwise, are automatically licensed under the terms of both of those licenses.

<!-- Note: these paths have to be absolute in order to work on PyPI -->
[contribution guidelines]: https://gitlab.archlinux.org/archlinux/alpm/alpm/-/blob/main/CONTRIBUTING.md
[Apache-2.0]: https://gitlab.archlinux.org/archlinux/alpm/alpm/-/blob/main/LICENSES/Apache-2.0.txt
[MIT]: https://gitlab.archlinux.org/archlinux/alpm/alpm/-/blob/main/LICENSES/MIT.txt

