Skip to content

Commit

Permalink
Merge pull request #276 from bluesky/267-versioning
Browse files Browse the repository at this point in the history
Update packaging to latest PyPA recommendations
  • Loading branch information
prjemian authored Oct 20, 2023
2 parents 299d39a + bb45fa5 commit ef74e8e
Show file tree
Hide file tree
Showing 18 changed files with 137 additions and 2,940 deletions.
2 changes: 1 addition & 1 deletion .coveragerc
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@ source=hkl

[report]
omit=
# ignore _version.py and versioneer.py
# ignore _version.py
.*version.*
*_version.py
2 changes: 0 additions & 2 deletions .flake8
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,7 @@ exclude =
__pycache__,
build,
dist,
versioneer.py,
docs/source,
hkl/_version.py,
dev_*
max-line-length = 115
ignore: E226,E402,E741,W503,W504
25 changes: 0 additions & 25 deletions .github/workflows/conda_unit_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,31 +16,6 @@ defaults:

jobs:

# lint:
# name: Code style
# runs-on: ubuntu-latest

# steps:
# - uses: actions/checkout@v4

# - uses: actions/setup-python@v4
# with:
# python-version: '3.11'

# - name: Install Dependencies
# run: |
# python -m pip install --upgrade pip
# pip install flake8

# - name: Run flake8
# run: |
# flake8

# - name: Run black
# uses: rickstaa/action-black@v1
# with:
# black_args: ". --check"

testing:

runs-on: ubuntu-latest
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/pre-commit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ name: pre-commit
# from: https://github.com/NSLS-II/scientific-python-cookiecutter/ ... /.github/workflows/pre-commit.yml

on:
pull_request:
push:
pull_request:
workflow_dispatch:

jobs:
Expand Down
22 changes: 19 additions & 3 deletions .github/workflows/publish-docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,19 @@ on:
push:
branches:
- main
pull_request:
branches:
- main
workflow_dispatch: # allow manual triggering
inputs:
deploy:
description: 'Deploy documentation'
type: boolean
required: true
default: false

jobs:
build:
docs:

if: github.repository_owner == 'bluesky'
runs-on: ubuntu-latest
Expand All @@ -29,7 +39,12 @@ jobs:
run: |
env | sort | grep hklpy
- uses: actions/checkout@v2
- uses: actions/checkout@v4

- name: Deploy Information
if: ${{ github.event.inputs.deploy }}
run: |
echo "The docs will be published from this workflow run."
- name: Install Python ${{ matrix.python-version }} Conda environment with micromamba from env-dev.yml
uses: mamba-org/provision-with-micromamba@main
Expand All @@ -52,13 +67,14 @@ jobs:
- name: Build Docs
shell: bash -l {0}
run: |
make
make -C docs clean html
# comment here for development use
- name: Deploy documentation to blueskyproject.io.
# We pin to the SHA, not the tag, for security reasons.
# https://docs.github.com/en/free-pro-team@latest/actions/learn-github-actions/security-hardening-for-github-actions#using-third-party-actions
uses: peaceiris/actions-gh-pages@bbdfb200618d235585ad98e965f4aafc39b4c501 # v3.7.3
if: ${{ github.event.inputs.deploy }}
with:
deploy_key: ${{ secrets.ACTIONS_DOCUMENTATION_DEPLOY_KEY }}
publish_branch: master
Expand Down
26 changes: 10 additions & 16 deletions .github/workflows/upload_pypi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,21 @@ name: Publish Python 🐍 distributions 📦 to PyPI and TestPyPI
on: push

jobs:
build-n-publish:
pypi:
name: Build and publish Python 🐍 distributions 📦 to PyPI and TestPyPI
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@master
- name: Set up Python
uses: actions/setup-python@v1
# with:
# python-version: 3.9
- uses: actions/setup-python@v4
with:
python-version: '3.10'

