Skip to content

Commit

Permalink
Merge pull request #2 from openkim/setup-upgrade
Browse files Browse the repository at this point in the history
Setup upgrade
  • Loading branch information
yafshar authored Mar 14, 2024
2 parents 84964c3 + dc7c1b8 commit 7c6c964
Show file tree
Hide file tree
Showing 24 changed files with 717 additions and 2,066 deletions.
22 changes: 0 additions & 22 deletions .appveyor.yml

This file was deleted.

19 changes: 10 additions & 9 deletions .github/workflows/pythonpackage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,12 @@ jobs:
strategy:
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
python-version: [3.6, 3.7, 3.8, 3.9]
exclude:
- os: windows-latest
python-version: '3.6'
python-version: [3.8, 3.9, '3.10', 3.11, 3.12]

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
Expand All @@ -29,13 +26,17 @@ jobs:
# stop the build if there are Python syntax errors or undefined names
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
flake8 . --count --exit-zero --max-complexity=51 --max-line-length=1023 --statistics
- name: Test with unittest
run: |
python -m tests
coverage run -m tests
- name: Post Coverage
uses: codecov/codecov-action@v1
if: matrix.os == 'ubuntu-latest' && matrix.python-version == '3.9'
uses: codecov/codecov-action@v4
if: matrix.os == 'ubuntu-latest' && matrix.python-version == '3.11'
with:
verbose: true
fail_ci_if_error: false
flags: unittests
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
20 changes: 10 additions & 10 deletions .github/workflows/pythonpublish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,19 @@ jobs:
deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v2
uses: actions/setup-python@v5
with:
python-version: '3.x'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install setuptools wheel twine
- name: Build and publish
env:
TWINE_USERNAME: ${{ secrets.PYPI_USERNAME_OPENKIM }}
TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD_OPENKIM }}
run: |
python setup.py sdist bdist_wheel
twine upload dist/*
pip install build
- name: Build package
run: python -m build
- name: Publish package
uses: pypa/gh-action-pypi-publish@release/v1.8
with:
user: __token__
password: ${{ secrets.PYPI_PASSWORD_OPENKIM }}
1 change: 0 additions & 1 deletion MANIFEST.in
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
include versioneer.py
include kim_edn/_version.py
45 changes: 33 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
# KIM-EDN encoder and decoder

[![Python package](https://github.com/openkim/kim-edn/workflows/Python%20package/badge.svg)](https://github.com/openkim/kim-edn/actions)
[![Windows Build status](https://ci.appveyor.com/api/projects/status/3amxmm9j5v8eykn2?svg=true)](https://ci.appveyor.com/project/yafshar/kim-edn)
[![codecov](https://codecov.io/gh/openkim/kim-edn/branch/master/graph/badge.svg)](https://codecov.io/gh/openkim/kim-edn)
[![Anaconda-Server Badge](https://img.shields.io/conda/vn/conda-forge/kim-edn.svg)](https://anaconda.org/conda-forge/kim-edn)
[![PyPI](https://img.shields.io/pypi/v/kim-edn.svg)](https://pypi.python.org/pypi/kim-edn)
Expand Down Expand Up @@ -297,24 +296,50 @@ reference.
Installing `kim-edn` from the `conda-forge` channel can be achieved by adding
`conda-forge` to your channels with:

```sh
```
conda config --add channels conda-forge
conda config --set channel_priority strict
```

Once the `conda-forge` channel has been enabled, `kim-edn` can be installed
with:
with `conda`:

```sh
```
conda install kim-edn
```

or with `mamba`:

```
mamba install kim-edn
```

It is possible to list all of the versions of `kim-edn` available on your
platform with:
platform with `conda`:

```sh
```
conda search kim-edn --channel conda-forge
```

or with `mamba`:

```
mamba search kim-edn --channel conda-forge
```

Alternatively, `mamba repoquery` may provide more information:

```
# Search all versions available on your platform:
mamba repoquery search kim-edn --channel conda-forge
# List packages depending on `kim-edn`:
mamba repoquery whoneeds kim-edn --channel conda-forge
# List dependencies of `kim-edn`:
mamba repoquery depends kim-edn --channel conda-forge
```

## References

This module has been adapted and updated from the
Expand All @@ -323,13 +348,9 @@ This module has been adapted and updated from the

## Copyright

Copyright (c) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010,
2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018, 2019 Python Software
Foundation;\
All Rights Reserved
Copyright © 2001-2024 Python Software Foundation. All rights reserved.

Copyright (c) 2019-2021, Regents of the University of Minnesota.\
All Rights Reserved
Copyright (c) 2019-2024, Regents of the University of Minnesota. All Rights Reserved.

## Contributing

Expand Down
47 changes: 18 additions & 29 deletions kim_edn/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,7 @@
>>> def encode_complex(obj):
... if isinstance(obj, complex):
... return [obj.real, obj.imag]
... msg = 'Object of type {} is not '.format(obj.__class__.__name__)
... msg += 'KIM-EDN serializable'
... msg = f'Object of type {obj.__class__.__name__} is not KIM-EDN serializable'
... raise TypeError(msg)
...
>>> kim_edn.dumps(2 + 1j, default=encode_complex)
Expand Down Expand Up @@ -143,9 +142,7 @@
}
}
"""
"""
Copyright (c) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010,
2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018, 2019 Python Software Foundation;
All Rights Reserved
Expand Down Expand Up @@ -296,7 +293,7 @@ def detect_encoding(b):
return 'utf-8'


def load(fp, *, cls=None, parse_float=None, parse_int=None, parse_constant=None,
def load(fp, *, cls=None, parse_float=None, parse_int=None,
object_hook=None, object_pairs_hook=None):
r"""Deserialize ``fp``.
Expand Down Expand Up @@ -334,13 +331,12 @@ def load(fp, *, cls=None, parse_float=None, parse_int=None, parse_constant=None,
cls=cls,
parse_float=parse_float,
parse_int=parse_int,
parse_constant=parse_constant,
object_hook=object_hook,
object_pairs_hook=object_pairs_hook)


def loads(s, *, cls=None, parse_float=None, parse_int=None,
parse_constant=None, object_hook=None, object_pairs_hook=None):
object_hook=None, object_pairs_hook=None):
r"""Deserialize ``s``.
Deserialize ``s`` (a ``str``, ``bytes`` or ``bytearray`` instance
Expand All @@ -367,11 +363,6 @@ def loads(s, *, cls=None, parse_float=None, parse_int=None,
int(num_str). This can be used to use another datatype or parser
for EDN integers (e.g. float).
``parse_constant``, if specified, will be called with one of the
following strings: -Infinity, Infinity, NaN.
This can be used to raise an exception if invalid EDN numbers
are encountered.
To use a custom ``KIMEDNDecoder`` subclass, specify it with the ``cls``
kwarg; otherwise ``KIMEDNDecoder`` is used.
Expand All @@ -383,41 +374,39 @@ def loads(s, *, cls=None, parse_float=None, parse_int=None,
else:
if not isinstance(s, (bytes, bytearray)):
msg = 'the EDN object must be str, bytes or bytearray, '
msg += 'not {}'.format(s.__class__.__name__)
msg += f'not {s.__class__.__name__}'
raise TypeError(msg)

s = s.decode(detect_encoding(s), 'surrogatepass')

if (cls is None
and parse_float is None
and parse_int is None
and parse_constant is None
and object_hook is None and
object_pairs_hook is None):
return _default_decoder.decode(s)

if cls is None:
cls = KIMEDNDecoder

kw = {}
if parse_float is not None:
kw['parse_float'] = parse_float
if type(cls) is type:
kw = {}
if parse_float is not None:
kw['parse_float'] = parse_float

if parse_int is not None:
kw['parse_int'] = parse_int
if parse_int is not None:
kw['parse_int'] = parse_int

if parse_constant is not None:
kw['parse_constant'] = parse_constant
if object_hook is not None:
kw['object_hook'] = object_hook

if object_hook is not None:
kw['object_hook'] = object_hook
if object_pairs_hook is not None:
kw['object_pairs_hook'] = object_pairs_hook

if object_pairs_hook is not None:
kw['object_pairs_hook'] = object_pairs_hook
return cls(**kw).decode(s)

return cls(**kw).decode(s)
return cls.decode(s)


from ._version import get_versions
__version__ = get_versions()['version']
del get_versions
from . import _version # noqa: E402
__version__ = _version.get_versions()['version']
Loading

0 comments on commit 7c6c964

Please sign in to comment.