COMPAS 2.1.1__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- compas/__init__.py +274 -0
- compas/__main__.py +31 -0
- compas/_iotools.py +80 -0
- compas/_os.py +746 -0
- compas/colors/__init__.py +14 -0
- compas/colors/cmcrameri/acton.txt +256 -0
- compas/colors/cmcrameri/actonS.txt +100 -0
- compas/colors/cmcrameri/bam.txt +256 -0
- compas/colors/cmcrameri/bamO.txt +256 -0
- compas/colors/cmcrameri/bamako.txt +256 -0
- compas/colors/cmcrameri/bamakoS.txt +100 -0
- compas/colors/cmcrameri/batlow.txt +256 -0
- compas/colors/cmcrameri/batlowK.txt +256 -0
- compas/colors/cmcrameri/batlowS.txt +100 -0
- compas/colors/cmcrameri/batlowW.txt +256 -0
- compas/colors/cmcrameri/berlin.txt +256 -0
- compas/colors/cmcrameri/bilbao.txt +256 -0
- compas/colors/cmcrameri/bilbaoS.txt +100 -0
- compas/colors/cmcrameri/broc.txt +256 -0
- compas/colors/cmcrameri/brocO.txt +256 -0
- compas/colors/cmcrameri/buda.txt +256 -0
- compas/colors/cmcrameri/budaS.txt +100 -0
- compas/colors/cmcrameri/bukavu.txt +256 -0
- compas/colors/cmcrameri/cork.txt +256 -0
- compas/colors/cmcrameri/corkO.txt +256 -0
- compas/colors/cmcrameri/davos.txt +256 -0
- compas/colors/cmcrameri/davosS.txt +100 -0
- compas/colors/cmcrameri/devon.txt +256 -0
- compas/colors/cmcrameri/devonS.txt +100 -0
- compas/colors/cmcrameri/fes.txt +256 -0
- compas/colors/cmcrameri/grayC.txt +256 -0
- compas/colors/cmcrameri/grayCS.txt +100 -0
- compas/colors/cmcrameri/hawaii.txt +256 -0
- compas/colors/cmcrameri/hawaiiS.txt +100 -0
- compas/colors/cmcrameri/imola.txt +256 -0
- compas/colors/cmcrameri/imolaS.txt +100 -0
- compas/colors/cmcrameri/lajolla.txt +256 -0
- compas/colors/cmcrameri/lajollaS.txt +100 -0
- compas/colors/cmcrameri/lapaz.txt +256 -0
- compas/colors/cmcrameri/lapazS.txt +100 -0
- compas/colors/cmcrameri/lisbon.txt +256 -0
- compas/colors/cmcrameri/nuuk.txt +256 -0
- compas/colors/cmcrameri/nuukS.txt +100 -0
- compas/colors/cmcrameri/oleron.txt +256 -0
- compas/colors/cmcrameri/oslo.txt +256 -0
- compas/colors/cmcrameri/osloS.txt +100 -0
- compas/colors/cmcrameri/roma.txt +256 -0
- compas/colors/cmcrameri/romaO.txt +256 -0
- compas/colors/cmcrameri/tofino.txt +256 -0
- compas/colors/cmcrameri/tokyo.txt +256 -0
- compas/colors/cmcrameri/tokyoS.txt +100 -0
- compas/colors/cmcrameri/turku.txt +256 -0
- compas/colors/cmcrameri/turkuS.txt +100 -0
- compas/colors/cmcrameri/vanimo.txt +256 -0
- compas/colors/cmcrameri/vik.txt +256 -0
- compas/colors/cmcrameri/vikO.txt +256 -0
- compas/colors/color.py +1118 -0
- compas/colors/colordict.py +103 -0
- compas/colors/colormap.py +306 -0
- compas/colors/html_colors.py +149 -0
- compas/colors/mpl_colormap.py +1064 -0
- compas/data/__init__.py +31 -0
- compas/data/coercion.py +71 -0
- compas/data/conftest.py +10 -0
- compas/data/data.py +342 -0
- compas/data/encoders.py +240 -0
- compas/data/exceptions.py +2 -0
- compas/data/json.py +240 -0
- compas/data/samples/boxes.obj +250 -0
- compas/data/samples/butt_model.obj +2829 -0
- compas/data/samples/cone.stl +0 -0
- compas/data/samples/cube.off +16 -0
- compas/data/samples/cube_ascii.stl +56114 -0
- compas/data/samples/cube_binary.stl +0 -0
- compas/data/samples/cube_binary_2.stl +0 -0
- compas/data/samples/doosabin.json +1 -0
- compas/data/samples/faces.obj +63 -0
- compas/data/samples/faces_big.obj +9663 -0
- compas/data/samples/faces_reversed.obj +63 -0
- compas/data/samples/fink.obj +135 -0
- compas/data/samples/grid_irregular.obj +303 -0
- compas/data/samples/hypar.obj +148 -0
- compas/data/samples/lines.json +1 -0
- compas/data/samples/lines.obj +282 -0
- compas/data/samples/lines_big.obj +40322 -0
- compas/data/samples/lines_bigger.obj +161282 -0
- compas/data/samples/lines_noleaves.obj +422 -0
- compas/data/samples/mesh.obj +874 -0
- compas/data/samples/mesh_100_faces.json +1893 -0
- compas/data/samples/mesh_110_faces.json +2081 -0
- compas/data/samples/open_edges.obj +424 -0
- compas/data/samples/point.json +1 -0
- compas/data/samples/quadmesh.obj +183 -0
- compas/data/samples/quadmesh_planar.obj +181 -0
- compas/data/samples/saddle.obj +314 -0
- compas/data/samples/spline.obj +72 -0
- compas/data/samples/tubemesh.json +1 -0
- compas/data/samples/tubemesh.obj +378 -0
- compas/data/samples/tubemesh.off +374 -0
- compas/data/samples/tubemesh.ply +551 -0
- compas/data/schema.py +137 -0
- compas/data/validators.py +243 -0
- compas/datastructures/__init__.py +75 -0
- compas/datastructures/_mutablemapping.py +148 -0
- compas/datastructures/assembly/__init__.py +0 -0
- compas/datastructures/assembly/assembly.py +234 -0
- compas/datastructures/assembly/exceptions.py +6 -0
- compas/datastructures/assembly/part.py +228 -0
- compas/datastructures/attributes.py +85 -0
- compas/datastructures/cell_network/__init__.py +0 -0
- compas/datastructures/cell_network/cell_network.py +4190 -0
- compas/datastructures/datastructure.py +309 -0
- compas/datastructures/graph/__init__.py +0 -0
- compas/datastructures/graph/duality.py +197 -0
- compas/datastructures/graph/graph.py +2478 -0
- compas/datastructures/graph/operations/__init__.py +0 -0
- compas/datastructures/graph/operations/join.py +124 -0
- compas/datastructures/graph/operations/split.py +63 -0
- compas/datastructures/graph/planarity.py +292 -0
- compas/datastructures/graph/smoothing.py +59 -0
- compas/datastructures/mesh/__init__.py +0 -0
- compas/datastructures/mesh/conway.py +553 -0
- compas/datastructures/mesh/duality.py +104 -0
- compas/datastructures/mesh/mesh.py +5103 -0
- compas/datastructures/mesh/operations/__init__.py +0 -0
- compas/datastructures/mesh/operations/collapse.py +350 -0
- compas/datastructures/mesh/operations/extrude.py +0 -0
- compas/datastructures/mesh/operations/insert.py +120 -0
- compas/datastructures/mesh/operations/merge.py +83 -0
- compas/datastructures/mesh/operations/split.py +263 -0
- compas/datastructures/mesh/operations/substitute.py +37 -0
- compas/datastructures/mesh/operations/swap.py +62 -0
- compas/datastructures/mesh/operations/weld.py +107 -0
- compas/datastructures/mesh/remesh.py +234 -0
- compas/datastructures/mesh/slice.py +170 -0
- compas/datastructures/mesh/smoothing.py +187 -0
- compas/datastructures/mesh/subdivision.py +754 -0
- compas/datastructures/tree/__init__.py +0 -0
- compas/datastructures/tree/tree.py +504 -0
- compas/datastructures/volmesh/__init__.py +0 -0
- compas/datastructures/volmesh/volmesh.py +4203 -0
- compas/files/__init__.py +27 -0
- compas/files/_xml/__init__.py +0 -0
- compas/files/_xml/xml_cli.py +213 -0
- compas/files/_xml/xml_cpython.py +32 -0
- compas/files/_xml/xml_pre_38.py +58 -0
- compas/files/_xml/xml_shared.py +40 -0
- compas/files/gltf/__init__.py +0 -0
- compas/files/gltf/constants.py +59 -0
- compas/files/gltf/data_classes.py +657 -0
- compas/files/gltf/extensions.py +317 -0
- compas/files/gltf/gltf.py +92 -0
- compas/files/gltf/gltf_children.py +64 -0
- compas/files/gltf/gltf_content.py +615 -0
- compas/files/gltf/gltf_exporter.py +465 -0
- compas/files/gltf/gltf_mesh.py +273 -0
- compas/files/gltf/gltf_node.py +348 -0
- compas/files/gltf/gltf_parser.py +115 -0
- compas/files/gltf/gltf_reader.py +310 -0
- compas/files/gltf/gltf_scene.py +125 -0
- compas/files/gltf/helpers.py +59 -0
- compas/files/obj.py +680 -0
- compas/files/off.py +296 -0
- compas/files/ply.py +697 -0
- compas/files/stl.py +436 -0
- compas/files/xml.py +328 -0
- compas/geometry/__init__.py +772 -0
- compas/geometry/_core/__init__.py +0 -0
- compas/geometry/_core/_algebra.py +2826 -0
- compas/geometry/_core/angles.py +408 -0
- compas/geometry/_core/centroids.py +573 -0
- compas/geometry/_core/distance.py +895 -0
- compas/geometry/_core/normals.py +149 -0
- compas/geometry/_core/nurbs.py +367 -0
- compas/geometry/_core/predicates_2.py +582 -0
- compas/geometry/_core/predicates_3.py +1111 -0
- compas/geometry/_core/quaternions.py +196 -0
- compas/geometry/_core/size.py +204 -0
- compas/geometry/_core/tangent.py +56 -0
- compas/geometry/_core/transformations.py +1121 -0
- compas/geometry/_core/transformations_numpy.py +279 -0
- compas/geometry/bbox.py +145 -0
- compas/geometry/bbox_numpy.py +306 -0
- compas/geometry/bestfit.py +77 -0
- compas/geometry/bestfit_numpy.py +259 -0
- compas/geometry/booleans.py +297 -0
- compas/geometry/booleans_shapely.py +147 -0
- compas/geometry/brep/__init__.py +112 -0
- compas/geometry/brep/brep.py +1131 -0
- compas/geometry/brep/edge.py +302 -0
- compas/geometry/brep/errors.py +22 -0
- compas/geometry/brep/face.py +329 -0
- compas/geometry/brep/loop.py +87 -0
- compas/geometry/brep/trim.py +46 -0
- compas/geometry/brep/vertex.py +46 -0
- compas/geometry/contours.py +32 -0
- compas/geometry/curves/__init__.py +0 -0
- compas/geometry/curves/arc.py +429 -0
- compas/geometry/curves/bezier.py +345 -0
- compas/geometry/curves/circle.py +500 -0
- compas/geometry/curves/conic.py +16 -0
- compas/geometry/curves/curve.py +614 -0
- compas/geometry/curves/ellipse.py +408 -0
- compas/geometry/curves/hyperbola.py +336 -0
- compas/geometry/curves/line.py +431 -0
- compas/geometry/curves/nurbs.py +412 -0
- compas/geometry/curves/parabola.py +256 -0
- compas/geometry/curves/polyline.py +724 -0
- compas/geometry/frame.py +769 -0
- compas/geometry/geometry.py +296 -0
- compas/geometry/hull.py +146 -0
- compas/geometry/hull_numpy.py +82 -0
- compas/geometry/icp_numpy.py +104 -0
- compas/geometry/interpolation_barycentric.py +38 -0
- compas/geometry/interpolation_coons.py +102 -0
- compas/geometry/interpolation_tweening.py +87 -0
- compas/geometry/intersection.py +121 -0
- compas/geometry/intersections.py +1105 -0
- compas/geometry/kdtree.py +153 -0
- compas/geometry/offset.py +208 -0
- compas/geometry/pca_numpy.py +87 -0
- compas/geometry/plane.py +657 -0
- compas/geometry/point.py +664 -0
- compas/geometry/pointcloud.py +409 -0
- compas/geometry/polygon.py +473 -0
- compas/geometry/polyhedron.py +650 -0
- compas/geometry/projection.py +155 -0
- compas/geometry/quadmesh_planarize.py +30 -0
- compas/geometry/quadmesh_planarize_none.py +114 -0
- compas/geometry/quaternion.py +544 -0
- compas/geometry/reflection.py +102 -0
- compas/geometry/rotation.py +354 -0
- compas/geometry/scale.py +100 -0
- compas/geometry/shapes/__init__.py +0 -0
- compas/geometry/shapes/box.py +747 -0
- compas/geometry/shapes/capsule.py +472 -0
- compas/geometry/shapes/cone.py +309 -0
- compas/geometry/shapes/cylinder.py +355 -0
- compas/geometry/shapes/shape.py +300 -0
- compas/geometry/shapes/sphere.py +362 -0
- compas/geometry/shapes/torus.py +294 -0
- compas/geometry/shear.py +115 -0
- compas/geometry/surfaces/__init__.py +0 -0
- compas/geometry/surfaces/conical.py +166 -0
- compas/geometry/surfaces/cylindrical.py +251 -0
- compas/geometry/surfaces/extrusion.py +0 -0
- compas/geometry/surfaces/nurbs.py +380 -0
- compas/geometry/surfaces/planar.py +223 -0
- compas/geometry/surfaces/revolution.py +0 -0
- compas/geometry/surfaces/spherical.py +259 -0
- compas/geometry/surfaces/surface.py +689 -0
- compas/geometry/surfaces/toroidal.py +198 -0
- compas/geometry/transformation.py +554 -0
- compas/geometry/translation.py +104 -0
- compas/geometry/triangulation_delaunay.py +102 -0
- compas/geometry/triangulation_earclip.py +300 -0
- compas/geometry/trimesh_curvature.py +113 -0
- compas/geometry/trimesh_descent_numpy.py +26 -0
- compas/geometry/trimesh_geodistance.py +35 -0
- compas/geometry/trimesh_gradient_numpy.py +74 -0
- compas/geometry/trimesh_isolines.py +41 -0
- compas/geometry/trimesh_matrices.py +31 -0
- compas/geometry/trimesh_matrices_numpy.py +191 -0
- compas/geometry/trimesh_parametrisation.py +55 -0
- compas/geometry/trimesh_pull_points_numpy.py +216 -0
- compas/geometry/trimesh_remeshing.py +97 -0
- compas/geometry/trimesh_samplepoints_numpy.py +108 -0
- compas/geometry/trimesh_slicing.py +28 -0
- compas/geometry/trimesh_smoothing_numpy.py +34 -0
- compas/geometry/vector.py +889 -0
- compas/itertools.py +441 -0
- compas/linalg.py +634 -0
- compas/matrices.py +314 -0
- compas/plugins.py +488 -0
- compas/rpc/__init__.py +20 -0
- compas/rpc/__main__.py +77 -0
- compas/rpc/dispatcher.py +181 -0
- compas/rpc/errors.py +11 -0
- compas/rpc/proxy.py +437 -0
- compas/rpc/server.py +79 -0
- compas/rpc/services/__init__.py +0 -0
- compas/rpc/services/default.py +87 -0
- compas/rpc/services/watcher.py +43 -0
- compas/scene/__init__.py +56 -0
- compas/scene/assemblyobject.py +3 -0
- compas/scene/context.py +154 -0
- compas/scene/descriptors/__init__.py +0 -0
- compas/scene/descriptors/attribute.py +30 -0
- compas/scene/descriptors/color.py +91 -0
- compas/scene/descriptors/colordict.py +101 -0
- compas/scene/descriptors/protocol.py +12 -0
- compas/scene/exceptions.py +7 -0
- compas/scene/geometryobject.py +58 -0
- compas/scene/graphobject.py +173 -0
- compas/scene/meshobject.py +238 -0
- compas/scene/scene.py +144 -0
- compas/scene/sceneobject.py +253 -0
- compas/scene/volmeshobject.py +252 -0
- compas/tolerance.py +879 -0
- compas/topology/__init__.py +45 -0
- compas/topology/combinatorics.py +108 -0
- compas/topology/connectivity.py +129 -0
- compas/topology/orientation.py +204 -0
- compas/topology/traversal.py +567 -0
- compas/utilities/__init__.py +25 -0
- compas/utilities/azync.py +155 -0
- compas/utilities/datetime.py +40 -0
- compas/utilities/decorators.py +136 -0
- compas/utilities/remote.py +54 -0
- compas/utilities/ssh.py +169 -0
- compas-2.1.1.dist-info/AUTHORS.md +42 -0
- compas-2.1.1.dist-info/LICENSE +21 -0
- compas-2.1.1.dist-info/METADATA +132 -0
- compas-2.1.1.dist-info/RECORD +468 -0
- compas-2.1.1.dist-info/WHEEL +5 -0
- compas-2.1.1.dist-info/entry_points.txt +2 -0
- compas-2.1.1.dist-info/top_level.txt +4 -0
- compas_blender/__init__.py +250 -0
- compas_blender/collections.py +130 -0
- compas_blender/conversions/__init__.py +48 -0
- compas_blender/conversions/breps.py +0 -0
- compas_blender/conversions/colors.py +23 -0
- compas_blender/conversions/curves.py +125 -0
- compas_blender/conversions/geometry.py +161 -0
- compas_blender/conversions/meshes.py +148 -0
- compas_blender/conversions/surfaces.py +48 -0
- compas_blender/conversions/transformations.py +46 -0
- compas_blender/data.py +30 -0
- compas_blender/geometry/__init__.py +14 -0
- compas_blender/geometry/booleans.py +100 -0
- compas_blender/install.py +338 -0
- compas_blender/objects.py +326 -0
- compas_blender/print_python_path.py +18 -0
- compas_blender/scene/__init__.py +116 -0
- compas_blender/scene/boxobject.py +64 -0
- compas_blender/scene/capsuleobject.py +73 -0
- compas_blender/scene/circleobject.py +53 -0
- compas_blender/scene/coneobject.py +70 -0
- compas_blender/scene/curveobject.py +58 -0
- compas_blender/scene/cylinderobject.py +70 -0
- compas_blender/scene/frameobject.py +105 -0
- compas_blender/scene/graphobject.py +257 -0
- compas_blender/scene/lineobject.py +60 -0
- compas_blender/scene/meshobject.py +508 -0
- compas_blender/scene/planeobject.py +81 -0
- compas_blender/scene/pointcloudobject.py +67 -0
- compas_blender/scene/pointobject.py +71 -0
- compas_blender/scene/polygonobject.py +57 -0
- compas_blender/scene/polyhedronobject.py +57 -0
- compas_blender/scene/polylineobject.py +54 -0
- compas_blender/scene/sceneobject.py +249 -0
- compas_blender/scene/sphereobject.py +72 -0
- compas_blender/scene/surfaceobject.py +54 -0
- compas_blender/scene/torusobject.py +73 -0
- compas_blender/scene/vectorobject.py +69 -0
- compas_blender/scene/volmeshobject.py +475 -0
- compas_blender/utilities/__init__.py +38 -0
- compas_blender/utilities/drawing.py +768 -0
- compas_ghpython/__init__.py +124 -0
- compas_ghpython/components/Compas_FromJson/code.py +18 -0
- compas_ghpython/components/Compas_Info/code.py +15 -0
- compas_ghpython/components/Compas_RpcCall/code.py +31 -0
- compas_ghpython/components/Compas_ToJson/code.py +19 -0
- compas_ghpython/components/Compas_ToRhinoGeometry/code.py +15 -0
- compas_ghpython/components/__init__.py +99 -0
- compas_ghpython/install.py +29 -0
- compas_ghpython/scene/__init__.py +115 -0
- compas_ghpython/scene/boxobject.py +40 -0
- compas_ghpython/scene/brepobject.py +40 -0
- compas_ghpython/scene/capsuleobject.py +41 -0
- compas_ghpython/scene/circleobject.py +40 -0
- compas_ghpython/scene/coneobject.py +40 -0
- compas_ghpython/scene/curveobject.py +42 -0
- compas_ghpython/scene/cylinderobject.py +38 -0
- compas_ghpython/scene/ellipseobject.py +40 -0
- compas_ghpython/scene/frameobject.py +67 -0
- compas_ghpython/scene/graphobject.py +77 -0
- compas_ghpython/scene/lineobject.py +39 -0
- compas_ghpython/scene/meshobject.py +137 -0
- compas_ghpython/scene/planeobject.py +61 -0
- compas_ghpython/scene/pointobject.py +38 -0
- compas_ghpython/scene/polygonobject.py +48 -0
- compas_ghpython/scene/polyhedronobject.py +48 -0
- compas_ghpython/scene/polylineobject.py +39 -0
- compas_ghpython/scene/sceneobject.py +12 -0
- compas_ghpython/scene/sphereobject.py +39 -0
- compas_ghpython/scene/surfaceobject.py +42 -0
- compas_ghpython/scene/torusobject.py +39 -0
- compas_ghpython/scene/vectorobject.py +51 -0
- compas_ghpython/scene/volmeshobject.py +154 -0
- compas_ghpython/sets.py +83 -0
- compas_ghpython/timer.py +36 -0
- compas_ghpython/uninstall.py +31 -0
- compas_ghpython/utilities/__init__.py +33 -0
- compas_ghpython/utilities/drawing.py +457 -0
- compas_rhino/__init__.py +607 -0
- compas_rhino/conduits/__init__.py +16 -0
- compas_rhino/conduits/base.py +121 -0
- compas_rhino/conduits/faces.py +91 -0
- compas_rhino/conduits/labels.py +102 -0
- compas_rhino/conduits/lines.py +109 -0
- compas_rhino/conduits/points.py +111 -0
- compas_rhino/conversions/__init__.py +168 -0
- compas_rhino/conversions/breps.py +122 -0
- compas_rhino/conversions/curves.py +453 -0
- compas_rhino/conversions/docobjects.py +0 -0
- compas_rhino/conversions/exceptions.py +7 -0
- compas_rhino/conversions/extrusions.py +80 -0
- compas_rhino/conversions/geometry.py +187 -0
- compas_rhino/conversions/meshes.py +281 -0
- compas_rhino/conversions/shapes.py +291 -0
- compas_rhino/conversions/surfaces.py +355 -0
- compas_rhino/conversions/transformations.py +45 -0
- compas_rhino/geometry/__init__.py +44 -0
- compas_rhino/geometry/booleans.py +118 -0
- compas_rhino/geometry/brep/__init__.py +40 -0
- compas_rhino/geometry/brep/brep.py +554 -0
- compas_rhino/geometry/brep/builder.py +184 -0
- compas_rhino/geometry/brep/edge.py +202 -0
- compas_rhino/geometry/brep/face.py +285 -0
- compas_rhino/geometry/brep/loop.py +129 -0
- compas_rhino/geometry/brep/trim.py +99 -0
- compas_rhino/geometry/brep/vertex.py +76 -0
- compas_rhino/geometry/curves/__init__.py +43 -0
- compas_rhino/geometry/curves/curve.py +382 -0
- compas_rhino/geometry/curves/nurbs.py +298 -0
- compas_rhino/geometry/surfaces/__init__.py +50 -0
- compas_rhino/geometry/surfaces/nurbs.py +370 -0
- compas_rhino/geometry/surfaces/surface.py +407 -0
- compas_rhino/geometry/trimesh_curvature.py +344 -0
- compas_rhino/geometry/trimesh_slicing.py +65 -0
- compas_rhino/install.py +382 -0
- compas_rhino/install_plugin.py +169 -0
- compas_rhino/install_with_pip.py +20 -0
- compas_rhino/layers.py +347 -0
- compas_rhino/objects.py +1141 -0
- compas_rhino/print_python_path.py +18 -0
- compas_rhino/scene/__init__.py +123 -0
- compas_rhino/scene/boxobject.py +44 -0
- compas_rhino/scene/brepobject.py +41 -0
- compas_rhino/scene/capsuleobject.py +45 -0
- compas_rhino/scene/circleobject.py +43 -0
- compas_rhino/scene/coneobject.py +43 -0
- compas_rhino/scene/curveobject.py +43 -0
- compas_rhino/scene/cylinderobject.py +43 -0
- compas_rhino/scene/ellipseobject.py +44 -0
- compas_rhino/scene/frameobject.py +99 -0
- compas_rhino/scene/graphobject.py +364 -0
- compas_rhino/scene/helpers.py +33 -0
- compas_rhino/scene/lineobject.py +43 -0
- compas_rhino/scene/meshobject.py +673 -0
- compas_rhino/scene/planeobject.py +71 -0
- compas_rhino/scene/pointobject.py +43 -0
- compas_rhino/scene/polygonobject.py +45 -0
- compas_rhino/scene/polyhedronobject.py +45 -0
- compas_rhino/scene/polylineobject.py +43 -0
- compas_rhino/scene/sceneobject.py +123 -0
- compas_rhino/scene/sphereobject.py +43 -0
- compas_rhino/scene/surfaceobject.py +42 -0
- compas_rhino/scene/torusobject.py +43 -0
- compas_rhino/scene/vectorobject.py +49 -0
- compas_rhino/scene/volmeshobject.py +518 -0
- compas_rhino/ui.py +114 -0
- compas_rhino/uninstall.py +243 -0
- compas_rhino/uninstall_plugin.py +91 -0
- compas_rhino/utilities/__init__.py +37 -0
- compas_rhino/utilities/constructors.py +71 -0
- compas_rhino/utilities/drawing.py +1081 -0
compas_rhino/install.py
ADDED
|
@@ -0,0 +1,382 @@
|
|
|
1
|
+
from __future__ import absolute_import
|
|
2
|
+
from __future__ import division
|
|
3
|
+
from __future__ import print_function
|
|
4
|
+
|
|
5
|
+
import importlib
|
|
6
|
+
import itertools
|
|
7
|
+
import os
|
|
8
|
+
import sys
|
|
9
|
+
|
|
10
|
+
import compas._os
|
|
11
|
+
import compas.plugins
|
|
12
|
+
import compas_rhino
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
def install(version=None, packages=None, clean=False):
|
|
16
|
+
"""Install COMPAS for Rhino.
|
|
17
|
+
|
|
18
|
+
Parameters
|
|
19
|
+
----------
|
|
20
|
+
version : {'5.0', '6.0', '7.0', '8.0'}, optional
|
|
21
|
+
The version number of Rhino.
|
|
22
|
+
Default is ``'7.0'``.
|
|
23
|
+
packages : list of str, optional
|
|
24
|
+
List of packages to install or None to use default package list.
|
|
25
|
+
Default is the result of ``installable_rhino_packages``,
|
|
26
|
+
which collects all installable packages in the current environment.
|
|
27
|
+
clean : bool, optional
|
|
28
|
+
If True, this will clean up the entire scripts folder and remove
|
|
29
|
+
also existing symlinks that are not importable in the current environment.
|
|
30
|
+
|
|
31
|
+
Examples
|
|
32
|
+
--------
|
|
33
|
+
.. code-block:: python
|
|
34
|
+
|
|
35
|
+
import compas_rhino.install
|
|
36
|
+
|
|
37
|
+
compas_rhino.install.install()
|
|
38
|
+
|
|
39
|
+
.. code-block:: bash
|
|
40
|
+
|
|
41
|
+
python -m compas_rhino.install
|
|
42
|
+
|
|
43
|
+
"""
|
|
44
|
+
version = compas_rhino._check_rhino_version(version)
|
|
45
|
+
|
|
46
|
+
# We install COMPAS packages in the scripts folder
|
|
47
|
+
# instead of directly as IPy module.
|
|
48
|
+
# scripts_path = compas_rhino._get_rhino_scripts_path(version)
|
|
49
|
+
|
|
50
|
+
# In Rhino 8 there is no scripts folder
|
|
51
|
+
if version == "8.0":
|
|
52
|
+
installation_path = compas_rhino._get_default_rhino_ironpython_sitepackages_path(version)
|
|
53
|
+
else:
|
|
54
|
+
installation_path = compas_rhino._get_rhino_scripts_path(version)
|
|
55
|
+
|
|
56
|
+
# This is for old installs
|
|
57
|
+
ipylib_path = compas_rhino._get_rhino_ironpython_lib_path(version)
|
|
58
|
+
|
|
59
|
+
# Filter the provided list of packages
|
|
60
|
+
# If no packages are provided
|
|
61
|
+
# this first collects all installable packages from the environment.
|
|
62
|
+
packages = _filter_installable_packages(version, packages)
|
|
63
|
+
|
|
64
|
+
results = []
|
|
65
|
+
symlinks_to_install = []
|
|
66
|
+
symlinks_to_uninstall = []
|
|
67
|
+
exit_code = 0
|
|
68
|
+
|
|
69
|
+
# check all installable packages
|
|
70
|
+
# add the packages that can't be imported from the current env to the list of symlinks to uninstall
|
|
71
|
+
# and remove the package name from the list of installable packages
|
|
72
|
+
# make a copy of the list to avoid problems with removing items
|
|
73
|
+
# note: perhaps this should already happen in the filter function...
|
|
74
|
+
for name in packages[:]:
|
|
75
|
+
try:
|
|
76
|
+
importlib.import_module(name)
|
|
77
|
+
except ImportError:
|
|
78
|
+
path = os.path.join(installation_path, name)
|
|
79
|
+
symlinks_to_uninstall.append(dict(name=name, link=path))
|
|
80
|
+
packages.remove(name)
|
|
81
|
+
|
|
82
|
+
# Also remove all broken symlinks from the scripts folder
|
|
83
|
+
# because ... they're broken!
|
|
84
|
+
# If it is an actual folder or a file, leave it alone
|
|
85
|
+
# because probably someone put it there on purpose.
|
|
86
|
+
for name in os.listdir(installation_path):
|
|
87
|
+
path = os.path.join(installation_path, name)
|
|
88
|
+
if os.path.islink(path):
|
|
89
|
+
if not os.path.exists(path):
|
|
90
|
+
symlinks_to_uninstall.append(dict(name=name, link=path))
|
|
91
|
+
try:
|
|
92
|
+
importlib.import_module(name)
|
|
93
|
+
except ImportError:
|
|
94
|
+
pass
|
|
95
|
+
else:
|
|
96
|
+
if name not in packages:
|
|
97
|
+
packages.append(name)
|
|
98
|
+
|
|
99
|
+
# If the scripts folder is supposed to be cleaned
|
|
100
|
+
# also remove all existing symlinks that cannot be imported
|
|
101
|
+
# and reinstall symlinks that can be imported
|
|
102
|
+
if clean:
|
|
103
|
+
for name in os.listdir(installation_path):
|
|
104
|
+
path = os.path.join(installation_path, name)
|
|
105
|
+
if os.path.islink(path):
|
|
106
|
+
if os.path.exists(path):
|
|
107
|
+
try:
|
|
108
|
+
importlib.import_module(name)
|
|
109
|
+
except ImportError:
|
|
110
|
+
path = os.path.join(installation_path, name)
|
|
111
|
+
symlinks_to_uninstall.append(dict(name=name, link=path))
|
|
112
|
+
else:
|
|
113
|
+
if name not in packages:
|
|
114
|
+
packages.append(name)
|
|
115
|
+
|
|
116
|
+
# add all of the packages in the list of installable packages
|
|
117
|
+
# to the list of symlinks to uninstall
|
|
118
|
+
# and to the list of symlinks to install
|
|
119
|
+
for package in packages:
|
|
120
|
+
symlink_path = os.path.join(installation_path, package)
|
|
121
|
+
symlinks_to_uninstall.append(dict(name=package, link=symlink_path))
|
|
122
|
+
|
|
123
|
+
package_path = compas_rhino._get_package_path(importlib.import_module(package))
|
|
124
|
+
symlinks_to_install.append(dict(name=package, source_path=package_path, link=symlink_path))
|
|
125
|
+
|
|
126
|
+
# Handle legacy install location
|
|
127
|
+
# This does not always work,
|
|
128
|
+
# and especially not in cases where it is not necessary :)
|
|
129
|
+
if ipylib_path:
|
|
130
|
+
legacy_path = os.path.join(ipylib_path, package)
|
|
131
|
+
if os.path.exists(legacy_path):
|
|
132
|
+
symlinks_to_uninstall.append(dict(name=package, link=legacy_path))
|
|
133
|
+
|
|
134
|
+
# -------------------------
|
|
135
|
+
# Uninstall first
|
|
136
|
+
# -------------------------
|
|
137
|
+
|
|
138
|
+
symlinks = [link["link"] for link in symlinks_to_uninstall]
|
|
139
|
+
uninstall_results = compas._os.remove_symlinks(symlinks)
|
|
140
|
+
|
|
141
|
+
# Let the user know if some symlinks could not be removed.
|
|
142
|
+
for uninstall_data, success in zip(symlinks_to_uninstall, uninstall_results):
|
|
143
|
+
if not success:
|
|
144
|
+
results.append(
|
|
145
|
+
(
|
|
146
|
+
uninstall_data["name"],
|
|
147
|
+
"ERROR: Cannot remove symlink, try to run as administrator.",
|
|
148
|
+
)
|
|
149
|
+
)
|
|
150
|
+
|
|
151
|
+
# Handle legacy bootstrapper
|
|
152
|
+
# Again, only if possible...
|
|
153
|
+
if ipylib_path:
|
|
154
|
+
if not compas_rhino._try_remove_bootstrapper(ipylib_path):
|
|
155
|
+
results.append(
|
|
156
|
+
(
|
|
157
|
+
"compas_bootstrapper",
|
|
158
|
+
"ERROR: Cannot remove legacy compas_bootstrapper, try to run as administrator.",
|
|
159
|
+
)
|
|
160
|
+
)
|
|
161
|
+
|
|
162
|
+
# -------------------------
|
|
163
|
+
# Ready to start installing
|
|
164
|
+
# -------------------------
|
|
165
|
+
|
|
166
|
+
# create new symlinks and register the results
|
|
167
|
+
symlinks = [(link["source_path"], link["link"]) for link in symlinks_to_install]
|
|
168
|
+
install_results = compas._os.create_symlinks(symlinks)
|
|
169
|
+
|
|
170
|
+
# set the exit code based on the installation results
|
|
171
|
+
if not all(install_results):
|
|
172
|
+
exit_code = -1
|
|
173
|
+
|
|
174
|
+
# make a list of installed packages
|
|
175
|
+
# based on the installation results
|
|
176
|
+
# and update the general results list
|
|
177
|
+
installed_packages = []
|
|
178
|
+
for install_data, success in zip(symlinks_to_install, install_results):
|
|
179
|
+
if success:
|
|
180
|
+
installed_packages.append(install_data["name"])
|
|
181
|
+
result = "OK"
|
|
182
|
+
else:
|
|
183
|
+
result = "ERROR: Cannot create symlink, try to run as administrator."
|
|
184
|
+
results.append((install_data["name"], result))
|
|
185
|
+
|
|
186
|
+
# finalize the general results list with info about the bootstrapper
|
|
187
|
+
if exit_code == -1:
|
|
188
|
+
results.append(
|
|
189
|
+
(
|
|
190
|
+
"compas_bootstrapper",
|
|
191
|
+
"WARNING: One or more packages failed, will not install bootstrapper, try uninstalling first",
|
|
192
|
+
)
|
|
193
|
+
)
|
|
194
|
+
else:
|
|
195
|
+
try:
|
|
196
|
+
_update_bootstrapper(installation_path, packages)
|
|
197
|
+
results.append(("compas_bootstrapper", "OK"))
|
|
198
|
+
except: # noqa: E722
|
|
199
|
+
results.append(
|
|
200
|
+
(
|
|
201
|
+
"compas_bootstrapper",
|
|
202
|
+
"ERROR: Could not create compas_bootstrapper to auto-determine Python environment",
|
|
203
|
+
)
|
|
204
|
+
)
|
|
205
|
+
|
|
206
|
+
# output the outcome of the installation process
|
|
207
|
+
# perhaps we should more info here
|
|
208
|
+
print("\nInstalling COMPAS packages to Rhino {0} scripts folder:".format(version))
|
|
209
|
+
print("{}\n".format(installation_path))
|
|
210
|
+
|
|
211
|
+
for package, status in results:
|
|
212
|
+
print(" {} {}".format(package.ljust(20), status))
|
|
213
|
+
if status != "OK":
|
|
214
|
+
exit_code = -1
|
|
215
|
+
|
|
216
|
+
if exit_code == 0 and len(installed_packages):
|
|
217
|
+
print("\nRunning post-installation steps...\n")
|
|
218
|
+
if not _run_post_execution_steps(after_rhino_install(installed_packages)):
|
|
219
|
+
exit_code = -1
|
|
220
|
+
|
|
221
|
+
print("\nInstall completed.")
|
|
222
|
+
if exit_code != 0:
|
|
223
|
+
sys.exit(exit_code)
|
|
224
|
+
|
|
225
|
+
compas_rhino.INSTALLED_VERSION = version
|
|
226
|
+
|
|
227
|
+
|
|
228
|
+
def _run_post_execution_steps(steps_generator):
|
|
229
|
+
all_steps_succeeded = True
|
|
230
|
+
post_execution_errors = []
|
|
231
|
+
|
|
232
|
+
for result in steps_generator:
|
|
233
|
+
if isinstance(result, Exception):
|
|
234
|
+
post_execution_errors.append(result)
|
|
235
|
+
continue
|
|
236
|
+
|
|
237
|
+
for item in result:
|
|
238
|
+
try:
|
|
239
|
+
package, message, success = item
|
|
240
|
+
status = "OK" if success else "ERROR"
|
|
241
|
+
if not success:
|
|
242
|
+
all_steps_succeeded = False
|
|
243
|
+
print(" {} {}: {}".format(package.ljust(20), status, message))
|
|
244
|
+
except ValueError:
|
|
245
|
+
post_execution_errors.append(ValueError("Step ran without errors but result is wrongly formatted: {}".format(str(item))))
|
|
246
|
+
|
|
247
|
+
if post_execution_errors:
|
|
248
|
+
print("\nOne or more errors occurred:\n")
|
|
249
|
+
for error in post_execution_errors:
|
|
250
|
+
print(" - {}".format(repr(error)))
|
|
251
|
+
|
|
252
|
+
all_steps_succeeded = False
|
|
253
|
+
|
|
254
|
+
return all_steps_succeeded
|
|
255
|
+
|
|
256
|
+
|
|
257
|
+
@compas.plugins.plugin(category="install", pluggable_name="installable_rhino_packages", tryfirst=True)
|
|
258
|
+
def default_installable_rhino_packages():
|
|
259
|
+
# While this list could obviously be hard-coded, I think
|
|
260
|
+
# eating our own dogfood and using plugins to define this, just like
|
|
261
|
+
# any other extension/plugin would be is a better way to ensure consistent behavior.
|
|
262
|
+
return ["compas", "compas_rhino"]
|
|
263
|
+
|
|
264
|
+
|
|
265
|
+
@compas.plugins.pluggable(category="install", selector="collect_all")
|
|
266
|
+
def installable_rhino_packages():
|
|
267
|
+
"""Provide a list of packages to make available inside Rhino.
|
|
268
|
+
|
|
269
|
+
Extensions providing Rhino or Grasshopper features
|
|
270
|
+
can implement this pluggable interface to automatically
|
|
271
|
+
have their packages made available inside Rhino when
|
|
272
|
+
COMPAS is installed into it.
|
|
273
|
+
|
|
274
|
+
Examples
|
|
275
|
+
--------
|
|
276
|
+
>>> import compas.plugins
|
|
277
|
+
>>> @compas.plugins.plugin(category="install")
|
|
278
|
+
... def installable_rhino_packages():
|
|
279
|
+
... return ["compas_fab"]
|
|
280
|
+
|
|
281
|
+
Returns
|
|
282
|
+
-------
|
|
283
|
+
:obj:`list` of :obj:`str`
|
|
284
|
+
List of package names to make available inside Rhino.
|
|
285
|
+
"""
|
|
286
|
+
pass
|
|
287
|
+
|
|
288
|
+
|
|
289
|
+
@compas.plugins.pluggable(category="install", selector="collect_all")
|
|
290
|
+
def after_rhino_install(installed_packages):
|
|
291
|
+
"""Allows extensions to execute actions after install to Rhino is done.
|
|
292
|
+
|
|
293
|
+
Extensions providing Rhino or Grasshopper features
|
|
294
|
+
can implement this pluggable interface to perform
|
|
295
|
+
additional steps after an installation to Rhino has
|
|
296
|
+
been completed.
|
|
297
|
+
|
|
298
|
+
Parameters
|
|
299
|
+
----------
|
|
300
|
+
installed_packages : :obj:`list` of :obj:`str`
|
|
301
|
+
List of packages that have been installed successfully.
|
|
302
|
+
|
|
303
|
+
Examples
|
|
304
|
+
--------
|
|
305
|
+
>>> import compas.plugins
|
|
306
|
+
>>> @compas.plugins.plugin(category="install")
|
|
307
|
+
... def after_rhino_install(installed_packages):
|
|
308
|
+
... # Do something after package is installed to Rhino, eg, copy components, etc
|
|
309
|
+
... return [("compas_ghpython", "GH Components installed", True)]
|
|
310
|
+
|
|
311
|
+
Returns
|
|
312
|
+
-------
|
|
313
|
+
:obj:`list` of 3-tuple (str, str, bool)
|
|
314
|
+
List containing a 3-tuple with component name, message and True/False success flag.
|
|
315
|
+
"""
|
|
316
|
+
pass
|
|
317
|
+
|
|
318
|
+
|
|
319
|
+
def _update_bootstrapper(install_path, packages):
|
|
320
|
+
# Take either the CONDA environment directory or the current Python executable's directory
|
|
321
|
+
python_directory = os.environ.get("CONDA_PREFIX", None) or os.path.dirname(sys.executable)
|
|
322
|
+
environment_name = os.environ.get("CONDA_DEFAULT_ENV", "")
|
|
323
|
+
conda_exe = os.environ.get("CONDA_EXE", "")
|
|
324
|
+
|
|
325
|
+
compas_bootstrapper = compas_rhino._get_bootstrapper_path(install_path)
|
|
326
|
+
|
|
327
|
+
bootstrapper_data = compas_rhino._get_bootstrapper_data(compas_bootstrapper)
|
|
328
|
+
installed_packages = bootstrapper_data.get("INSTALLED_PACKAGES", [])
|
|
329
|
+
installed_packages = list(set(installed_packages + list(packages)))
|
|
330
|
+
|
|
331
|
+
with open(compas_bootstrapper, "w") as f:
|
|
332
|
+
f.write('ENVIRONMENT_NAME = r"{}"\n'.format(environment_name))
|
|
333
|
+
f.write('PYTHON_DIRECTORY = r"{}"\n'.format(python_directory))
|
|
334
|
+
f.write('CONDA_EXE = r"{}"\n'.format(conda_exe))
|
|
335
|
+
f.write("INSTALLED_PACKAGES = {}".format(repr(installed_packages)))
|
|
336
|
+
|
|
337
|
+
|
|
338
|
+
def _filter_installable_packages(version, packages):
|
|
339
|
+
ghpython_incompatible = False
|
|
340
|
+
|
|
341
|
+
if compas.OSX and version == 5.0:
|
|
342
|
+
ghpython_incompatible = True
|
|
343
|
+
|
|
344
|
+
if not packages:
|
|
345
|
+
# Flatten list of results (resulting from collect_all pluggable)
|
|
346
|
+
packages = sorted(set(itertools.chain.from_iterable(installable_rhino_packages()))) # type: ignore
|
|
347
|
+
elif "compas_ghpython" in packages and ghpython_incompatible:
|
|
348
|
+
print("Skipping installation of compas_ghpython since it's not supported for Rhino 5 for Mac")
|
|
349
|
+
|
|
350
|
+
if ghpython_incompatible:
|
|
351
|
+
packages.remove("compas_ghpython")
|
|
352
|
+
|
|
353
|
+
return packages
|
|
354
|
+
|
|
355
|
+
|
|
356
|
+
# =============================================================================
|
|
357
|
+
# =============================================================================
|
|
358
|
+
# =============================================================================
|
|
359
|
+
# Main
|
|
360
|
+
# =============================================================================
|
|
361
|
+
# =============================================================================
|
|
362
|
+
# =============================================================================
|
|
363
|
+
|
|
364
|
+
if __name__ == "__main__":
|
|
365
|
+
import argparse
|
|
366
|
+
|
|
367
|
+
parser = argparse.ArgumentParser()
|
|
368
|
+
|
|
369
|
+
parser.add_argument(
|
|
370
|
+
"-v",
|
|
371
|
+
"--version",
|
|
372
|
+
choices=compas_rhino.SUPPORTED_VERSIONS,
|
|
373
|
+
default=compas_rhino.DEFAULT_VERSION,
|
|
374
|
+
help="The version of Rhino to install the packages in.",
|
|
375
|
+
)
|
|
376
|
+
parser.add_argument("-p", "--packages", nargs="+", help="The packages to install.")
|
|
377
|
+
parser.add_argument("-c", "--clean", default=False, action="store_true", help="Clean up the installation directory")
|
|
378
|
+
|
|
379
|
+
args = parser.parse_args()
|
|
380
|
+
compas_rhino.INSTALLATION_ARGUMENTS = args
|
|
381
|
+
|
|
382
|
+
install(version=args.version, packages=args.packages, clean=args.clean)
|
|
@@ -0,0 +1,169 @@
|
|
|
1
|
+
import imp
|
|
2
|
+
import os
|
|
3
|
+
|
|
4
|
+
import compas_rhino
|
|
5
|
+
from compas._os import create_symlinks
|
|
6
|
+
from compas._os import remove_symlinks
|
|
7
|
+
|
|
8
|
+
from .install import install as install_packages
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
def install_plugin(plugin, version=None):
|
|
12
|
+
"""Install a Rhino Python Command Plugin.
|
|
13
|
+
|
|
14
|
+
Parameters
|
|
15
|
+
----------
|
|
16
|
+
plugin : str
|
|
17
|
+
The path to the plugin folder.
|
|
18
|
+
version : {'5.0', '6.0', '7.0', '8.0'}, optional
|
|
19
|
+
The version of Rhino for which the plugin should be installed.
|
|
20
|
+
Default is ``'6.0'``.
|
|
21
|
+
|
|
22
|
+
Notes
|
|
23
|
+
-----
|
|
24
|
+
The version info is only relevant for Rhino on Windows.
|
|
25
|
+
|
|
26
|
+
The function creates an *editable install*, which means that the plugin
|
|
27
|
+
folder is *symlinked* into the correct location so Rhino can find and load it.
|
|
28
|
+
The contents of the source folder can still be edited and next time you start
|
|
29
|
+
Rhino those canges will be reflected in the loaded plugin.
|
|
30
|
+
|
|
31
|
+
Examples
|
|
32
|
+
--------
|
|
33
|
+
Assuming the plugin folder is at the following location on your computer
|
|
34
|
+
|
|
35
|
+
.. code-block:: none
|
|
36
|
+
|
|
37
|
+
~/Code/compas_xxx/ui/Rhino/XXX
|
|
38
|
+
|
|
39
|
+
and contains at least a "dev" folder with a ``__plugin__.py`` file with
|
|
40
|
+
|
|
41
|
+
* the GUID of the tool: ``id={...}``, and
|
|
42
|
+
* the name of the tool: ``title="..."``,
|
|
43
|
+
|
|
44
|
+
it can be installed with the following command,
|
|
45
|
+
|
|
46
|
+
.. code-block:: bash
|
|
47
|
+
|
|
48
|
+
cd ~/Code/compas_xxx
|
|
49
|
+
python -m compas_rhino.install_plugin ui/Rhino/XXX
|
|
50
|
+
|
|
51
|
+
or the following, if the plugin should be installed for Rhino 7.
|
|
52
|
+
|
|
53
|
+
.. code-block:: bash
|
|
54
|
+
|
|
55
|
+
cd ~/Code/compas_xxx
|
|
56
|
+
python -m compas_rhino.install_plugin -v 7.0 ui/Rhino/XXX
|
|
57
|
+
|
|
58
|
+
"""
|
|
59
|
+
if not os.path.isdir(plugin):
|
|
60
|
+
raise Exception("Cannot find the plugin: {}".format(plugin))
|
|
61
|
+
|
|
62
|
+
version = compas_rhino._check_rhino_version(version)
|
|
63
|
+
|
|
64
|
+
plugin_dir = os.path.abspath(plugin)
|
|
65
|
+
|
|
66
|
+
# Clean up the plugin directory
|
|
67
|
+
# by removing all broken symlinks
|
|
68
|
+
# because ... they're broken!
|
|
69
|
+
|
|
70
|
+
symlinks_to_remove = []
|
|
71
|
+
|
|
72
|
+
for name in os.listdir(plugin_dir):
|
|
73
|
+
path = os.path.join(plugin_dir, name)
|
|
74
|
+
if os.path.islink(path):
|
|
75
|
+
if not os.path.exists(path):
|
|
76
|
+
symlinks_to_remove.append(dict(name=name, link=path))
|
|
77
|
+
|
|
78
|
+
symlinks_removed = []
|
|
79
|
+
symlinks_unremoved = []
|
|
80
|
+
|
|
81
|
+
if symlinks_to_remove:
|
|
82
|
+
symlinks = [link["link"] for link in symlinks_to_remove]
|
|
83
|
+
removal_results = remove_symlinks(symlinks)
|
|
84
|
+
for uninstall_data, success in zip(symlinks_to_remove, removal_results):
|
|
85
|
+
if success:
|
|
86
|
+
symlinks_removed.append(uninstall_data["name"])
|
|
87
|
+
else:
|
|
88
|
+
symlinks_unremoved.append(uninstall_data["name"])
|
|
89
|
+
|
|
90
|
+
if symlinks_removed:
|
|
91
|
+
print("\nThe following package symlinks are broken and were removed:\n")
|
|
92
|
+
for name in symlinks_removed:
|
|
93
|
+
print(" {}".format(name.ljust(20)))
|
|
94
|
+
|
|
95
|
+
if symlinks_unremoved:
|
|
96
|
+
print("\nThe following package symlinks are broken but could not be removed:\n")
|
|
97
|
+
for name in symlinks_unremoved:
|
|
98
|
+
print(" {}".format(name.ljust(20)))
|
|
99
|
+
|
|
100
|
+
# -----------------------------
|
|
101
|
+
# proceed with the installation
|
|
102
|
+
# -----------------------------
|
|
103
|
+
|
|
104
|
+
plugin_path, plugin_name = os.path.split(plugin_dir)
|
|
105
|
+
plugin_path = plugin_path or os.getcwd()
|
|
106
|
+
|
|
107
|
+
plugin_dev = os.path.join(plugin_dir, "dev")
|
|
108
|
+
|
|
109
|
+
if not os.path.isdir(plugin_dev):
|
|
110
|
+
raise Exception("The plugin does not contain a dev folder.")
|
|
111
|
+
|
|
112
|
+
plugin_info = os.path.join(plugin_dev, "__plugin__.py")
|
|
113
|
+
|
|
114
|
+
if not os.path.isfile(plugin_info):
|
|
115
|
+
raise Exception("The plugin does not contain plugin info.")
|
|
116
|
+
|
|
117
|
+
__plugin__ = imp.load_source("__plugin__", plugin_info)
|
|
118
|
+
|
|
119
|
+
if not __plugin__.id:
|
|
120
|
+
raise Exception("Plugin id is not set.")
|
|
121
|
+
|
|
122
|
+
if not __plugin__.title:
|
|
123
|
+
raise Exception("Plugin title is not set.")
|
|
124
|
+
|
|
125
|
+
plugin_fullname = "{}{}".format(__plugin__.title, __plugin__.id)
|
|
126
|
+
|
|
127
|
+
python_plugins_path = compas_rhino._get_rhino_pythonplugins_path(version)
|
|
128
|
+
|
|
129
|
+
if not os.path.exists(python_plugins_path):
|
|
130
|
+
os.mkdir(python_plugins_path)
|
|
131
|
+
|
|
132
|
+
source = plugin_dir
|
|
133
|
+
destination = os.path.join(python_plugins_path, plugin_fullname)
|
|
134
|
+
|
|
135
|
+
# Stat the installation process
|
|
136
|
+
|
|
137
|
+
if hasattr(__plugin__, "packages"):
|
|
138
|
+
install_packages(version=version, packages=__plugin__.packages)
|
|
139
|
+
|
|
140
|
+
print("\nInstalling PlugIn {} to Rhino PythonPlugIns.".format(plugin_name))
|
|
141
|
+
|
|
142
|
+
remove_symlinks([destination])
|
|
143
|
+
create_symlinks([(source, destination)])
|
|
144
|
+
|
|
145
|
+
print("\nPlugIn {} Installed.".format(plugin_name))
|
|
146
|
+
print("\nRestart Rhino and open the Python editor at least once to make it available.")
|
|
147
|
+
|
|
148
|
+
|
|
149
|
+
# ==============================================================================
|
|
150
|
+
# Main
|
|
151
|
+
# ==============================================================================
|
|
152
|
+
|
|
153
|
+
if __name__ == "__main__":
|
|
154
|
+
import argparse
|
|
155
|
+
|
|
156
|
+
parser = argparse.ArgumentParser(description="COMPAS Rhino Plugin Installation command-line utility.")
|
|
157
|
+
|
|
158
|
+
parser.add_argument("plugin", help="The path to the plugin directory.")
|
|
159
|
+
parser.add_argument(
|
|
160
|
+
"-v",
|
|
161
|
+
"--version",
|
|
162
|
+
choices=compas_rhino.SUPPORTED_VERSIONS,
|
|
163
|
+
default=compas_rhino.DEFAULT_VERSION,
|
|
164
|
+
help="The version of Rhino.",
|
|
165
|
+
)
|
|
166
|
+
|
|
167
|
+
args = parser.parse_args()
|
|
168
|
+
|
|
169
|
+
install_plugin(args.plugin, version=args.version)
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import subprocess
|
|
2
|
+
|
|
3
|
+
import compas_rhino
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
def install(args):
|
|
7
|
+
subprocess.check_call([compas_rhino._get_default_rhino_cpython_path("8.0"), "-m", "pip", "install"] + args)
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
if __name__ == "__main__":
|
|
11
|
+
import argparse
|
|
12
|
+
|
|
13
|
+
parser = argparse.ArgumentParser()
|
|
14
|
+
|
|
15
|
+
parser.add_argument("pipargs", help="Arguments to be passed on to pip as a string")
|
|
16
|
+
|
|
17
|
+
args = parser.parse_args()
|
|
18
|
+
pipargs = args.pipargs.split()
|
|
19
|
+
|
|
20
|
+
install(pipargs)
|