Skip to content

Commit

Permalink
gh-11: Add code to push to builds to pypi
Browse files Browse the repository at this point in the history
  • Loading branch information
monkeyman192 committed Sep 30, 2024
1 parent 9d1ba06 commit 556436c
Show file tree
Hide file tree
Showing 4 changed files with 105 additions and 38 deletions.
50 changes: 42 additions & 8 deletions .github/workflows/pipeline.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,18 +41,52 @@ jobs:
- name: Upload Wheels
uses: actions/upload-artifact@v4
with:
name: pyMHF
path: dist/*
name: python-package-distributions
path: dist/
release:
name: Release pyMHF wheels and source build
name: Release pyMHF wheels and source build to PyPI
# Only run this job if the commit was tagged.
if: ${{ startsWith(github.ref, 'refs/tags/') }}
runs-on: windows-latest
needs: [build_test]
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags')
needs:
- build_test
runs-on: ubuntu-latest
environment:
name: testpypi
url: https://pypi.org/p/pyMHF
permissions:
id-token: write # IMPORTANT: this permission is mandatory for trusted publishing
steps:
- name: Download files for release
uses: actions/download-artifact@v4
with:
name: python-package-distributions
path: dist/
- name: See what files we have
run: ls
run: ls ./dist/
shell: bash
# TODO: Add release action
- name: Publish package distributions to PyPI
uses: pypa/gh-action-pypi-publish@release/v1

test-release:
name: Release pyMHF wheels and source build to test-PyPI
needs:
- build_test
runs-on: ubuntu-latest
environment:
name: testpypi
url: https://test.pypi.org/p/pyMHF
permissions:
id-token: write # IMPORTANT: this permission is mandatory for trusted publishing
steps:
- name: Download files for release
uses: actions/download-artifact@v4
with:
name: python-package-distributions
path: dist/
- name: See what files we have
run: ls ./dist/
shell: bash
- name: Publish package distributions to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
repository-url: https://test.pypi.org/legacy/
47 changes: 27 additions & 20 deletions pymhf/core/mod_loader.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import logging
import os
import os.path as op
import re
import sys
import traceback
from abc import ABC
Expand All @@ -19,7 +20,6 @@
from typing import TYPE_CHECKING, Any, Optional, Union

import keyboard
import semver

import pymhf.core._internal as _internal
import pymhf.core.common as common
Expand All @@ -34,6 +34,10 @@
from pymhf.gui.gui import GUI


VERSION_PATT = r"(?<major>\d+)\.(?<minor>\d+)\.(?<patch>\d+)(?<rest>\..+)*"
VERSION_RE = re.compile(VERSION_PATT)


mod_logger = logging.getLogger("ModManager")


Expand Down Expand Up @@ -215,25 +219,28 @@ def _load_module(self, module: ModuleType) -> bool:
mod_name = list(d.keys())[0]
mod = d[mod_name]
if mod.__pymhf_required_version__ is not None:
from pymhf import __version__ as _pymhf_version

pymhf_version = semver.Version.parse(_pymhf_version)
try:
mod_version = semver.Version.parse(mod.__pymhf_required_version__)
except ValueError:
mod_logger.warning(
"__pymhf_required_version__ defined on mod "
f"{mod.__name__} is not a valid version string"
)
mod_version = None
if mod_version is None or mod_version <= pymhf_version:
self._preloaded_mods[mod_name] = mod
else:
mod_logger.error(
f"Mod {mod.__name__} requires a newer verison of "
f"pyMHF ({mod_version}{pymhf_version})! "
"Please update"
)
# TODO: Reimplement
pass
# from pymhf import __version__ as _pymhf_version
# if (pymhf_version := VERSION_RE.match(_pymhf_version)) is not None:
# pass
# try:
# if (mod_version := VERSION_RE.match(mod.__pymhf_required_version__)) is not None:
# pass
# except ValueError:
# mod_logger.warning(
# "__pymhf_required_version__ defined on mod "
# f"{mod.__name__} is not a valid version string"
# )
# mod_version = None
# if mod_version is None or mod_version <= pymhf_version:
# self._preloaded_mods[mod_name] = mod
# else:
# mod_logger.error(
# f"Mod {mod.__name__} requires a newer verison of "
# f"pyMHF ({mod_version} ≥ {pymhf_version})! "
# "Please update"
# )
else:
self._preloaded_mods[mod_name] = mod
# Only get mod states if the mod name doesn't already have a cached
Expand Down
8 changes: 5 additions & 3 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,20 +25,22 @@ dependencies = [
"psutil~=5.9.5",
"pymem[speed]~=1.12.0",
"keyboard",
"semver",
"pywin32",
"dearpygui~=1.11.0",
"questionary",
]
version = "0.1.7+dev2"
dynamic = ["version"]

[tool.setuptools.package-dir]
pymhf = "pymhf"

[tool.setuptools_scm]

[tool.uv]
dev-dependencies = [
"pytest",
"ruff",
"setuptools_scm",
]

[tool.ruff]
Expand All @@ -59,5 +61,5 @@ Repository = "https://github.com/monkeyman192/pyMHF.git"
pymhf = "pymhf:run"

[build-system]
requires = ["setuptools>=43.0.0", "wheel"]
requires = ["setuptools>=64", "wheel", "setuptools-scm>=8", "setuptools_scm_git_semver"]
build-backend = "setuptools.build_meta"
38 changes: 31 additions & 7 deletions uv.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 556436c

Please sign in to comment.