Skip to content

Commit

Permalink
Merge pull request #117 from laws-africa/pypi
Browse files Browse the repository at this point in the history
Publish to pypi
  • Loading branch information
longhotsummer authored Jun 23, 2023
2 parents 2e1366c + 314558c commit ebe5e98
Show file tree
Hide file tree
Showing 10 changed files with 104 additions and 186 deletions.
28 changes: 28 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: Publish to PyPI

on:
release:
types: [created]

jobs:
pypi-publish:
name: Upload release to PyPI
runs-on: ubuntu-latest
environment:
name: pypi
url: https://pypi.org/p/bluebell-akn
permissions:
id-token: write # IMPORTANT: this permission is mandatory for trusted publishing
steps:
- uses: actions/checkout@v2

- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: 3.8

- name: Build distribution
run: python -m pip install build && python -m build

- name: Publish package distributions to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
2 changes: 0 additions & 2 deletions MANIFEST.in

This file was deleted.

25 changes: 25 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,25 @@ while being simple to use and not requiring that authors have an in-depth knowle
Bluebell will always produce structurally valid Akoma Ntoso, no matter what input is given. It will never refuse to parse
malformed input. If it does, it's a bug.

## Getting started

1. Install from pypi: `pip install bluebell-akn`
2. Create an `AkomaNtosoParser` object with a valid FRBR URI, and parse your text:

```python
from bluebell.parser import AkomaNtosoParser
from cobalt.uri import FrbrUri
from lxml import etree

frbr_uri = FrbrUri.parse("/akn/za/act/2009/1")
parser = AkomaNtosoParser(frbr_uri)
xml = parser.parse_to_xml("""
CHAPTER 1
1. Section 1
Some text""", "act")
print(etree.tostring(xml, encoding='unicode'))
```

## Elements

### Preface, preamble and conclusions
Expand Down Expand Up @@ -587,6 +606,12 @@ and removes the `displaced` element.
2. Build canopy: `cd canopy; npm install; make; cd ..`
3. Build grammar changes with `make`, which runs our Makefile to compile the grammar

## Releasing a new version

1. Update the version by changing the `__version__` variable in [bluebell/__init__.py](bluebell/__init__.py)
2. Commit your changes and push to the master branch on GitHub
3. Create a release in GitHub and it will automatically be pushed to PyPi

# License

Copyright 2020 Laws.Africa.
Expand Down
1 change: 0 additions & 1 deletion VERSION

This file was deleted.

1 change: 1 addition & 0 deletions bluebell/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
__version__ = "2.2.0"
3 changes: 1 addition & 2 deletions bin/bluebell → bluebell/cli.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
#!/usr/bin/env python
import json
import sys
import argparse
Expand All @@ -16,7 +15,7 @@ def print_with_lines(lines):
print(f'{i:02}: {line}', file=sys.stderr)


if __name__ == '__main__':
def main():
parser = argparse.ArgumentParser(description='Parse text into Akoma Ntoso.')
parser.add_argument('frbr_uri', type=str, help='frbr_uri for the document to parse')
parser.add_argument('root', type=str, help='the type of document to parse (eg. judgment)')
Expand Down
82 changes: 0 additions & 82 deletions hier.txt

This file was deleted.

47 changes: 47 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
[build-system]
requires = ["setuptools", "setuptools_scm[toml]>=6.2", "wheel"]
build-backend = "setuptools.build_meta"

[project]
name = "bluebell-akn"
description = "Transforms text to and from Akoma Ntoso"
authors = [
{ name="Laws.Africa", email="[email protected]" },
]
license = {text = "LGPLv3+"}
readme = "README.md"
requires-python = ">=3.7"
classifiers = [
"Development Status :: 5 - Production/Stable",
"Intended Audience :: Developers",
"Topic :: Text Processing",
"Topic :: Text Processing :: Markup :: XML",
"Intended Audience :: Legal Industry",
"License :: OSI Approved :: GNU Lesser General Public License v3 or later (LGPLv3+)",
"Programming Language :: Python",
"Programming Language :: Python :: 3",
]
dependencies = [
"cobalt>=7.0.0",
"lxml>=3.4.1",
]
dynamic = ["version"]

[project.urls]
"Homepage" = "https://github.com/laws-africa/bluebell"
"Bug Tracker" = "https://github.com/laws-africa/bluebell/issues"

[project.optional-dependencies]
test = ["nose", "flake8"]

[project.scripts]
bluebell = "bluebell.cli:main"

[tool.setuptools.packages.find]
include = ["bluebell"] # package names should match these glob patterns (["*"] by default)
exclude = ["tests*"] # exclude packages matching these glob patterns (empty by default)
namespaces = false

[tool.setuptools.dynamic]
version = {attr = "bluebell.__version__"}

81 changes: 2 additions & 79 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,80 +1,3 @@
from setuptools import setup, find_packages
from codecs import open
from os import path
from setuptools import setup

here = path.abspath(path.dirname(__file__))

# Get the long description from the relevant file
with open(path.join(here, 'README.md'), encoding='utf-8') as f:
long_description = f.read()

with open(path.join(here, 'VERSION')) as f:
version = f.read().strip()

setup(
name='bluebell',

# Versions should comply with PEP440. For a discussion on single-sourcing
# the version across setup.py and the project code, see
# https://packaging.python.org/en/latest/single_source_version.html
version=version,

description='Transforms text to and from Akoma Ntoso',
long_description=long_description,

# The project's main homepage.
url='https://github.com/laws-africa/bluebell',

# Author details
author='Laws.Africa',
author_email='[email protected]',

# See https://pypi.python.org/pypi?%3Aaction=list_classifiers
classifiers=[
# How mature is this project? Common values are
# 3 - Alpha
# 4 - Beta
# 5 - Production/Stable
'Development Status :: 5 - Production/Stable',

# Indicate who your project is intended for
'Intended Audience :: Developers',
'Topic :: Text Processing',
'Topic :: Text Processing :: Markup :: XML',
'Intended Audience :: Legal Industry',

# License
'License :: OSI Approved :: GNU Lesser General Public License v3 or later (LGPLv3+)',

# Specify the Python versions you support here. In particular, ensure
# that you indicate whether you support Python 2, Python 3 or both.
'Programming Language :: Python',
'Programming Language :: Python :: 3',
'Programming Language :: Python :: 3.7',
],

# You can just specify the packages manually here if your project is
# simple. Or you can use find_packages().
packages=find_packages(exclude=['docs', 'tests*']),
include_package_data=True,

scripts=['bin/bluebell'],

# List run-time dependencies here. These will be installed by pip when
# your project is installed. For an analysis of "install_requires" vs pip's
# requirements files see:
# https://packaging.python.org/en/latest/requirements.html
install_requires=[
'lxml >= 3.4.1',
'cobalt >= 7.0.0',
],

# List additional groups of dependencies here (e.g. development
# dependencies). You can install these using the following syntax,
# for example:
# $ pip install -e .[dev,test]
extras_require={
'dev': ['nose', 'flake8'],
'test': ['nose', 'flake8'],
},
)
setup()
20 changes: 0 additions & 20 deletions statement.txt

This file was deleted.

0 comments on commit ebe5e98

Please sign in to comment.