Skip to content

Commit

Permalink
Fix macOS build_ext for old and new versions
Browse files Browse the repository at this point in the history
- Removed old C code for Python 2.5
- Fixed error: equality comparison with extraneous parentheses
- Removed use of `distuils.util.get_platform()` for `sys.platform` in `setup.py`
- Removed `-Werror` to fix several issues when compiling the extension
- Moved requirements to `setup.cfg`
  • Loading branch information
BoboTiG committed Jan 30, 2020
1 parent 9134164 commit ec4902e
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 29 deletions.
5 changes: 5 additions & 0 deletions changelog.rst
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,11 @@ Changelog
Other Changes
=============
- Fixed Python 2.7 to 3.6 installation when the OS locale is set to POSIX (`#615 <https://github.com/gorakhargosh/watchdog/pull/615>`__)
- Fixed the ``build_ext`` command on macOS (`#618 <https://github.com/gorakhargosh/watchdog/pull/618>`__)
- Moved requirements to ``setup.cfg`` (`#617 <https://github.com/gorakhargosh/watchdog/pull/617>`__)
- [mac] Fixed error: equality comparison with extraneous parentheses (`#620 <https://github.com/gorakhargosh/watchdog/pull/620>`__)
- [mac] Added ``-Wno-error=nullability-completeness`` to fix Catalina+ errors (`#620 <https://github.com/gorakhargosh/watchdog/pull/620>`__)
- [mac] Removed old C code for Python 2.5
- [snapshot] Added ``EmptyDirectorySnapshot`` (`#613 <https://github.com/gorakhargosh/watchdog/pull/613>`__)
- Thanks to our beloved contributors: @Ajordat, @tehkirill, @BoboTiG

Expand Down
11 changes: 11 additions & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
@@ -1,3 +1,14 @@
[options]
install_requires =
pathtools >= 0.1.1
pyobjc-framework-Cocoa >= 4.2.2 ; sys_platform == "darwin"
pyobjc-framework-FSEvents >= 4.2.2 ; sys_platform == "darwin"

[options.extras_require]
watchmedo =
PyYAML >= 3.10
argh >= 0.24.1

[build_sphinx]
source-dir = docs/source
build-dir = docs/build
Expand Down
15 changes: 1 addition & 14 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
from setuptools import setup, find_packages
from setuptools.extension import Extension
from setuptools.command.build_ext import build_ext
from distutils.util import get_platform

SRC_DIR = 'src'
WATCHDOG_PKG_DIR = os.path.join(SRC_DIR, 'watchdog')
Expand All @@ -38,7 +37,7 @@
version = imp.load_source('version', os.path.join(WATCHDOG_PKG_DIR, 'version.py'))

ext_modules = []
if get_platform().startswith('macosx'):
if sys.platform == 'darwin':
ext_modules = [
Extension(
name='_watchdog_fsevents',
Expand All @@ -61,7 +60,6 @@
'-std=c99',
'-pedantic',
'-Wall',
'-Werror',
'-Wextra',
'-fPIC',

Expand All @@ -71,15 +69,6 @@
),
]

install_requires = [
"pathtools>=0.1.1",
'pyobjc-framework-Cocoa>=4.2.2 ; sys_platform == "darwin"',
'pyobjc-framework-FSEvents>=4.2.2 ; sys_platform == "darwin"',
]
extras_require = {
'watchmedo': ['PyYAML>=3.10', 'argh>=0.24.1'],
}

with open('README.rst', encoding='utf-8') as f:
readme = f.read()

Expand Down Expand Up @@ -136,8 +125,6 @@
package_dir={'': SRC_DIR},
packages=find_packages(SRC_DIR),
include_package_data=True,
install_requires=install_requires,
extras_require=extras_require,
cmdclass={
'build_ext': build_ext,
},
Expand Down
24 changes: 9 additions & 15 deletions src/watchdog_fsevents.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,22 +26,16 @@
#include <signal.h>


#if (PY_VERSION_HEX < 0x02050000) && !defined(PY_SSIZE_T_MIN)
typedef int Py_ssize_t;
#define PY_SSIZE_T_MIN INT_MIN
#define PY_SSIZE_T_MAX INT_MAX
#endif

/* Convenience macros to make code more readable. */
#define G_NOT(o) (!(o))
#define G_IS_NULL(o) ((o) == NULL)
#define G_IS_NOT_NULL(o) ((o) != NULL)
#define G_RETURN_NULL_IF_NULL(o) do{if(NULL == (o)){ return NULL; }}while(0)
#define G_RETURN_NULL_IF(condition) do{if((condition)){ return NULL; }}while(0)
#define G_RETURN_NULL_IF_NOT(condition) do{if(!(condition)){ return NULL; }}while(0)
#define G_RETURN_IF(condition) do{if((condition)){ return; }}while(0)
#define G_RETURN_IF_NOT(condition) do{if(!(condition)){ return; }}while(0)
#define UNUSED(x) (void)(x)
#define G_NOT(o) !o
#define G_IS_NULL(o) o == NULL
#define G_IS_NOT_NULL(o) o != NULL
#define G_RETURN_NULL_IF_NULL(o) do { if (NULL == o) { return NULL; } } while (0)
#define G_RETURN_NULL_IF(condition) do { if (condition) { return NULL; } } while (0)
#define G_RETURN_NULL_IF_NOT(condition) do { if (!condition) { return NULL; } } while (0)
#define G_RETURN_IF(condition) do { if (condition) { return; } } while (0)
#define G_RETURN_IF_NOT(condition) do { if (!condition) { return; } } while (0)
#define UNUSED(x) (void)x

/* Error message definitions. */
#define ERROR_CANNOT_CALL_CALLBACK "Unable to call Python callback."
Expand Down
1 change: 1 addition & 0 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ skip_missing_interpreters = True

[testenv]
deps =
-e .
eventlet
flake8
pytest-cov
Expand Down

0 comments on commit ec4902e

Please sign in to comment.