Skip to content
Open
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
24 changes: 19 additions & 5 deletions djcompiler/compiler/djcompiler.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,15 @@
A django Cython compiler that compiles django projects into C and outputs it to build folder.
"""
import sys
from distutils.core import setup
from distutils.extension import Extension
from setuptools import setup
from setuptools import Extension
from Cython.Distutils import build_ext
import Cython
from Cython.Build import cythonize
import os
import shutil
from typing import List, Set
from pathlib import Path


class DjangoCompiler:
Expand Down Expand Up @@ -145,11 +146,24 @@ def python_modules_rules(self, path_name):

def initial_python_modules(self):
print("#################### Initial Python Modules ####################")
for path, subdirs, files in os.walk(f"./{self.build_directory}"):

source_root = Path(".").resolve()
build_root = Path(self.build_directory).resolve()

for path, subdirs, files in os.walk(build_root):
if self.python_modules_rules(path):
continue
f = open(f"{path}/__init__.py", "w")
f.close()

rel_path = Path(path).relative_to(build_root)
source_path = source_root / rel_path
src_init = source_path / "__init__.py"
dest_init = Path(path) / "__init__.py"

if src_init.exists():
shutil.copy2(src_init, dest_init)
print(f"Copied __init__.py from {src_init} → {dest_init}")
else:
print(f"No __init__.py in source for {rel_path}, skipping.")

def copy_needed_files(self, files: list = None):
print("#################### Copy needed files ####################")
Expand Down
6 changes: 5 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,11 @@
overlay_warning = True
break

setup()
setup(install_requires=[
"setuptools>=54",
"cython>=0.29.33",
'wheel',
])

if overlay_warning:
sys.stderr.write(
Expand Down