Skip to content

Commit 8de715d

Browse files
authored
Merge pull request #54 from neutrons/create-conda-packaging
Move to pyproject.toml
2 parents f184ebf + 0e696ed commit 8de715d

23 files changed

+211
-2544
lines changed

.github/workflows/actions.yml

Lines changed: 0 additions & 79 deletions
This file was deleted.

.github/workflows/package.yml

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
name: conda packaging and deployment
2+
3+
on:
4+
workflow_dispatch:
5+
push:
6+
branches: [master]
7+
tags: ['v*']
8+
9+
jobs:
10+
linux:
11+
runs-on: ubuntu-latest
12+
defaults:
13+
run:
14+
shell: bash -l {0}
15+
steps:
16+
- uses: actions/checkout@v3
17+
- uses: conda-incubator/setup-miniconda@v2
18+
with:
19+
auto-update-conda: true
20+
channels: conda-forge,defaults
21+
mamba-version: "*"
22+
environment-file: environment.yml
23+
cache-environment-key: ${{ runner.os }}-env-${{ hashFiles('**/environment.yml') }}
24+
cache-downloads-key: ${{ runner.os }}-downloads-${{ hashFiles('**/environment.yml') }}
25+
- name: install additional dependencies
26+
run: |
27+
echo "installing additional dependencies from environment_development.yml"
28+
- name: build conda package
29+
run: |
30+
# set up environment
31+
cd conda.recipe
32+
echo "versioningit $(versioningit ../)"
33+
# build the package
34+
VERSION=$(versioningit ../) conda mambabuild --output-folder . .
35+
conda verify noarch/pystog*.tar.bz2
36+
- name: upload conda package to anaconda
37+
shell: bash -l {0}
38+
if: startsWith(github.ref, 'refs/tags/v')
39+
env:
40+
ANACONDA_API_TOKEN: ${{ secrets.ANACONDA_TOKEN }}
41+
IS_RC: ${{ contains(github.ref, 'rc') }}
42+
run: |
43+
# label is main or rc depending on the tag-name
44+
CONDA_LABEL="master"
45+
if [ "${IS_RC}" = "true" ]; then CONDA_LABEL="rc"; fi
46+
echo pushing ${{ github.ref }} with label $CONDA_LABEL
47+
anaconda upload --label $CONDA_LABEL conda.recipe/noarch/pystog*.tar.bz2

.github/workflows/test.yml

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
name: test
2+
3+
on:
4+
workflow_dispatch:
5+
pull_request:
6+
push:
7+
branches: [master]
8+
tags: ['v*']
9+
10+
jobs:
11+
linux:
12+
runs-on: ubuntu-latest
13+
defaults:
14+
run:
15+
shell: bash -l {0}
16+
steps:
17+
- uses: actions/checkout@v3
18+
- uses: conda-incubator/setup-miniconda@v2
19+
with:
20+
auto-update-conda: true
21+
channels: conda-forge,defaults
22+
mamba-version: "*"
23+
environment-file: environment.yml
24+
cache-environment-key: ${{ runner.os }}-env-${{ hashFiles('**/environment.yml') }}
25+
cache-downloads-key: ${{ runner.os }}-downloads-${{ hashFiles('**/environment.yml') }}
26+
- name: install additional dependencies
27+
run: |
28+
echo "installing additional dependencies if cannot be installed from conda"
29+
- name: run tests
30+
run: |
31+
echo "running tests"
32+
python -m pytest --cov=src --cov-report=xml --cov-report=term-missing tests/
33+
- name: upload coverage to codecov
34+
uses: codecov/codecov-action@v4
35+
with:
36+
token: ${{ secrets.CODECOV_TOKEN }}
37+
- name: build conda package
38+
run: |
39+
# test that the conda package builds
40+
cd conda.recipe
41+
echo "versioningit $(versioningit ../)"
42+
# conda channels could have been defined in the conda-incubator, but you can copy/paste the lines
43+
# below to build the conda package in your local machine
44+
VERSION=$(versioningit ../) conda mambabuild --output-folder . .
45+
conda verify noarch/pystog*.tar.bz2

Pipfile

Lines changed: 0 additions & 21 deletions
This file was deleted.

conda.recipe/meta.yaml

