Skip to content

Commit 965a0d6

Browse files
authored
Merge pull request #32 from openmc-data-storage/develop
update python setup
2 parents 6426e9e + e677bdd commit 965a0d6

File tree

8 files changed

+78
-60
lines changed

8 files changed

+78
-60
lines changed

.github/workflows/docker_ci_main.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ jobs:
2121

2222
- name: Setup package
2323
run: |
24-
python setup.py install
24+
pip install .
2525
2626
- name: test test_command_line_usage.py
2727
run: |

.github/workflows/python-publish.yml

Lines changed: 3 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -25,27 +25,16 @@ jobs:
2525
with:
2626
python-version: '3.x'
2727

28-
- name: Autobump version
29-
run: |
30-
# from refs/tags/v1.2.3 get 1.2.3
31-
VERSION=$(echo $GITHUB_REF | sed 's#.*/v##')
32-
PLACEHOLDER='version="develop"'
33-
VERSION_FILE='setup.py'
34-
# Grep checks that the placeholder is in the file. If grep doesn't find
35-
# the placeholder then it exits with exit code 1 and github actions fails.
36-
grep "$PLACEHOLDER" "$VERSION_FILE"
37-
sed -i "s@$PLACEHOLDER@version=\"${VERSION}\"@g" "$VERSION_FILE"
38-
shell: bash
39-
4028
- name: Install dependencies
4129
run: |
4230
python -m pip install --upgrade pip
43-
pip install setuptools wheel twine
31+
pip install setuptools wheel build twine
4432
4533
- name: Build and publish
4634
env:
4735
TWINE_USERNAME: __token__
4836
TWINE_PASSWORD: ${{ secrets.PYPI_API_TOKEN }}
4937
run: |
50-
python setup.py sdist bdist_wheel
38+
python -m build
39+
twine check dist/*
5140
twine upload dist/*

.gitignore

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,4 +130,6 @@ dmypy.json
130130

131131
# OpenMC files
132132
*.xml
133-
*.h5
133+
*.h5
134+
135+
**_version.py

conda/meta.yaml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,9 @@ test:
3434
source_files:
3535
- tests/
3636
commands:
37-
- pytest tests
38-
37+
- pytest tests/test_command_line_usage.py
38+
- pytest tests/test_functions.py
39+
# test_use_in_openmc.py skipped for now as test is failing for upstream bug
3940

4041
about:
4142
home: "https://github.com/openmc-data-storage/openmc_data_downloader"

openmc_data_downloader/__init__.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,18 @@
1+
try:
2+
# this works for python 3.7 and lower
3+
from importlib.metadata import version, PackageNotFoundError
4+
except (ModuleNotFoundError, ImportError):
5+
# this works for python 3.8 and higher
6+
from importlib_metadata import version, PackageNotFoundError
7+
try:
8+
__version__ = version("openmc_data_downloader")
9+
except PackageNotFoundError:
10+
from setuptools_scm import get_version
11+
12+
__version__ = get_version(root="..", relative_to=__file__)
13+
14+
__all__ = ["__version__"]
15+
116
from .cross_sections_directory import (
217
NATURAL_ABUNDANCE,
318
LIB_OPTIONS,

pyproject.toml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
[build-system]
2+
requires = [
3+
"setuptools >= 46.4.0",
4+
"wheel",
5+
"setuptools_scm[toml] >= 6.3.1",
6+
]
7+
build-backend = "setuptools.build_meta"
8+
9+
[tool.setuptools_scm]
10+
write_to = "openmc_data_downloader/_version.py"

setup.cfg

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
[metadata]
2+
name = openmc_data_downloader
3+
version = attr: openmc_data_downloader.__version__
4+
author = The openmc_data_downloader Development Team
5+
author_email = [email protected]
6+
description = A tool for selectively downloading h5 files for specified isotopes / elements from your libraries of choice
7+
long_description = file: README.md
8+
long_description_content_type = text/markdown
9+
url = https://github.com/openmc-data-storage/openmc_data_downloader
10+
license = MIT
11+
license_file = LICENSE
12+
classifiers =
13+
Natural Language :: English
14+
Topic :: Scientific/Engineering
15+
Programming Language :: Python :: 3
16+
Programming Language :: Python :: 3.7
17+
Programming Language :: Python :: 3.8
18+
Programming Language :: Python :: 3.9
19+
Programming Language :: Python :: 3.10
20+
License :: OSI Approved :: MIT License
21+
Operating System :: OS Independent
22+
project_urls =
23+
Source = https://github.com/openmc-data-storage/openmc_data_downloader
24+
Tracker = https://github.com/openmc-data-storage/openmc_data_downloader/issues
25+
26+
[options]
27+
packages = find:
28+
scripts =
29+
openmc_data_downloader/openmc_data_downloader
30+
python_requires= >=3.7
31+
install_requires=
32+
pandas
33+
retry
34+
# 'openmc' is optional for this package but is not available via pip install at the moment
35+
36+
[options.extras_require]
37+
tests =
38+
pytest >= 5.4.3
39+
40+
[flake8]
41+
per-file-ignores = __init__.py:F401

setup.py

Lines changed: 2 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -1,44 +1,4 @@
11
import setuptools
22

3-
with open("README.md", "r") as fh:
4-
long_description = fh.read()
5-
6-
setuptools.setup(
7-
name="openmc_data_downloader",
8-
version="develop",
9-
summary="Download cross section h5 files for use in OpenMC",
10-
author="Jonathan Shimwell",
11-
author_email="[email protected]",
12-
description="A tool for selectively downloading h5 files for specified isotopes / elements from your libraries of choice",
13-
long_description=long_description,
14-
long_description_content_type="text/markdown",
15-
url="https://github.com/openmc-data-storage/openmc_data_downloader",
16-
packages=setuptools.find_packages(),
17-
zip_safe=True,
18-
package_dir={"openmc_data_downloader": "openmc_data_downloader"},
19-
scripts=["openmc_data_downloader/openmc_data_downloader"],
20-
package_data={
21-
"openmc_data_downloader": [
22-
"requirements.txt",
23-
"README.md",
24-
"LICENSE",
25-
]
26-
},
27-
classifiers=[
28-
"Natural Language :: English",
29-
"Topic :: Scientific/Engineering",
30-
"Programming Language :: Python :: 3",
31-
"Programming Language :: Python :: 3.6",
32-
"Programming Language :: Python :: 3.7",
33-
"Programming Language :: Python :: 3.8",
34-
"Programming Language :: Python :: 3.9",
35-
"License :: OSI Approved :: MIT License",
36-
"Operating System :: OS Independent",
37-
],
38-
tests_require=["pytest-cov", "pytest-runner"],
39-
install_requires=[
40-
"pandas",
41-
"retry",
42-
# 'openmc' is optional for this package but is not available via pip install at the moment
43-
],
44-
)
3+
if __name__ == "__main__":
4+
setuptools.setup()

0 commit comments

Comments
 (0)