Skip to content

Commit

Permalink
update the setup scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
chunyuma committed Dec 10, 2024
1 parent 9e5dddf commit 3cef6df
Show file tree
Hide file tree
Showing 5 changed files with 46 additions and 17 deletions.
1 change: 1 addition & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Include C++ source files
include src/cpp/*.cpp
include src/cpp/*.hpp
include src/cpp/*.h

# Include other necessary files
include LICENSE.txt
Expand Down
8 changes: 4 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@ SRC_DIR = src/cpp
BIN_DIR = src/yacht

# Source files
SRC_FILES = $(SRC_DIR)/yacht_train_core.cpp $(SRC_DIR)/utils.cpp $(SRC_DIR)/compute_similarity.cpp
SRC_FILES = $(SRC_DIR)/yacht_train_core.cpp $(SRC_DIR)/utils.cpp $(SRC_DIR)/yacht_run_compute_similarity.cpp

# Object files
OBJ_FILES = $(SRC_FILES:.cpp=.o)

# target executable
TARGET1 = $(BIN_DIR)/run_yacht_train_core
TARGET2 = $(BIN_DIR)/run_compute_similarity
TARGET1 = $(BIN_DIR)/yacht_train_core
TARGET2 = $(BIN_DIR)/yacht_run_compute_similarity

# Build rules
all: $(TARGET1) $(TARGET2)
Expand All @@ -23,7 +23,7 @@ $(TARGET1): $(OBJ_FILES)
$(CXX) $(CXXFLAGS) $(SRC_DIR)/yacht_train_core.cpp $(SRC_DIR)/utils.cpp -o $(TARGET1)

$(TARGET2): $(OBJ_FILES)
$(CXX) $(CXXFLAGS) $(SRC_DIR)/compute_similarity.cpp $(SRC_DIR)/utils.cpp -o $(TARGET2)
$(CXX) $(CXXFLAGS) $(SRC_DIR)/yacht_run_compute_similarity.cpp $(SRC_DIR)/utils.cpp -o $(TARGET2)

%.o: %.cpp
$(CXX) $(CXXFLAGS) -c $< -o $@
Expand Down
34 changes: 27 additions & 7 deletions build_windows.bat
Original file line number Diff line number Diff line change
@@ -1,21 +1,41 @@
@echo off
setlocal enabledelayedexpansion

REM Set up paths for directories
rem Set up paths for directories
set SRC_DIR=src\cpp
set BIN_DIR=src\yacht

REM Create bin directory if it doesn't exist
rem Create bin directory if it doesn't exist
if not exist %BIN_DIR% (
mkdir %BIN_DIR%
)

REM Compile the main.cpp file using g++ from MinGW or another suitable compiler
g++ -std=c++17 -Wsign-compare -Wall -O3 -o %BIN_DIR%\run_yacht_train_core.exe %SRC_DIR%\main.cpp
rem Compile source files into object files
set OBJ_FILES=
for %%f in (%SRC_DIR%\*.cpp) do (
g++ -std=c++17 -Wall -O3 -Wsign-compare -c %%f -o %%~nf.o
if %errorlevel% neq 0 (
echo Compilation failed for %%f!
exit /b %errorlevel%
)
set OBJ_FILES=!OBJ_FILES! %%~nf.o
)

rem Create yacht_train_core.exe
g++ %OBJ_FILES% -o %BIN_DIR%\yacht_train_core.exe
if %errorlevel% neq 0 (
echo Linking failed for yacht_train_core.exe!
exit /b %errorlevel%
)

REM Check if compilation succeeded
rem Create yacht_run_compute_similarity.exe
g++ %OBJ_FILES% -o %BIN_DIR%\yacht_run_compute_similarity.exe
if %errorlevel% neq 0 (
echo Compilation failed!
echo Linking failed for yacht_run_compute_similarity.exe!
exit /b %errorlevel%
)

echo Compilation successful. Executable created at %BIN_DIR%\run_yacht_train_core.exe
rem Clean up object files
del *.o

echo Compilation successful. Executables created in %BIN_DIR%.
1 change: 0 additions & 1 deletion env/yacht_env.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ dependencies:
- pytaxonkit
- requests
- pip
- sourmash_plugin_branchwater
- pip:
- openpyxl
- ruff
19 changes: 14 additions & 5 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,15 +30,24 @@ def run(self):
print(f"Error during Unix compilation: {e}")
raise e

# Move the compiled binary to the correct location for packaging
compiled_binary = os.path.join('src', 'yacht', 'run_yacht_train_core')
if os.path.exists(compiled_binary):
# Move the compiled binary files to the correct location for packaging
compiled_binary1 = os.path.join('src', 'yacht', 'yacht_train_core')
compiled_binary2 = os.path.join('src', 'yacht', 'yacht_run_compute_similarity')
if os.path.exists(compiled_binary1):
destination = os.path.join(self.build_lib, 'yacht')
os.makedirs(destination, exist_ok=True)
shutil.move(compiled_binary, destination)
shutil.move(compiled_binary1, destination)
else:
print("Compiled binary not found after build step.")
raise FileNotFoundError("The executable 'run_yacht_train_core' was not generated successfully.")
raise FileNotFoundError("The executable 'yacht_train_core' was not generated successfully.")

if os.path.exists(compiled_binary2):
destination = os.path.join(self.build_lib, 'yacht')
os.makedirs(destination, exist_ok=True)
shutil.move(compiled_binary2, destination)
else:
print("Compiled binary not found after build step.")
raise FileNotFoundError("The executable 'yacht_run_compute_similarity' was not generated successfully.")

# Run the usual build_ext logic (necessary to continue with setuptools)
super().run()
Expand Down

0 comments on commit 3cef6df

Please sign in to comment.