├── .github └── workflows │ ├── Linux.yml │ ├── Windows.yml │ └── macOS.yml ├── .gitignore ├── LICENSE ├── README.md ├── manylinux-cross.sh ├── manylinux.sh └── pyproject.toml /.github/workflows/Linux.yml: -------------------------------------------------------------------------------- 1 | on: 2 | push: 3 | branches: 4 | - master 5 | tags: 6 | - 'v*' 7 | pull_request: 8 | workflow_dispatch: 9 | 10 | name: Linux Build 11 | 12 | jobs: 13 | build: 14 | name: Build 15 | runs-on: ubuntu-latest 16 | strategy: 17 | fail-fast: false 18 | matrix: 19 | python-version: ['3.12'] 20 | arch: ["x86_64", "i686"] 21 | steps: 22 | - uses: actions/checkout@v4 23 | - uses: actions/checkout@v4 24 | with: 25 | repository: facebookresearch/fastText 26 | ref: v0.9.2 27 | path: fastText 28 | - name: Set up Python 29 | uses: actions/setup-python@v5 30 | with: 31 | python-version: ${{ matrix.python-version }} 32 | - name: Display Python version 33 | run: python -c "import sys; print(sys.version)" 34 | - name: Build manylinux wheels 35 | run: | 36 | docker run --rm -v `pwd`:/io -w /io quay.io/pypa/manylinux2014_${{ matrix.arch }} sh manylinux.sh 37 | ls -lrth dist/ 38 | - name: Upload wheels 39 | uses: actions/upload-artifact@v3 40 | with: 41 | name: linux-wheels 42 | path: dist/fasttext_wheel-* 43 | - name: Publish manylinux package 44 | if: github.event_name == 'workflow_dispatch' || startsWith(github.event.ref, 'refs/tags') 45 | uses: pypa/gh-action-pypi-publish@master 46 | with: 47 | user: __token__ 48 | password: ${{ secrets.pypi_password }} 49 | skip_existing: true 50 | 51 | cross-build: 52 | name: Cross Build 53 | runs-on: ubuntu-latest 54 | strategy: 55 | fail-fast: false 56 | matrix: 57 | arch: ["aarch64", "armv7l", "s390x", "ppc64le", "ppc64"] 58 | steps: 59 | - uses: actions/checkout@v4 60 | - uses: actions/checkout@v4 61 | with: 62 | repository: facebookresearch/fastText 63 | ref: master 64 | path: fastText 65 | - name: Build manylinux wheels 66 | run: | 67 | docker run -e ARCH=${{ matrix.arch }} --rm -v `pwd`:/io -w /io messense/manylinux2014-cross:${{ matrix.arch }} sh manylinux-cross.sh 68 | ls -lrth dist/ 69 | - name: Upload wheels 70 | uses: actions/upload-artifact@v3 71 | with: 72 | name: linux-wheels 73 | path: dist/fasttext_wheel-*.whl 74 | - name: Publish manylinux package 75 | if: github.event_name == 'workflow_dispatch' || startsWith(github.event.ref, 'refs/tags') 76 | uses: pypa/gh-action-pypi-publish@master 77 | with: 78 | user: __token__ 79 | password: ${{ secrets.pypi_password }} 80 | skip_existing: true 81 | -------------------------------------------------------------------------------- /.github/workflows/Windows.yml: -------------------------------------------------------------------------------- 1 | on: 2 | push: 3 | branches: 4 | - master 5 | tags: 6 | - 'v*' 7 | pull_request: 8 | workflow_dispatch: 9 | 10 | name: Windows Build 11 | 12 | jobs: 13 | build: 14 | name: Build 15 | runs-on: windows-latest 16 | strategy: 17 | fail-fast: false 18 | matrix: 19 | python-version: [3.8, 3.9, '3.10', '3.11', '3.12'] 20 | arch: [x64, x86] 21 | steps: 22 | - uses: actions/checkout@v4 23 | - uses: actions/checkout@v4 24 | with: 25 | repository: messense/fastText 26 | ref: main 27 | path: fastText 28 | - name: Set up Python 29 | uses: actions/setup-python@v5 30 | with: 31 | architecture: ${{ matrix.arch }} 32 | python-version: ${{ matrix.python-version }} 33 | - name: Display Python version 34 | run: python -c "import sys; print(sys.version)" 35 | - name: Install visualcpp-build-tools 36 | run: choco install -y visualcpp-build-tools 37 | - name: Build Windows wheels 38 | run: | 39 | sed -i "s/name='fasttext',/name='fasttext-wheel',/" fastText/setup.py 40 | pip install build 41 | cd fastText 42 | python -m build --wheel -o ../dist 43 | cd .. 44 | ls -lrth dist/ 45 | shell: bash 46 | - name: Upload wheels 47 | uses: actions/upload-artifact@v3 48 | with: 49 | name: windows-wheels 50 | path: dist/fasttext_wheel-*.whl 51 | - name: Publish Windows package 52 | if: github.event_name == 'workflow_dispatch' || startsWith(github.event.ref, 'refs/tags') 53 | run: | 54 | pip install twine 55 | TWINE_USERNAME=__token__ TWINE_PASSWORD=${{ secrets.pypi_password }} twine upload --skip-existing dist/* 56 | shell: bash 57 | -------------------------------------------------------------------------------- /.github/workflows/macOS.yml: -------------------------------------------------------------------------------- 1 | on: 2 | push: 3 | branches: 4 | - master 5 | tags: 6 | - 'v*' 7 | pull_request: 8 | workflow_dispatch: 9 | 10 | name: macOS Build 11 | 12 | jobs: 13 | build: 14 | name: Build 15 | runs-on: macos-latest 16 | strategy: 17 | fail-fast: false 18 | matrix: 19 | python-version: [3.8, 3.9, '3.10', '3.11', '3.12'] 20 | steps: 21 | - uses: actions/checkout@v4 22 | - uses: actions/checkout@v4 23 | with: 24 | repository: facebookresearch/fastText 25 | ref: v0.9.2 26 | path: fastText 27 | - name: Set up Python 28 | uses: conda-incubator/setup-miniconda@v2 29 | with: 30 | architecture: x64 31 | python-version: ${{ matrix.python-version }} 32 | channels: conda-forge 33 | miniconda-version: latest 34 | - name: Build macOS wheels 35 | shell: bash -l {0} 36 | run: | 37 | export MACOSX_DEPLOYMENT_TARGET=10.9 38 | curl -sqL https://github.com/phracker/MacOSX-SDKs/releases/download/10.15/MacOSX10.9.sdk.tar.xz | tar -xC $HOME 39 | # set minimum sdk version to our target 40 | plutil -replace MinimumSDKVersion -string ${MACOSX_DEPLOYMENT_TARGET} $(xcode-select -p)/Platforms/MacOSX.platform/Info.plist 41 | plutil -replace DTSDKName -string macosx${MACOSX_DEPLOYMENT_TARGET}internal $(xcode-select -p)/Platforms/MacOSX.platform/Info.plist 42 | conda create -qy -n fasttext_venv python=${{ matrix.python-version }} wheel 43 | conda init bash 44 | source ~/.bash_profile 45 | conda activate fasttext_venv 46 | python -c "import sys; print(sys.version)" 47 | sed -i '' "s/name='fasttext',/name='fasttext-wheel',/" fastText/setup.py 48 | sed -i '' '/mac_osx_version/d' fastText/setup.py 49 | cd fastText 50 | export CFLAGS="${CFLAGS} -isysroot $HOME/MacOSX10.9.sdk" 51 | export CXXFLAGS="${CXXFLAGS} -isysroot $HOME/MacOSX10.9.sdk" 52 | python setup.py bdist_wheel 53 | pip install delocate 54 | delocate-wheel -w ../dist -v dist/fasttext*.whl 55 | cd .. 56 | ls -lrth dist/ 57 | - name: Upload wheels 58 | uses: actions/upload-artifact@v3 59 | with: 60 | name: macos-wheels 61 | path: dist/fasttext_wheel-*.whl 62 | - name: Publish macOS package 63 | if: github.event_name == 'workflow_dispatch' || startsWith(github.event.ref, 'refs/tags') 64 | shell: bash -l {0} 65 | run: | 66 | conda activate fasttext_venv 67 | pip install twine 68 | TWINE_USERNAME=__token__ TWINE_PASSWORD=${{ secrets.pypi_password }} twine upload --skip-existing dist/* 69 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Byte-compiled / optimized / DLL files 2 | __pycache__/ 3 | *.py[cod] 4 | *$py.class 5 | 6 | # C extensions 7 | *.so 8 | 9 | # Distribution / packaging 10 | .Python 11 | build/ 12 | develop-eggs/ 13 | dist/ 14 | downloads/ 15 | eggs/ 16 | .eggs/ 17 | lib/ 18 | lib64/ 19 | parts/ 20 | sdist/ 21 | var/ 22 | wheels/ 23 | pip-wheel-metadata/ 24 | share/python-wheels/ 25 | *.egg-info/ 26 | .installed.cfg 27 | *.egg 28 | MANIFEST 29 | 30 | # PyInstaller 31 | # Usually these files are written by a python script from a template 32 | # before PyInstaller builds the exe, so as to inject date/other infos into it. 33 | *.manifest 34 | *.spec 35 | 36 | # Installer logs 37 | pip-log.txt 38 | pip-delete-this-directory.txt 39 | 40 | # Unit test / coverage reports 41 | htmlcov/ 42 | .tox/ 43 | .nox/ 44 | .coverage 45 | .coverage.* 46 | .cache 47 | nosetests.xml 48 | coverage.xml 49 | *.cover 50 | *.py,cover 51 | .hypothesis/ 52 | .pytest_cache/ 53 | 54 | # Translations 55 | *.mo 56 | *.pot 57 | 58 | # Django stuff: 59 | *.log 60 | local_settings.py 61 | db.sqlite3 62 | db.sqlite3-journal 63 | 64 | # Flask stuff: 65 | instance/ 66 | .webassets-cache 67 | 68 | # Scrapy stuff: 69 | .scrapy 70 | 71 | # Sphinx documentation 72 | docs/_build/ 73 | 74 | # PyBuilder 75 | target/ 76 | 77 | # Jupyter Notebook 78 | .ipynb_checkpoints 79 | 80 | # IPython 81 | profile_default/ 82 | ipython_config.py 83 | 84 | # pyenv 85 | .python-version 86 | 87 | # pipenv 88 | # According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control. 89 | # However, in case of collaboration, if having platform-specific dependencies or dependencies 90 | # having no cross-platform support, pipenv may install dependencies that don't work, or not 91 | # install all needed dependencies. 92 | #Pipfile.lock 93 | 94 | # PEP 582; used by e.g. github.com/David-OConnor/pyflow 95 | __pypackages__/ 96 | 97 | # Celery stuff 98 | celerybeat-schedule 99 | celerybeat.pid 100 | 101 | # SageMath parsed files 102 | *.sage.py 103 | 104 | # Environments 105 | .env 106 | .venv 107 | env/ 108 | venv/ 109 | ENV/ 110 | env.bak/ 111 | venv.bak/ 112 | 113 | # Spyder project settings 114 | .spyderproject 115 | .spyproject 116 | 117 | # Rope project settings 118 | .ropeproject 119 | 120 | # mkdocs documentation 121 | /site 122 | 123 | # mypy 124 | .mypy_cache/ 125 | .dmypy.json 126 | dmypy.json 127 | 128 | # Pyre type checker 129 | .pyre/ 130 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2020 messense 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # fasttext-wheel 2 | 3 | ![macOS Build](https://github.com/messense/fasttext-wheel/workflows/macOS%20Build/badge.svg) 4 | ![Linux Build](https://github.com/messense/fasttext-wheel/workflows/Linux%20Build/badge.svg) 5 | ![Windows Build](https://github.com/messense/fasttext-wheel/workflows/Windows%20Build/badge.svg) 6 | [![PyPI](https://img.shields.io/pypi/v/fasttext-wheel.svg)](https://pypi.org/project/fasttext-wheel) 7 | [![Downloads](https://pepy.tech/badge/fasttext-wheel)](https://pepy.tech/project/fasttext-wheel) 8 | 9 | Build and upload fastText Python wheels to PyPI 10 | 11 | ## Installation 12 | 13 | ```bash 14 | pip install fasttext-wheel 15 | ``` 16 | -------------------------------------------------------------------------------- /manylinux-cross.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -e -x 3 | 4 | sed -i "s/name='fasttext',/name='fasttext-wheel',/" fastText/setup.py 5 | cd fastText 6 | cp ../pyproject.toml . 7 | 8 | SYSROOT=`$TARGET_CC --print-sysroot` 9 | 10 | # Compile wheels 11 | for PY_MINOR in 8 9 10 11 12; do 12 | PYTHON="python3.${PY_MINOR}" 13 | PYTHON_ABI="cp3${PY_MINOR}-cp3${PY_MINOR}" 14 | if [ "$PY_MINOR" = "7" ]; then 15 | PYTHON_ABI="${PYTHON_ABI}m" 16 | fi 17 | # $PYTHON -m pip install crossenv 18 | $PYTHON -m pip install https://github.com/virtuald/crossenv/archive/refs/heads/py-311.zip 19 | $PYTHON -m crossenv "/opt/python/${PYTHON_ABI}/bin/python3" --cc $TARGET_CC --cxx $TARGET_CXX --sysroot $SYSROOT "venv-py3${PY_MINOR}" 20 | . "venv-py3${PY_MINOR}/bin/activate" 21 | pip install wheel setuptools 22 | python setup.py bdist_wheel --plat-name "manylinux2014_$ARCH" --dist-dir ../dist/ 23 | deactivate 24 | done 25 | 26 | cd .. 27 | 28 | # auditwheel symbols 29 | python3 -m pip install -U auditwheel-symbols 30 | for whl in dist/fasttext*.whl; do 31 | auditwheel-symbols "$whl" 32 | done 33 | 34 | # Bundle external shared libraries into the wheels 35 | # for whl in dist/fasttext*.whl; do 36 | # python3.9 -m auditwheel repair "$whl" -w /io/dist/ 37 | # done 38 | -------------------------------------------------------------------------------- /manylinux.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -e -x 3 | 4 | sed -i "s/name='fasttext',/name='fasttext-wheel',/" fastText/setup.py 5 | cd fastText 6 | cp ../pyproject.toml . 7 | 8 | # Build a sdist 9 | /opt/python/cp310-cp310/bin/python setup.py sdist 10 | mkdir -p /io/dist/ 11 | mv dist/*.tar.gz /io/dist/ 12 | 13 | # Compile wheels 14 | for PYBIN in /opt/python/cp3{8..12}*/bin; do 15 | "${PYBIN}/python" -m pip install build 16 | "${PYBIN}/python" -m build --wheel -o dist 17 | done 18 | 19 | # Bundle external shared libraries into the wheels 20 | for whl in dist/fasttext*.whl; do 21 | auditwheel repair "$whl" -w /io/dist/ 22 | done 23 | -------------------------------------------------------------------------------- /pyproject.toml: -------------------------------------------------------------------------------- 1 | [build-system] 2 | requires = ["setuptools", "wheel", "pybind11"] 3 | --------------------------------------------------------------------------------