Skip to content

Commit

Permalink
Merge pull request #17 from fusion-energy/develop
Browse files Browse the repository at this point in the history
updated install and optional coolprops for python3.9 support
  • Loading branch information
shimwell authored Feb 15, 2022
2 parents 859bc74 + 89fef67 commit 79a7f6a
Show file tree
Hide file tree
Showing 20 changed files with 1,002 additions and 710 deletions.
12 changes: 7 additions & 5 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,21 +9,22 @@ version: 2.1
jobs:
build:
docker:
- image: openmc/openmc:develop
- image: continuumio/miniconda3:4.9.2

working_directory: ~/repo

steps:
- checkout
- run:
name: install
command:
pip install .
command: |
conda install -c conda-forge openmc==0.13.0
pip install .[density,tests]
# run tests!
- run:
name: run tests
command:
command:
pytest tests -v --cov=neutronics_material_maker --cov-report term --cov-report html:htmlcov --cov-report xml --junitxml=test-reports/junit.xml
- store_test_results:
path: test-reports
Expand All @@ -32,6 +33,7 @@ jobs:
path: test-reports
- run:
name: install curl
command:
command: |
apt-get --allow-releaseinfo-change update
apt-get update && apt-get -y install curl
- run: curl -s https://codecov.io/bash | bash
17 changes: 3 additions & 14 deletions .github/workflows/python-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,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/*
140 changes: 110 additions & 30 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,52 +1,132 @@
# Compiled python modules.
**.pyc

.eggs/

# Setuptools distribution folder.
/dist/
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class

# Python egg metadata, regenerated from source files by setuptools.
/*.egg-info
# C extensions
*.so

*.pyo
# Distribution / packaging
.Python
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
wheels/
pip-wheel-metadata/
share/python-wheels/
*.egg-info/
.installed.cfg
*.egg
MANIFEST

# PyInstaller
# Usually these files are written by a python script from a template
# before PyInstaller builds the exe, so as to inject date/other infos into it.
*.manifest
*.spec

# Installer logs
pip-log.txt
pip-delete-this-directory.txt

# Unit test / coverage reports
htmlcov/
.tox/
.nox/
.coverage
.coverage.*
.cache
nosetests.xml
coverage.xml
*.cover
*.py,cover
.hypothesis/
.pytest_cache/

__pycache__/
# Translations
*.mo
*.pot

.idea/
# Django stuff:
*.log
local_settings.py
db.sqlite3
db.sqlite3-journal

.gitignore
# Flask stuff:
instance/
.webassets-cache

.ipynb_checkpoints/
# Scrapy stuff:
.scrapy

.pytest_cache/
# Sphinx documentation
docs/_build/

*.py[cod]
# PyBuilder
target/

build/
# Jupyter Notebook
.ipynb_checkpoints

neutronics_material_maker.egg-info/
# IPython
profile_default/
ipython_config.py

.ipynb_checkpoints/
# pyenv
.python-version

dist_pac.sh
# pipenv
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
# However, in case of collaboration, if having platform-specific dependencies or dependencies
# having no cross-platform support, pipenv may install dependencies that don't work, or not
# install all needed dependencies.
#Pipfile.lock

setup.cfg
# PEP 582; used by e.g. github.com/David-OConnor/pyflow
__pypackages__/

twine_upload.sh
# Celery stuff
celerybeat-schedule
celerybeat.pid

upload.sh
# SageMath parsed files
*.sage.py

setup.py___jb_old___
# Environments
.env
.venv
env/
venv/
ENV/
env.bak/
venv.bak/

setup.py___jb_tmp___
# Spyder project settings
.spyderproject
.spyproject

.coverage
# Rope project settings
.ropeproject

refs/
# mkdocs documentation
/site

new_materials/
# mypy
.mypy_cache/
.dmypy.json
dmypy.json

.vscode/
# Pyre type checker
.pyre/

.tox/
# file containing version number
_version.py
26 changes: 5 additions & 21 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,35 +1,19 @@
# build with the following command
# sudo docker build -t neutronics_material_maker .

FROM ubuntu:18.04
FROM continuumio/miniconda3:4.9.2

# Updating Ubuntu packages
RUN apt-get update && yes|apt-get upgrade

# Adding wget and bzip2
RUN apt-get install -y wget bzip2

# Anaconda installing
RUN wget https://repo.continuum.io/archive/Anaconda3-2020.02-Linux-x86_64.sh

RUN bash Anaconda3-2020.02-Linux-x86_64.sh -b

RUN rm Anaconda3-2020.02-Linux-x86_64.sh

# Set path to conda
ENV PATH /root/anaconda3/bin:$PATH

# install openmc from conda involves less sets compared to compiling it from source
# install openmc from conda
RUN conda install -c conda-forge openmc


# install endf nuclear data

# clone the openmc nuclear data repository
RUN apt-get update
RUN apt-get install -y git

# clone the openmc nuclear data repository
RUN git clone https://github.com/openmc-dev/data.git

# install endf nuclear data
# run script that converts ACE data to hdf5 data
RUN python data/convert_nndc71.py --cleanup

Expand Down
4 changes: 0 additions & 4 deletions MANIFEST.in

This file was deleted.

22 changes: 17 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,24 +26,36 @@ temperature and pressure.

## Installation

### Conda

To use the code you will need to have OpenMC installed
[OpenMC](https://docs.openmc.org/en/latest/quickinstall.html).

The recommended method is to install from
[Conda Forge](https://conda-forge.org) which also installs all the dependencies
including OpenMC.

```
```bash
conda create --name new_env python=3.8
conda activate new_env
conda install neutronics_material_maker -c conda-forge
```
### Pip
Alternatively the code can be easily installed using pip. This method doesn't
currently include OpenMC so that will have to be installed separately using
Conda or compiled.

Alternatively the code can be easily installed using pip (which doesn't
currently include OpenMC)

```
```bash
pip install neutronics_material_maker
```

To include the optional capability of calculating the density of coolants
additional packages are needed (CoolProp). A slightly modified pip install
is required in this case.
```bash
pip install "neutronics_material_maker[density]"
```

## Features

Materials for using in neutronics codes have two main aspects; a list of
Expand Down
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
5 changes: 1 addition & 4 deletions docs/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,7 @@
# Add any Sphinx extension module names here, as strings. They can be
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
# ones.
extensions = [
"sphinx.ext.autodoc",
"sphinx.ext.coverage",
"sphinx.ext.napoleon"]
extensions = ["sphinx.ext.autodoc", "sphinx.ext.coverage", "sphinx.ext.napoleon"]

# Add any paths that contain templates here, relative to this directory.
templates_path = ["_templates"]
Expand Down
10 changes: 9 additions & 1 deletion docs/source/install.rst
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ environment.
Install (conda + pip)
---------------------

Create a new environment (Python 3.6, 3.7 or 3.8 are supported).
Create a new environment (Python 3.6, 3.7, 3.8, 3.9 are supported).

.. code-block:: bash
Expand Down Expand Up @@ -76,3 +76,11 @@ Then pip install the package.
Now you should be ready to import neutronics-material-maker from your new python
environment.

To include the optional capability of calculating the density of coolants
additional packages are needed (CoolProp). A slightly modified pip install
is required in this case.

.. code-block:: bash
pip install "neutronics_material_maker[density]"
13 changes: 13 additions & 0 deletions neutronics_material_maker/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,16 @@
try:
from importlib.metadata import version, PackageNotFoundError
except (ModuleNotFoundError, ImportError):
from importlib_metadata import version, PackageNotFoundError
try:
__version__ = version("neutronics_material_maker")
except PackageNotFoundError:
from setuptools_scm import get_version

__version__ = get_version(root="..", relative_to=__file__)

__all__ = ["__version__"]

from .utils import make_fispact_material
from .utils import make_serpent_material
from .utils import make_mcnp_material
Expand Down
Loading

0 comments on commit 79a7f6a

Please sign in to comment.