UnicodePlots.jl icon indicating copy to clipboard operation
UnicodePlots.jl copied to clipboard

Non-trivial dependencies

Open juliohm opened this issue 1 year ago • 1 comments

Using the awesome PkgDepencency.jl package, I realized that one of my heaviest dependencies is UnicodePlots.jl:

image

I wonder if there is a way to split these dependencies on external libraries (e.g. EarCut_jll), GeometryBasics.jl etc? If that is not possible, do you know any alternative package for simple bar plots on the terminal that I could use to print compositional data as shown in this readme? https://github.com/JuliaEarth/CoDa.jl

Alternatively, could the recipes in UnicodePlots.jl be split into separate modules and glued together into UnicodePlots.jl for end-users? As a package developer I would really prefer to just add a UnicodeBarPlots.jl package to avoid all the fuzz with 3D dependencies.

juliohm avatar Sep 12 '22 21:09 juliohm

dependency tree
 UnicodePlots v3.1.0                                                        
━━━━━━━━━━━━━━━━━━━━━                                                       
          │                                                                 
          ├── MarchingCubes v0.1.4                                          
          │   ├── StaticArrays v1.5.6                                       
          │   │   └── StaticArraysCore v1.3.0                               
          │   └── SnoopPrecompile v1.0.1                                    
          ├── ColorSchemes v3.19.0                                          
          │   ├── ColorTypes v0.11.4                                        
          │   │   └── FixedPointNumbers v0.8.4                              
          │   ├── ColorVectorSpace v0.9.9                                   
          │   │   ├── ColorTypes v0.11.4 (*)                                
          │   │   ├── TensorCore v0.1.1                                     
          │   │   ├── SpecialFunctions v2.1.7                               
          │   │   │   ├── IrrationalConstants v0.1.1                        
          │   │   │   ├── ChainRulesCore v1.15.5                            
          │   │   │   │   └── Compat v3.46.0                                
          │   │   │   │       ├── Pkg v1.8.0                                
          │   │   │   │       │   ├── Downloads v1.6.0                      
          │   │   │   │       │   │   ├── LibCURL v0.6.3                    
          │   │   │   │       │   │   │   ├── MozillaCACerts_jll v2022.2.1  
          │   │   │   │       │   │   │   └── LibCURL_jll v7.84.0+0         
          │   │   │   │       │   │   │       ├── LibSSH2_jll v1.10.2+0     
          │   │   │   │       │   │   │       │   └── MbedTLS_jll v2.28.0+0 
          │   │   │   │       │   │   │       ├── MbedTLS_jll v2.28.0+0 (*) 
          │   │   │   │       │   │   │       ├── nghttp2_jll v1.48.0+0     
          │   │   │   │       │   │   │       └── Zlib_jll v1.2.12+3        
          │   │   │   │       │   │   ├── NetworkOptions v1.2.0             
          │   │   │   │       │   │   └── ArgTools v1.1.1                   
          │   │   │   │       │   ├── Tar v1.10.0                           
          │   │   │   │       │   │   ├── SHA v0.7.0                        
          │   │   │   │       │   │   └── ArgTools v1.1.1 (*)               
          │   │   │   │       │   ├── SHA v0.7.0 (*)                        
          │   │   │   │       │   ├── p7zip_jll v17.4.0+0                   
          │   │   │   │       │   └── TOML v1.0.0                           
          │   │   │   │       └── SHA v0.7.0 (*)                            
          │   │   │   ├── LogExpFunctions v0.3.18                           
          │   │   │   │   ├── IrrationalConstants v0.1.1 (*)                
          │   │   │   │   ├── ChainRulesCore v1.15.5 (*)                    
          │   │   │   │   ├── ChangesOfVariables v0.1.4                     
          │   │   │   │   │   └── ChainRulesCore v1.15.5 (*)                
          │   │   │   │   ├── DocStringExtensions v0.8.6                    
          │   │   │   │   └── InverseFunctions v0.1.7                       
          │   │   │   ├── OpenLibm_jll v0.8.1+0                             
          │   │   │   └── OpenSpecFun_jll v0.5.5+0                          
          │   │   │       ├── JLLWrappers v1.4.1                            
          │   │   │       │   └── Preferences v1.3.0                        
          │   │   │       │       └── TOML v1.0.0 (*)                       
          │   │   │       ├── Pkg v1.8.0 (*)                                
          │   │   │       └── CompilerSupportLibraries_jll v0.5.2+0         
          │   │   └── FixedPointNumbers v0.8.4 (*)                          
          │   ├── Colors v0.12.8                                            
          │   │   ├── ColorTypes v0.11.4 (*)                                
          │   │   ├── Reexport v1.2.2                                       
          │   │   └── FixedPointNumbers v0.8.4 (*)                          
          │   └── FixedPointNumbers v0.8.4 (*)                              
          ├── SnoopPrecompile v1.0.1 (*)                                    
          ├── StatsBase v0.33.21                                            
          │   ├── LogExpFunctions v0.3.18 (*)                               
          │   ├── SortingAlgorithms v1.0.1                                  
          │   │   └── DataStructures v0.18.13                               
          │   │       ├── Compat v3.46.0 (*)                                
          │   │       └── OrderedCollections v1.4.1                         
          │   ├── Missings v1.0.2                                           
          │   │   └── DataAPI v1.10.0                                       
          │   ├── DataStructures v0.18.13 (*)                               
          │   ├── StatsAPI v1.5.0                                           
          │   └── DataAPI v1.10.0 (*)                                       
          ├── ColorTypes v0.11.4 (*)                                        
          ├── Crayons v4.1.1                                                
          ├── FileIO v1.15.0                                                
          │   ├── Pkg v1.8.0 (*)                                            
          │   └── Requires v1.3.0                                           
          ├── StaticArrays v1.5.6 (*)                                       
          ├── Unitful v1.11.0                                               
          │   └── ConstructionBase v1.4.1                                   
          ├── FreeTypeAbstraction v0.10.0                                   
          │   ├── FreeType v4.0.0                                           
          │   │   ├── CEnum v0.4.2                                          
          │   │   └── FreeType2_jll v2.10.4+0                               
          │   │       ├── JLLWrappers v1.4.1 (*)                            
          │   │       ├── Pkg v1.8.0 (*)                                    
          │   │       ├── Bzip2_jll v1.0.8+0                                
          │   │       │   ├── JLLWrappers v1.4.1 (*)                        
          │   │       │   └── Pkg v1.8.0 (*)                                
          │   │       └── Zlib_jll v1.2.12+3 (*)                            
          │   ├── ColorVectorSpace v0.9.9 (*)                               
          │   ├── Colors v0.12.8 (*)                                        
          │   └── GeometryBasics v0.4.3                                     
          │       ├── IterTools v1.4.0                                      
          │       ├── StaticArrays v1.5.6 (*)                               
          │       ├── Tables v1.7.0                                         
          │       │   ├── DataAPI v1.10.0 (*)                               
          │       │   ├── OrderedCollections v1.4.1 (*)                     
          │       │   ├── IteratorInterfaceExtensions v1.0.0                
          │       │   ├── DataValueInterfaces v1.0.0                        
          │       │   └── TableTraits v1.0.1                                
          │       │       └── IteratorInterfaceExtensions v1.0.0 (*)        
          │       ├── EarCut_jll v2.2.3+0                                   
          │       │   ├── JLLWrappers v1.4.1 (*)                            
          │       │   └── Pkg v1.8.0 (*)                                    
          │       ├── StructArrays v0.6.12                                  
          │       │   ├── DataAPI v1.10.0 (*)                               
          │       │   ├── StaticArraysCore v1.3.0 (*)                       
          │       │   ├── Tables v1.7.0 (*)                                 
          │       │   └── Adapt v3.4.0                                      
          │       └── GeoInterface v1.0.1                                   
          │           └── Extents v0.1.1                                    
          ├── LazyModules v0.3.1                                            
          ├── Contour v0.6.2                                                
          ├── Requires v1.3.0 (*)                                           
          └── NaNMath v1.0.1                                                
              └── OpenLibm_jll v0.8.1+0 (*)  

