-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Loading status checks…
Merge pull request #34 from jorisv/topic/minimize_build_memory
Avoid to consume too much memory while building
Showing
14 changed files
with
219 additions
and
210 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
name: PyCppAD CI for Windows | ||
on: | ||
pull_request: | ||
push: | ||
|
||
env: | ||
# Customize the CMake build type here (Release, Debug, RelWithDebInfo, etc.) | ||
BUILD_TYPE: Release | ||
|
||
jobs: | ||
build: | ||
runs-on: ${{ matrix.os }} | ||
|
||
strategy: | ||
fail-fast: true | ||
matrix: | ||
os: [windows-2019] | ||
compiler: | ||
- cmd: cl | ||
cppad_codegen: OFF | ||
- cmd: clang-cl | ||
cppad_codegen: ON | ||
|
||
steps: | ||
- uses: actions/checkout@v4 | ||
with: | ||
submodules: recursive | ||
|
||
- uses: conda-incubator/setup-miniconda@v3 | ||
with: | ||
activate-environment: pycppad | ||
auto-update-conda: true | ||
environment-file: .github/workflows/conda/conda-env.yml | ||
python-version: 3.8 | ||
auto-activate-base: false | ||
|
||
- name: Build PyCppAD | ||
shell: cmd /C CALL {0} | ||
run: | | ||
:: Set compiler to use. | ||
:: This must be done here and not in env since | ||
:: cxx-compiler activation script set this variable | ||
:: and is called before. | ||
set CC=${{ matrix.compiler.cmd }} | ||
set CXX=${{ matrix.compiler.cmd }} | ||
:: Create build directory | ||
mkdir build | ||
pushd build | ||
:: Configure | ||
cmake ^ | ||
-G "Ninja" ^ | ||
-DCMAKE_BUILD_TYPE=Release ^ | ||
-DCMAKE_INSTALL_PREFIX=%CONDA_PREFIX%\Library ^ | ||
-DPYTHON_SITELIB=%CONDA_PREFIX%\Lib\site-packages ^ | ||
-DPYTHON_EXECUTABLE=%CONDA_PREFIX%\python.exe ^ | ||
-DBUILD_WITH_CPPAD_CODEGEN_BINDINGS=${{ matrix.compiler.cppad_codegen }} ^ | ||
.. | ||
:: Build | ||
ninja -j1 | ||
:: Testing | ||
ctest --output-on-failure -C Release -V | ||
:: Test Python import | ||
ninja install | ||
cd .. | ||
python -c "import pycppad" |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,14 @@ | ||
name: pycppad | ||
channels: | ||
- conda-forge | ||
- nodefaults | ||
dependencies: | ||
- boost | ||
- eigenpy | ||
- python | ||
- cppad | ||
- cppadcodegen | ||
- cppadcodegen | ||
- ninja | ||
- cmake | ||
- pkg-config | ||
- ninja | ||
- cxx-compiler |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Submodule cmake
updated
41 files
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
import os | ||
import sys | ||
import contextlib | ||
|
||
|
||
def get_dll_paths(): | ||
pycppad_paths = os.getenv("PYCPPAD_WINDOWS_DLL_PATH") | ||
if pycppad_paths is None: | ||
# From https://peps.python.org/pep-0250/#implementation | ||
# lib/python-version/site-packages/package | ||
RELATIVE_DLL_PATH1 = "..\\..\\..\\..\\bin" | ||
# lib/site-packages/package | ||
RELATIVE_DLL_PATH2 = "..\\..\\..\\bin" | ||
# For unit test | ||
RELATIVE_DLL_PATH3 = "..\\..\\bin" | ||
return [ | ||
os.path.join(os.path.dirname(__file__), RELATIVE_DLL_PATH1), | ||
os.path.join(os.path.dirname(__file__), RELATIVE_DLL_PATH2), | ||
os.path.join(os.path.dirname(__file__), RELATIVE_DLL_PATH3), | ||
] | ||
else: | ||
return pycppad_paths.split(os.pathsep) | ||
|
||
|
||
class PathManager(contextlib.AbstractContextManager): | ||
"""Restore PATH state after importing Python module""" | ||
|
||
def add_dll_directory(self, dll_dir: str): | ||
os.environ["PATH"] += os.pathsep + dll_dir | ||
|
||
def __enter__(self): | ||
self.old_path = os.environ["PATH"] | ||
return self | ||
|
||
def __exit__(self, *exc_details): | ||
os.environ["PATH"] = self.old_path | ||
|
||
|
||
class DllDirectoryManager(contextlib.AbstractContextManager): | ||
"""Restore DllDirectory state after importing Python module""" | ||
|
||
def add_dll_directory(self, dll_dir: str): | ||
# add_dll_directory can fail on relative path and non | ||
# existing path. | ||
# Since we don't know all the fail criterion we just ignore | ||
# thrown exception | ||
try: | ||
self.dll_dirs.append(os.add_dll_directory(dll_dir)) | ||
except OSError: | ||
pass | ||
|
||
def __enter__(self): | ||
self.dll_dirs = [] | ||
return self | ||
|
||
def __exit__(self, *exc_details): | ||
for d in self.dll_dirs: | ||
d.close() | ||
|
||
|
||
def build_directory_manager(): | ||
if sys.version_info >= (3, 8): | ||
return DllDirectoryManager() | ||
else: | ||
return PathManager() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
/* | ||
* Copyright 2024 INRIA | ||
*/ | ||
|
||
#include "pycppad/cppad.hpp" | ||
#include "pycppad/cppad-scalar.hpp" | ||
|
||
typedef ::CppAD::AD<double> ADScalar; | ||
template void eigenpy::exposeType<ADScalar, Eigen::RowMajor>(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
/* | ||
* Copyright 2024 INRIA | ||
*/ | ||
|
||
#include "pycppad/cppad.hpp" | ||
#include "pycppad/cppad-scalar.hpp" | ||
|
||
typedef ::CppAD::AD<double> ADScalar; | ||
template void eigenpy::exposeType<ADScalar>(); |