pypi release prep!

modified:   .gitlab-ci.yml
	modified:   Makefile
	modified:   README.rst
	modified:   setup.py
This commit is contained in:
Russell Ballestrini 2025-03-02 08:36:51 -05:00
parent 29e8d9a503
commit 79aa2ddd6c
4 changed files with 231 additions and 90 deletions

149
Makefile
View file

@ -1,31 +1,128 @@
env:
python3 -m venv env
. env/bin/activate
env/bin/pip install --upgrade pip
env/bin/pip install --upgrade -r requirements.py3.txt
# Makefile for operating the make_post_sell server using either PyPI packages or source
dev: env
env/bin/pip install --upgrade -r requirements-dev.txt
env/bin/pip install --upgrade -r requirements-test.txt
env/bin/pip install --editable .
cp -rp env env.vanilla
# Variables (using the current working directory)
VENV_DIR = $(shell pwd)/env
DATA_DIR = $(shell pwd)/data
CONFIG_FILE = development.ini
# Using the provided configuration URL.
CONFIG_URL = https://git.unturf.com/engineering/make-post-sell/make_post_sell/-/raw/master/development.ini
prod: env
env/bin/pip install --upgrade -r requirements-prod.txt
env/bin/pip install .
cp -rp env env.vanilla
PYTHON = $(VENV_DIR)/bin/python
PIP = $(VENV_DIR)/bin/pip
PSERVE = $(VENV_DIR)/bin/pserve
ALEMBIC = $(VENV_DIR)/bin/alembic
MPS_INIT = $(VENV_DIR)/bin/initialize_make_post_sell_db
init_db: env
env/bin/initialize_make_post_sell_db ${config}
# Default target: install from PyPI and then start the server.
all: install-from-pypi serve
# -----------------------------------------------------------------------------
# Environment Setup Targets
# -----------------------------------------------------------------------------
# Create virtual environment if not present.
$(VENV_DIR)/bin/activate:
@echo "Creating virtual environment in $(VENV_DIR)..."
python3 -m venv $(VENV_DIR)
venv: $(VENV_DIR)/bin/activate
# Create data directory and download configuration file if missing.
$(DATA_DIR)/$(CONFIG_FILE):
@echo "Creating data directory in $(DATA_DIR) and downloading configuration file..."
mkdir -p $(DATA_DIR)
cd $(DATA_DIR) && wget -O $(CONFIG_FILE) $(CONFIG_URL)
config: $(DATA_DIR)/$(CONFIG_FILE)
# -----------------------------------------------------------------------------
# Package Installation Targets for PyPI Installation
# -----------------------------------------------------------------------------
# Install the make_post_sell core package from PyPI.
install-core: venv
@echo "Installing make_post_sell core package from PyPI..."
$(PIP) install make_post_sell
# Install development extras from PyPI.
install-dev: venv
@echo "Installing make_post_sell development extras from PyPI..."
$(PIP) install make_post_sell[dev]
# Combined PyPI installation target.
install: install-core install-dev
# -----------------------------------------------------------------------------
# Package Installation Targets for Source Installation
# -----------------------------------------------------------------------------
# Install from source (editable mode) for development and testing.
install-source-dev-and-test: venv
@echo "Installing make_post_sell from source (editable mode) for development..."
$(PIP) install --editable .
$(PIP) install --upgrade -r requirements-dev.txt
$(PIP) install --upgrade -r requirements-test.txt
cp -rp $(VENV_DIR) $(VENV_DIR).vanilla
# Install from source for production (noneditable).
install-source-prod: venv
@echo "Installing make_post_sell from source for production (noneditable)..."
$(PIP) install .
$(PIP) install --upgrade -r requirements-prod.txt
cp -rp $(VENV_DIR) $(VENV_DIR).vanilla
# -----------------------------------------------------------------------------
# Database Initialization and Server Targets
# -----------------------------------------------------------------------------
# Initialize the database using the configuration file.
init-db: venv config
@echo "Initializing the make_post_sell database..."
$(MPS_INIT) $(DATA_DIR)/$(CONFIG_FILE)
$(ALEMBIC) -c $(DATA_DIR)/$(CONFIG_FILE) stamp head
# Start the development server with auto-reload.
serve: venv config
@echo "Starting the make_post_sell development server..."
$(PSERVE) $(DATA_DIR)/$(CONFIG_FILE) --reload
# -----------------------------------------------------------------------------
# Combined Setup Targets
# -----------------------------------------------------------------------------
# Install and set up using PyPI packages.
install-from-pypi: venv config install init-db
# Install and set up from source (editable mode) for development and testing.
install-from-source: venv config install-source-dev-and-test init-db
# Install and set up from source for production (noneditable).
install-from-source-prod: venv config install-source-prod init-db
# -----------------------------------------------------------------------------
# Additional Targets
# -----------------------------------------------------------------------------
# Print instructions for activating the virtual environment.
activate:
@echo "To activate the virtual environment, run:"
@echo " source $(VENV_DIR)/bin/activate"
# Run the test suite.
test: install-source-dev-and-test
@echo "Running tests..."
$(VENV_DIR)/bin/py.test
# Start a simple HTTP server (if needed for static files).
http: venv
@echo "Starting simple HTTP server on port 8000..."
$(PYTHON) -m http.server 8000
# -----------------------------------------------------------------------------
# Cleanup Target
# -----------------------------------------------------------------------------
# Remove the virtual environment directories.
clean:
rm -rf env
rm -rf env.vanilla
test: dev
#env/bin/py.test --lf
env/bin/py.test
serve: dev
# In the first shell, run a copy of make_post_sell using:
env/bin/pserve development.ini --reload
@echo "Cleaning up: removing $(VENV_DIR) and $(VENV_DIR).vanilla..."
rm -rf $(VENV_DIR) $(VENV_DIR).vanilla