Skip to content
This repository has been archived by the owner on Dec 18, 2023. It is now read-only.

Commit

Permalink
Remove vcpkg requirement and use conda for range-v3
Browse files Browse the repository at this point in the history
Now that range-v3 is available in conda-forge, we could simplify the installation and get rid of the need to install vcpkg
  • Loading branch information
horizon-blue committed Oct 17, 2023
1 parent 00f2e1c commit fb56348
Show file tree
Hide file tree
Showing 8 changed files with 19 additions and 166 deletions.
30 changes: 3 additions & 27 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,28 +48,9 @@ jobs:
python-version: ${{ matrix.python-version }}
activate-environment: build_env

- name: Install Windows range-v3 dependency
if: matrix.os == 'windows-latest'
run: |
git clone https://github.com/Microsoft/vcpkg.git
cd vcpkg
bootstrap-vcpkg.bat
vcpkg integrate install
vcpkg install range-v3
- name: Install Unix range-v3 dependency
if: matrix.os != 'windows-latest'
run: |
git clone https://github.com/Microsoft/vcpkg.git
cd vcpkg
./bootstrap-vcpkg.sh
./vcpkg integrate install
./vcpkg install range-v3
sudo mv ./packages/range-v3_x64-linux/include /usr/include/range-v3
- name: Install other dependencies
run: |
conda install -c conda-forge -y boost-cpp eigen=3.4.0
conda install -c conda-forge -y boost-cpp eigen range-v3
python -m pip install --upgrade pip
pip install -U build
Expand Down Expand Up @@ -124,13 +105,8 @@ jobs:
CIBW_SKIP: "*-manylinux_i686 *-musllinux_*"
CIBW_ARCHS_MACOS: x86_64 universal2 arm64
CIBW_MANYLINUX_X86_64_IMAGE: manylinux2014
CIBW_BEFORE_ALL_LINUX: > # Manually install range-v3 with vcpkg and Eigen3.4 since yum is not up to date
yum install -y curl zip unzip tar wget boost169-devel &&
git clone https://github.com/Microsoft/vcpkg.git &&
cd vcpkg &&
./bootstrap-vcpkg.sh &&
./vcpkg integrate install &&
./vcpkg install range-v3 &&
CIBW_BEFORE_ALL_LINUX: > # Manually install Eigen3.4 since yum is not up to date
yum install -y curl zip unzip tar wget boost169-devel range-v3-devel &&
wget https://gitlab.com/libeigen/eigen/-/archive/3.4.0/eigen-3.4.0.tar.gz &&
tar -xvf eigen-3.4.0.tar.gz &&
mv eigen-3.4.0 /usr/include/eigen3
Expand Down
10 changes: 1 addition & 9 deletions .github/workflows/docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,18 +29,10 @@ jobs:
python-version: ${{ matrix.python-version }}
activate-environment: test_env

- name: Install range-v3 dependency
run: |
git clone https://github.com/Microsoft/vcpkg.git
cd vcpkg
./bootstrap-vcpkg.sh
./vcpkg integrate install
./vcpkg install range-v3
- name: Install other dependencies
run: |
sudo apt-get install -y yarn
conda install -c conda-forge -y boost-cpp eigen=3.4.0
conda install -c conda-forge -y boost-cpp eigen range-v3
python -m pip install --upgrade pip
python -m pip install setuptools
python -m pip install notebook
Expand Down
13 changes: 2 additions & 11 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,18 +30,9 @@ jobs:
python-version: ${{ matrix.python-version }}
activate-environment: test_env

- name: Install Unix range-v3 dependency
if: matrix.os != 'windows-latest'
run: |
git clone https://github.com/Microsoft/vcpkg.git
cd vcpkg
./bootstrap-vcpkg.sh
./vcpkg integrate install
./vcpkg install range-v3
- name: Install dependencies
run: |
conda install -c conda-forge -y boost-cpp eigen=3.4.0
conda install -c conda-forge -y boost-cpp eigen range-v3
pip install torch --extra-index-url https://download.pytorch.org/whl/cpu
VERSION=$(grep "version" .pyre_configuration | sed -n -e 's/.*\(0\.0\.[0-9]*\).*/\1/p')
pip install pyre-check-nightly==$VERSION
Expand All @@ -51,7 +42,7 @@ jobs:
run: pip list

