Skip to content

Commit 44c0876

Browse files
committed
Update action.yml and entrypoint.sh for Cython output path; simplify cython_build.py
1 parent d493f16 commit 44c0876

3 files changed

Lines changed: 9 additions & 42 deletions

File tree

action.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ inputs:
2626
required: False
2727
default: "requirements.txt"
2828
cython_out:
29-
description: 'Specify a folder path for precompiled cython files (relative to the root of the project)'
29+
description: 'Specify a folder path for precompiled cython files (relative to the SRC folder)'
3030
required: False
3131
default: ""
3232
outputs:
@@ -42,3 +42,4 @@ runs:
4242
- ${{ inputs.pypi_index_url }}
4343
- ${{ inputs.spec }}
4444
- ${{ inputs.requirements }}
45+
- ${{ inputs.cython_out }}

cython_build.py

Lines changed: 5 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -4,52 +4,17 @@
44
# FOR EXAMPLE IN CASE OF OLDER PYTHON VERSIONS
55

66
# Import necessary modules
7-
from sys import argv, exit
8-
from os import path, walk, getenv
9-
from shutil import move
10-
from re import search
7+
from sys import argv
118
from setuptools import setup
129
from Cython.Build import cythonize
1310

1411
# Append "build_ext" and "--inplace" to sys.argv to ensure the extension is built in place
1512
argv.append("build_ext")
1613
argv.append("--inplace")
1714
argv.append("--compiler=mingw32")
18-
print("arguments: ", argv)
1915

20-
try:
21-
ext_modules=cythonize(".\\src\\*.pyx", build_dir=".\\build")
22-
print("Cythonizing files... ", ext_modules)
23-
setup(ext_modules=ext_modules)
24-
print("Setup build successful")
25-
except Exception as e:
26-
print(f"An error occurred during the Cython build: {e}")
27-
raise
16+
ext_modules=cythonize(".\\src\\*.pyx", build_dir=".\\build")
17+
print("Cythonizing files... ", ext_modules)
2818

29-
30-
def find_name(name_regex: str) -> str | None:
31-
for root, _, files in walk(
32-
"./"
33-
): # Traverse all directories and files starting from the current directory
34-
for file in files: # For each file in the directory
35-
if search(
36-
name_regex, file
37-
): # Check if the file name matches the given regex
38-
return path.join(
39-
root, file
40-
) # Return the full file path if a match is found
41-
return None # Return None if no file matches the regex pattern
42-
43-
44-
# Find the compiled Cython file matching the pattern "helpers.c*"
45-
file_name = find_name(r".*\.pyd")
46-
if file_name is None:
47-
# If no file matching "helpers.c*" is found, print a message and exit the script
48-
print("No file found with extension .pyd")
49-
exit(1)
50-
51-
print(f"Found file: {file_name}")
52-
53-
# Move the matched file to the "src/prec" directory
54-
move(path.join(file_name), path.join(getenv("CYTHON_OUT"), path.basename(file_name)))
55-
print("File moved successfully")
19+
setup(ext_modules=ext_modules)
20+
print("Setup build successful")

entrypoint.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,13 +39,14 @@ if [ -f $REQUIREMENTS ]; then
3939
pip install -r $REQUIREMENTS
4040
fi
4141

42-
if [ -f $CYTHON_OUT ]; then
42+
if [ -n "$CYTHON_OUT" ]; then
4343
cd ..
4444
mkdir ./build
4545
wine reg add "HKEY_CURRENT_USER\Environment" /v PATH /t REG_SZ /d "C:\\mingw64\bin;%PATH%" /f
4646
echo "gcc --version"| wine cmd
4747
python /cython_build.py
4848
cd $WORKDIR
49+
mv ../*.pyd "$CYTHON_OUT/"
4950
fi
5051

5152
pyinstaller --clean -y --dist ./dist/windows --workpath /tmp $SPEC_FILE

0 commit comments

Comments
 (0)