Skip to content

Commit 82232ef

Browse files
committed
Pre-release (v3)
1 parent 1ed10cf commit 82232ef

24 files changed

+683
-128
lines changed

.editorconfig

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,10 @@ trim_trailing_whitespace = true # Remove trailing whitespace
1616
[*.rs]
1717
max_line_length = 100
1818

19+
# Python files
20+
[*.py]
21+
max_line_length = 100
22+
1923
# Markdown files
2024
[*.md]
2125
max_line_length = 120
@@ -29,3 +33,7 @@ indent_size = 2
2933
[*.{yaml,yml}]
3034
indent_size = 2
3135
36+
# TOML files
37+
[*.toml]
38+
indent_size = 2
39+

.github/workflows/publish_py.yml

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
name: Publish to PyPI
2+
3+
on:
4+
workflow_dispatch: # Enable manual runs
5+
push:
6+
tags:
7+
- 'v*' # Trigger on version tags
8+
9+
jobs:
10+
11+
# # Run tests before publishing
12+
# call_tests:
13+
# uses: ./.github/workflows/tests_py.yml
14+
15+
publish_to_pypi:
16+
runs-on: ubuntu-latest
17+
# needs: call_tests
18+
19+
steps:
20+
- name: Checkout Repository
21+
uses: actions/checkout@v4
22+
23+
- name: Set Up Python
24+
uses: actions/setup-python@v4
25+
with:
26+
python-version: "3.10"
27+
28+
- name: Install Poetry
29+
run: |
30+
sudo apt-get update
31+
sudo apt-get install -y python3-pip make
32+
pip install poetry
33+
34+
- name: Install Python Dependencies
35+
run: |
36+
poetry install --no-root
37+
38+
- name: Build and Publish Package
39+
run: |
40+
poetry run make wheel-manylinux
41+
PYPI_TOKEN=${{ secrets.PYPI_API_TOKEN }} poetry run make publish_py

.gitignore

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -64,16 +64,14 @@ tmp/
6464
*.wal
6565
*.sqlite
6666

67-
# Dependency lock files (uncomment to ignore)
68-
poetry.lock
69-
7067
# Rust specific
7168
/target/
7269
.cargo-ok
7370
cobertura.xml
7471
tarpaulin-report.html
7572

76-
# Comment out the next line if you want to checkin your lock file for Cargo
73+
# Dependency lock files (uncomment to ignore)
74+
poetry.lock
7775
Cargo.lock
7876

7977
# Miscellaneous files and directories to ignore
@@ -82,3 +80,6 @@ Cargo.lock
8280
tmp_*
8381
temp_*
8482
output_*
83+
*.so
84+
.benchmarks/
85+
ci.yml

Cargo.toml

Lines changed: 19 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "graphina"
3-
version = "0.2.0"
3+
version = "0.2.1"
44
description = "A graph data science library for Rust"
55
repository = "https://github.com/habedi/graphina"
66
license = "MIT OR Apache-2.0"
@@ -16,28 +16,24 @@ rust-version = "1.83"
1616
resolver = "2"
1717

1818
include = [
19-
"docs/**/*",
20-
"src/**/*",
21-
"Cargo.toml",
22-
"README.md",
23-
"LICENSE-MIT",
24-
"LICENSE-APACHE"
19+
"docs/**/*",
20+
"src/**/*",
21+
"Cargo.toml",
22+
"README.md",
23+
"LICENSE-MIT",
24+
"LICENSE-APACHE"
2525
]
2626

2727
[lib]
2828
name = "graphina"
2929
path = "src/lib.rs"
3030

31-
[[bin]]
32-
name = "graphina"
33-
path = "src/main.rs"
34-
3531
[features]
3632
default = [] # No features enabled by default
3733
binaries = []
3834

3935
[dependencies]
40-
ctor = "0.2.9"
36+
ctor = "0.3.6"
4137
tracing = "0.1.41"
4238
tracing-subscriber = "0.3.19"
4339
rand = "0.9.0"
@@ -61,3 +57,14 @@ lto = true
6157

6258
[profile.bench]
6359
debug = true
60+
61+
[package.metadata.rustfmt]
62+
max_width = 100
63+
hard_tabs = false
64+
tab_spaces = 4
65+
66+
[workspace]
67+
members = [
68+
".",
69+
"pygraphina"
70+
]

Makefile

Lines changed: 67 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -6,75 +6,123 @@ PATH := /snap/bin:$(PATH)
66
DEBUG_GRAPHINA = 1
77
RUST_LOG = info
88
RUST_BACKTRACE = full
9+
WHEEL_DIR = dist
10+
PYGRAPHINA_DIR = pygraphina
11+
12+
# Find the built Python wheel file (the latest one)
13+
WHEEL_FILE = $(shell ls $(PYGRAPHINA_DIR)/$(WHEEL_DIR)/pygraphina-*.whl | head -n 1)
914

1015
# Default target
1116
.DEFAULT_GOAL := help
1217

1318
.PHONY: help
14-
help: ## Show this help message
19+
help: ## Show the list of available targets with their descriptions
1520
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'
1621

22+
########################################################################################
23+
## Rust targets
24+
########################################################################################
25+
1726
.PHONY: format
1827
format: ## Format Rust files
1928
@echo "Formatting Rust files..."
20-
cargo fmt
29+
@cargo fmt
2130

2231
.PHONY: test
2332
test: format ## Run tests
2433
@echo "Running tests..."
25-
DEBUG_GRAPHINA=$(DEBUG_GRAPHINA) RUST_LOG=debug RUST_BACKTRACE=$(RUST_BACKTRACE) cargo test -- --nocapture
34+
@DEBUG_GRAPHINA=$(DEBUG_GRAPHINA) RUST_LOG=debug RUST_BACKTRACE=$(RUST_BACKTRACE) cargo test -- --nocapture
2635