- name: Lint with flake8
run: flake8 . --exclude ./vcpkg
run: flake8 . --exclude

- name: Lint with ufmt (black + usort)
run: ufmt check .*/beanmachine/src
Expand Down
11 changes: 1 addition & 10 deletions .github/workflows/nightly.yml.disabled
Original file line number Diff line number Diff line change
Expand Up @@ -31,18 +31,9 @@ jobs:
python-version: ${{ matrix.python-version }}
activate-environment: test_env

- name: Install Unix range-v3 dependency
if: matrix.os != 'windows-latest'
run: |
git clone https://github.com/Microsoft/vcpkg.git
cd vcpkg
./bootstrap-vcpkg.sh
./vcpkg integrate install
./vcpkg install range-v3

- name: Install other dependencies
run: |
conda install -c conda-forge -y boost-cpp eigen=3.4.0
conda install -c conda-forge -y boost-cpp eigen range-v3
python -m pip install --upgrade pip

- name: Install Bean Machine
Expand Down
20 changes: 1 addition & 19 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,27 +35,9 @@ jobs:
python-version: ${{ matrix.python-version }}
activate-environment: test_env

- name: Install Windows range-v3 dependency
if: matrix.os == 'windows-latest'
run: |
git clone https://github.com/Microsoft/vcpkg.git
cd vcpkg
bootstrap-vcpkg.bat
vcpkg integrate install
vcpkg install range-v3
- name: Install Unix range-v3 dependency
if: matrix.os != 'windows-latest'
run: |
git clone https://github.com/Microsoft/vcpkg.git
cd vcpkg
./bootstrap-vcpkg.sh
./vcpkg integrate install
./vcpkg install range-v3
- name: Install other dependencies
run: |
conda install -c conda-forge -y boost-cpp eigen=3.4.0
conda install -c conda-forge -y boost-cpp eigen range-v3
python -m pip install --upgrade pip
- name: Install CPU PyTorch (only for Linux)
Expand Down
3 changes: 0 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,3 @@ website/static/js/*
!website/static/js/code_block_buttons.js
website/static/_sphinx-sources/
docs/api/

## ignore user's local installation of vcpkg
vcpkg
23 changes: 6 additions & 17 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ Bean Machine supports Python 3.7-3.10 and PyTorch 1.12.
### Install the Latest Release with Pip

```bash
python -m pip install beanmachine
pip install beanmachine
```

### Install from Source
Expand All @@ -33,31 +33,20 @@ cd beanmachine

Then, you can choose from any of the following installation options.

#### Package Managers (Anaconda and Vcpkg)
#### Package Managers (Conda)

Installing Bean Machine from source requires three external dependencies: [Boost](https://www.boost.org/), [Eigen](https://eigen.tuxfamily.org/index.php?title=Main_Page), and [`range-v3`](https://github.com/ericniebler/range-v3).

For installing Boost and Eigen, we recommend using [conda](https://docs.conda.io/en/latest/) to manage the virtual environment and install the necessary build dependencies.
We recommend using [conda](https://docs.conda.io/en/latest/) to manage the virtual environment and install the necessary build dependencies.

```bash
conda create -n {env name} python=3.8; conda activate {env name}
conda install -c conda-forge boost-cpp eigen=3.4.0
```

There are [multiple ways of installing `range-v3`](https://github.com/ericniebler/range-v3#building-range-v3---using-vcpkg), including through [`vcpkg`](https://github.com/Microsoft/vcpkg):

```
git clone https://github.com/Microsoft/vcpkg.git
cd vcpkg
./bootstrap-vcpkg.sh
./vcpkg integrate install
./vcpkg install range-v3
conda install -c conda-forge boost-cpp eigen range-v3
```

Once dependencies are installed, install Bean Machine by running Pip:

```
python -m pip install .
pip install .
```

#### Docker
Expand All @@ -72,7 +61,7 @@ docker run -it beanmachine:latest bash
If you would like to run the builtin unit tests:

```bash
python -m pip install "beanmachine[test]"
pip install "beanmachine[test]"
pytest .
```

Expand Down
75 changes: 5 additions & 70 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,11 @@
"/wd4244",
]
else:
CPP_COMPILE_ARGS = ["-std=c++2a", "-Werror"]
CPP_COMPILE_ARGS = [
"-std=c++2a",
"-Werror",
"-Wno-unused-but-set-variable", # Eigen 3.4 triggers this
]


# Check for python version
Expand Down Expand Up @@ -129,75 +133,6 @@
+ glob("/usr/local/Cellar/boost/*/include")
)

