Skip to content

Commit

Permalink
Fix windows builds (#3)
Browse files Browse the repository at this point in the history
  • Loading branch information
robomics authored Aug 6, 2023
1 parent deb31ba commit ffcd113
Show file tree
Hide file tree
Showing 6 changed files with 77 additions and 9 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/pip.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,7 @@ jobs:
strategy:
fail-fast: false
matrix:
# platform: [windows-latest, macos-latest, ubuntu-latest]
platform: [macos-latest, ubuntu-latest]
platform: [windows-latest, macos-latest, ubuntu-latest]
python-version: ["3.7", "3.11"]

runs-on: ${{ matrix.platform }}
Expand Down Expand Up @@ -90,7 +89,8 @@ jobs:
path: ${{ env.CONAN_HOME }}

- name: Test
run: python -m pytest test
if: matrix.platform != 'windows-latest'
run: python -m pytest test -v


pip-status-check:
Expand Down
64 changes: 63 additions & 1 deletion .github/workflows/wheels.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ env:
CCACHE_DIR: "${{ github.workspace }}/ccache/"

jobs:
build_sdist:
build-sdist:
name: Build SDist
runs-on: ubuntu-latest
steps:
Expand Down Expand Up @@ -138,3 +138,65 @@ jobs:
with:
name: wheels-macos-py${{ matrix.python-version }}
path: ./*.whl

build-wheels-windows:
name: Wheels on Windows
runs-on: windows-latest
strategy:
fail-fast: false
matrix:
python-version: [ '3.7', '3.8', '3.9', '3.10', '3.11' ]

steps:
- uses: actions/checkout@v3

- uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}

- name: Generate cache key
id: cache-key
run: |
hash="${{ hashFiles('conanfile.txt') }}" #, '.github/workflows/wheels.yml') }}"
echo "conan-key=conan-windows-$hash" >> $GITHUB_OUTPUT
- name: Restore Conan cache
id: cache-conan
uses: actions/cache/restore@v3
with:
key: ${{ steps.cache-key.outputs.conan-key }}
path: ${{ env.CONAN_HOME }}

- name: Build wheels
run: pip wheel . -vv --no-deps

- name: Save Conan cache
uses: actions/cache/save@v3
if: steps.cache-conan.outputs.cache-hit != 'true'
with:
key: ${{ steps.cache-key.outputs.conan-key }}
path: ${{ env.CONAN_HOME }}

- name: Fix wheels
run: |
pip install delvewheel
mkdir dlls/
find "$CONAN_HOME/p/" -type f -name deflate.dll -exec cp '{}' dlls/ \;
find "$CONAN_HOME/p/" -type f -name hdf5.dll -exec cp '{}' dlls/ \;
find "$CONAN_HOME/p/" -type f -name zlib.dll -exec cp '{}' dlls/ \;
delvewheel repair --add-path ./dlls/ hictkpy*.whl
- name: Test wheels
run: |
wheel=(wheelhouse/hictkpy*.whl)
pip install "${wheel[@]}[test]"
pytest test -v
- name: Upload wheels
uses: actions/upload-artifact@v3
with:
name: wheels-windows-py${{ matrix.python-version }}
path: wheelhouse/*.whl
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,11 @@ m2 = sel.to_coo() # Get interactions as a scipy.sparse.coo_matrix

# Loop over interactions
for bin1_id, bin2_id, count in clr.fetch("chr1"):
print(bin1_id ...)
print(bin1_id, ...)

# Loop over interactions
for chrom1, start1, end1, chrom2, start2, end2, count in clr.fetch("chr1", join=True):
print(chrom1 ...)
print(chrom1, ...)

# Fetch interactions using UCSC queries
clr.fetch("chr1:0-10,000,000").to_df()
Expand Down
2 changes: 2 additions & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ author = Roberto Rossini
author_email = [email protected]
description = Blazing fast toolkit to work with .hic and .cool files
long_description = file: README.md, LICENSE
long_description_content_type = text/markdown
license = MIT
classifiers =
Programming Language :: Python :: 3
Expand All @@ -17,6 +18,7 @@ classifiers =
zip_safe = False
python_requires = >=3.6
install_requires =
msvc-runtime; os_name=="nt"
numpy
pandas
scipy
Expand Down
6 changes: 5 additions & 1 deletion setup.py
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,11 @@ class CMakeBuild(build_ext):
def build_extension(self, ext: CMakeExtension) -> None:
# Must be in this form due to bug in .resolve() only fixed in Python 3.10+
ext_fullpath = Path.cwd() / self.get_ext_fullpath(ext.name)
extdir = ext_fullpath.parent.resolve()
extdir = ext_fullpath.parent.resolve() / ext.name
extdir.mkdir(exist_ok=True, parents=True)
with open(extdir / "__init__.py", "w") as f:
symbols = ["File", "is_cooler", "is_hic_file", "__version__"]
f.write("from .hictkpy import " + ", ".join(symbols) + "\n")

# Using this requires trailing slash for auto-detection & inclusion of
# auxiliary "native" libs
Expand Down
4 changes: 2 additions & 2 deletions src/hictkpy_pixel_selector.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ py::object PixelSelector::to_coo() const {
const auto num_rows = span1 == 0 ? bins().size() : (span1 + bin_size - 1) / bin_size;
const auto num_cols = span2 == 0 ? bins().size() : (span2 + bin_size - 1) / bin_size;
return std::visit(
[&](const auto& s) {
[&, num_rows, num_cols](const auto& s) {
if (int_pixels()) {
using T = std::int32_t;
return pixel_iterators_to_coo(s->template begin<T>(), s->template end<T>(), num_rows,
Expand All @@ -183,7 +183,7 @@ py::object PixelSelector::to_numpy() const {
const auto mirror_matrix = coord1().bin1.chrom() == coord2().bin1.chrom();

return std::visit(
[&](const auto& s) {
[&, num_rows, num_cols, mirror_matrix](const auto& s) {
if (int_pixels()) {
using T = std::int32_t;
return pixel_iterators_to_numpy(s->template begin<T>(), s->template end<T>(), num_rows,
Expand Down

0 comments on commit ffcd113

Please sign in to comment.