Skip to content

Commit 995e6f3

Browse files
committed
Changes required to release pip wheel
1 parent 572e407 commit 995e6f3

File tree

3 files changed

+79
-6
lines changed

3 files changed

+79
-6
lines changed

MANIFEST.in

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
# Include CMake files
2+
include CMakeLists.txt
3+
include Utils.cmake
4+
recursive-include cmake *
5+
6+
# Include C++ source files
7+
recursive-include src *.cpp *.h *.hpp
8+
recursive-include include *.h *.hpp
9+
10+
# Include third-party dependencies
11+
recursive-include third-party *
12+
13+
# Include test files
14+
recursive-include test *.py *.cpp *.h
15+
16+
# Include examples
17+
recursive-include examples *
18+
19+
# Include documentation
20+
include README.md
21+
include LICENSE
22+
include CONTRIBUTING.md
23+
include CODE_OF_CONDUCT
24+
25+
# Include other necessary files
26+
include pyproject.toml
27+
include pytest.ini
28+
include TARGETS
29+
include targets.bzl
30+
31+
# Exclude build artifacts and unnecessary files
32+
global-exclude *.pyc
33+
global-exclude *.pyo
34+
global-exclude __pycache__
35+
global-exclude .git*
36+
global-exclude .DS_Store
37+
prune build
38+
prune dist
39+
prune *.egg-info

setup.py

Lines changed: 37 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,12 @@
1010
import re
1111
import subprocess
1212
import sys
13+
import shutil
1314
from pathlib import Path
1415

1516
from setuptools import Extension, find_packages, setup
1617
from setuptools.command.build_ext import build_ext
18+
from setuptools.command.build_py import build_py as build_py_orig
1719

1820
# Read the README file
1921
with open("README.md", "r") as f:
@@ -126,19 +128,52 @@ def build_extension(self, ext): # noqa C901
126128
)
127129

128130

131+
class BuildPy(build_py_orig):
132+
"""Ensure header files are copied into the package during build."""
133+
134+
def run(self):
135+
super().run()
136+
headers_src = Path("include")
137+
if not headers_src.exists():
138+
return
139+
140+
headers_dst = Path(self.build_lib) / "pytorch_tokenizers" / "include"
141+
for file_path in headers_src.rglob("*"):
142+
if file_path.is_file():
143+
destination = headers_dst / file_path.relative_to(headers_src)
144+
destination.parent.mkdir(parents=True, exist_ok=True)
145+
shutil.copy2(file_path, destination)
146+
147+
129148
setup(
130149
name="pytorch-tokenizers",
131-
version="0.1.0",
150+
version="1.0.1",
132151
long_description=long_description,
133152
long_description_content_type="text/markdown",
134153
url="https://github.com/meta-pytorch/tokenizers",
135154
packages=find_packages(),
155+
include_package_data=True,
156+
package_data={
157+
"pytorch_tokenizers": [
158+
"include/*.h",
159+
"include/**/*.h",
160+
"include/*.hpp",
161+
"include/**/*.hpp",
162+
]
163+
},
136164
ext_modules=[CMakeExtension("pytorch_tokenizers.pytorch_tokenizers_cpp")],
137-
cmdclass={"build_ext": CMakeBuild},
165+
cmdclass={
166+
"build_ext": CMakeBuild,
167+
"build_py": BuildPy,
168+
},
138169
zip_safe=False,
139170
python_requires=">=3.10",
140171
install_requires=[
141172
"pybind11>=2.6.0",
173+
"sentencepiece",
174+
"mistral-common",
175+
"tokenizers",
176+
"tiktoken",
142177
],
143178
setup_requires=[
144179
"pybind11>=2.6.0",
@@ -150,8 +185,6 @@ def build_extension(self, ext): # noqa C901
150185
"License :: OSI Approved :: BSD License",
151186
"Operating System :: OS Independent",
152187
"Programming Language :: Python :: 3",
153-
"Programming Language :: Python :: 3.8",
154-
"Programming Language :: Python :: 3.9",
155188
"Programming Language :: Python :: 3.10",
156189
"Programming Language :: Python :: 3.11",
157190
"Programming Language :: Python :: 3.12",

src/re2_regex.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,10 @@ Error Re2Regex::compile(const std::string& pattern) {
1919
if (regex_->ok()) {
2020
return Error::Ok;
2121
} else {
22+
// It should log using Error level but it's too confusing.
2223
TK_LOG(
23-
Error,
24-
"Failed to compile regex: %s, error: %s",
24+
Info,
25+
"Re2 failed to compile regex: %s, error: %s\nThis may be ok if a fallback regex is used.",
2526
pattern.c_str(),
2627
regex_->error().c_str());
2728
return Error::RegexFailure;

0 commit comments

Comments
 (0)