# Add range-v3 'include' directory to configuration
RANGE_V3_INCLUDE_DIR_CANDIDATES = [
c for c in [os.environ.get("RANGE_V3_INCLUDE_DIR")] if c is not None
]
if sys.platform.startswith("linux"):
RANGE_V3_INCLUDE_DIR_CANDIDATES.extend(
[
os.path.join(current_dir, "vcpkg/packages/range-v3_x64-linux/include"),
"/usr/include/range-v3",
]
)
elif sys.platform.startswith("darwin"):
RANGE_V3_INCLUDE_DIR_CANDIDATES.extend(
[
os.path.join(current_dir, "vcpkg/packages/range-v3_x64-osx/include"),
*glob("/usr/local/Cellar/range-v3/*/include"), # Homebrew
]
)
elif platform.system() == "Windows":
RANGE_V3_INCLUDE_DIR_CANDIDATES.extend(
[
os.path.join(current_dir, "vcpkg/packages/range-v3_x86-windows/include"),
# The following option was observed being used on GitHub Actions runner:
"C:/vcpkg/packages/range-v3_x86-windows/include",
]
)
print(
"Checking directories for range-v3 'include':\n",
"\n".join(RANGE_V3_INCLUDE_DIR_CANDIDATES),
)
selected_range_v3_include_dirs = [
candidate
for candidate in RANGE_V3_INCLUDE_DIR_CANDIDATES
if os.path.isdir(candidate)
]
print(
"Existing candidate directories for range-v3 'include':\n",
"\n".join(selected_range_v3_include_dirs),
)
if len(selected_range_v3_include_dirs) == 0:
if os.environ.get("RANGE_V3_INCLUDE_DIR"):
message = (
"Could not find 'include' directory for range-v3 library dependency "
+ f"either at {os.environ.get('RANGE_V3_INCLUDE_DIR')}\n"
+ "as indicated in environment variable RANGE_V3_INCLUDE_DIR, "
+ "nor in some other common locations.\n"
+ "Please make sure library is installed (see README.md) and "
+ "set RANGE_V3_INCLUDE_DIR environment variable to the right directory."
)
else:
message = (
"Could not find 'include' directory for range-v3 library dependency "
+ "in some common locations.\n"
+ "Please make sure library is installed (see README.md). "
+ "You can also manually indicate the correct 'include' directory by "
+ "setting the environment variable RANGE_V3_INCLUDE_DIR environment "
+ "variable to the right directory."
)
message += "Here are the directories we checked:\n " + "\n".join(
RANGE_V3_INCLUDE_DIR_CANDIDATES
)
sys.exit(message)
else:
print(
"Using the following directory for range-v3 'include':\n",
selected_range_v3_include_dirs[0],
)
INCLUDE_DIRS.append(selected_range_v3_include_dirs[0])

setup(
name="beanmachine",
version=version,
Expand Down

0 comments on commit fb56348

Please sign in to comment.