Skip to content

Commit edce098

Browse files
committed
Fix pip install
1 parent 07e4b73 commit edce098

File tree

4 files changed

+26
-21
lines changed

4 files changed

+26
-21
lines changed

.github/workflows/trunk.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,5 @@ jobs:
3939
${CONDA_RUN} pip install . -v
4040
${CONDA_RUN} pip install pytest
4141
42-
4342
# Run tests
4443
${CONDA_RUN} pytest

CMakeLists.txt

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,7 @@ if(TOKENIZERS_BUILD_PYTHON)
131131
GIT_TAG v2.13.6
132132
)
133133
FetchContent_MakeAvailable(pybind11)
134+
134135
# Create the Python extension module
135136
pybind11_add_module(pytorch_tokenizers_cpp
136137
${CMAKE_CURRENT_SOURCE_DIR}/src/python_bindings.cpp
@@ -142,26 +143,28 @@ if(TOKENIZERS_BUILD_PYTHON)
142143
# Set properties for the Python extension
143144
target_compile_definitions(pytorch_tokenizers_cpp PRIVATE VERSION_INFO=${PROJECT_VERSION})
144145

145-
# Set the output name - let setuptools handle the output directory
146+
# Set the output name and let setuptools control the output directory
146147
set_target_properties(pytorch_tokenizers_cpp PROPERTIES
147148
OUTPUT_NAME "pytorch_tokenizers_cpp"
148149
)
149150

150151
# Don't install the Python extension here - let setuptools handle it
151-
# The install() command is not needed for Python extensions built via setuptools
152+
# The setup.py will copy the built extension to the appropriate location
152153
endif()
153154

154155
# Installation rules
155156
include(GNUInstallDirs)
156157

157-
# Install the library and its dependencies
158-
install(
159-
TARGETS tokenizers re2 sentencepiece-static
160-
EXPORT tokenizers-targets
161-
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
162-
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
163-
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
164-
)
158+
if(NOT TOKENIZERS_BUILD_PYTHON)
159+
# Install the library and its dependencies
160+
install(
161+
TARGETS tokenizers re2 sentencepiece-static
162+
EXPORT tokenizers-targets
163+
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
164+
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
165+
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
166+
)
167+
endif()
165168

166169
# Install header files
167170
install(

pytest.ini

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,24 @@
11
[pytest]
22
# Pytest configuration for PyTorch Tokenizers
33

4-
# Test discovery - be very explicit about what to test
4+
# Test discovery
55
testpaths = test
66
python_files = test_*.py *_test.py
77
python_classes = Test*
88
python_functions = test_*
99

10-
# Add the project root to Python path
11-
pythonpath = .
12-
1310
# Output options with explicit ignores
1411
addopts =
15-
-v
16-
--tb=short
17-
--strict-markers
18-
--disable-warnings
12+
# show summary of all tests that did not pass
13+
-rEfX
14+
# Make tracebacks shorter
15+
--tb=native
16+
# capture only Python print and C++ py::print, but not C output (low-level Python errors)
17+
--capture=sys
18+
# don't suppress warnings, but don't shove them all to the end either
19+
-p no:warnings
20+
# Ignore backends/arm tests you need to run examples/arm/setup.sh to install some tool to make them work
21+
# For GitHub testing this is setup/executed in the unittest-arm job see .github/workflows/pull.yml for more info.
1922
--ignore=third-party
2023
--ignore=build
2124
--ignore=cmake

setup.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ def build_extension(self, ext):
5252
"-DTOKENIZERS_BUILD_PYTHON=ON",
5353
"-DCMAKE_POSITION_INDEPENDENT_CODE=ON",
5454
]
55-
build_args = []
55+
build_args = ["--target", "pytorch_tokenizers_cpp"]
5656

5757
# Adding CMake arguments set as environment variable
5858
# (needed e.g. to build for ARM OSX on conda-forge)
@@ -133,7 +133,7 @@ def build_extension(self, ext):
133133
ext_modules=[CMakeExtension("pytorch_tokenizers_cpp")],
134134
cmdclass={"build_ext": CMakeBuild},
135135
zip_safe=False,
136-
python_requires=">=3.8",
136+
python_requires=">=3.10",
137137
install_requires=[
138138
"pybind11>=2.6.0",
139139
],

0 commit comments

Comments
 (0)