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

Using scikit-build to install package #30

Open
wants to merge 19 commits into
base: master
Choose a base branch
from
Open
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
16 changes: 16 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
cmake_minimum_required(VERSION 3.15...3.26)

project(sdtw)

find_package(PythonExtensions REQUIRED)
find_package(Cython REQUIRED)

# Add NumPy include directory
execute_process(
COMMAND "${PYTHON_EXECUTABLE}" -c "import numpy as np; print(np.get_include())"
OUTPUT_VARIABLE NUMPY_INCLUDE_DIR
OUTPUT_STRIP_TRAILING_WHITESPACE
)
include_directories(${NUMPY_INCLUDE_DIR})

add_subdirectory(sdtw)
4 changes: 1 addition & 3 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -84,9 +84,7 @@ or, if `git` is unavailable, `download as a ZIP from GitHub <https://github.com/
3. Build and install soft-dtw::

cd soft-dtw
make cython
python setup.py build
sudo python setup.py install
pip install .


References
Expand Down
10 changes: 10 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
[build-system]
requires = [
"setuptools>=42",
"scikit-build>=0.13",
"cmake>=3.18",
"ninja",
"cython",
"numpy",
]
build-backend = "setuptools.build_meta"
5 changes: 5 additions & 0 deletions sdtw/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
add_cython_target(soft_dtw_fast soft_dtw_fast.pyx)
add_library(soft_dtw_fast MODULE ${soft_dtw_fast})
python_extension_module(soft_dtw_fast)

install(TARGETS soft_dtw_fast LIBRARY DESTINATION sdtw)
21 changes: 0 additions & 21 deletions sdtw/setup.py

This file was deleted.

2 changes: 1 addition & 1 deletion sdtw/soft_dtw_fast.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
# cython: cdivision=True
# cython: boundscheck=False
# cython: wraparound=False

# cython: language_level=3str
import numpy as np
cimport numpy as np
np.import_array()
Expand Down
79 changes: 17 additions & 62 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,65 +1,20 @@
from __future__ import print_function
import os.path
import sys
import setuptools
from numpy.distutils.core import setup


try:
import numpy
except ImportError:
print('numpy is required during installation')
sys.exit(1)


DISTNAME = 'soft-dtw'
from skbuild import setup
DISTNAME = 'softdtw'
DESCRIPTION = "Python implementation of soft-DTW"
LONG_DESCRIPTION = open('README.rst').read()
MAINTAINER = 'Mathieu Blondel'
MAINTAINER_EMAIL = ''
URL = 'https://github.com/mblondel/soft-dtw/'
MAINTAINER = 'Mathieu Blondel,Cesar Rodas'
MAINTAINER_EMAIL = '[email protected]'
LICENSE = 'Simplified BSD'
DOWNLOAD_URL = 'https://github.com/mblondel/soft-dtw/'
PACKAGES=['sdtw']
VERSION = '0.1.dev0'


def configuration(parent_package='', top_path=None):
from numpy.distutils.misc_util import Configuration

config = Configuration(None, parent_package, top_path)

config.add_subpackage('sdtw')

return config


if __name__ == '__main__':
old_path = os.getcwd()
local_path = os.path.dirname(os.path.abspath(sys.argv[0]))

os.chdir(local_path)
sys.path.insert(0, local_path)

setup(configuration=configuration,
name=DISTNAME,
maintainer=MAINTAINER,
include_package_data=True,
maintainer_email=MAINTAINER_EMAIL,
description=DESCRIPTION,
license=LICENSE,
url=URL,
version=VERSION,
download_url=DOWNLOAD_URL,
long_description=LONG_DESCRIPTION,
zip_safe=False, # the package can run out of an .egg file
classifiers=[
'Intended Audience :: Science/Research',
'Intended Audience :: Developers', 'License :: OSI Approved',
'Programming Language :: C', 'Programming Language :: Python',
'Topic :: Software Development',
'Topic :: Scientific/Engineering',
'Operating System :: Microsoft :: Windows',
'Operating System :: POSIX', 'Operating System :: Unix',
'Operating System :: MacOS'
]
)
CMAKE_INSTALL_DIR='sdtw'
setup(
name=DISTNAME,
version=VERSION,
description=DESCRIPTION,
author=MAINTAINER,
license=LICENSE,
packages=PACKAGES,
python_requires=">=3.7",
cmake_install_dir=CMAKE_INSTALL_DIR,
cmake_args=["-DCMAKE_BUILD_TYPE=Release"], # Adjust as needed
)