|
| 1 | + |
| 2 | +# Building |
| 3 | + |
| 4 | +## Be sure to check out all submodules: |
| 5 | + |
| 6 | +``` |
| 7 | +$ git clone --recursive https://github.com/googleapis/python-crc32c |
| 8 | +``` |
| 9 | + |
| 10 | +## Building and Testing Wheels |
| 11 | + |
| 12 | +The scripts directory contains multiple scripts for building. They are also |
| 13 | +used by the CI workflows which can be found at .github/workflows. |
| 14 | + |
| 15 | +On Linux: |
| 16 | + |
| 17 | +``` |
| 18 | +./scripts/manylinux/build.sh |
| 19 | +
|
| 20 | +
|
| 21 | +# Install the wheel that was built as a result |
| 22 | +pip install --no-index --find-links=wheels google-crc32c |
| 23 | +
|
| 24 | +# Check the package, try and load the native library. |
| 25 | +python ./scripts/check_crc32c_extension.py |
| 26 | +``` |
| 27 | + |
| 28 | +On OS X: |
| 29 | + |
| 30 | +``` |
| 31 | +# Build the C library and wheel |
| 32 | +./scripts/osx/build.sh |
| 33 | +
|
| 34 | +# Install the wheel that was built as a result |
| 35 | +pip install --no-index --find-links=wheels google-crc32c |
| 36 | +
|
| 37 | +# Check the package, try and load the native library. |
| 38 | +python ./scripts/check_crc32c_extension.py |
| 39 | +``` |
| 40 | + |
| 41 | +On Windows: |
| 42 | + |
| 43 | +``` |
| 44 | +.\scripts\windows\build.bat |
| 45 | +.\scripts\windows\test.bat |
| 46 | +``` |
| 47 | + |
| 48 | + |
| 49 | +## Installing locally for testing |
| 50 | + |
| 51 | +Initialize the submodules and build the main `libcrc32c.so` shared |
| 52 | +library using `cmake` / `make`: |
| 53 | + |
| 54 | +```bash |
| 55 | +$ cd python-crc32c |
| 56 | +$ git submodule update --init --recursive |
| 57 | +$ python -m venv venv |
| 58 | +$ venv/bin/pip install --upgrade setuptools pip wheel |
| 59 | +$ venv/bin/pip install cmake |
| 60 | +$ mkdir usr |
| 61 | +$ export CRC32C_INSTALL_PREFIX=$(pwd)/usr |
| 62 | +$ mkdir google_crc32c/build |
| 63 | +$ cd google_crc32c/build |
| 64 | +$ ../../venv/bin/cmake \ |
| 65 | +> -DCMAKE_BUILD_TYPE=Release \ |
| 66 | +> -DCRC32C_BUILD_TESTS=no \ |
| 67 | +> -DCRC32C_BUILD_BENCHMARKS=no \ |
| 68 | +> -DBUILD_SHARED_LIBS=yes \ |
| 69 | +> -DCMAKE_INSTALL_PREFIX:PATH=${CRC32C_INSTALL_PREFIX} \ |
| 70 | +> .. |
| 71 | +$ make all install |
| 72 | +$ cd ../.. |
| 73 | +``` |
| 74 | + |
| 75 | +Now, run the tests: |
| 76 | + |
| 77 | +```bash |
| 78 | +$ venv/bin/python setup.py build_ext \ |
| 79 | + --include-dirs=$(pwd)/usr/include \ |
| 80 | + --library-dirs=$(pwd)/usr/lib \ |
| 81 | + --rpath=$(pwd)/usr/lib |
| 82 | +$ venv/bin/pip install -e .[testing] |
| 83 | +$ venv/bin/py.test tests/ |
| 84 | +============================= test session starts ============================== |
| 85 | +platform linux -- Python 3.6.7, pytest-3.10.0, py-1.7.0, pluggy-0.8.0 |
| 86 | +rootdir: ..., inifile: |
| 87 | +collected 9 items |
| 88 | + |
| 89 | +tests/test___init__.py ......... [100%] |
| 90 | + |
| 91 | +=========================== 9 passed in 0.03 seconds =========================== |
| 92 | +``` |
0 commit comments