From 2f3c3d4a2f758a3121eaf1ca638292c5e3be40c8 Mon Sep 17 00:00:00 2001 From: Talley Lambert Date: Tue, 7 Mar 2023 10:48:28 -0500 Subject: [PATCH 01/17] test: test windows --- .github/workflows/ci.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 4924bd0..c6128e3 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -20,7 +20,7 @@ jobs: fail-fast: false matrix: python-version: ["3.8", "3.9", "3.10", "3.11"] - platform: [ubuntu-latest, macos-latest] + platform: [ubuntu-latest, macos-latest, windows-latest] steps: - uses: actions/checkout@v3 with: From 7d802e5f6edab39d125f3094c27c6fde6089d0bb Mon Sep 17 00:00:00 2001 From: Talley Lambert Date: Tue, 7 Mar 2023 11:21:47 -0500 Subject: [PATCH 02/17] dir on windows --- .github/workflows/ci.yaml | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 2143817..dc4f0bc 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -28,12 +28,19 @@ jobs: submodules: true - uses: conda-incubator/setup-miniconda@v2 with: + auto-update-conda: true python-version: ${{ matrix.python-version }} mamba-version: "*" channels: conda-forge,gurobi,defaults channel-priority: true - name: install build deps run: mamba install scip gurobi + - name: list + if: matrix.platform == 'windows-latest' + run: | + dir C:\Miniconda\envs\test\Include + dir C:\Miniconda\envs\test\Include\scip + - name: install package run: | python -m pip install -U pip From 0a993cb6e4cfaae67f68cd082dc7606873d2ea86 Mon Sep 17 00:00:00 2001 From: Talley Lambert Date: Tue, 7 Mar 2023 11:34:14 -0500 Subject: [PATCH 03/17] switch bracket --- .github/workflows/ci.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index dc4f0bc..9c4b340 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -38,8 +38,8 @@ jobs: - name: list if: matrix.platform == 'windows-latest' run: | - dir C:\Miniconda\envs\test\Include - dir C:\Miniconda\envs\test\Include\scip + dir C:/Miniconda/envs/test/Include + dir C:/Miniconda/envs/test/Include/scip - name: install package run: | From 67980fa1562872faeba486097192524d5dc75109 Mon Sep 17 00:00:00 2001 From: Talley Lambert Date: Tue, 7 Mar 2023 17:19:40 -0500 Subject: [PATCH 04/17] specify env --- .github/workflows/ci.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 9c4b340..4e97942 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -34,7 +34,7 @@ jobs: channels: conda-forge,gurobi,defaults channel-priority: true - name: install build deps - run: mamba install scip gurobi + run: mamba install -n test scip gurobi - name: list if: matrix.platform == 'windows-latest' run: | From 494af3fb8f26e012e0ad6e4bd3de2ec06bd725ce Mon Sep 17 00:00:00 2001 From: Talley Lambert Date: Tue, 7 Mar 2023 17:27:00 -0500 Subject: [PATCH 05/17] print different dirs --- .github/workflows/ci.yaml | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 4e97942..9f389ac 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -28,18 +28,16 @@ jobs: submodules: true - uses: conda-incubator/setup-miniconda@v2 with: - auto-update-conda: true python-version: ${{ matrix.python-version }} - mamba-version: "*" channels: conda-forge,gurobi,defaults channel-priority: true - name: install build deps - run: mamba install -n test scip gurobi + run: conda install -n test scip gurobi - name: list if: matrix.platform == 'windows-latest' run: | - dir C:/Miniconda/envs/test/Include - dir C:/Miniconda/envs/test/Include/scip + dir C:/Miniconda/envs/test/Library/include + dir C:/Miniconda/envs/test/Library/include/scip - name: install package run: | From 2f3af5f0b1526b7956897ed02d279f77f0b8a87e Mon Sep 17 00:00:00 2001 From: Talley Lambert Date: Tue, 7 Mar 2023 17:30:15 -0500 Subject: [PATCH 06/17] print vars --- .github/workflows/ci.yaml | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 9f389ac..a1bba1b 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -33,12 +33,8 @@ jobs: channel-priority: true - name: install build deps run: conda install -n test scip gurobi - - name: list - if: matrix.platform == 'windows-latest' - run: | - dir C:/Miniconda/envs/test/Library/include - dir C:/Miniconda/envs/test/Library/include/scip - + - if: matrix.platform == 'windows-latest' + run: set - name: install package run: | python -m pip install -U pip From c317b58943204470f2096b248e22d8dcdfa4b65c Mon Sep 17 00:00:00 2001 From: Talley Lambert Date: Tue, 7 Mar 2023 17:56:56 -0500 Subject: [PATCH 07/17] add include on windows --- setup.py | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/setup.py b/setup.py index c6b4f2f..ee5ad4a 100644 --- a/setup.py +++ b/setup.py @@ -1,3 +1,5 @@ +import os + from ctypes import util from Cython.Build import cythonize @@ -5,8 +7,18 @@ from setuptools.extension import Extension libraries = ["scip"] +include_dirs = ['ilpy/impl'] compile_args = ["-O3", "-std=c++11", "-DHAVE_SCIP"] +# include conda environment windows include if it exists +# this will be done automatically by conda build, but is useful if someone +# tries to build this directly with pip install in a conda environment +if 'CONDA_PREFIX' in os.environ: + win_include = os.path.join(os.environ['CONDA_PREFIX'], 'Library', 'include') + if os.path.exists(win_include): + include_dirs.append(win_include) + + # look for various gurobi versions, which are annoyingly # suffixed with the version number, and wildcards don't work for v in ["100"]: @@ -38,7 +50,7 @@ 'ilpy/wrapper.pyx', ], extra_compile_args=compile_args, - include_dirs=['ilpy/impl'], + include_dirs=include_dirs, libraries=libraries, language='c++') ]), From e08be6274ae814c090d73c6bb86d9d1fc09241f1 Mon Sep 17 00:00:00 2001 From: Talley Lambert Date: Tue, 7 Mar 2023 20:06:47 -0500 Subject: [PATCH 08/17] include lib on windows --- setup.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/setup.py b/setup.py index ee5ad4a..a69dec9 100644 --- a/setup.py +++ b/setup.py @@ -7,16 +7,20 @@ from setuptools.extension import Extension libraries = ["scip"] +library_dirs = [] include_dirs = ['ilpy/impl'] compile_args = ["-O3", "-std=c++11", "-DHAVE_SCIP"] -# include conda environment windows include if it exists +# include conda environment windows include/lib if it exists # this will be done automatically by conda build, but is useful if someone # tries to build this directly with pip install in a conda environment if 'CONDA_PREFIX' in os.environ: win_include = os.path.join(os.environ['CONDA_PREFIX'], 'Library', 'include') if os.path.exists(win_include): include_dirs.append(win_include) + win_lib = os.path.join(os.environ['CONDA_PREFIX'], 'Library', 'lib') + if os.path.exists(win_lib): + library_dirs.append(win_lib) # look for various gurobi versions, which are annoyingly @@ -52,6 +56,7 @@ extra_compile_args=compile_args, include_dirs=include_dirs, libraries=libraries, + library_dirs=library_dirs, language='c++') ]), extras_require={ From d4c73056d65fd0c7fe5b1505c8a0df9eb63b100c Mon Sep 17 00:00:00 2001 From: Talley Lambert Date: Tue, 7 Mar 2023 20:20:44 -0500 Subject: [PATCH 09/17] try bin --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index a69dec9..54a2d94 100644 --- a/setup.py +++ b/setup.py @@ -18,7 +18,7 @@ win_include = os.path.join(os.environ['CONDA_PREFIX'], 'Library', 'include') if os.path.exists(win_include): include_dirs.append(win_include) - win_lib = os.path.join(os.environ['CONDA_PREFIX'], 'Library', 'lib') + win_lib = os.path.join(os.environ['CONDA_PREFIX'], 'Library', 'bin') if os.path.exists(win_lib): library_dirs.append(win_lib) From 962e7d9a23b6439f088f2e495ce825f1ffe12df2 Mon Sep 17 00:00:00 2001 From: Talley Lambert Date: Tue, 7 Mar 2023 20:22:56 -0500 Subject: [PATCH 10/17] simplify --- setup.py | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/setup.py b/setup.py index 54a2d94..3f36aa4 100644 --- a/setup.py +++ b/setup.py @@ -14,14 +14,10 @@ # include conda environment windows include/lib if it exists # this will be done automatically by conda build, but is useful if someone # tries to build this directly with pip install in a conda environment -if 'CONDA_PREFIX' in os.environ: - win_include = os.path.join(os.environ['CONDA_PREFIX'], 'Library', 'include') - if os.path.exists(win_include): - include_dirs.append(win_include) - win_lib = os.path.join(os.environ['CONDA_PREFIX'], 'Library', 'bin') - if os.path.exists(win_lib): - library_dirs.append(win_lib) - +if os.name == 'nt' and 'CONDA_PREFIX' in os.environ: + include_dirs.append(os.path.join(os.environ['CONDA_PREFIX'], 'Library', 'include')) + library_dirs.append(os.path.join(os.environ['CONDA_PREFIX'], 'Library', 'bin')) + # look for various gurobi versions, which are annoyingly # suffixed with the version number, and wildcards don't work From bfa5d1d406ea3dc059ee2fad23cb4f3140d47bcf Mon Sep 17 00:00:00 2001 From: Talley Lambert Date: Wed, 8 Mar 2023 17:25:03 -0500 Subject: [PATCH 11/17] update setup.py --- .github/workflows/ci.yaml | 5 ++--- conda/conda_build_config.yaml | 4 ++++ conda/meta.yaml | 2 +- setup.py | 4 ++-- 4 files changed, 9 insertions(+), 6 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index a1bba1b..2143817 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -29,12 +29,11 @@ jobs: - uses: conda-incubator/setup-miniconda@v2 with: python-version: ${{ matrix.python-version }} + mamba-version: "*" channels: conda-forge,gurobi,defaults channel-priority: true - name: install build deps - run: conda install -n test scip gurobi - - if: matrix.platform == 'windows-latest' - run: set + run: mamba install scip gurobi - name: install package run: | python -m pip install -U pip diff --git a/conda/conda_build_config.yaml b/conda/conda_build_config.yaml index 77f0eec..f57249d 100644 --- a/conda/conda_build_config.yaml +++ b/conda/conda_build_config.yaml @@ -2,3 +2,7 @@ python: - 3.9 - 3.10 - 3.11 +channel_targets: + - funkelab main +channel_sources: + - gurobi,conda-forge,defaults diff --git a/conda/meta.yaml b/conda/meta.yaml index e4f7bf1..cac6092 100644 --- a/conda/meta.yaml +++ b/conda/meta.yaml @@ -17,7 +17,7 @@ requirements: - cython - python {{python}} - scip - - gurobi + - gurobi ==10.0.1 run: - python {{python}} - scip diff --git a/setup.py b/setup.py index 3f36aa4..ce5ce55 100644 --- a/setup.py +++ b/setup.py @@ -6,7 +6,7 @@ from setuptools import setup from setuptools.extension import Extension -libraries = ["scip"] +libraries = ["libscip"] library_dirs = [] include_dirs = ['ilpy/impl'] compile_args = ["-O3", "-std=c++11", "-DHAVE_SCIP"] @@ -22,7 +22,7 @@ # look for various gurobi versions, which are annoyingly # suffixed with the version number, and wildcards don't work for v in ["100"]: - GUROBI_LIB = f"gurobi{v}" + GUROBI_LIB = f"libgurobi{v}" if (gurolib := util.find_library(GUROBI_LIB)) is not None: print("FOUND GUROBI library: ", gurolib) libraries.append(GUROBI_LIB) From d74c0e27b4500a33828c900ecd459b6644f151bb Mon Sep 17 00:00:00 2001 From: Talley Lambert Date: Wed, 8 Mar 2023 17:26:16 -0500 Subject: [PATCH 12/17] remove lines --- setup.py | 13 +------------ 1 file changed, 1 insertion(+), 12 deletions(-) diff --git a/setup.py b/setup.py index ce5ce55..5ba6a26 100644 --- a/setup.py +++ b/setup.py @@ -7,18 +7,8 @@ from setuptools.extension import Extension libraries = ["libscip"] -library_dirs = [] -include_dirs = ['ilpy/impl'] compile_args = ["-O3", "-std=c++11", "-DHAVE_SCIP"] -# include conda environment windows include/lib if it exists -# this will be done automatically by conda build, but is useful if someone -# tries to build this directly with pip install in a conda environment -if os.name == 'nt' and 'CONDA_PREFIX' in os.environ: - include_dirs.append(os.path.join(os.environ['CONDA_PREFIX'], 'Library', 'include')) - library_dirs.append(os.path.join(os.environ['CONDA_PREFIX'], 'Library', 'bin')) - - # look for various gurobi versions, which are annoyingly # suffixed with the version number, and wildcards don't work for v in ["100"]: @@ -50,9 +40,8 @@ 'ilpy/wrapper.pyx', ], extra_compile_args=compile_args, - include_dirs=include_dirs, + include_dirs=['ilpy/impl'], libraries=libraries, - library_dirs=library_dirs, language='c++') ]), extras_require={ From 843b0a82c990b39eb0b8545e37f021f142aa20df Mon Sep 17 00:00:00 2001 From: Talley Lambert Date: Wed, 8 Mar 2023 17:30:12 -0500 Subject: [PATCH 13/17] fix non windows --- setup.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/setup.py b/setup.py index 5ba6a26..d3e67c8 100644 --- a/setup.py +++ b/setup.py @@ -6,13 +6,13 @@ from setuptools import setup from setuptools.extension import Extension -libraries = ["libscip"] +libraries = ["libscip"] if os.name == "nt" else ["scip"] compile_args = ["-O3", "-std=c++11", "-DHAVE_SCIP"] # look for various gurobi versions, which are annoyingly # suffixed with the version number, and wildcards don't work for v in ["100"]: - GUROBI_LIB = f"libgurobi{v}" + GUROBI_LIB = f"libgurobi{v}" if os.name == 'nt' else f"gurobi{v}" if (gurolib := util.find_library(GUROBI_LIB)) is not None: print("FOUND GUROBI library: ", gurolib) libraries.append(GUROBI_LIB) From 52de73af01d074a208b4208463e6776459e4c017 Mon Sep 17 00:00:00 2001 From: Talley Lambert Date: Thu, 9 Mar 2023 09:18:11 -0500 Subject: [PATCH 14/17] add back lib_dirs --- setup.py | 56 +++++++++++++++++++++++++++++++++----------------------- 1 file changed, 33 insertions(+), 23 deletions(-) diff --git a/setup.py b/setup.py index d3e67c8..1af89cc 100644 --- a/setup.py +++ b/setup.py @@ -1,3 +1,4 @@ +from dbm.ndbm import library import os from ctypes import util @@ -7,12 +8,21 @@ from setuptools.extension import Extension libraries = ["libscip"] if os.name == "nt" else ["scip"] +include_dirs = ["ilpy/impl"] +library_dirs = [] compile_args = ["-O3", "-std=c++11", "-DHAVE_SCIP"] +# include conda environment windows include/lib if it exists +# this will be done automatically by conda build, but is useful if someone +# tries to build this directly with pip install in a conda environment +if os.name == "nt" and "CONDA_PREFIX" in os.environ: + include_dirs.append(os.path.join(os.environ["CONDA_PREFIX"], "Library", "include")) + library_dirs.append(os.path.join(os.environ["CONDA_PREFIX"], "Library", "bin")) + # look for various gurobi versions, which are annoyingly # suffixed with the version number, and wildcards don't work for v in ["100"]: - GUROBI_LIB = f"libgurobi{v}" if os.name == 'nt' else f"gurobi{v}" + GUROBI_LIB = f"libgurobi{v}" if os.name == "nt" else f"gurobi{v}" if (gurolib := util.find_library(GUROBI_LIB)) is not None: print("FOUND GUROBI library: ", gurolib) libraries.append(GUROBI_LIB) @@ -23,31 +33,31 @@ setup( - name='ilpy', - version='0.2', - description='Python wrappers for popular MIP solvers.', - url='https://github.com/funkelab/ilpy', - author='Jan Funke', - author_email='funkej@janelia.hhmi.org', - license='MIT', - packages=[ - 'ilpy' - ], - ext_modules=cythonize([ + name="ilpy", + version="0.2", + description="Python wrappers for popular MIP solvers.", + url="https://github.com/funkelab/ilpy", + author="Jan Funke", + author_email="funkej@janelia.hhmi.org", + license="MIT", + packages=["ilpy"], + ext_modules=cythonize( + [ Extension( - 'ilpy.wrapper', + "ilpy.wrapper", sources=[ - 'ilpy/wrapper.pyx', + "ilpy/wrapper.pyx", ], extra_compile_args=compile_args, - include_dirs=['ilpy/impl'], + include_dirs=include_dirs, libraries=libraries, - language='c++') - ]), - extras_require={ - "dev": ["flake8", "pytest", "pytest-cov"], - }, - package_data={ - "ilpy": ["py.typed", "*.pyi"] - }, + library_dirs=library_dirs, + language="c++", + ) + ] + ), + extras_require={ + "dev": ["flake8", "pytest", "pytest-cov"], + }, + package_data={"ilpy": ["py.typed", "*.pyi"]}, ) From 0618764dd2e31095c11ac48c0e5dfae2a896ec04 Mon Sep 17 00:00:00 2001 From: Talley Lambert Date: Thu, 9 Mar 2023 10:05:15 -0500 Subject: [PATCH 15/17] fix setup.py import --- setup.py | 46 +++++++++++++++++++++++----------------------- 1 file changed, 23 insertions(+), 23 deletions(-) diff --git a/setup.py b/setup.py index 1af89cc..baa1347 100644 --- a/setup.py +++ b/setup.py @@ -1,4 +1,3 @@ -from dbm.ndbm import library import os from ctypes import util @@ -8,7 +7,7 @@ from setuptools.extension import Extension libraries = ["libscip"] if os.name == "nt" else ["scip"] -include_dirs = ["ilpy/impl"] +include_dirs = ['ilpy/impl'] library_dirs = [] compile_args = ["-O3", "-std=c++11", "-DHAVE_SCIP"] @@ -22,7 +21,7 @@ # look for various gurobi versions, which are annoyingly # suffixed with the version number, and wildcards don't work for v in ["100"]: - GUROBI_LIB = f"libgurobi{v}" if os.name == "nt" else f"gurobi{v}" + GUROBI_LIB = f"libgurobi{v}" if os.name == 'nt' else f"gurobi{v}" if (gurolib := util.find_library(GUROBI_LIB)) is not None: print("FOUND GUROBI library: ", gurolib) libraries.append(GUROBI_LIB) @@ -33,31 +32,32 @@ setup( - name="ilpy", - version="0.2", - description="Python wrappers for popular MIP solvers.", - url="https://github.com/funkelab/ilpy", - author="Jan Funke", - author_email="funkej@janelia.hhmi.org", - license="MIT", - packages=["ilpy"], - ext_modules=cythonize( - [ + name='ilpy', + version='0.2', + description='Python wrappers for popular MIP solvers.', + url='https://github.com/funkelab/ilpy', + author='Jan Funke', + author_email='funkej@janelia.hhmi.org', + license='MIT', + packages=[ + 'ilpy' + ], + ext_modules=cythonize([ Extension( - "ilpy.wrapper", + 'ilpy.wrapper', sources=[ - "ilpy/wrapper.pyx", + 'ilpy/wrapper.pyx', ], extra_compile_args=compile_args, include_dirs=include_dirs, libraries=libraries, library_dirs=library_dirs, - language="c++", - ) - ] - ), - extras_require={ - "dev": ["flake8", "pytest", "pytest-cov"], - }, - package_data={"ilpy": ["py.typed", "*.pyi"]}, + language='c++') + ]), + extras_require={ + "dev": ["flake8", "pytest", "pytest-cov"], + }, + package_data={ + "ilpy": ["py.typed", "*.pyi"] + }, ) From cdc8988250e930e4c342f3001b12e986ba4097aa Mon Sep 17 00:00:00 2001 From: Talley Lambert Date: Fri, 10 Mar 2023 11:51:52 -0500 Subject: [PATCH 16/17] bin to lib --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index baa1347..4978725 100644 --- a/setup.py +++ b/setup.py @@ -16,7 +16,7 @@ # tries to build this directly with pip install in a conda environment if os.name == "nt" and "CONDA_PREFIX" in os.environ: include_dirs.append(os.path.join(os.environ["CONDA_PREFIX"], "Library", "include")) - library_dirs.append(os.path.join(os.environ["CONDA_PREFIX"], "Library", "bin")) + library_dirs.append(os.path.join(os.environ["CONDA_PREFIX"], "Library", "lib")) # look for various gurobi versions, which are annoyingly # suffixed with the version number, and wildcards don't work From 3aec97adb625a369e01ed72092804e0fa610fbba Mon Sep 17 00:00:00 2001 From: Talley Lambert Date: Fri, 10 Mar 2023 11:56:21 -0500 Subject: [PATCH 17/17] remove extra --- conda/conda_build_config.yaml | 4 ---- conda/meta.yaml | 2 +- 2 files changed, 1 insertion(+), 5 deletions(-) diff --git a/conda/conda_build_config.yaml b/conda/conda_build_config.yaml index f57249d..77f0eec 100644 --- a/conda/conda_build_config.yaml +++ b/conda/conda_build_config.yaml @@ -2,7 +2,3 @@ python: - 3.9 - 3.10 - 3.11 -channel_targets: - - funkelab main -channel_sources: - - gurobi,conda-forge,defaults diff --git a/conda/meta.yaml b/conda/meta.yaml index cac6092..e4f7bf1 100644 --- a/conda/meta.yaml +++ b/conda/meta.yaml @@ -17,7 +17,7 @@ requirements: - cython - python {{python}} - scip - - gurobi ==10.0.1 + - gurobi run: - python {{python}} - scip