Skip to content

Commit

Permalink
Merge pull request #7 from fusion-energy/develop
Browse files Browse the repository at this point in the history
improved setup and conda install
  • Loading branch information
shimwell authored Feb 8, 2022
2 parents 950aed1 + 8263b9b commit e10e4c1
Show file tree
Hide file tree
Showing 15 changed files with 154 additions and 80 deletions.
3 changes: 1 addition & 2 deletions .github/workflows/ci_with_install.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,8 @@ jobs:

- name: install package
run: |
pip install -r requirements-test.txt
conda install -c conda-forge moab
python setup.py install
pip install .[tests]
- name: Run test_utils
run: |
Expand Down
19 changes: 5 additions & 14 deletions .github/workflows/python-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
name: Upload Python Package

on:
# allows us to run workflows manually
workflow_dispatch:
release:
types: [created]

Expand All @@ -23,27 +25,16 @@ jobs:
with:
python-version: '3.x'

- name: Autobump version
run: |
# from refs/tags/v1.2.3 get 1.2.3
VERSION=$(echo $GITHUB_REF | sed 's#.*/v##')
PLACEHOLDER='version="develop"'
VERSION_FILE='setup.py'
# Grep checks that the placeholder is in the file. If grep doesn't find
# the placeholder then it exits with exit code 1 and github actions fails.
grep "$PLACEHOLDER" "$VERSION_FILE"
sed -i "s/$PLACEHOLDER/version=\"${VERSION}\"/g" "$VERSION_FILE"
shell: bash

- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install setuptools wheel twine
pip install setuptools wheel build twine
- name: Build and publish
env:
TWINE_USERNAME: __token__
TWINE_PASSWORD: ${{ secrets.PYPI_API_TOKEN }}
run: |
python setup.py sdist bdist_wheel
python -m build
twine check dist/*
twine upload dist/*
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -130,3 +130,6 @@ dmypy.json

# dagmc files
*.h5m

# version file
_version.py
File renamed without changes.
2 changes: 2 additions & 0 deletions build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
python3 -m pip install --upgrade build
python3 -m build
47 changes: 47 additions & 0 deletions conda/meta.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
{% set name = "stl_to_h5m" %}
{% set version = "0.0.3" %}

package:
name: "{{ name|lower }}"
version: {{ version }}

source:
path: ..

build:
number: 0
script: python setup.py install --single-version-externally-managed --record=record.txt

requirements:
build:
- python {{ python }}
- setuptools
run:
- python
- moab
- numpy

test:
imports:
- stl_to_h5m
requires:
- pytest
# source_files:
# - tests/
# - examples/
# commands:
# - pytest tests


about:
home: "https://github.com/fusion-energy/stl_to_h5m"
license: MIT
license_family: MIT
license_file: LICENSE.txt
doc_url: https://github.com/fusion-energy/stl_to_h5m
dev_url: https://github.com/fusion-energy/stl_to_h5m
summary: stl_to_h5m - Converts STL files to a DAGMC h5m file using PyMoab

extra:
recipe-maintainers:
- shimwell
32 changes: 32 additions & 0 deletions conda_build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@

#assumes anaconda-client and conda-build have been installed
# conda install -y anaconda-client
# conda install -y conda-build
# anaconda login

#cleans up files that get uploaded to the anaconda repo if not deleted
find . -name \*.stl -type f -delete


rm -rf /tmp/conda-build
mkdir -p /tmp/conda-build
rm -rf /tmp/conda-build

conda-build conda/ -c conda-forge --croot /tmp/conda-build

# converting using all includes quite a few oxs and linux versions.
# conda convert /tmp/conda-build/linux-64/*.tar.bz2 --platform all -o /tmp/conda-build

# option for converting package to specified platforms
# currently there is no moab conda install on win-64
platforms=( osx-64 linux-64 )
find /tmp/conda-build/linux-64/ -name *.tar.bz2 | while read file
do
echo $file
for platform in "${platforms[@]}"
do
conda convert --platform $platform $file -o /tmp/conda-build/
done
done

anaconda upload -f /tmp/conda-build/*/*.tar.bz2
7 changes: 7 additions & 0 deletions conda_build_config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
python:
- 3.10
- 3.9
- 3.8
- 3.7
moab:
- 5.3.1
10 changes: 10 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
[build-system]
requires = [
"setuptools >= 45",
"wheel",
"setuptools_scm[toml] >= 6.2",
]
build-backend = "setuptools.build_meta"

[tool.setuptools_scm]
write_to = "stl_to_h5m/_version.py"
4 changes: 0 additions & 4 deletions requirements-test.txt

This file was deleted.

2 changes: 0 additions & 2 deletions requirements.txt

This file was deleted.

