Skip to content

Commit

Permalink
Finalize hatch-vcs configuration (#31)
Browse files Browse the repository at this point in the history
* Finalize hatch-vcs configuration

* Add PyPI workflow

* Pin actions

* Do not depend on conda in pyproject.toml's dependencies (just in the conda deps)

* depth 0
  • Loading branch information
jaimergp authored Jun 13, 2024
1 parent 9adcbe7 commit 02da97b
Show file tree
Hide file tree
Showing 6 changed files with 86 additions and 10 deletions.
9 changes: 4 additions & 5 deletions .github/workflows/docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,10 @@ jobs:
docs:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4.1.6
with:
fetch-depth: 0
- uses: prefix-dev/setup-pixi@v0.6.0
- uses: prefix-dev/setup-pixi@ba3bb36eb2066252b2363392b7739741bb777659 # v0.8.1
with:
environments: docs
- name: Setup project
Expand All @@ -37,7 +36,7 @@ jobs:
- name: Build docs
run: pixi run docs
- name: Upload artifact
uses: actions/upload-pages-artifact@v1
uses: actions/upload-pages-artifact@56afc609e74202658d3ffba0e8f6dda462b719fa # v3.0.1
with:
path: 'docs/_build/dirhtml'

Expand All @@ -59,4 +58,4 @@ jobs:
steps:
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v1
uses: actions/deploy-pages@d6db90164ac5ed86f2b6aed7e0febac5b3c0c03e # v4.0.5
59 changes: 59 additions & 0 deletions .github/workflows/pypi.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
name: Publish to PyPI

on:
pull_request:
push:
branches:
- main
release:
types:
- published

jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4.1.6
with:
fetch-tags: true
fetch-depth: 0

- name: Set up Python
uses: actions/setup-python@82c7e631bb3cdc910f68e0081d67478d79c6982d # v5.1.0
with:
python-version: "3.x"

- name: Install build tools
run: python -m pip install --upgrade pip wheel setuptools build twine

- name: Build wheels
run: python -m build --sdist --wheel . --outdir dist

- name: Check wheels
working-directory: dist
run: |
ls -alh
python -m pip install *.whl
python -m twine check *
- name: Upload release distributions
uses: actions/upload-artifact@65462800fd760344b1a7b4382951275a0abb4808 # v4.3.3
with:
name: release-dists
path: dist/

publish:
runs-on: ubuntu-latest
if: github.event_name == 'release'
needs: [build]
permissions:
id-token: write

steps:
- name: Retrieve release distributions
uses: actions/download-artifact@65a9edc5881444af0b9093a5e628f2fe47ea3b2e # v4.1.7
with:
name: release-dists
path: dist/
- name: Publish release distributions to PyPI
uses: pypa/gh-action-pypi-publish@81e9d935c883d0b210363ab89cf05f3894778450 # v1.8.14
6 changes: 3 additions & 3 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,10 @@ jobs:
env:
PIXI_ENV_NAME: test-py${{ matrix.python-version }}
steps:
- name: Checkout
uses: actions/checkout@v3
- uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4.1.6
with:
fetch-depth: 0
- uses: prefix-dev/setup-pixi@v0.6.0
- uses: prefix-dev/setup-pixi@ba3bb36eb2066252b2363392b7739741bb777659 # v0.8.1
with:
environments: ${{ env.PIXI_ENV_NAME }}
- name: Setup project
Expand All @@ -56,3 +55,4 @@ jobs:
- name: Build recipe (${{ env.PIXI_ENV_NAME }})
if: matrix.python-version == '3.10'
run: pixi run build

3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -133,3 +133,6 @@ dmypy.json

# Used in debugging
explicit.txt

# hatch-vcs
conda_pypi/_version.py
14 changes: 13 additions & 1 deletion conda_pypi/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,16 @@
conda-pypi
"""

__version__ = "0.1.0"
try:
from ._version import __version__
except ImportError:
# _version.py is only created after running `pip install`
try:
from setuptools_scm import get_version

__version__ = get_version(root="..", relative_to=__file__)
except (ImportError, OSError, LookupError):
# ImportError: setuptools_scm isn't installed
# OSError: git isn't installed
# LookupError: setuptools_scm unable to detect version
__version__ = "0.0.0.dev0+placeholder"
5 changes: 4 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ classifiers = [
]
requires-python = ">=3.8"
dependencies = [
"conda >=23.7.3",
# "conda >=23.9.0",
"pip",
"grayskull",
"importlib_resources",
Expand Down Expand Up @@ -106,5 +106,8 @@ test-py311 = ["test", "py311"]
[tool.hatch.version]
source = "vcs"

[tool.hatch.build.hooks.vcs]
version-file = "conda_pypi/_version.py"

[tool.ruff]
line-length = 99

0 comments on commit 02da97b

Please sign in to comment.