Skip to content

Commit

Permalink
Change deploy
Browse files Browse the repository at this point in the history
  • Loading branch information
rmanhaeve authored Oct 25, 2024
1 parent 2df2ae8 commit 87b4731
Show file tree
Hide file tree
Showing 14 changed files with 55 additions and 147 deletions.
145 changes: 22 additions & 123 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
@@ -1,142 +1,41 @@

name: Python PySDD package

on:
push:
branches: [ deploy ]
# pull_request:
# branches: [ deploy ]

jobs:
build_unix:
build_wheels:
name: Build wheels on ${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: true
fail-fast: false
matrix:
# os: [ubuntu-20.04,ubuntu-18.04]
python-version: ["3.11"]
os: [ ubuntu-22.04 ]
# cibuildwheel will automatically provide all Python versions
# python-version: [ "3.9" ]
steps:
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
python -m pip install cibuildwheel==2.19.1
- name: Build wheel
run: |
pwd
ls
python -m cibuildwheel --output-dir dist/
env:
CIBW_BUILD_VERBOSITY: 2
# cp36-* and cp37-* do not support f-strings
CIBW_SKIP: cp36-* cp37-* pp* *-manylinux_i686 *-musllinux_i686 *-musllinux_x86_64
CIBW_TEST_EXTRAS: "dev"
CIBW_TEST_COMMAND: python -m pytest --ignore=venv {project}/tests
- name: Store wheels
uses: actions/upload-artifact@v4
with:
name: dist-${{ matrix.os }}-${{ matrix.python-version }}
path: dist/*.whl
os: [windows-latest, ubuntu-latest, macos-13, macos-14]


build_macos:
name: Build wheels on ${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: true
matrix:
os: [ macos-12, macos-13, macos-14 ]
python-version: ["3.8","3.9","3.10", "3.11", "3.12"]
steps:
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
python -m pip install pytest build
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
- name: Compile and install
run: |
python -m pip install . -v
ls ${{ github.workspace }}/build || true
- name: Test with pytest
run: |
mv pysdd pysdd_pkg
python -m pytest --ignore=venv
mv pysdd_pkg pysdd
- name: Build
run: |
python -m build
- name: Store wheels
uses: actions/upload-artifact@v4
with:
name: dist-${{ matrix.os }}-${{ matrix.python-version }}
path: dist/*.whl

build_windows:
name: Build wheels on ${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: true
matrix:
os: [ windows-2022 ] # windows-2019 (produces same filenames as 2022)
python-version: ["3.8","3.9","3.10", "3.11", "3.12"]
steps:
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
id: setuppython
uses: actions/setup-python@v5
- name: Set up QEMU
if: runner.os == 'Linux'
uses: docker/setup-qemu-action@v3
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
python -m pip install --upgrade setuptools
python -m pip install pytest build SCons
python -m pip install "cython>=0.29.6"
- name: Compile libsdd
run: |
cd ${{ github.workspace }}/pysdd/lib/libsdd-2.0
ls
scons
cp ${{ github.workspace }}/pysdd/lib/libsdd-2.0/build/sdd.dll ${{ github.workspace }}/pysdd/lib/sdd-2.0/lib/Windows/
cp ${{ github.workspace }}/pysdd/lib/libsdd-2.0/build/sdd.dll ${{ github.workspace }}/pysdd/
cp ${{ github.workspace }}/pysdd/lib/libsdd-2.0/build/sdd.lib ${{ github.workspace }}/pysdd/lib/sdd-2.0/lib/Windows/
- name: Store pysdd library
uses: actions/upload-artifact@v4
with:
name: library-${{ matrix.os }}-${{ matrix.python-version }}
path: ${{ github.workspace }}/pysdd/lib/libsdd-2.0/build/sdd.dll
- name: Compile and install
run: |
python -m pip install . -vvv
ls ${{ github.workspace }}/build || true
- name: Test with pytest
run: |
mv pysdd pysdd_pkg
python -m pytest --ignore=venv
mv pysdd_pkg pysdd
- name: Build
run: |
python -m build
- name: Store wheels
uses: actions/upload-artifact@v4
with:
name: dist-${{ matrix.os }}-${{ matrix.python-version }}
path: dist/*.whl
platforms: all

- name: Build wheels
uses: pypa/[email protected]
env:
# configure cibuildwheel to build native archs ('auto') and ARM64
CIBW_ARCHS_LINUX: auto aarch64
CIBW_SKIP: cp36-* cp37-* pp* *i686 *ppc64le *s390x *win32*
CIBW_TEST_REQUIRES: pytest
CIBW_TEST_COMMAND: "pytest {project}/tests"
CIBW_BEFORE_ALL: "pip install SCons && cd pysdd/lib/libsdd-2.0 && scons && cp -r build ../sdd-2.0/lib"

- uses: actions/upload-artifact@v4
with:
name: cibw-wheels-${{ matrix.os }}-${{ strategy.job-index }}
path: ./wheelhouse/*.whl
build_sdist:
name: Prepare source distribution
runs-on: ubuntu-latest
Expand All @@ -163,7 +62,7 @@ jobs:
runs-on: ubuntu-latest
# upload to PyPI on every tag starting with 'v'
# if: github.event_name == 'push' && startsWith(github.event.ref, 'refs/tags/v')
needs: [ build_unix,build_macos,build_windows,build_sdist ]
needs: [ build_wheels,build_sdist ]

steps:
- uses: actions/download-artifact@v4
Expand Down
4 changes: 2 additions & 2 deletions pysdd/lib/libsdd-2.0/SConstruct
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ lib = ['m']

# compile
if "Windows" in platform.system():
env = Environment(CCFLAGS='/TC /Wall /O2', LINKFLAGS='/DEF:sdd.def',
env = Environment(CCFLAGS='/TC /Wall /O2', #LINKFLAGS='/DEF:sdd.def',
CPPPATH=['#/include', '#/src'], ENV=os.environ, TARGET_ARCH ='x86_64')

if mode == 'debug':
Expand All @@ -36,7 +36,7 @@ if "Windows" in platform.system():
#-DNDEBUG
# env.Append(CCFLAGS='/O2 ')
else:
env = Environment(CC='gcc',CCFLAGS='-std=c99 -Wall ',
env = Environment(CC='gcc',CCFLAGS='-std=c99 -Wall -fPIC ',
CPPPATH=['#/include', '#/src'], ENV=os.environ)

if mode == 'debug':
Expand Down
4 changes: 2 additions & 2 deletions pysdd/lib/libsdd-2.0/src/SConscript
Original file line number Diff line number Diff line change
Expand Up @@ -34,5 +34,5 @@ if not "Windows" in platform.system():
env_version.Append(CCFLAGS=ver_flags)
obj = env_version.Object('version.c')
sobj = env_version.SharedObject('version.c')
env.Library(name,src+[obj])
env.SharedLibrary(name,src+[sobj])
env.StaticLibrary(name,src+[obj])
#env.SharedLibrary(name,src+[sobj])
Binary file removed pysdd/lib/sdd-2.0/lib/Darwin-arm/libsdd.a
Binary file not shown.
Binary file removed pysdd/lib/sdd-2.0/lib/Darwin-arm/libsdd.dylib
Binary file not shown.
Binary file removed pysdd/lib/sdd-2.0/lib/Darwin/libsdd.a
Binary file not shown.
Binary file removed pysdd/lib/sdd-2.0/lib/Linux-arm/libsdd.a
Binary file not shown.
Binary file removed pysdd/lib/sdd-2.0/lib/Linux-arm/libsdd.so
Binary file not shown.
Binary file removed pysdd/lib/sdd-2.0/lib/Linux/libsdd.a
Binary file not shown.
Binary file removed pysdd/lib/sdd-2.0/lib/Linux/libsdd.so
Binary file not shown.
Binary file removed pysdd/lib/sdd-2.0/lib/Windows/sdd.dll
Binary file not shown.
Binary file removed pysdd/lib/sdd-2.0/lib/Windows/sdd.lib
Binary file not shown.
Binary file removed pysdd/sdd.dll
Binary file not shown.
49 changes: 29 additions & 20 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import platform
import os
import re
import shutil
from pathlib import Path


Expand Down Expand Up @@ -81,10 +82,10 @@ def __init__(self, attrs=None):
all_c_file_paths = [str(p) for p in c_files_paths] + [str(p) for p in wo_c_files_paths]
# print("Found c files: ", ", ".join([str(p) for p in all_c_file_paths]))

os.environ["LDFLAGS"] = f"-L{lib_path}"
#os.environ["LDFLAGS"] = f"-L{lib_path}"
os.environ["CPPFLAGS"] = f"-I{inc_path} " + f"-I{wo_inc_path} " + f"-I{sdd_extra_inc_path} " + f"-I{csrc_path} " + \
" ".join(f"-I{p}" for p in c_dirs_paths)
library_dirs = [str(lib_path)]
library_dirs = []# [str(lib_path)]
include_dirs = [str(inc_path), str(wo_inc_path), str(sdd_extra_inc_path), str(csrc_path)] + \
[str(p) for p in c_dirs_paths]

Expand Down Expand Up @@ -167,25 +168,33 @@ def build_extensions(self):
else:
print("Warning: import cysignals failed")
# Extra objects
if "Darwin" in platform.system():
if "arm" in platform.platform():
cur_lib_path = lib_path / "Darwin-arm"
else:
cur_lib_path = lib_path / "Darwin"
if build_type == "debug":
cur_lib_path = cur_lib_path / "debug"
libsdd_path = cur_lib_path / "libsdd.a"
elif "Linux" in platform.system():
if "arm" in platform.platform():
cur_lib_path = lib_path / "Linux-arm"
else:
cur_lib_path = lib_path / "Linux"
libsdd_path = cur_lib_path / "libsdd.a"
elif "Windows" in platform.system():
cur_lib_path = lib_path / "Windows"
libsdd_path = cur_lib_path / "sdd.lib"
print('System', platform.system())
print('platform', platform.platform())
# lib_path = libwrapper_path / "libsdd-2.0" / "build"
if "Windows" in platform.system():
libsdd_path = lib_path / "sdd.lib"
#shutil.copyfile(lib_path / "sdd.dll", Path(".") / "pysdd")
else:
libsdd_path = lib_path / "libsdd.a"
# if "Darwin" in platform.system():
# if "arm" in platform.platform():
# cur_lib_path = lib_path / "Darwin-arm"
# else:
# cur_lib_path = lib_path / "Darwin"
# if build_type == "debug":
# cur_lib_path = cur_lib_path / "debug"
# libsdd_path = cur_lib_path / "libsdd.a"
# elif "Linux" in platform.system():
# if "arm" in platform.platform() or "aarch" in platform.platform():
# cur_lib_path = lib_path / "Linux-arm"
# else:
# cur_lib_path = lib_path / "Linux"
# libsdd_path = cur_lib_path / "libsdd.a"
# elif "Windows" in platform.system():
# cur_lib_path = lib_path / "Windows"
# libsdd_path = cur_lib_path / "sdd.lib"
# else:
# libsdd_path = lib_path / "libsdd.a"
for e in self.extensions: # type: Extension
e.extra_objects = [str(libsdd_path)]
BuildExtCommand.build_extensions(self)
Expand All @@ -196,7 +205,7 @@ def build_extensions(self):
Extension(
"pysdd.sdd", [str(here / "pysdd" / "sdd.pyx")] + all_c_file_paths,
include_dirs=include_dirs,
library_dirs=library_dirs
# library_dirs=library_dirs
# extra_objects=[str(libsdd_path)],
# extra_compile_args=extra_compile_args,
# extra_link_args=extra_link_args
Expand Down

0 comments on commit 87b4731

Please sign in to comment.