38 changes: 38 additions & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
[metadata]
name = stl_to_h5m
author = The stl_to_h5m Development Team
author_email = mail@jshimwell.com
description = Converts STL files to a DAGMC h5m file using PyMoab
long_description = file: README.md
long_description_content_type = text/markdown
url = https://github.com/fusion-energy/stl_to_h5m
license = MIT
license_file = LICENSE.txt
classifiers =
Natural Language :: English
Topic :: Scientific/Engineering
Programming Language :: Python :: 3
Programming Language :: Python :: 3.6
Programming Language :: Python :: 3.7
Programming Language :: Python :: 3.8
Programming Language :: Python :: 3.9
License :: OSI Approved :: MIT License
Operating System :: OS Independent
project_urls =
Source = https://github.com/fusion-energy/stl_to_h5m
Tracker = https://github.com/fusion-energy/stl_to_h5m/issues

[options]
packages = find:
python_requires= >=3.6
install_requires=
numpy >= 1.21.1
# moab is required as well but installed via conda

[options.extras_require]
tests =
pytest >= 5.4.3
dagmc_h5m_file_inspector

[flake8]
per-file-ignores = __init__.py:F401
40 changes: 2 additions & 38 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,40 +1,4 @@
import setuptools

with open("README.md", "r") as fh:
long_description = fh.read()

setuptools.setup(
name="stl_to_h5m",
version="develop",
author="The stl_to_h5m Development Team",
author_email="mail@jshimwell.com",
description="Converts STL files to a DAGMC h5m file using PyMoab",
long_description=long_description,
long_description_content_type="text/markdown",
url="https://github.com/fusion-energy/stl_to_h5m",
packages=setuptools.find_packages(),
package_data={
"stl_to_h5m": [
"requirements.txt",
"README.md",
"LICENSE",
"tests/*.stl",
]
},
classifiers=[
'Natural Language :: English',
'Topic :: Scientific/Engineering',
'Programming Language :: Python :: 3',
'Programming Language :: Python :: 3.6',
'Programming Language :: Python :: 3.7',
'Programming Language :: Python :: 3.8',
'Programming Language :: Python :: 3.9',
'License :: OSI Approved :: MIT License',
'Operating System :: OS Independent',
],
python_requires='>=3.6',
install_requires=[
"numpy",
# 'pymoab' currently only available via conda-forge
],
)
if __name__ == "__main__":
setuptools.setup()
8 changes: 2 additions & 6 deletions stl_to_h5m/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,12 +44,8 @@ def stl_to_h5m(
material_tag = entry[1]

moab_core = _add_stl_to_moab_core(
moab_core,
surface_id,
volume_id,
material_tag,
moab_tags,
stl_filename)
moab_core, surface_id, volume_id, material_tag, moab_tags, stl_filename
)
volume_id += 1
surface_id += 1

Expand Down
19 changes: 5 additions & 14 deletions tests/test_python_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,7 @@ def test_h5m_file_creation_and_contents(self):
os.system(f"rm {test_h5m_filename}")

returned_filename = stl_to_h5m(
files_with_tags=[
("tests/part2.stl", "mat1")
],
files_with_tags=[("tests/part2.stl", "mat1")],
h5m_filename=test_h5m_filename,
)

Expand All @@ -29,8 +27,7 @@ def test_h5m_file_creation_and_contents(self):
assert test_h5m_filename == returned_filename
assert di.get_volumes_from_h5m(test_h5m_filename) == [1]
assert di.get_materials_from_h5m(test_h5m_filename) == ["mat1"]
assert di.get_volumes_and_materials_from_h5m(
test_h5m_filename) == {1: "mat1"}
assert di.get_volumes_and_materials_from_h5m(test_h5m_filename) == {1: "mat1"}

def test_h5m_file_creation_and_contents_in_subfolder(self):
"""Checks that a h5m file is created in a subfolder from a single stl
Expand All @@ -40,9 +37,7 @@ def test_h5m_file_creation_and_contents_in_subfolder(self):
os.system(f"rm {test_h5m_filename}")

returned_filename = stl_to_h5m(
files_with_tags=[
("tests/part1.stl", "mat1")
],
files_with_tags=[("tests/part1.stl", "mat1")],
h5m_filename=test_h5m_filename,
)

Expand All @@ -51,8 +46,7 @@ def test_h5m_file_creation_and_contents_in_subfolder(self):
assert test_h5m_filename == returned_filename
assert di.get_volumes_from_h5m(test_h5m_filename) == [1]
assert di.get_materials_from_h5m(test_h5m_filename) == ["mat1"]
assert di.get_volumes_and_materials_from_h5m(
test_h5m_filename) == {1: "mat1"}
assert di.get_volumes_and_materials_from_h5m(test_h5m_filename) == {1: "mat1"}

def test_h5m_file_creation_and_contents_from_multiple_h5m_files(self):
"""Checks that a h5m file is created from multiple stl files"""
Expand All @@ -61,10 +55,7 @@ def test_h5m_file_creation_and_contents_from_multiple_h5m_files(self):
os.system(f"rm {test_h5m_filename}")

returned_filename = stl_to_h5m(
files_with_tags=[
("tests/part1.stl", "mat1"),
("tests/part2.stl", "mat2")
],
files_with_tags=[("tests/part1.stl", "mat1"), ("tests/part2.stl", "mat2")],
h5m_filename=test_h5m_filename,
)

Expand Down

0 comments on commit e10e4c1

Please sign in to comment.