Skip to content

Commit ccc3bb2

Browse files
authored
Merge pull request #20 from branchv/pyproject
#8 Migrate to pyproject.toml and uv
2 parents 6759dce + f81d1b4 commit ccc3bb2

File tree

22 files changed

+1285
-868
lines changed

22 files changed

+1285
-868
lines changed

.classpath

Lines changed: 0 additions & 6 deletions
This file was deleted.

.github/workflows/ci.yaml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches: [master]
6+
pull_request:
7+
branches: [master]
8+
9+
jobs:
10+
build:
11+
strategy:
12+
matrix:
13+
os: [ubuntu-latest]
14+
python-version: ["3.9", "3.10", "3.11", "3.12", "3.13", "3.14"]
15+
runs-on: ${{ matrix.os }}
16+
steps:
17+
- uses: actions/checkout@v6
18+
- uses: actions/setup-python@v6
19+
with:
20+
python-version: ${{ matrix.python-version }}
21+
- uses: astral-sh/setup-uv@v7
22+
with:
23+
enable-cache: true
24+
- name: Lint
25+
uses: pre-commit/action@v3.0.1
26+
- run: ant test

.landscape.yaml

Lines changed: 0 additions & 3 deletions
This file was deleted.

.pre-commit-config.yaml

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
repos:
2+
- repo: https://github.com/astral-sh/ruff-pre-commit
3+
rev: v0.14.6
4+
hooks:
5+
- id: ruff-check
6+
args: [--fix]
7+
- id: ruff-format
8+
9+
- repo: https://github.com/pre-commit/mirrors-prettier
10+
rev: v3.1.0
11+
hooks:
12+
- id: prettier
13+
14+
- repo: https://github.com/pre-commit/pre-commit-hooks
15+
rev: v6.0.0
16+
hooks:
17+
- id: fix-byte-order-marker
18+
- id: trailing-whitespace
19+
- id: end-of-file-fixer
20+
- id: mixed-line-ending
21+
- id: check-added-large-files
22+
- id: check-ast
23+
- id: check-json
24+
- id: check-merge-conflict
25+
- id: check-xml
26+
- id: check-yaml
27+
- id: debug-statements
28+
- id: no-commit-to-branch
29+
args: [--branch, master]

.project

Lines changed: 0 additions & 17 deletions
This file was deleted.

CONTRIBUTING.md

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
## Developer cheat sheet
2+
3+
Bump version number:
4+
5+
1. Possibly update copyright year in:
6+
7+
- `ebcdic/__init__.py`
8+
- `LICENSE.txt` and
9+
- `README.rst`
10+
11+
2. Edit `ebcdic/_version.py:__version__`.
12+
3. Describe changes in `README.rst`.
13+
14+
Upload release to PyPI::
15+
16+
```console
17+
$ git checkout master
18+
$ git pull
19+
$ ant test
20+
$ cd ebcdic
21+
$ uv build
22+
$ uv publish
23+
```
24+
25+
Update production branch::
26+
27+
```console
28+
$ git checkout production
29+
$ git merge master
30+
$ git push
31+
```
32+
33+
Tag a release::
34+
35+
```console
36+
$ git tag -a -m "Tagged version 1.x.x." v1.x.x
37+
$ git push --tags
38+
```

README.md

Lines changed: 11 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,18 @@
1-
CodecMapper
2-
===========
1+
# CodecMapper
32

43
CodecMapper derives mapping files from Java Charsets which can be processed
54
by Python's gencodec.py.
65

7-
8-
Requirements
9-
------------
6+
## Requirements
107

118
To build and run CodecMapper, you need:
129

13-
1. Java 1.7 or later
14-
2. ant 1.8 or later, available from https://ant.apache.org/.
10+
1. Java 1.7 or later
11+
2. ant 1.8 or later, available from https://ant.apache.org/.
1512

1613
It might also work with earlier versions of ant but this has not been tested.
1714

18-
19-
Usage
20-
-----
15+
## Usage
2116

2217
To build CodecMapper, run:
2318