2736
.PHONY: coverage
2837
coverage: format ## Generate test coverage report
2938
@echo "Generating test coverage report..."
30-
DEBUG_GRAPHINA=$(DEBUG_GRAPHINA) cargo tarpaulin --out Xml --out Html
39+
@DEBUG_GRAPHINA=$(DEBUG_GRAPHINA) cargo tarpaulin --out Xml --out Html
3140

3241
.PHONY: build
3342
build: format ## Build the binary for the current platform
3443
@echo "Building the project..."
35-
DEBUG_GRAPHINA=$(DEBUG_GRAPHINA) cargo build --release
44+
@DEBUG_GRAPHINA=$(DEBUG_GRAPHINA) cargo build --release
3645

3746
.PHONY: run
3847
run: build ## Build and run the binary
3948
@echo "Running the $(BINARY) binary..."
40-
DEBUG_GRAPHINA=$(DEBUG_GRAPHINA) ./$(BINARY)
49+
@DEBUG_GRAPHINA=$(DEBUG_GRAPHINA) ./$(BINARY)
4150

4251
.PHONY: clean
4352
clean: ## Remove generated and temporary files
4453
@echo "Cleaning up..."
45-
cargo clean
54+
@cargo clean
55+
@rm -rf dist/
56+
@rm -rf $(PYGRAPHINA_DIR)/$(WHEEL_DIR)
57+
@rm -f $(PYGRAPHINA_DIR)/*.so
4658

4759
.PHONY: install-snap
4860
install-snap: ## Install a few dependencies using Snapcraft
4961
@echo "Installing the snap package..."
50-
sudo apt-get update
51-
sudo apt-get install -y snapd
52-
sudo snap refresh
53-
sudo snap install rustup --classic
62+
@sudo apt-get update
63+
@sudo apt-get install -y snapd
64+
@sudo snap refresh
65+
@sudo snap install rustup --classic
5466

5567
.PHONY: install-deps
5668
install-deps: install-snap ## Install development dependencies
5769
@echo "Installing dependencies..."
58-
rustup component add rustfmt clippy
59-
cargo install cargo-tarpaulin
60-
cargo install cargo-audit
70+
@rustup component add rustfmt clippy
71+
@cargo install cargo-tarpaulin
72+
@cargo install cargo-audit
6173

6274
.PHONY: lint
6375
lint: format ## Run linters on Rust files
6476
@echo "Linting Rust files..."
65-
DEBUG_GRAPHINA=$(DEBUG_GRAPHINA) cargo clippy -- -D warnings
77+
@DEBUG_GRAPHINA=$(DEBUG_GRAPHINA) cargo clippy -- -D warnings
6678

6779
.PHONY: publish
68-
publish: ## Publish the package to crates.io (requires CARGO_REGISTRY_TOKEN to be set)
80+
publish: ## Publish the package to crates.io (needs CARGO_REGISTRY_TOKEN to be set)
6981
@echo "Publishing the package to Cargo registry..."
70-
cargo publish --token $(CARGO_REGISTRY_TOKEN)
82+
@cargo publish --token $(CARGO_REGISTRY_TOKEN)
7183

7284
.PHONY: bench
7385
bench: ## Run benchmarks
7486
@echo "Running benchmarks..."
75-
DEBUG_GRAPHINA=$(DEBUG_GRAPHINA) cargo bench
87+
@DEBUG_GRAPHINA=$(DEBUG_GRAPHINA) cargo bench
7688

7789
.PHONY: audit
7890
audit: ## Run security audit on Rust dependencies
7991
@echo "Running security audit..."
80-
cargo audit
92+
@cargo audit
93+
94+
########################################################################################
95+
## Python targets
96+
########################################################################################
97+
98+
.PHONY: develop_py
99+
develop_py: ## Build and install PyGraphina in current Python environment
100+
@echo "Building and installing PyGraphina in current Python environment..."
101+
@unset CONDA_PREFIX && cd $(PYGRAPHINA_DIR) && maturin develop && cd ..
102+
103+
.PHONY: wheel
104+
wheel: ## Build the wheel file for PyGraphina
105+
@echo "Make the Python wheel file..."
106+
@cd $(PYGRAPHINA_DIR) && maturin build --release --out $(WHEEL_DIR) --auditwheel check && cd ..
107+
108+
.PHONY: wheel-manylinux
109+
wheel-manylinux: ## Build the wheel file for PyGraphina (manylinux version using Zig)
110+
@echo "Make the Python wheel file..."
111+
@cd $(PYGRAPHINA_DIR) && maturin build --release --out $(WHEEL_DIR) --auditwheel check --zig && cd ..
112+
113+
.PHONY: test_py
114+
test_py: develop_py ## Run Python tests
115+
@echo "Running Python tests..."
116+
@poetry run pytest $(PYGRAPHINA_DIR)/tests
117+
118+
.PHONY: publish_py
119+
publish_py: wheel ## Publish the PyGraphina wheel to PyPI (needs PYPI_TOKEN to be set)
120+
@echo "Publishing the PyGraphina wheel to PyPI..."
121+
@echo "Found wheel file: $(WHEEL_FILE)"
122+
@twine upload -u __token__ -p $(PYPI_TOKEN) $(WHEEL_FILE)
123+
124+
.PHONY: generat_ci
125+
generate_ci: ## Generate CI configuration files (GitHub Actions workflow)
126+
@echo "Generating CI configuration files..."
127+
@cd $(PYGRAPHINA_DIR) && maturin generate-ci --zig --pytest --platform all \
128+
-o ../.github/workflows/ci.yml github && cd ..

0 commit comments

Comments
 (0)