Skip to content

Commit eb92b76

Browse files
authored
Merge pull request #26 from memgraph/change-win-workflow
Update windows workflow
2 parents c4a3cfd + f2a5e31 commit eb92b76

File tree

8 files changed

+41
-30
lines changed

8 files changed

+41
-30
lines changed

.github/workflows/ci.yml

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -68,10 +68,10 @@ jobs:
6868
arch:
6969
- { mingw: "64", msys: x86_64, python: "x64" }
7070
python_version:
71-
- 3.6
71+
- 3.7
7272
- 3.9
7373
mgversion:
74-
- 1.4.0
74+
- 2.0.0
7575
steps:
7676
- uses: actions/checkout@v2
7777
with:
@@ -120,11 +120,7 @@ jobs:
120120
run: python -m pip install -f dist --no-index pymgclient
121121
- name: Run tests
122122
run: |
123-
if( ${{ matrix.mgversion }} -match "^2" ) {
124-
python3 -m pytest -v
125-
}else {
126-
python3 -m pytest -v -m "not temporal"
127-
}
123+
python3 -m pytest -v
128124
env:
129125
MEMGRAPH_HOST: "localhost"
130126
MEMGRAPH_STARTED_WITH_SSL:

.github/workflows/release.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,6 @@ jobs:
6363
arch:
6464
- { mingw: "64", msys: x86_64, python: "x64"}
6565
python_version:
66-
- 3.6
6766
- 3.7
6867
- 3.8
6968
- 3.9

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ pymgclient.egg-info/
88
*.swo
99

1010
# python temporary files
11+
.venv
1112
*.pyc
1213
*.pyo
13-
__pycache__/
14+
__pycache__/

CHANGELOG.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ Changelog
1111
Breaking Changes
1212
****************
1313

14+
* `pymgclient` is supported only for >3.7 python versions on Windows.
15+
1416
******************************
1517
Major Feature and Improvements
1618
******************************

docs/source/introduction.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ pymgclient has prebuilt binary packages for
2323
* macOS 10.15+ x86_64 (not arm64) with `Python
2424
<https://www.python.org/downloads/>`_ 3.7+
2525

26-
* Windows 10 x86_64 with `Python <https://www.python.org/downloads/>`_ 3.6+
26+
* Windows 10 x86_64 with `Python <https://www.python.org/downloads/>`_ 3.7+
2727

2828
To intall pymgclient binaries on these platforms see `Install binaries`_
2929
section or check `Install from source`_ for other platforms.

pytest.ini

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[pytest]
2+
markers =
3+
temporal: mark a test that tests temporal types.

setup.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,17 +12,16 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15-
import sys
1615
import os
1716
import pathlib
1817
import platform
1918
import shutil
20-
21-
from setuptools import setup, Extension
22-
from setuptools.command.build_ext import build_ext
19+
import sys
2320
from distutils import log
2421
from distutils.core import DistutilsExecError, DistutilsPlatformError
2522

23+
from setuptools import Extension, setup
24+
from setuptools.command.build_ext import build_ext
2625

2726
IS_WINDOWS = sys.platform == 'win32'
2827
IS_APPLE = sys.platform == 'darwin'

src/glue.c

Lines changed: 27 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -239,7 +239,7 @@ PyObject *make_py_date(int y, int m, int d) {
239239
return date;
240240
}
241241

