Skip to content

Commit

Permalink
Merge pull request #54 from neutrons/create-conda-packaging
Browse files Browse the repository at this point in the history
Move to pyproject.toml
  • Loading branch information
Kvieta1990 authored Jun 3, 2024
2 parents f184ebf + 0e696ed commit 8de715d
Show file tree
Hide file tree
Showing 23 changed files with 211 additions and 2,544 deletions.
79 changes: 0 additions & 79 deletions .github/workflows/actions.yml

This file was deleted.

47 changes: 47 additions & 0 deletions .github/workflows/package.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
name: conda packaging and deployment

on:
workflow_dispatch:
push:
branches: [master]
tags: ['v*']

jobs:
linux:
runs-on: ubuntu-latest
defaults:
run:
shell: bash -l {0}
steps:
- uses: actions/checkout@v3
- uses: conda-incubator/setup-miniconda@v2
with:
auto-update-conda: true
channels: conda-forge,defaults
mamba-version: "*"
environment-file: environment.yml
cache-environment-key: ${{ runner.os }}-env-${{ hashFiles('**/environment.yml') }}
cache-downloads-key: ${{ runner.os }}-downloads-${{ hashFiles('**/environment.yml') }}
- name: install additional dependencies
run: |
echo "installing additional dependencies from environment_development.yml"
- name: build conda package
run: |
# set up environment
cd conda.recipe
echo "versioningit $(versioningit ../)"
# build the package
VERSION=$(versioningit ../) conda mambabuild --output-folder . .
conda verify noarch/pystog*.tar.bz2
- name: upload conda package to anaconda
shell: bash -l {0}
if: startsWith(github.ref, 'refs/tags/v')
env:
ANACONDA_API_TOKEN: ${{ secrets.ANACONDA_TOKEN }}
IS_RC: ${{ contains(github.ref, 'rc') }}
run: |
# label is main or rc depending on the tag-name
CONDA_LABEL="master"
if [ "${IS_RC}" = "true" ]; then CONDA_LABEL="rc"; fi
echo pushing ${{ github.ref }} with label $CONDA_LABEL
anaconda upload --label $CONDA_LABEL conda.recipe/noarch/pystog*.tar.bz2
45 changes: 45 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
name: test

on:
workflow_dispatch:
pull_request:
push:
branches: [master]
tags: ['v*']

jobs:
linux:
runs-on: ubuntu-latest
defaults:
run:
shell: bash -l {0}
steps:
- uses: actions/checkout@v3
- uses: conda-incubator/setup-miniconda@v2
with:
auto-update-conda: true
channels: conda-forge,defaults
mamba-version: "*"
environment-file: environment.yml
cache-environment-key: ${{ runner.os }}-env-${{ hashFiles('**/environment.yml') }}
cache-downloads-key: ${{ runner.os }}-downloads-${{ hashFiles('**/environment.yml') }}
- name: install additional dependencies
run: |
echo "installing additional dependencies if cannot be installed from conda"
- name: run tests
run: |
echo "running tests"
python -m pytest --cov=src --cov-report=xml --cov-report=term-missing tests/
- name: upload coverage to codecov
uses: codecov/codecov-action@v4
with:
token: ${{ secrets.CODECOV_TOKEN }}
- name: build conda package
run: |
# test that the conda package builds
cd conda.recipe
echo "versioningit $(versioningit ../)"
# conda channels could have been defined in the conda-incubator, but you can copy/paste the lines
# below to build the conda package in your local machine
VERSION=$(versioningit ../) conda mambabuild --output-folder . .
conda verify noarch/pystog*.tar.bz2
21 changes: 0 additions & 21 deletions Pipfile

This file was deleted.

33 changes: 25 additions & 8 deletions conda.recipe/meta.yaml
Original file line number Diff line number Diff line change
@@ -1,24 +1,41 @@
{% set data = load_setup_py_data() %}
# load information from pyproject.toml
{% set pyproject = load_file_data('pyproject.toml') %}
{% set project = pyproject.get('project', {}) %}
{% set license = project.get('license').get('text') %}
{% set description = project.get('description') %}
{% set project_url = pyproject.get('project', {}).get('urls') %}
{% set url = project_url.get('homepage') %}
# this will get the version set by environment variable
{% set version = environ.get('VERSION') %}
{% set version_number = version.split('+')[0] %}
{% set git_describe_number = environ.get('GIT_DESCRIBE_NUMBER', '0') | string %}

package:
name: pystog
version: "{{ data['version'] }}"
version: {{ version_number }}

source:
path: ..

build:
noarch: python
number: {{ git_describe_number }}
string: py{{py}}
script: python setup.py install --single-version-externally-managed --record=record.txt
entry_points:
- pystog_cli = pystog.cli:pystog_cli
script: {{ PYTHON }} -m pip install . --no-deps --ignore-installed -vvv
#entry_points:
# - pystog_cli = pystog.cli:pystog_cli

requirements:
host:
- python
- versioningit
build:
- setuptools
- versioningit
- numpy
- h5py
run:
- python
- numpy
- h5py

Expand All @@ -28,9 +45,9 @@ test:
- pystog.stog

about:
home: https://github.com/neutrons/pystog
license: GPL (version 3)
license_family: GPL3
home: {{ url }}
license: {{ license }}
license_family: GPL
license_file:
summary: "Transforms reciprocal and real space total scattering functions"

Expand Down
17 changes: 17 additions & 0 deletions environment.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
name: pystog
channels:
- conda-forge
dependencies:
- h5py
- numpy
- pytest
- pytest-cov
- versioningit
# packaging
- anaconda-client
- boa
- conda-build < 4
- conda-verify
- libmamba
- libarchive
- python-build
66 changes: 66 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
[project]
name = "pystog"
description = "Total scattering function manipulator"
dynamic = ["version"]
requires-python = ">=3.6"
dependencies = [
# list all runtime dependencies here
]
license = { text = "GPL3.0" }

[project.urls]
homepage = "https://github.com/neutrons/pystog/" # if no homepage, use repo url

[build-system]
requires = [
"setuptools >= 40.6.0",
"wheel",
"toml",
"versioningit"
]
build-backend = "setuptools.build_meta"

[tool.black]
line-length = 119

[tool.versioningit.vcs]
method = "git"
default-tag = "0.0.1"

[tool.versioningit.next-version]
method = "minor"

[tool.versioningit.format]
distance = "{next_version}.dev{distance}"
dirty = "{version}+d{build_date:%Y%m%d}"
distance-dirty = "{next_version}.dev{distance}+d{build_date:%Y%m%d%H%M}"

[tool.versioningit.write]
file = "src/pystog/_version.py"

[tool.setuptools.packages.find]
where = ["src"]
exclude = ["fortran"]

[tool.setuptools.package-data]
"*" = ["*.yml","*.yaml","*.ini"]

[project.scripts]
pystog-cli = "pystog.cli:pystog_cli"

[tool.pytest.ini_options]
pythonpath = [
".", "src", "scripts"
]
testpaths = ["tests"]
python_files = ["test*.py"]
norecursedirs = [".git", "tmp*", "_tmp*", "__pycache__", "*dataset*", "*data_set*"]
markers = [
"mymarker: example markers goes here"
]

[tool.ruff]
line-length = 120
select = ["A", "ARG","ASYNC","BLE","C90", "E", "F", "I", "N", "UP032", "W"]

# Add additional 3rd party tool configuration here as needed
Loading

0 comments on commit 8de715d

Please sign in to comment.