Lines changed: 25 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,41 @@
1-
{% set data = load_setup_py_data() %}
1+
# load information from pyproject.toml
2+
{% set pyproject = load_file_data('pyproject.toml') %}
3+
{% set project = pyproject.get('project', {}) %}
4+
{% set license = project.get('license').get('text') %}
5+
{% set description = project.get('description') %}
6+
{% set project_url = pyproject.get('project', {}).get('urls') %}
7+
{% set url = project_url.get('homepage') %}
8+
# this will get the version set by environment variable
9+
{% set version = environ.get('VERSION') %}
10+
{% set version_number = version.split('+')[0] %}
11+
{% set git_describe_number = environ.get('GIT_DESCRIBE_NUMBER', '0') | string %}
212

313
package:
414
name: pystog
5-
version: "{{ data['version'] }}"
15+
version: {{ version_number }}
616

717
source:
818
path: ..
919

1020
build:
1121
noarch: python
22+
number: {{ git_describe_number }}
1223
string: py{{py}}
13-
script: python setup.py install --single-version-externally-managed --record=record.txt
14-
entry_points:
15-
- pystog_cli = pystog.cli:pystog_cli
24+
script: {{ PYTHON }} -m pip install . --no-deps --ignore-installed -vvv
25+
#entry_points:
26+
# - pystog_cli = pystog.cli:pystog_cli
1627

1728
requirements:
29+
host:
30+
- python
31+
- versioningit
1832
build:
33+
- setuptools
34+
- versioningit
1935
- numpy
2036
- h5py
2137
run:
38+
- python
2239
- numpy
2340
- h5py
2441

@@ -28,9 +45,9 @@ test:
2845
- pystog.stog
2946

3047
about:
31-
home: https://github.com/neutrons/pystog
32-
license: GPL (version 3)
33-
license_family: GPL3
48+
home: {{ url }}
49+
license: {{ license }}
50+
license_family: GPL
3451
license_file:
3552
summary: "Transforms reciprocal and real space total scattering functions"
3653

environment.yml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
name: pystog
2+
channels:
3+
- conda-forge
4+
dependencies:
5+
- h5py
6+
- numpy
7+
- pytest
8+
- pytest-cov
9+
- versioningit
10+
# packaging
11+
- anaconda-client
12+
- boa
13+
- conda-build < 4
14+
- conda-verify
15+
- libmamba
16+
- libarchive
17+
- python-build

pyproject.toml

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
[project]
2+
name = "pystog"
3+
description = "Total scattering function manipulator"
4+
dynamic = ["version"]
5+
requires-python = ">=3.6"
6+
dependencies = [
7+
# list all runtime dependencies here
8+
]
9+
license = { text = "GPL3.0" }
10+
11+
[project.urls]
12+
homepage = "https://github.com/neutrons/pystog/" # if no homepage, use repo url
13+
14+
[build-system]
15+
requires = [
16+
"setuptools >= 40.6.0",
17+
"wheel",
18+
"toml",
19+
"versioningit"
20+
]
21+
build-backend = "setuptools.build_meta"
22+
23+
[tool.black]
24+
line-length = 119
25+
26+
[tool.versioningit.vcs]
27+
method = "git"
28+
default-tag = "0.0.1"
29+
30+
[tool.versioningit.next-version]
31+
method = "minor"
32+
33+
[tool.versioningit.format]
34+
distance = "{next_version}.dev{distance}"
35+
dirty = "{version}+d{build_date:%Y%m%d}"
36+
distance-dirty = "{next_version}.dev{distance}+d{build_date:%Y%m%d%H%M}"
37+
38+
[tool.versioningit.write]
39+
file = "src/pystog/_version.py"
40+
41+
[tool.setuptools.packages.find]
42+
where = ["src"]
43+
exclude = ["fortran"]
44+
45+
[tool.setuptools.package-data]
46+
"*" = ["*.yml","*.yaml","*.ini"]
47+
48+
[project.scripts]
49+
pystog-cli = "pystog.cli:pystog_cli"
50+
51+
[tool.pytest.ini_options]
52+
pythonpath = [
53+
".", "src", "scripts"
54+
]
55+
testpaths = ["tests"]
56+
python_files = ["test*.py"]
57+
norecursedirs = [".git", "tmp*", "_tmp*", "__pycache__", "*dataset*", "*data_set*"]
58+
markers = [
59+
"mymarker: example markers goes here"
60+
]
61+
62+
[tool.ruff]
63+
line-length = 120
64+
select = ["A", "ARG","ASYNC","BLE","C90", "E", "F", "I", "N", "UP032", "W"]
65+
66+
# Add additional 3rd party tool configuration here as needed

0 commit comments

Comments
 (0)