-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
PYTHON-4451 Use Hatch as Build Backend #1644
Merged
Merged
Changes from 23 commits
Commits
Show all changes
24 commits
Select commit
Hold shift + click to select a range
0b0d31c
PYTHON-4451 Replace Setuptools with Hatch and CMake
blink1073 496faf8
fix warning handling
blink1073 ac18c7f
fix import
blink1073 4361f54
fix import
blink1073 9310777
use scikit-build-core directly
blink1073 db46308
clean up build
blink1073 f79414c
debug
blink1073 ca6850b
debug
blink1073 5e35224
do not require development module or cmake
blink1073 dd4d1fd
add dev module
blink1073 fd6d343
fix typing and debug compilation
blink1073 ed9ad5e
debug
blink1073 6c1f2e6
fix cmake def
blink1073 2971ce9
stay with setuptools for now
blink1073 0a2fa64
add setup.py file
blink1073 17503f0
try with setuptools
blink1073 a57e6e1
clean up
blink1073 0ead71e
fix api
blink1073 28494f4
fix api
blink1073 c45e030
fix api
blink1073 589d89d
Merge branch 'master' of github.com:mongodb/mongo-python-driver into …
blink1073 799830e
Add get_version_tuple function and tests
blink1073 8571970
allow major.minor versions
blink1073 3cc40a6
Merge branch 'master' of github.com:mongodb/mongo-python-driver into …
blink1073 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
"""A custom hatch build hook for pymongo.""" | ||
from __future__ import annotations | ||
|
||
import os | ||
import subprocess | ||
import sys | ||
from pathlib import Path | ||
|
||
from hatchling.builders.hooks.plugin.interface import BuildHookInterface | ||
|
||
|
||
class CustomHook(BuildHookInterface): | ||
"""The pymongo build hook.""" | ||
|
||
def initialize(self, version, build_data): | ||
"""Initialize the hook.""" | ||
if self.target_name == "sdist": | ||
return | ||
here = Path(__file__).parent.resolve() | ||
sys.path.insert(0, str(here)) | ||
|
||
subprocess.check_call([sys.executable, "setup.py", "build_ext", "-i"]) | ||
|
||
# Ensure wheel is marked as binary and contains the binary files. | ||
build_data["infer_tag"] = True | ||
build_data["pure_python"] = False | ||
if os.name == "nt": | ||
patt = ".pyd" | ||
else: | ||
patt = ".so" | ||
for pkg in ["bson", "pymongo"]: | ||
dpath = here / pkg | ||
for fpath in dpath.glob(f"*{patt}"): | ||
relpath = os.path.relpath(fpath, here) | ||
build_data["artifacts"].append(relpath) | ||
build_data["force_include"][relpath] = relpath |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -136,32 +136,8 @@ def build_extension(self, ext): | |
) | ||
ext_modules = [] | ||
|
||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You were able to get rid of all this because of the way that requirements.txt is handled? That's awesome! |
||
def parse_reqs_file(fname): | ||
with open(fname) as fid: | ||
lines = [li.strip() for li in fid.readlines()] | ||
return [li for li in lines if li and not li.startswith("#")] | ||
|
||
|
||
dependencies = parse_reqs_file("requirements.txt") | ||
|
||
extras_require = dict( | ||
aws=parse_reqs_file("requirements/aws.txt"), | ||
encryption=parse_reqs_file("requirements/encryption.txt"), | ||
gssapi=parse_reqs_file("requirements/gssapi.txt"), | ||
ocsp=parse_reqs_file("requirements/ocsp.txt"), | ||
snappy=parse_reqs_file("requirements/snappy.txt"), | ||
# PYTHON-3423 Removed in 4.3 but kept here to avoid pip warnings. | ||
srv=[], | ||
tls=[], | ||
# PYTHON-2133 Removed in 4.0 but kept here to avoid pip warnings. | ||
zstd=parse_reqs_file("requirements/zstd.txt"), | ||
test=parse_reqs_file("requirements/test.txt"), | ||
) | ||
|
||
setup( | ||
cmdclass={"build_ext": custom_build_ext}, | ||
install_requires=dependencies, | ||
extras_require=extras_require, | ||
ext_modules=ext_modules, | ||
packages=["bson", "pymongo", "gridfs"], | ||
) # type:ignore |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No manifest file!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I read the Why Hatch? page. I'm starting to get it. Very nice.