- name: Install OS packages
run: >-
sudo apt-get -y update
&& sudo apt-get install -y libgirepository1.0-dev
- name: Install pypa/build
run: >-
python -m
Expand All @@ -40,20 +44,10 @@ jobs:
run: >-
twine check dist/*
# NOTE: "Secrets" page, not "Environments"
# NOTE: testpypi upload with versioneer only works on new tags.
# - name: Publish distribution 📦 to Test PyPI
# uses: pypa/gh-action-pypi-publish@master
# with:
# user: __token__
# password: ${{ secrets.TEST_PYPI_API_TOKEN }}
# repository_url: https://test.pypi.org/legacy/
# verbose: true

# TODO: restrict to tags on main branch only?
- name: Publish distribution 📦 to PyPI
if: startsWith(github.ref, 'refs/tags')
uses: pypa/gh-action-pypi-publish@master
uses: pypa/gh-action-pypi-publish@release/v1
with:
user: __token__
password: ${{ secrets.PYPI_API_TOKEN }}
Expand Down
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
BSD 3-Clause License

Copyright (c) 2015-2020, Brookhaven National Laboratory
Copyright (c) 2014-2023, Brookhaven National Laboratory
All rights reserved.

Redistribution and use in source and binary forms, with or without
Expand Down
3 changes: 0 additions & 3 deletions MANIFEST.in
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,8 @@ include README.md
include RELEASE_NOTES.rst
include conftest.py
include environment.yml
include hkl/_version.py
include pyproject.toml
include pytest.ini
include requirements.txt
include versioneer.py

recursive-include docs *.rst conf.py Makefile make.bat
recursive-include Makefile README.md *.ipynb resources/*
Expand Down
17 changes: 0 additions & 17 deletions Makefile

This file was deleted.

5 changes: 5 additions & 0 deletions RELEASE_NOTES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,11 @@ Fixes

* ``util.restore_reflections()`` use renamed motor axes if so defined.

Maintenance
-----------

* Update packaging to latest PyPA recommendations.

v1.0.4 (released 2023-10-06)
======================================

Expand Down
11 changes: 7 additions & 4 deletions docs/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,16 @@
# All configuration values have a default; values that are commented out
# serve to show the default.

import sys, os
import pathlib
import sphinx_rtd_theme
import sys

# If extensions (or modules to document with autodoc) are in another directory,
# add these directories to sys.path here. If the directory is relative to the
# documentation root, use os.path.abspath to make it absolute, like shown here.
# fmt: off
sys.path.insert(0, os.path.abspath(os.path.join("..", "..",)))
docs_source = pathlib.Path(__file__).parent
sys.path.insert(0, str(docs_source / ".." / ".."))
# fmt: on
# imports here for sphinx to build the documents without many WARNINGS.
import hkl
Expand Down Expand Up @@ -61,7 +63,7 @@

# General information about the project.
project = "hklpy"
copyright = "2014-2021, Brookhaven National Laboratory"
copyright = "2014-2023, Brookhaven National Laboratory"

# The version info for the project you're documenting, acts as replacement for
# |version| and |release|, also used in various other places throughout the
Expand Down Expand Up @@ -132,11 +134,12 @@
autodoc_mock_imports = [
"pint",
]

# -- Options for HTML output ---------------------------------------------------

# The theme to use for HTML and HTML Help pages. See the documentation for
# a list of builtin themes.
sys.path.append(os.path.abspath("_themes"))
sys.path.append(str(docs_source / "_themes"))
html_theme = "sphinx_rtd_theme"

# Theme options are theme-specific and customize the look and feel of a theme
Expand Down
36 changes: 0 additions & 36 deletions docs/source/install.rst
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ This tutorial covers:
* Installation for users using :ref:`install.conda.user`
* Installation for developers using :ref:`install.conda.developer`
* Installation for users using :ref:`install.pip.user`
* Installation for developers using :ref:`install.pip.developer`
* Test the installation using :ref:`install.test`

.. note:: *hklpy* only runs on Linux, since it relies on the *hkl*
Expand Down Expand Up @@ -80,41 +79,6 @@ Install *hklpy* from PyPI.
python3 -m pip install hklpy
Until a new version after 1.0.2 is release, you'll also need to download the
the `requirements.txt` file from the source code, then install using:

.. code:: bash
pip install -r requirements.txt
.. _install.pip.developer:

Pip for *hklpy* Developers
--------------------------

We strongly recommend creating a fresh environment (here, named ``dev-hklpy``).
Both Python and the *hkl* library must already be installed. Here, we create
a conda environment with just these packages required:

.. code:: bash
conda create -y -n dev-hklpy python=3.9 hkl -c conda-forge
conda activate dev-hklpy
Install requirements from PyPI.

.. code:: bash
python3 -m pip install -r requirements.txt
Install *hklpy* from source directory. If necessary, clone from github.

.. code:: bash
git clone https://github.com/bluesky/hklpy
cd hklpy
python3 -m pip install -e . --no-deps
.. _install.test:

Test that *hklpy* is installed
Expand Down
12 changes: 9 additions & 3 deletions hkl/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,16 @@
logger = logging.getLogger(__name__)
logger.addHandler(logging.NullHandler())

from ._version import get_versions # noqa: F402, E402
try:
from setuptools_scm import get_version

__version__ = get_versions()["version"]
del get_versions
__version__ = get_version(root="..", relative_to=__file__)
del get_version
except (LookupError, ModuleNotFoundError):
from importlib.metadata import version

__version__ = version("pkgdemo")
del version

# gobject-introspection, to access libhkl
import gi
Expand Down
Loading

0 comments on commit ef74e8e

Please sign in to comment.