Skip to content

Commit

Permalink
Merge pull request #50 from MC-kit/devel
Browse files Browse the repository at this point in the history
Devel
  • Loading branch information
dvp2015 authored Jan 9, 2021
2 parents db25d8c + f616a60 commit d67309d
Show file tree
Hide file tree
Showing 9 changed files with 46 additions and 32 deletions.
28 changes: 15 additions & 13 deletions .github/workflows/test-pypi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ jobs:
runs-on: ubuntu-latest
if: |
!startsWith(github.event.head_commit.message, 'bump:') &&
!startsWith(github.event.head_commit.message, 'ci:') &&
!contains(github.event.head_commit.message, '[skip_ci]')
steps:
- name: Checkout repository
Expand All @@ -31,7 +30,7 @@ jobs:
run: |
set -e
python -m ensurepip
python -m pip install -U pip
python -m pip install -U pip wheel
pip install poetry==1.1.4
- name: Run Safety test
run: nox -s safety
Expand All @@ -42,16 +41,15 @@ jobs:
runs-on: "${{ matrix.os }}"
if: |
!startsWith(github.event.head_commit.message, 'bump:') &&
!startsWith(github.event.head_commit.message, 'ci:') &&
!contains(github.event.head_commit.message, '[skip_ci]')
strategy:
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
python-version: ['3.7', '3.8', '3.9']
exclude:
- os: windows-latest
python-version: 3.7 # py37 on Windows takes too much, and it wants nlopt.dll
fail-fast: false
matrix:
os: [ubuntu-latest] # , macos-latest, windows-latest]
python-version: ['3.9'] #, '3.8', '3.7']
# exclude:
# - os: windows-latest
# python-version: 3.7 # py37 on Windows takes too much, and it wants nlopt.dll
steps:
- uses: actions/checkout@v2
- uses: actions/setup-python@v1
Expand All @@ -62,7 +60,7 @@ jobs:
run: |
set -e
python -m ensurepip
python -m pip install -U pip
python -m pip install -U pip wheel
pip install poetry==1.1.4
- run: |
set -e
Expand All @@ -72,15 +70,19 @@ jobs:
- name: Checkout submodules
run: git submodule update --init --recursive --depth=1
- run: poetry install --no-dev
- run: poetry build
- name: Build wheel
run: poetry build -f wheel
- name: Build sdist
run: python setup-generated.py sdist --formats=gztar,xztar,zip
if: matrix.os == 'ubuntu-latest' && matrix.python-version == '3.9'
- name: GitHub Release wheels (deploy)
if: (github.event_name == 'push' && startsWith(github.event.ref, 'refs/tags'))
uses: softprops/action-gh-release@v1
with:
files: dist/*.whl
files: dist/*
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Publish to PyPI
- name: Publish to TestPyPI
run: |
poetry config repositories.testpypi https://test.pypi.org/legacy/
poetry publish -r testpypi -u __token__ -p ${{ secrets.TEST_PYPI_TOKEN }}
19 changes: 16 additions & 3 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,24 @@ name: MCKit Tests

on:
push:
branches: ["master", "devel"]
branches:
- "master"
- "devel"
paths:
- "**.py"
- "**.c"
- "**.h"
- "**.yml"
pull_request:
branches: ["master", "devel"]
branches:
- "master"
- "devel"
# workflow_dispatch:

paths:
- "**.py"
- "**.c"
- "**.h"
- "**.yml"
jobs:
tests:
name: "Python ${{ matrix.python-version }} on ${{ matrix.os }}"
Expand Down
4 changes: 2 additions & 2 deletions build.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ def get_shared_lib_name(name: str) -> str:
if sys_name == "Linux":
if sys.platform.startswith("darwin"):
return f"lib{name}.dylib"
return f"lib{name}.so"
return f"lib{name}.so.0"
if sys_name == "Darwin":
return f"lib{name}.dylib"
if sys_name == "Windows":
Expand Down Expand Up @@ -55,7 +55,7 @@ def finalize_options(self):
def build_extension(self, extension: Extension) -> None:
assert extension.name == "mckit.geometry"
ext_dir = Path(self.get_ext_fullpath(extension.name)).parent.absolute()
nlopt_build_dir = build_nlopt(clean=False)
nlopt_build_dir = build_nlopt(clean=True)
nlopt_lib = nlopt_build_dir / get_shared_lib_name("nlopt")
log.info(f"---*** nlopt lib path: {nlopt_lib}")
build_ext.build_extension(self, extension)
Expand Down
4 changes: 2 additions & 2 deletions mckit/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
def get_shared_lib_name(name: str) -> str:
sys_name = platform.system()
if sys_name == "Linux":
return f"lib{name}.so.1"
return f"lib{name}.so"
if sys_name == "Darwin":
return f"lib{name}.dylib"
if sys_name == "Windows":
Expand Down Expand Up @@ -43,7 +43,7 @@ def find_file(_file: str, *directories: Path) -> Path:
os.environ.get("LD_LIBRARY_PATH") is None
): # a user can use other location form mkl library.
# preload library
mkl_lib_path = Path(sys.prefix, "lib", get_shared_lib_name("mkl_rt"))
mkl_lib_path = Path(sys.prefix, "lib", "libmkl_rt.so")
assert (
mkl_lib_path.exists()
), f"The MKL library should be either available at {mkl_lib_path}, or with LD_LIBRARY_PATH"
Expand Down
7 changes: 4 additions & 3 deletions mckit/utils/resource.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
import inspect
import pkg_resources as pkg

from pathlib import Path

import pkg_resources as pkg


def filename_resolver(package=None):
if package is None:
caller_package = inspect.getmodule(inspect.stack()[1][0]).__name__
package = caller_package
module = inspect.getmodule(inspect.stack()[1][0])
package = module.__name__

resource_manager = pkg.ResourceManager()

Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "mckit"
version = "0.5.8-alpha.0"
version = "0.5.9-alpha.0"
description = "Tools to process MCNP models and results"
authors = ["rrn <[email protected]>"]
maintainers = ["dpv2015 <[email protected]>"]
Expand Down
8 changes: 4 additions & 4 deletions tests/parser/test_mcnp_sly_parser.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
from typing import List, NamedTuple
import pytest

import pytest

from mckit.parser.mcnp_input_sly_parser import from_file, from_text, ParseResult
from mckit.parser.mcnp_input_sly_parser import ParseResult, from_file, from_text
from mckit.utils import filename_resolver

file_resolver = filename_resolver()
file_resolver = filename_resolver("tests.parser")


class TExpected(NamedTuple):
Expand Down Expand Up @@ -288,7 +288,7 @@ def test_mcnp_parser(parse_file, expected):
parse_file = file_resolver(parse_file)
result: ParseResult = from_file(parse_file)
assert expected["title"] == result.sections.title
# TODO dvp: orgainize correct comparison of result with expected data
# TODO dvp: organize correct comparison of result with expected data
# assert expected['cells'] == result.cells
# assert expected['surfaces'] == result.surfaces
# assert expected['data'] == result.data
4 changes: 2 additions & 2 deletions tests/test_mcnp_parser.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import pytest
import numpy as np
import pytest

from mckit.parser.mcnp_input_parser import mcnp_input_lexer, mcnp_input_parser
from mckit.parser.mctal_parser import read_mctal
from mckit.utils import filename_resolver

file_resolver = filename_resolver()
file_resolver = filename_resolver("tests")


@pytest.mark.parametrize(
Expand Down
2 changes: 0 additions & 2 deletions tests/utils/test_resource.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
# -*- coding: utf-8 -*-

import pytest

from mckit.utils.resource import Path, filename_resolver, path_resolver
Expand Down

0 comments on commit d67309d

Please sign in to comment.