Skip to content

Commit b54c303

Browse files
authored
Merge pull request #913 from compas-dev/planarity-pip-extra
Change planarity to requires extra for pip installs
2 parents d659253 + 3a36735 commit b54c303

File tree

6 files changed

+28
-10
lines changed

6 files changed

+28
-10
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
2828
* `compas_blender.artists.RobotModelArtist.collection` can be assigned as a Blender collection or a name.
2929
* Generalized the parameter `color` of `compas_blender.draw_texts` and various label drawing methods.
3030
* Changed `compas.IPY` to `compas.RHINO` in `orientation_rhino`.
31+
* Changed `planarity` to `requires_extra` for pip installations.
3132

3233
### Removed
3334

docs/installation.rst

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,17 @@ Note that installation with ``pip`` is also possible within a ``conda`` environm
7979
conda activate my-project
8080
pip install -e .
8181
82+
By default, ``planarity`` is marked as an optional requirement for installation with ``pip`` on Windows.
83+
To include ``planarity``, add a conditional to the install command.
84+
85+
.. code-block:: bash
86+
87+
pip install compas[planarity]
88+
89+
.. code-block:: bash
90+
91+
pip install -e .[planarity]
92+
8293
8394
Update with conda
8495
=================

requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ networkx
1212
numba
1313
numpy >= 1.15.4
1414
pillow
15-
planarity
15+
planarity ; sys_platform != 'win32'
1616
pycollada
1717
schema
1818
jsonschema

setup.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,9 @@ def read(*names, **kwargs):
6666
zip_safe=False,
6767
install_requires=requirements,
6868
python_requires='>=2.7',
69-
extras_require=optional_requirements,
69+
extras_require={
70+
'planarity': ['planarity'],
71+
},
7072
entry_points={
7173
'console_scripts': [
7274
'compas_rpc=compas.rpc.__main__:main'

src/compas/datastructures/network/planarity.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,16 +8,11 @@
88

99
from itertools import product
1010

11-
import compas
12-
1311
from compas.geometry import angle_vectors_xy
1412
from compas.geometry import is_intersection_segment_segment_xy
1513
from compas.geometry import is_ccw_xy
1614
from compas.geometry import subtract_vectors_xy
1715

18-
if not compas.IPY:
19-
import planarity
20-
2116

2217
__all__ = [
2318
'network_is_crossed',
@@ -198,6 +193,12 @@ def network_is_planar(network):
198193
--------
199194
>>>
200195
"""
196+
try:
197+
import planarity
198+
except ImportError:
199+
print("Planarity is not installed.")
200+
raise
201+
201202
return planarity.is_planar(list(network.edges()))
202203

203204

tests/compas/datastructures/test_network.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import pytest
22

3-
import compas
43
from compas.datastructures import Network
54

65

@@ -33,15 +32,19 @@ def test_add_node():
3332

3433

3534
def test_non_planar(k5_network):
36-
if compas.IPY:
35+
try:
36+
import planarity # noqa: F401
37+
except ImportError:
3738
return
3839

3940
from compas.datastructures import network_is_planar
4041
assert network_is_planar(k5_network) is not True
4142

4243

4344
def test_planar(k5_network):
44-
if compas.IPY:
45+
try:
46+
import planarity # noqa: F401
47+
except ImportError:
4548
return
4649

4750
from compas.datastructures import network_is_planar

0 commit comments

Comments
 (0)