File tree 2 files changed +20
-6
lines changed
2 files changed +20
-6
lines changed Original file line number Diff line number Diff line change 24
24
"humanize" ,
25
25
# required to decompress repodata into tar
26
26
"zstandard" ,
27
- "psycopg" ,
28
- "psycopg[c] ; platform_python_implementation == 'CPython'" ,
29
27
],
28
+ extras_require = {
29
+ "history" : [
30
+ "psycopg" ,
31
+ "psycopg[c] ; platform_python_implementation == 'CPython'" ,
32
+ ]
33
+ },
30
34
include_package_data = True ,
31
35
entry_points = {
32
36
"console_scripts" : [
Original file line number Diff line number Diff line change 26
26
import gevent .time
27
27
import gevent .util
28
28
import msgpack as msgpk
29
- import psycopg
30
29
import toml
31
30
import valideer as V
32
31
import zmq .green as zmq
33
32
from logbook import Logger , StderrHandler
34
33
34
+ try :
35
+ from psycopg import Connection as PgConnection
36
+ except ImportError :
37
+ PgConnection = None
38
+
35
39
import xbbs .messages as msgs
36
40
import xbbs .protocol
37
41
import xbbs .util as xutils
@@ -161,7 +165,7 @@ class Xbbs:
161
165
project_greenlets = attr .ib (factory = list )
162
166
zmq = attr .ib (default = zmq .Context .instance ())
163
167
outgoing_job_queue = attr .ib (factory = lambda : gevent .queue .Queue (1 ))
164
- db : psycopg . Connection = attr .ib (default = None )
168
+ db : PgConnection = attr .ib (default = None )
165
169
166
170
@classmethod
167
171
def create (cls , cfg ):
@@ -1172,8 +1176,14 @@ def main():
1172
1176
1173
1177
database_conn = contextlib .nullcontext (None )
1174
1178
if cfg .get ("artifact_history" ):
1175
- database_conn = psycopg .connect ()
1176
- log .debug ("established PG connection ({})" , database_conn )
1179
+ if PgConnection :
1180
+ database_conn = PgConnection .connect ()
1181
+ log .debug ("established PG connection ({})" , database_conn )
1182
+ else :
1183
+ log .error (
1184
+ "psycopg3 was not found. In order to use artifact_history, you will"
1185
+ " need to install xbbs with the history extras group."
1186
+ )
1177
1187
1178
1188
with database_conn as inst .db , \
1179
1189
inst .zmq .socket (zmq .REP ) as sock_cmd , \
You can’t perform that action at this time.
0 commit comments