@@ -35,42 +30,29 @@ The resulting mapping file is stored in `iso-8859-15.txt`. The generated mapping
3530
are located in the same folder and have names like
3631
`iso-8859.15.mapping`.
3732

38-
39-
EBCDIC codecs for Python
40-
------------------------
33+
## EBCDIC codecs for Python
4134

4235
As an example usage, CodecMapper can provide additional EBCDIC codecs for
4336
Python, which can easily be packaged and distributed.
4437

45-
To test the Python codecs you need to setup a Pythen venv:
46-
47-
```sh
48-
$ python -m venv venv
49-
$ source venv/bin/activate
50-
$ pip install --upgrade pip
51-
$ pip install pycodestyle wheel
52-
```
53-
38+
To test the Python codecs, first install [uv](https://docs.astral.sh/uv/getting-started/installation/).
5439
After that you can build the Python codecs and run the tests:
5540

5641
```sh
5742
$ ant test
5843
```
44+
5945
For more information, browse the "ebcdic" folder of this distribution and
6046
take a look at the README.rst.
6147

62-
63-
Source code
64-
-----------
48+
## Source code
6549

6650
See https://github.com/roskakori/CodecMapper.
6751

68-
69-
License
70-
-------
52+
## License
7153

7254
Copyright (c) 2013 - 2019, Thomas Aglassinger
7355
All rights reserved.
7456

7557
Distributed under the BSD license, see [LICENSE.txt](LICENSE.txt) for more
76-
information.
58+
information.

build.xml

Lines changed: 15 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
<description>
33
Build CodecMapper and additional codecs for Python.
44
</description>
5-
<property name="python" value="${basedir}/venv/bin/python"/>
65
<property name="source" location="source"/>
76
<property name="build" location="build"/>
87
<property name="dist" location="dist"/>
@@ -34,10 +33,6 @@
3433
<fileset dir="ebcdic/ebcdic" includes="cp*.*" excludes="cp*ms.py"/>
3534
</delete>
3635
<delete dir="ebcdic/ebcdic/temp" includeemptydirs="true" quiet="true"/>
37-
<exec executable="${python}" dir="ebcdic" failonerror="true">
38-
<arg path="ebcdic/setup.py"/>
39-
<arg value="clean"/>
40-
</exec>
4136
</target>
4237

4338
<target name="ebcdic" description="build ebcdic package for Python" depends="dist">
@@ -96,20 +91,20 @@
9691
<!-- <arg value="cp4971" /> --><!-- Unavailable: Greece -->
9792
<!-- <arg value="cp9067" /> --><!-- Unavailable: Greece -->
9893
</java>
99-
<exec executable="${python}" dir="ebcdic/ebcdic" failonerror="true">
94+
<exec executable="uv" dir="ebcdic/ebcdic" failonerror="true">
95+
<arg value="run"/>
10096
<arg value="${basedir}/tools/gencodec.py"/>
10197
<arg value="temp"/>
10298
</exec>
10399
<delete includeemptydirs="true">
104100
<fileset dir="ebcdic/ebcdic" includes="*.mapping, temp"/>
105101
<fileset dir="ebcdic/ebcdic/temp"/>
106102
</delete>
107-
<exec executable="${python}" dir="ebcdic" failonerror="true">
108-
<arg path="ebcdic/setup.py"/>
109-
<arg value="sdist"/>
110-
<arg value="--dist-dir"/>
103+
<exec executable="uv" dir="ebcdic" failonerror="true">
104+
<arg value="build"/>
105+
<arg value="--out-dir"/>
111106
<arg path="${dist}"/>
112-
<arg value="--formats=zip"/>
107+
<arg value="--sdist"/>
113108
</exec>
114109
</target>
115110

@@ -119,22 +114,18 @@
119114
</java>
120115
</target>
121116

122-
<target name="pep8" description="validate Python code style">
123-
<exec executable="pycodestyle" failonerror="true">
124-
<arg path="ebcdic/setup.py"/>
125-
<arg value="--config"/>
126-
<arg path="ebcdic/setup.cfg"/>
127-
<arg value="--max-line-length=120"/>
128-
<arg path="ebcdic/setup.py"/>
129-
<arg path="ebcdic/ebcdic/__init__.py"/>
130-
<arg path="ebcdic/ebcdic/test/test_ebcdic.py"/>
117+
<target name="lint" description="validate Python code style">
118+
<exec executable="uv" dir="ebcdic" failonerror="true">
119+
<arg value="run"/>
120+
<arg value="ruff"/>
121+
<arg value="check"/>
131122
</exec>
132123
</target>
133124

134-
<target name="test" description="run test suite" depends="ebcdic, pep8">
135-
<exec executable="${python}" dir="ebcdic" failonerror="true">
136-
<arg path="ebcdic/setup.py"/>
137-
<arg value="test"/>
125+
<target name="test" description="run test suite" depends="ebcdic, lint">
126+
<exec executable="uv" dir="ebcdic" failonerror="true">
127+
<arg value="run"/>
128+
<arg value="pytest"/>
138129
</exec>
139130
</target>
140131
</project>

ebcdic/README.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ Then run::
140140

141141
to build and test the distribution.
142142

143-
The ``ebcdic/setup.py`` automatically includes the new encoding in the package
143+
The ``ebcdic/pyproject.toml`` automatically includes the new encoding in the package
144144
and ``ebcdic/__init__.py`` registers it during ``import ebcdic``, so no
145145
further steps are needed.
146146

ebcdic/ebcdic/__init__.py

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -27,19 +27,18 @@
2727
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
2828
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
2929
# POSSIBILITY OF SUCH DAMAGE.
30-
from __future__ import absolute_import
30+
3131
import codecs
3232

33+
from ._version import __version__, __version_info__
3334

3435
__all__ = [
35-
'codec_names',
36-
'ignored_codec_names',
37-
'lookup',
38-
'__version__',
39-
'__version_info__'
36+
"codec_names",
37+
"ignored_codec_names",
38+
"lookup",
39+
"__version__",
40+
"__version_info__",
4041
]
41-
__version_info__ = (1, 1, 1)
42-
__version__ = '.'.join([str(item) for item in __version_info__])
4342

4443

4544
def _codec_names():
@@ -50,15 +49,15 @@ def _codec_names():
5049
import os.path
5150

5251
package_folder = os.path.dirname(__file__)
53-
for codec_path in glob.glob(os.path.join(package_folder, 'cp*.py')):
52+
for codec_path in glob.glob(os.path.join(package_folder, "cp*.py")):
5453
codec_name = os.path.splitext(os.path.basename(codec_path))[0]
5554
yield codec_name
5655

5756

5857
def _create_codec_name_to_info_map():
5958
result = {}
6059
for codec_name in codec_names:
61-
codec_module = __import__('ebcdic.' + codec_name, globals(), locals(), ['getregentry'])
60+
codec_module = __import__("ebcdic." + codec_name, globals(), locals(), ["getregentry"])
6261
result[codec_name] = codec_module.getregentry()
6362
return result
6463

@@ -76,9 +75,10 @@ def ignored_codec_names():
7675
A list of codec names in this package that are ignored because they are
7776
already provided by other means, e.g. the standard library.
7877
"""
79-
return [codec_name
80-
for codec_name, codec_info in sorted(_codec_name_to_info_map.items())
81-
if codec_info != codecs.lookup(codec_name)
78+
return [
79+
codec_name
80+
for codec_name, codec_info in sorted(_codec_name_to_info_map.items())
81+
if codec_info != codecs.lookup(codec_name)
8282
]
8383

8484

@@ -89,7 +89,7 @@ def lookup(codec_name):
8989
"""
9090
result = _find_ebcdic_codec(codec_name)
9191
if result is None:
92-
raise LookupError('EBCDIC codec is %r but must be one of: %s' % (codec_name, codec_names))
92+
raise LookupError(f"EBCDIC codec is {codec_name!r} but must be one of: {codec_names}")
9393
return result
9494

9595

0 commit comments

Comments
 (0)