242-
PyObject *make_py_time(int h, int min, int sec, int mi) {
242+
PyObject *make_py_time(int64_t h, int64_t min, int64_t sec, int64_t mi) {
243243
PyObject *time = PyTime_FromTime(h, min, sec, mi);
244244
if (!time) {
245245
PyErr_Print();
@@ -279,15 +279,28 @@ PyObject *mg_date_to_py_date(const mg_date *date) {
279279
}
280280

281281
PyObject *mg_local_time_to_py_time(const mg_local_time *lt) {
282-
long nanos = mg_local_time_nanoseconds(lt);
283-
long one_sec_to_nanos = 1000000000;
284-
SCOPED_CLEANUP PyObject *seconds = PyLong_FromLong(nanos / one_sec_to_nanos);
285-
long leftover_nanos = nanos % one_sec_to_nanos;
282+
const int64_t nanos = mg_local_time_nanoseconds(lt);
283+
const int64_t one_sec_to_nanos = 1000000000;
284+
SCOPED_CLEANUP PyObject *seconds =
285+
PyLong_FromLongLong(nanos / one_sec_to_nanos);
286+
const int64_t leftover_nanos = nanos % one_sec_to_nanos;
287+
// The reason for different implementation of getting utc time from timestamp
288+
// is because we need to explicitly define utc timezone on Windows unlike on
289+
// linux, but that API is only allowed in py3.7, therefore the support for
290+
// Windows is only for python version >= 3.7.
291+
#ifdef _WIN32
292+
SCOPED_CLEANUP PyObject *method_name = PyUnicode_FromString("fromtimestamp");
293+
IF_PTR_IS_NULL_RETURN(method_name, NULL);
294+
SCOPED_CLEANUP PyObject *result = PyObject_CallMethodObjArgs(
295+
(PyObject *)PyDateTimeAPI->DateTimeType, method_name, seconds,
296+
PyDateTime_TimeZone_UTC, NULL);
297+
#else
286298
SCOPED_CLEANUP PyObject *method_name =
287299
PyUnicode_FromString("utcfromtimestamp");
288300
IF_PTR_IS_NULL_RETURN(method_name, NULL);
289-
SCOPED_CLEANUP PyObject *result =
290-
PyObject_CallMethodObjArgs((PyObject*)PyDateTimeAPI->DateTimeType, method_name, seconds, NULL);
301+
SCOPED_CLEANUP PyObject *result = PyObject_CallMethodObjArgs(
302+
(PyObject *)PyDateTimeAPI->DateTimeType, method_name, seconds, NULL);
303+
#endif
291304
IF_PTR_IS_NULL_RETURN(result, NULL);
292305
SCOPED_CLEANUP PyObject *h = PyObject_GetAttrString(result, "hour");
293306
IF_PTR_IS_NULL_RETURN(h, NULL);
@@ -307,8 +320,8 @@ PyObject *mg_local_date_time_to_py_datetime(const mg_local_date_time *ldt) {
307320
IF_PTR_IS_NULL_RETURN(seconds, NULL);
308321
SCOPED_CLEANUP PyObject *method_name = PyUnicode_FromString("fromtimestamp");
309322
IF_PTR_IS_NULL_RETURN(method_name, NULL);
310-
SCOPED_CLEANUP PyObject *result =
311-
PyObject_CallMethodObjArgs((PyObject*)PyDateTimeAPI->DateTimeType, method_name, seconds, NULL);
323+
SCOPED_CLEANUP PyObject *result = PyObject_CallMethodObjArgs(
324+
(PyObject *)PyDateTimeAPI->DateTimeType, method_name, seconds, NULL);
312325
IF_PTR_IS_NULL_RETURN(result, NULL);
313326
SCOPED_CLEANUP PyObject *y = PyObject_GetAttrString(result, "year");
314327
SCOPED_CLEANUP PyObject *mo = PyObject_GetAttrString(result, "month");
@@ -495,9 +508,7 @@ int64_t microseconds_to_nanos(int64_t microseconds) {
495508
return microseconds * 1000;
496509
}
497510

498-
int64_t seconds_to_nanos(int64_t seconds) {
499-
return microseconds_to_nanos(seconds * 1000000);
500-
}
511+
int64_t seconds_to_nanos(int64_t seconds) { return seconds * 1000000 * 1000; }
501512

502513
int64_t minutes_to_nanos(int64_t minutes) {
503514
return seconds_to_nanos(minutes * 60);
@@ -506,10 +517,10 @@ int64_t minutes_to_nanos(int64_t minutes) {
506517
int64_t hours_to_nanos(int64_t hours) { return minutes_to_nanos(hours * 60); }
507518

508519
int64_t nanoseconds_since_epoch(PyObject *obj) {
509-
int h = PyDateTime_TIME_GET_HOUR(obj);
510-
int m = PyDateTime_TIME_GET_MINUTE(obj);
511-
int s = PyDateTime_TIME_GET_SECOND(obj);
512-
int mi = PyDateTime_TIME_GET_MICROSECOND(obj);
520+
int64_t h = PyDateTime_TIME_GET_HOUR(obj);
521+
int64_t m = PyDateTime_TIME_GET_MINUTE(obj);
522+
int64_t s = PyDateTime_TIME_GET_SECOND(obj);
523+
int64_t mi = PyDateTime_TIME_GET_MICROSECOND(obj);
513524
return hours_to_nanos(h) + minutes_to_nanos(m) + seconds_to_nanos(s) +
514525
microseconds_to_nanos(mi);
515526
}

0 commit comments

Comments
 (0)