Skip to content

Commit

Permalink
Merge pull request #54 from matsui528/build
Browse files Browse the repository at this point in the history
Clean up the build process
  • Loading branch information
matsui528 authored Nov 4, 2023
2 parents 5fe5e28 + 36ea79b commit 2255091
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 34 deletions.
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

0 comments on commit 2255091

Please sign in to comment.