Skip to content

Commit

Permalink
Merge pull request nschloe#212 from nschloe/pypi-markdown
Browse files Browse the repository at this point in the history
Pypi markdown, gmsh fixes
  • Loading branch information
nschloe authored Mar 28, 2018
2 parents 29a2780 + bb6b7a6 commit 763c16d
Show file tree
Hide file tree
Showing 8 changed files with 36 additions and 39 deletions.
5 changes: 0 additions & 5 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,6 @@ jobs:
- run: pip3 install .[exodus,hdf5]
# Make sure to get numpy 1.13.0
- run: pip3 install -U numpy
# make sure that rst converts correctly
- run: apt install -y pandoc
- run: pip3 install docutils pygments
- run: make README.rst
- run: python3 setup.py check -r -s
# The actual test
- run: pylint setup.py meshio/ test/*.py tools/meshio-convert
- run: cd test/ && pytest --cov meshio
Expand Down
25 changes: 12 additions & 13 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,26 +3,25 @@ VERSION=$(shell python3 -c "import meshio; print(meshio.__version__)")
default:
@echo "\"make publish\"?"

README.rst: README.md
cat README.md | sed -e 's_<img src="\([^"]*\)" width="\([^"]*\)">_![](\1){width="\2"}_g' -e 's_<p[^>]*>__g' -e 's_</p>__g' > /tmp/README.md
pandoc /tmp/README.md -o README.rst
python3 setup.py check -r -s || exit 1
tag:
@if [ "$(shell git rev-parse --abbrev-ref HEAD)" != "master" ]; then exit 1; fi
@echo "Tagging v$(VERSION)..."
git tag v$(VERSION)
git push --tags

upload: setup.py README.rst
upload: setup.py
# Make sure we're on the master branch
@if [ "$(shell git rev-parse --abbrev-ref HEAD)" != "master" ]; then exit 1; fi
rm -f dist/*
python3 setup.py sdist
python3 setup.py bdist_wheel --universal
gpg --detach-sign -a dist/*
twine upload dist/*

tag:
@if [ "$(shell git rev-parse --abbrev-ref HEAD)" != "master" ]; then exit 1; fi
@echo "Tagging v$(VERSION)..."
git tag v$(VERSION)
git push --tags
# https://dustingram.com/articles/2018/03/16/markdown-descriptions-on-pypi
twine upload dist/*.tar.gz
twine upload dist/*.whl

publish: tag upload

clean:
rm -f README.rst
@find . | grep -E "(__pycache__|\.pyc|\.pyo$\)" | xargs rm -rf
@rm -rf *.egg-info/ build/ dist/
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
[![CircleCI](https://img.shields.io/circleci/project/github/nschloe/meshio/master.svg)](https://circleci.com/gh/nschloe/meshio)
[![codecov](https://img.shields.io/codecov/c/github/nschloe/meshio.svg)](https://codecov.io/gh/nschloe/meshio)
[![Codacy grade](https://img.shields.io/codacy/grade/dc23fe7f7d4540b0a405110b3ae97dc6.svg)](https://app.codacy.com/app/nschloe/meshio/dashboard)
[![PyPi Version](https://img.shields.io/pypi/v/meshio.svg)](https://pypi.python.org/pypi/meshio)
[![PyPi Version](https://img.shields.io/pypi/v/meshio.svg)](https://pypi.org/project/meshio)
[![DOI](https://zenodo.org/badge/DOI/10.5281/zenodo.1173115.svg)](https://doi.org/10.5281/zenodo.1173115)
[![GitHub stars](https://img.shields.io/github/stars/nschloe/meshio.svg?logo=github&style=social&label=Stars)](https://github.com/nschloe/meshio)
[![GitHub stars](https://img.shields.io/github/stars/nschloe/meshio.svg?logo=github&label=Stars)](https://github.com/nschloe/meshio)

<p align="center">
<img src="https://nschloe.github.io/meshio/meshio_logo.png" width="20%">
Expand Down Expand Up @@ -68,7 +68,7 @@ For both input and output, you can optionally specify the exact `file_format`
### Installation

meshio is [available from the Python Package
Index](https://pypi.python.org/pypi/meshio/), so simply type
Index](https://pypi.org/project/meshio/), so simply type
```
pip install -U meshio
```
Expand Down
2 changes: 1 addition & 1 deletion meshio/__about__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
#
__version__ = '1.11.9'
__version__ = '1.11.10'
__author__ = u'Nico Schlömer'
__author_email__ = '[email protected]'
__copyright__ = \
Expand Down
4 changes: 0 additions & 4 deletions meshio/dolfin_io.py
Original file line number Diff line number Diff line change
Expand Up @@ -241,16 +241,12 @@ def write(filename,
assert 'triangle' in cells
cell_type = 'triangle'

print('a')
_write_mesh(filename, points, cell_type, cells)

print('b')

if cell_type in cell_data:
for key, data in cell_data[cell_type].items():
cell_data_filename = \
'{}_{}.xml'.format(os.path.splitext(filename)[0], key)
dim = 2 if all(points[:, 2] == 0) else 3
_write_cell_data(cell_data_filename, dim, numpy.array(data))
print('c')
return
7 changes: 4 additions & 3 deletions meshio/gmsh_io.py
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,7 @@ def _read_data(f, tag, data_dict, int_size, data_size, is_ascii):
# Read string tags
num_string_tags = int(f.readline().decode('utf-8'))
string_tags = [
f.readline().decode('utf-8').strip()
f.readline().decode('utf-8').strip().replace('"', '')
for _ in range(num_string_tags)
]
# The real tags typically only contain one value, the time.
Expand Down Expand Up @@ -468,6 +468,7 @@ def _write_elements(fh, cells, tag_data, write_binary):
)[:, numpy.newaxis]
a += 1 + consecutive_index
array = numpy.hstack([a, fcd, node_idcs + 1])
assert array.dtype == numpy.int32
fh.write(array.tostring())
else:
form = '{} ' + str(_meshio_to_gmsh_type[cell_type]) \
Expand Down Expand Up @@ -498,7 +499,7 @@ def _write_data(fh, tag, name, data, write_binary):
# > the second as the name of the interpolation scheme. The interpolation
# > scheme is provided in the $InterpolationScheme section (see below).
fh.write('{}\n'.format(1).encode('utf-8'))
fh.write('{}\n'.format(name).encode('utf-8'))
fh.write('"{}"\n'.format(name).encode('utf-8'))
fh.write('{}\n'.format(1).encode('utf-8'))
fh.write('{}\n'.format(0.0).encode('utf-8'))
# three integer tags:
Expand Down Expand Up @@ -583,7 +584,7 @@ def write(filename,
other_data[cell_type] = {}
for key, data in a.items():
if key in ['gmsh:physical', 'gmsh:geometrical']:
tag_data[cell_type][key] = data
tag_data[cell_type][key] = data.astype(numpy.int32)
else:
other_data[cell_type][key] = data

Expand Down
9 changes: 9 additions & 0 deletions meshio/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,9 @@ def read(filename, file_format=None):
if not file_format:
# deduce file format from extension
extension = '.' + os.path.basename(filename).split(os.extsep, 1)[-1]
assert extension in _extension_to_filetype, \
'Could not deduce file format from extension \'{}\'.' \
.format(extension)
file_format = _extension_to_filetype[extension]

format_to_reader = {
Expand Down Expand Up @@ -128,6 +131,9 @@ def read(filename, file_format=None):
'exodus': exodus_io,
}

assert file_format in format_to_reader, \
'Unknown file format \'{}\' of \'{}\'.'.format(file_format, filename)

return format_to_reader[file_format].read(filename)


Expand All @@ -153,6 +159,9 @@ def write(filename,
if not file_format:
# deduce file format from extension
extension = '.' + os.path.basename(filename).split(os.extsep, 1)[-1]
assert extension in _extension_to_filetype, \
'Could not deduce file format from extension \'{}\'.' \
.format(extension)
file_format = _extension_to_filetype[extension]

# check cells for sanity
Expand Down
17 changes: 7 additions & 10 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,7 @@


def read(fname):
try:
content = codecs.open(
os.path.join(base_dir, fname),
encoding='utf-8'
).read()
except IOError:
content = ''
return content
return codecs.open(os.path.join(base_dir, fname), encoding='utf-8').read()


setup(
Expand All @@ -31,16 +24,20 @@ def read(fname):
author_email=about['__author_email__'],
packages=find_packages(),
description='I/O for various mesh formats',
long_description=read('README.rst'),
long_description=read('README.md'),
long_description_content_type='text/markdown',
url='https://github.com/nschloe/meshio',
download_url='https://pypi.python.org/pypi/meshio',
project_urls={
'Issues': 'https://github.com/nschloe/meshio/issues',
},
license=about['__license__'],
platforms='any',
install_requires=[
'numpy',
'pipdate',
],
extras_require={
'all': ['netCDF4', 'h5py'],
'exodus': ['netCDF4'],
'hdf5': ['h5py'], # MED, MOAB, XDMF formats
},
Expand Down

0 comments on commit 763c16d

Please sign in to comment.