Skip to content
Closed
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
2 changes: 0 additions & 2 deletions .coveralls.yml

This file was deleted.

62 changes: 0 additions & 62 deletions .travis.yml

This file was deleted.

222 changes: 61 additions & 161 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,177 +1,77 @@
# From http://peterdowns.com/posts/first-time-with-pypi.html
# To register a package on PyPiTest:
# python setup.py register -r pypitest
# OPGEE Makefile
#
# Then to upload the actual package:
# python setup.py sdist upload -r pypitest
#
# Do the same with pypi instead of pypitest to go live
.ONESHELL:
SHELL=/bin/bash
CONDA_ENV = opgee
CONDA_ACTIVATE = source $$(conda info --base)/etc/profile.d/conda.sh; conda activate; conda activate

LOCK=opgee.conda.lock
ifeq ($(OS),Windows_NT)
CONDA_INIT_CMD = call "$(shell where conda | grep Scripts\\conda.exe | sed 's/conda.exe/activate.bat/')"
CONDA_PATH_CHECK = where conda
CONDA_INIT_IN_SUBSHELL = call activate.bat
else
UNAME_S := $(shell uname -s)
ifeq ($(UNAME_S),Linux)
CONDA_ROOT = ~/anaconda3
CONDA_INIT_CMD = source $(CONDA_ROOT)/bin/activate
CONDA_PATH_CHECK = which conda
else
UNAME_P := $(shell uname -p)
ifeq ($(UNAME_P),arm)
CONDA_ROOT = /opt/homebrew/anaconda3
CONDA_INIT_CMD = source $(CONDA_ROOT)/bin/activate
CONDA_PATH_CHECK = which conda
else
CONDA_ROOT = ~/anaconda3
CONDA_INIT_CMD = source $(CONDA_ROOT)/bin/activate
CONDA_PATH_CHECK = which conda
endif
endif
CONDA_INIT_IN_SUBSHELL = source $(CONDA_ROOT)/bin/activate
endif

check-conda:
@$(CONDA_PATH_CHECK) >/dev/null 2>&1 || \
(echo "Conda not found. Initializing conda..." && \
$(CONDA_INIT_CMD))

act:
$(CONDA_ACTIVATE)
a: act
# py=$$(which python3)
# @echo "before $$py"
# $(CONDA_ACTIVATE) base
py2=$$(which python)
echo "after $$py2"

t:
py=$$(which python3)
echo "after $$py"

list:
@$(CONDA_ACTIVATE) ./foo; conda list

dc:
$(conda deactivate)

check-active-env: check-conda
@bash -c '$(CONDA_INIT_IN_SUBSHELL) && \
active_env=$$(conda info --envs | grep "*" | cut -d" " -f1) && \
echo "Current environment: $$active_env" && \
if [ "$$active_env" = "$(CONDA_ENV)" ]; then \
echo "Deactivating $(CONDA_ENV) environment..." && \
conda deactivate; \
else \
echo "Environment $(CONDA_ENV) is not active"; \
fi'

remove-opgee: check-conda check-active-env
@echo "Removing $(CONDA_ENV) environment..."
@conda env remove -n $(CONDA_ENV)
all: clean html sdist wheel

version = `./version.sh`

test-upload: # sdist
twine upload dist/opgee-$(version).tar.gz -r testpypi

upload: pypi-upload

pypi-upload: sdist
twine upload dist/opgee-$(version).tar.gz

clean-html:
make -C docs clean
# Uses uv for Python package management
# See: https://docs.astral.sh/uv/

html:
make -C docs html
.PHONY: test test-v test-cov lint format check clean build upload docs help

pdf:
make -C docs latexpdf
# ============================================
# Development
# ============================================

clean-setup:
python setup.py clean
test: ## Run tests
uv run pytest

sdist:
python setup.py sdist
test-v: ## Run tests (verbose)
uv run pytest -v

wheel:
python setup.py bdist_wheel
test-cov: ## Run tests with coverage
uv run pytest --cov=opgee

clean: clean-html clean-setup clean-requirements
lint: ## Run linter
uv run ruff check .

dev:
pip install -e .
format: ## Format code
uv run ruff format .

EMPTY :=
SPACE := $(EMPTY) $(EMPTY)
RQMTS := $(shell cat requirements.in)
MODS := $(subst $(SPACE),|,$(RQMTS))
EXPR := $(shell printf "^(%s)=\n" '$(MODS)')
check: lint test ## Run all checks (lint + test)
@echo "All checks passed"

RTD_REQS = rtd.requirements.txt
TRAVIS_REQS = requirements.txt
dev: ## Install in development mode
uv sync

clean-reqs:
rm $(RTD_REQS) $(TRAVIS_REQS)
# ============================================
# Build & Release
# ============================================

rtd-reqs $(RTD_REQS): requirements.in
python -V|sed -e 's/Python /python==/' > $(RTD_REQS)
pip freeze | egrep '$(EXPR)' >> $(RTD_REQS)
build: ## Build sdist and wheel
uv build

# "pip freeze" erroneously reports pytest==0.0.0
travis-reqs $(TRAVIS_REQS): requirements.in
./update-reqs.py
clean-build: ## Clean build artifacts
rm -rf dist/ build/ *.egg-info/

#
# Virtual environment / package dependency support
#
YML_FILE=py3-opgee.yml
upload-test: build ## Upload to TestPyPI
uv run twine upload dist/* -r testpypi

upload: build ## Upload to PyPI
uv run twine upload dist/*

#INPUT_YML=py3-opgee-macos.yml
#
#test-yml: $(TEST_YML)
#
## drops all commment lines
#$(TEST_YML) : $(INPUT_YML)
# egrep -v '^#' $(INPUT_YML) > $(TEST_YML)

# remove-opgee:
# conda env remove -n opgee

create-opgee: $(YML_FILE)
conda env create -f $(YML_FILE)

install-opgee:
bash -l -c 'conda activate opgee && pip install -e .'

rebuild-opgee: remove-opgee create-opgee travis-reqs install-opgee

# Generate a detailed package list to cache for validation of
# environment on CI platform (currently github actions)
env-pkg-list:
conda list --export > opgee.pkg_list.txt

NUITKA_EXE = opgee.exe
NUITKA_OUTDIR = /tmp/opgee-nuitka
NUITKA_LOG = /tmp/opgee-nuitka.txt

$(NUITKA_EXE):
python -m nuitka opgee/main.py -o $@ \
--output-dir=$(NUITKA_OUTDIR) \
--include-package-data=opgee \
--onefile \
--plugin-enable=numpy \
--plugin-enable=pylint-warnings \
--warn-unusual-code \
--warn-implicit-exceptions \
--verbose --verbose-output=$(NUITKA_LOG)
# --standalone
# ============================================
# Documentation
# ============================================

docs: ## Build HTML documentation
uv run make -C docs html

docs-pdf: ## Build PDF documentation
uv run make -C docs latexpdf

clean-docs: ## Clean documentation build
make -C docs clean

# ============================================
# Cleanup
# ============================================

clean: clean-build clean-docs ## Clean all build artifacts
find . -type d -name __pycache__ -exec rm -rf {} + 2>/dev/null || true
find . -type f -name "*.pyc" -delete 2>/dev/null || true

# ============================================
# Help
# ============================================

help: ## Show this help
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-15s\033[0m %s\n", $$1, $$2}'

.DEFAULT_GOAL := help
4 changes: 0 additions & 4 deletions codecov.yml

This file was deleted.

Loading
Loading