Home
About
Blog
Products
Forum
Support
Contact
Sunbelt Computer Software
PL/B Language Development and Support
Home
About
Blog
Products
Forum
Support
Contact
mongo-python-driver/_setup.py at main · mongodb/mongo-python-driver · GitHub
Skip to content
Navigation Menu
Sign in
Appearance settings
Platform
AI CODE CREATION
GitHub Copilot
Write better code with AI
GitHub Copilot app
Direct agents from issue to merge
MCP Registry
Integrate external tools
DEVELOPER WORKFLOWS
Actions
Automate any workflow
Codespaces
Instant dev environments
Issues
Plan and track work
Code Review
Manage code changes
Code Quality
Enforce quality at merge
APPLICATION SECURITY
GitHub Advanced Security
Find and fix vulnerabilities
Code security
Secure your code as you build
Secret protection
Stop leaks before they start
EXPLORE
Why GitHub
Documentation
Blog
Changelog
Marketplace
View all features
Solutions
BY COMPANY SIZE
Enterprises
Small and medium teams
Startups
Nonprofits
BY USE CASE
App Modernization
DevSecOps
DevOps
CI/CD
View all use cases
BY INDUSTRY
Healthcare
Financial services
Manufacturing
Government
View all industries
View all solutions
Resources
EXPLORE BY TOPIC
AI
Software Development
DevOps
Security
View all topics
EXPLORE BY TYPE
Customer stories
Events & webinars
Ebooks & reports
Business insights
GitHub Skills
SUPPORT & SERVICES
Documentation
Customer support
Community forum
Trust center
Partners
View all resources
Open Source
COMMUNITY
GitHub Sponsors
Fund open source developers
PROGRAMS
Security Lab
Maintainer Community
GitHub Stars
Archive Program
REPOSITORIES
Topics
Trending
Collections
Enterprise
ENTERPRISE SOLUTIONS
Enterprise platform
AI-powered developer platform
AVAILABLE ADD-ONS
GitHub Advanced Security
Enterprise-grade security features
Copilot for Business
Enterprise-grade AI features
Premium Support
Enterprise-grade 24/7 support
Pricing
Search
/
Sign in
Sign up
Appearance settings
You signed in with another tab or window.
Reload
to refresh your session.
You signed out in another tab or window.
Reload
to refresh your session.
You switched accounts on another tab or window.
Reload
to refresh your session.
Dismiss alert
{{ message }}
Uh oh!
There was an error while loading.
Please reload this page
.
mongodb
/
mongo-python-driver
Public
Notifications
You must be signed in to change notification settings
Fork
1.2k
Star
4.4k
Code
Pull requests
16
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Pull requests
Actions
Projects
Security and quality
Insights
Files
Expand file tree
main
Breadcrumbs
mongo-python-driver
/
_setup.py
Copy path
Blame
More file actions
Blame
More file actions
Latest commit
History
History
History
152 lines (126 loc) · 4.56 KB
main
Breadcrumbs
mongo-python-driver
/
_setup.py
Copy path
Top
File metadata and controls
Code
Blame
152 lines (126 loc) · 4.56 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
from
__future__
import
annotations
import
os
import
sys
import
warnings
# Hack to silence atexit traceback in some Python versions
try
:
import
multiprocessing
# noqa: F401
except
ImportError
:
pass
from
setuptools
import
setup
from
setuptools
.
command
.
build_ext
import
build_ext
from
setuptools
.
extension
import
Extension
class
custom_build_ext
(
build_ext
):
"""Allow C extension building to fail.
The C extension speeds up BSON encoding, but is not essential.
"""
warning_message
=
"""
********************************************************************
WARNING: %s could not
be compiled. No C extensions are essential for PyMongo to run,
although they do result in significant speed improvements.
%s
Please see the installation docs for solutions to build issues:
https://pymongo.readthedocs.io/en/stable/installation.html
Here are some hints for popular operating systems:
If you are seeing this message on Linux you probably need to
install GCC and/or the Python development package for your
version of Python.
Debian and Ubuntu users should issue the following command:
$ sudo apt-get install build-essential python-dev
Users of Red Hat based distributions (RHEL, CentOS, Amazon Linux,
Oracle Linux, Fedora, etc.) should issue the following command:
$ sudo yum install gcc python-devel
If you are seeing this message on Microsoft Windows please install
PyMongo using pip. Modern versions of pip will install PyMongo
from binary wheels available on pypi. If you must install from
source read the documentation here:
https://pymongo.readthedocs.io/en/stable/installation.html#installing-from-source-on-windows
If you are seeing this message on macOS / OSX please install PyMongo
using pip. Modern versions of pip will install PyMongo from binary
wheels available on pypi. If wheels are not available for your version
of macOS / OSX, or you must install from source read the documentation
here:
https://pymongo.readthedocs.io/en/stable/installation.html#osx
********************************************************************
"""
def
run
(
self
):
try
:
build_ext
.
run
(
self
)
except
Exception
:
if
os
.
environ
.
get
(
"PYMONGO_C_EXT_MUST_BUILD"
):
raise
e
=
sys
.
exc_info
()[
1
]
sys
.
stdout
.
write
(
f"
{
e
!s
}
\n
"
)
warnings
.
warn
(
self
.
warning_message
%
(
"Extension modules"
,
"There was an issue with your platform configuration - see above."
,
),
stacklevel
=
2
,
)
def
build_extension
(
self
,
ext
):
# "ProgramFiles(x86)" is not a valid environment variable in Cygwin but is needed for
# the MSVCCompiler in distutils.
if
os
.
name
==
"nt"
:
if
"ProgramFiles"
in
os
.
environ
and
"ProgramFiles(x86)"
not
in
os
.
environ
:
os
.
environ
[
"ProgramFiles(x86)"
]
=
os
.
environ
[
"ProgramFiles"
]
+
" (x86)"
name
=
ext
.
name
try
:
build_ext
.
build_extension
(
self
,
ext
)
except
Exception
:
if
os
.
environ
.
get
(
"PYMONGO_C_EXT_MUST_BUILD"
):
raise
e
=
sys
.
exc_info
()[
1
]
sys
.
stdout
.
write
(
f"
{
e
!s
}
\n
"
)
warnings
.
warn
(
self
.
warning_message
%
(
"The %s extension module"
%
(
name
,),
# noqa: UP031
"The output above this warning shows how the compilation failed."
,
),
stacklevel
=
2
,
)
ext_modules
=
[
Extension
(
"bson._cbson"
,
include_dirs
=
[
"bson"
],
sources
=
[
"bson/_cbsonmodule.c"
,
"bson/time64.c"
,
"bson/buffer.c"
],
),
Extension
(
"pymongo._cmessage"
,
include_dirs
=
[
"bson"
],
sources
=
[
"pymongo/_cmessagemodule.c"
,
"bson/_cbsonmodule.c"
,
"bson/time64.c"
,
"bson/buffer.c"
,
],
),
]
if
"--no_ext"
in
sys
.
argv
or
os
.
environ
.
get
(
"NO_EXT"
):
try
:
sys
.
argv
.
remove
(
"--no_ext"
)
except
ValueError
:
pass
ext_modules
=
[]
elif
(
sys
.
platform
.
startswith
(
"java"
)
or
sys
.
platform
==
"cli"
or
sys
.
implementation
.
name
in
(
"pypy"
,
"graalpy"
)
):
sys
.
stdout
.
write
(
"""
*****************************************************
\n
The optional C extensions are currently not supported
\n
by this python implementation.
\n
*****************************************************
\n
"""
)
ext_modules
=
[]
setup
(
cmdclass
=
{
"build_ext"
:
custom_build_ext
},
ext_modules
=
ext_modules
,
packages
=
[
"bson"
,
"pymongo"
,
"gridfs"
],
)
# type:ignore
You can’t perform that action at this time.