Skip to content
Merged
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
56 changes: 43 additions & 13 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,10 @@

.DEFAULT_GOAL := all

CC ?= cc
AR ?= ar
RM ?= rm -f
CC ?= cc
AR ?= ar
RM ?= rm -f
PREFIX ?= /usr/local

CFLAGS = -O2 -Wall -Wextra -fPIC
LDFLAGS =
Expand All @@ -21,22 +22,33 @@ HDR = ciph.h

UNAME_S := $(shell uname -s)

# -------------------------
# Platform detection
# -------------------------

ifeq ($(UNAME_S),Linux)
SHARED = libciph.so
SHARED = libciph.so
LDFLAGS += -shared -Wl,-soname,libciph.so
endif

ifeq ($(UNAME_S),Darwin)
SHARED = libciph.dylib
SHARED = libciph.dylib
LDFLAGS += -dynamiclib
endif

ifeq ($(findstring MINGW,$(UNAME_S)),MINGW)
SHARED = ciph.dll
SHARED = libciph.dll
LDFLAGS += -shared
endif

STATIC = libciph.a

# -------------------------
# Targets
# -------------------------

all: check shared static

check:
@pkg-config --exists libsodium || ( \
echo "libsodium not found."; \
Expand All @@ -49,26 +61,44 @@ check:
exit 1 \
)

all: check shared static

shared: $(SHARED)

static: $(STATIC)

# -------------------------
# Build rules
# -------------------------

$(OBJ): $(SRC) $(HDR)
$(CC) $(CFLAGS) -c $(SRC) -o $(OBJ)

$(SHARED): $(OBJ)
$(CC) $(CFLAGS) $(LDFLAGS) -shared $(OBJ) -o $(SHARED) $(LIBS)
$(CC) $(CFLAGS) $(LDFLAGS) $(OBJ) -o $(SHARED) $(LIBS)

$(STATIC): $(OBJ)
$(AR) rcs $(STATIC) $(OBJ)

# -------------------------
# Install / Clean
# -------------------------

install:
install -Dm755 $(SHARED) $(PREFIX)/lib/$(SHARED)
install -Dm644 $(HDR) $(PREFIX)/include/ciph.h

clean:
$(RM) $(OBJ) $(SHARED) $(STATIC)

install:
install -Dm755 $(SHARED) /usr/local/lib/$(SHARED)
install -Dm644 $(HDR) /usr/local/include/ciph.h
# -------------------------
# Debug helper
# -------------------------

print-config:
@echo "OS : $(UNAME_S)"
@echo "CC : $(CC)"
@echo "CFLAGS : $(CFLAGS)"
@echo "LDFLAGS : $(LDFLAGS)"
@echo "SHARED : $(SHARED)"
@echo "PREFIX : $(PREFIX)"

.PHONY: all check shared static clean install
.PHONY: all check shared static install clean print-config
2 changes: 1 addition & 1 deletion ciph/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "1.2.1"
__version__ = "1.2.2"
4 changes: 4 additions & 0 deletions ciph/_build.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
/* dummy file to force build_ext */
int ciph_build_dummy(void) {
return 0;
}
45 changes: 22 additions & 23 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,43 +4,42 @@ build-backend = "setuptools.build_meta"

[project]
name = "ciph"
version = "1.2.1"
version = "1.2.2"
description = "High-performance streaming encryption engine for large files"
readme = "README.md"
requires-python = ">=3.8"
license = { text = "Apache License 2.0" }
license = "Apache-2.0"

authors = [
{ name = "Ankit Chaubey", email = "m.ankitchaubey@gmail.com" }
{ name = "Ankit Chaubey", email = "m.ankitchaubey@gmail.com" }
]

dependencies = [
"tqdm>=4.60.0"
"tqdm>=4.60.0"
]

keywords = [
"encryption",
"cryptography",
"security",
"aes",
"chacha20",
"streaming",
"files",
"privacy",
"libsodium"
"encryption",
"cryptography",
"security",
"aes",
"chacha20",
"streaming",
"files",
"privacy",
"libsodium"
]

classifiers = [
"Development Status :: 5 - Production/Stable",
"Intended Audience :: Developers",
"Topic :: Security :: Cryptography",
"Topic :: System :: Archiving :: Backup",
"License :: OSI Approved :: Apache Software License",
"Programming Language :: C",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3 :: Only",
"Operating System :: POSIX :: Linux",
"Operating System :: Unix"
"Development Status :: 5 - Production/Stable",
"Intended Audience :: Developers",
"Topic :: Security :: Cryptography",
"Topic :: System :: Archiving :: Backup",
"Programming Language :: C",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3 :: Only",
"Operating System :: POSIX :: Linux",
"Operating System :: Unix"
]

[project.urls]
Expand Down
70 changes: 55 additions & 15 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,20 +1,60 @@
from setuptools import setup, find_packages
from setuptools import setup, find_packages, Extension
from setuptools.command.build_ext import build_ext
import subprocess
import os
import sys
import shutil


class BuildCiphExt(build_ext):
def run(self):
root = os.path.abspath(os.path.dirname(__file__))

print("\n🔧 Building native libciph")

# Clean is best-effort
try:
subprocess.check_call(["make", "clean"], cwd=root)
except Exception:
pass

subprocess.check_call(["make"], cwd=root)

if sys.platform.startswith("linux"):
libname = "libciph.so"
elif sys.platform == "darwin":
libname = "libciph.dylib"
elif sys.platform.startswith(("win32", "cygwin", "msys")):
libname = "ciph.dll"
else:
raise RuntimeError(f"Unsupported platform: {sys.platform}")

src = os.path.join(root, libname)
if not os.path.exists(src):
raise RuntimeError(f"Native build failed: {libname} not found")

dst = os.path.join(root, "ciph", "_native")
os.makedirs(dst, exist_ok=True)
shutil.copy2(src, os.path.join(dst, libname))

print(f"✔ Native library installed → ciph/_native/{libname}\n")

super().run()


# Dummy extension to force build_ext execution
ext_modules = [
Extension(
"ciph._build",
sources=["ciph/_build.c"],
)
]

setup(
name="ciph",
version="1.2.1",
description="Fast, streaming file encryption for large media files and cloud uploads",
long_description=open("README.md").read(),
long_description_content_type="text/markdown",

packages=find_packages(),
include_package_data=True,
entry_points={
"console_scripts": [
"ciph=ciph.cli:main",
]
},
python_requires=">=3.8",
install_requires=[
"tqdm>=4.60.0",
],

ext_modules=ext_modules,
cmdclass={"build_ext": BuildCiphExt},
)