Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clean up the build process #54

Merged
merged 7 commits into from
Nov 4, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,9 @@ jobs:
python -m pip install --upgrade pip
pip install -r requirements.txt
- uses: ilammy/msvc-dev-cmd@v1
- name: Install Rii
run: |
make build
- name: Test with CC=${{ matrix.compiler }}
env:
CC: ${{ matrix.compiler }}
Expand Down
14 changes: 8 additions & 6 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,16 +1,18 @@
.PHONY: test clean build deploy test_deploy
.PHONY: test clean build

test:
python setup.py test

clean:
rm -rf build tmp dist *.egg-info *.so .eggs



build:
python setup.py sdist
pip install .

deploy: clean build
twine upload dist/*
# deploy: clean build
# twine upload dist/*

test_deploy: clean build
twine upload --repository-url https://test.pypi.org/legacy/ dist/*
# test_deploy: clean build
# twine upload --repository-url https://test.pypi.org/legacy/ dist/*
4 changes: 2 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
[build-system]
requires = ["setuptools", "pybind11"]
build-backend = "setuptools.build_meta:__legacy__"
requires = ["setuptools>=64", "pybind11>=2.9"]
build-backend = "setuptools.build_meta"
28 changes: 2 additions & 26 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from pybind11.setup_helpers import Pybind11Extension, build_ext
from setuptools import setup, Extension, find_packages
from setuptools.command.build_ext import build_ext
import sys
import setuptools
import re
Expand All @@ -17,36 +17,12 @@
version = re.search(r'__version__ = \'(.*?)\'', f.read()).group(1)


class get_pybind_include(object):
"""Helper class to determine the pybind11 include path

The purpose of this class is to postpone importing pybind11
until it is actually installed, so that the ``get_include()``
method can be invoked. """

def __init__(self, user=False):
try:
import pybind11
except ImportError:
if subprocess.call([sys.executable, '-m', 'pip', 'install', 'pybind11']):
raise RuntimeError('pybind11 install failed.')
self.user = user

def __str__(self):
import pybind11
return pybind11.get_include(self.user)


ext_modules = [
Extension(
Pybind11Extension(
'main',
['src/main.cpp',
'src/pqkmeans.cpp'], # For c++ pqkmeans
include_dirs=[
# Path to pybind11 headers
get_pybind_include(),
get_pybind_include(user=True)
],
language='c++',
undef_macros=['NDEBUG'], # This makes sure assert() works
),
Expand Down