I agree that some dependencies are problematic. However, as a developer I try to reuse as much existing julia packages in order to reduce maintenance and avoid re-inventing the wheel. Adding dependencies is unavoidable in a certain way: users are requesting more and more features: e.g. when you asked for Unitful support in https://github.com/JuliaPlots/UnicodePlots.jl/issues/230, we had to add the Unitful dependency, and they just pile up.

I see two problematic dependencies:

  1. FreeTypeAbstraction: solely used for png exports of plots, and currently lazily loaded (https://github.com/JuliaPlots/UnicodePlots.jl/pull/260) in order to reduce latency;
  2. ColorSchemes: there was a splitting attempt at https://github.com/JuliaGraphics/ColorSchemes.jl/issues/19, the problematic dependency looks like ColorVectorSpace (also used in FreeTypeAbstraction, so considered minor ?).

If that is not possible, do you know any alternative package for simple bar plots on the terminal that I could use to print compositional data as shown in this readme?

Not to my knowledge.

Alternatively, could the recipes in UnicodePlots.jl be split into separate modules and glued together into UnicodePlots.jl for end-users?

That would be quite difficult to implement, and I guess for small benefit (I won't have the bandwidth to work on this). IMO it is better to open upstream issues in problematic packages to request splitting packages or reduce dependencies.

As a package developer I would really prefer to just add a UnicodeBarPlots.jl package to avoid all the fuzz with 3D dependencies.

I think we can open an issue in FreeTypeAbstraction since adding GeometryBasics (with induced artifacts dependencies, and un-needed mesh related stuff) looks like an overkill for rendering characters.

t-bltg avatar Sep 13 '22 10:09 t-bltg

ColorSchemes was split successfully. But the "pretty lightweight" dependency on ColorVectorSpace was added in https://github.com/JuliaGraphics/ColorSchemes.jl/issues/91 - to improve speed and memory use, apparently. SpecialFunctions (https://github.com/JuliaGraphics/ColorVectorSpace.jl/issues/182) is being looked at...😀

cormullion avatar Sep 29 '22 21:09 cormullion

Thanks @cormullion, I don't really see where to go with this issue.

I've made my part in https://github.com/JuliaGeometry/GeometryBasics.jl/pull/179, but it seems to go nowhere.

Yes, here too we lazy load FreetypeAbstraction, but it is still listed in the dependencies. I do think this lazy approach is acceptable, since what is truly important is the load time, not the number of dependencies (if you omit the dependency hell problem :laughing: ).

t-bltg avatar Sep 30 '22 07:09 t-bltg