Skip to content
Merged

Dev #305

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,9 @@ jobs:
run: |
echo "Starting Docker deployment to GHCR for sigprofilersuite..."

VERSION_TAG=$(grep "VERSION = " setup.py | cut -d'"' -f2)
python -m pip install --upgrade setuptools_scm
VERSION_TAG=$(python -m setuptools_scm)
VERSION_TAG=${VERSION_TAG//+/-}

# Get the repository name and convert it to lowercase
REPO_NAME=$(basename ${{ github.repository }} | tr '[:upper:]' '[:lower:]')
Expand Down
92 changes: 92 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
name: Release

on:
push:
tags:
- "v*"
release:
types:
- published
workflow_dispatch:

jobs:
build:
name: Build distributions
runs-on: ubuntu-latest
permissions:
contents: read
steps:
- uses: actions/checkout@v6
with:
fetch-depth: 0

- name: Set up Python 3.12
uses: actions/setup-python@v6
with:
python-version: "3.12"

- name: Install build tooling
run: |
python -m pip install --upgrade pip build twine

- name: Build distributions
run: |
python -m build

- name: Check distributions
run: |
python -m twine check dist/*

- name: Verify package version
run: |
python -m pip install dist/*.whl
python -c "import SigProfilerExtractor; print(SigProfilerExtractor.__version__)"

- name: Upload distributions
uses: actions/upload-artifact@v7
with:
name: python-package-distributions
path: dist/
if-no-files-found: error

publish-testpypi:
name: Publish to TestPyPI
needs: build
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v')
runs-on: ubuntu-latest
environment:
name: testpypi
url: https://test.pypi.org/p/SigProfilerExtractor
permissions:
id-token: write
steps:
- name: Download distributions
uses: actions/download-artifact@v5
with:
name: python-package-distributions
path: dist/

- name: Publish package distributions to TestPyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
repository-url: https://test.pypi.org/legacy/

publish-pypi:
name: Publish to PyPI
needs: build
if: github.event_name == 'release' && github.event.action == 'published'
runs-on: ubuntu-latest
environment:
name: pypi
url: https://pypi.org/p/SigProfilerExtractor
permissions:
id-token: write
steps:
- name: Download distributions
uses: actions/download-artifact@v5
with:
name: python-package-distributions
path: dist/

- name: Publish package distributions to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
4 changes: 2 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ share/python-wheels/
.installed.cfg
*.egg
MANIFEST
SigProfilerExtractor/version.py
SigProfilerExtractor/_version.py

# PyInstaller
# Usually these files are written by a python script from a template
Expand Down Expand Up @@ -139,4 +139,4 @@ test_vcf_output/
test_matrix_*_output/
SigProfilerExtractor/data/VCFInput/logs/
SigProfilerExtractor/data/VCFInput/input/
SigProfilerExtractor/data/VCFInput/output/
SigProfilerExtractor/data/VCFInput/output/
27 changes: 27 additions & 0 deletions SigProfilerExtractor/version.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
try:
from ._version import version as _scm_version
except Exception:
_scm_version = None

try:
from importlib.metadata import PackageNotFoundError, version as _dist_version
except Exception: # pragma: no cover
PackageNotFoundError = Exception # type: ignore

def _dist_version(_name: str) -> str: # type: ignore
raise PackageNotFoundError()


def _resolve_version() -> str:
if _scm_version is not None:
return _scm_version

try:
return _dist_version("SigProfilerExtractor")
except PackageNotFoundError:
return "0+unknown"


short_version = _resolve_version()
version = short_version
Update = "Managed by setuptools_scm from git tags"
8 changes: 7 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
[build-system]
requires = ["setuptools>=61", "wheel", "build"]
requires = ["setuptools>=69", "setuptools_scm[toml]>=8", "wheel"]
build-backend = "setuptools.build_meta"

[tool.setuptools_scm]
tag_regex = "^v(?P<version>.+)$"
version_scheme = "guess-next-dev"
local_scheme = "node-and-date"
fallback_version = "0+unknown"
93 changes: 14 additions & 79 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,40 +1,11 @@
from setuptools import setup
import shutil
import os
import sys
import subprocess
from pathlib import Path

# remove the dist folder first if exists
if os.path.exists("dist"):
shutil.rmtree("dist")
from setuptools import find_namespace_packages, setup

VERSION = "1.2.7"

LONG_DESCRIPTION = Path("README.md").read_text(encoding="utf-8")

with open("README.md") as f:
long_description = f.read()


def write_version_py(filename="SigProfilerExtractor/version.py"):
# Copied from numpy setup.py
cnt = """
# THIS FILE IS GENERATED FROM SIGPROFILEREXTRACTOR SETUP.PY
short_version = '%(version)s'
version = '%(version)s'
Update = 'v1.2.7: Removed nimfa dependency and implemented NNDSVD directly for NumPy 2.0 compatibility'

"""
fh = open(filename, "w")
fh.write(
cnt
% {
"version": VERSION,
}
)
fh.close()


requirements = [
INSTALL_REQUIRES = [
"scipy>=1.6.3",
"torch>=1.8.1",
"numpy>=2.0.0",
Expand All @@ -47,61 +18,25 @@ def write_version_py(filename="SigProfilerExtractor/version.py"):
"psutil>=5.6.1",
]

operating_system = sys.platform
print(operating_system)
if operating_system in ["win32", "cygwin", "windows"]:
requirements.remove("matplotlib>=3.3.0")
requirements.remove("torch==1.5.1")
print("Trying to install pytorch!")
code = 1
try:
code = subprocess.call(
[
"pip",
"install",
"torch===1.5.1+cpu",
"-f",
"https://download.pytorch.org/whl/torch_stable.html",
]
)
if code != 0:
raise Exception("Torch instalation failed !")
except:
try:
code = subprocess.call(
[
"pip3",
"install",
"torch===1.5.1+cpu",
"-f",
"https://download.pytorch.org/whl/torch_stable.html",
]
)
if code != 0:
raise Exception("Torch instalation failed !")
except:
print(
"Failed to install pytorch, please install pytorch manually be following the simple instructions over at: https://pytorch.org/get-started/locally/"
)
if code == 0:
print(
"Successfully installed pytorch version! (If you need the GPU version, please install it manually, checkout the mindsdb docs and the pytroch docs if you need help)"
)
VERSION_TEMPLATE = "version = '{version}'\n"


write_version_py()
setup(
name="SigProfilerExtractor",
version=VERSION,
use_scm_version={
"write_to": "SigProfilerExtractor/_version.py",
"write_to_template": VERSION_TEMPLATE,
"fallback_version": "0+unknown",
},
description="Extracts mutational signatures from mutational catalogues",
long_description=long_description,
long_description_content_type="text/markdown", # This is important!
long_description=LONG_DESCRIPTION,
long_description_content_type="text/markdown",
url="https://github.com/SigProfilerSuite/SigProfilerExtractor.git",
author="S Mishu Ashiqul Islam",
author_email="m0islam@ucsd.edu",
license="UCSD",
packages=["SigProfilerExtractor"],
install_requires=requirements,
packages=find_namespace_packages(include=["SigProfilerExtractor*"]),
install_requires=INSTALL_REQUIRES,
include_package_data=True,
python_requires=">=3.9",
entry_points={
Expand Down