Skip to content

Commit

Permalink
Publish releases to PyPI
Browse files Browse the repository at this point in the history
  • Loading branch information
calcmogul committed Dec 14, 2023
1 parent 627340b commit 0ff857d
Show file tree
Hide file tree
Showing 4 changed files with 75 additions and 3 deletions.
29 changes: 29 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -135,3 +135,32 @@ jobs:
with:
name: Wasm
path: pkg

pypi-publish:
name: Upload release to PyPI
runs-on: ubuntu-22.04
needs: [build-python]
if: ${{ github.repository_owner == 'SleipnirGroup' && github.ref == 'refs/heads/main' }}
environment:
name: pypi
url: https://pypi.org/p/sleipnirgroup-jormungandr
permissions:
id-token: write
steps:
- uses: actions/download-artifact@v3
with:
name: Windows - python
path: dist
- uses: actions/download-artifact@v3
with:
name: Linux - python
path: dist
- uses: actions/download-artifact@v3
with:
name: macOS - python
path: dist
- name: Diagnostics
run: ls -R

#- name: Publish package distributions to PyPI
# uses: pypa/gh-action-pypi-publish@release/v1
6 changes: 5 additions & 1 deletion jormungandr/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,8 @@
that uses the interior-point method.
"""

from ._jormungandr import *
try:
from ._jormungandr import *
except:
print("Warning: No module named 'jormungandr._jormungandr'")
pass
30 changes: 30 additions & 0 deletions jormungandr/version.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import re
import subprocess


def get_version():
proc = subprocess.run(
[
"git",
"describe",
],
check=True,
encoding="utf-8",
stdout=subprocess.PIPE,
)
if proc.returncode:
raise RuntimeError("Couldn't find tag for version number")

m = re.search(
r"^v ([0-9]+\.[0-9]+\.[0-9]+) (- ([0-9]+) )?",
proc.stdout.rstrip(),
re.X,
)

# Version number: <tag>.dev<# commits since tag>
version = m.group(1)
try:
version += f".dev{m.group(2)}"
except:
pass
return version
13 changes: 11 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[project]
name = "sleipnirgroup-jormungandr"
description = "A linearity-exploiting sparse nonlinear constrained optimization problem solver that uses the interior-point method."
version = "0.0.1"
dynamic = [ "version" ]
readme = "README.md"
requires-python = ">=3.7"
dependencies = [ "numpy" ]
Expand All @@ -13,7 +13,12 @@ dependencies = [ "numpy" ]
Documentation = "https://sleipnirgroup.github.io/Sleipnir/"

[build-system]
requires = [ "py-build-cmake~=0.1.8", "pybind11", "pybind11-stubgen" ]
requires = [
"py-build-cmake~=0.1.8",
"pybind11",
"pybind11-stubgen",
"setuptools-git-versioning"
]
build-backend = "py_build_cmake.build"

[tool.py-build-cmake.module]
Expand Down Expand Up @@ -43,6 +48,10 @@ install_args = [ "--strip" ]
BUILD_TESTING = "OFF"
BUILD_PYTHON = "ON"

[tool.setuptools-git-versioning]
enabled = true
version_callback = "jormungandr.version:get_version"

[tool.pytest.ini_options]
minversion = "6.0"
testpaths = [ "jormungandr/test" ]

0 comments on commit 0ff857d

Please sign in to comment.