@@ -228,34 +228,6 @@ def is_installed(self) -> bool:
228
228
"""
229
229
return self .installed_version is not None
230
230
231
- def __getitem__ (self , key : Union [int , str ]):
232
- r"""
233
- Only for backwards compatibility to allow dict-like access.
234
-
235
- TESTS::
236
-
237
- sage: from sage.misc.package import PackageInfo
238
- sage: package = PackageInfo("test_package")
239
- sage: package["name"]
240
- doctest:warning...
241
- dict-like access is deprecated, use pkg.name instead of pkg['name'], for example
242
- See https://github.com/sagemath/sage/issues/31013 for details.
243
- 'test_package'
244
- sage: package[0]
245
- 'test_package'
246
- """
247
- if isinstance (key , str ):
248
- from sage .misc .superseded import deprecation
249
-
250
- if key == "installed" :
251
- deprecation (31013 , "dict-like access via 'installed' is deprecated, use method is_installed instead" )
252
- return self .is_installed ()
253
- else :
254
- deprecation (31013 , "dict-like access is deprecated, use pkg.name instead of pkg['name'], for example" )
255
- return self .__getattribute__ (key )
256
- else :
257
- return tuple .__getitem__ (self , key )
258
-
259
231
260
232
def list_packages (* pkg_types : str , pkg_sources : List [str ] = ['normal' , 'pip' , 'script' ],
261
233
local : bool = False , ignore_URLError : bool = False , exclude_pip : bool = False ) -> Dict [str , PackageInfo ]:
@@ -547,109 +519,6 @@ def package_versions(package_type, local=False):
547
519
return {pkg .name : (pkg .installed_version , pkg .remote_version ) for pkg in list_packages (package_type , local = local ).values ()}
548
520
549
521
550
- def standard_packages ():
551
- """
552
- Return two lists. The first contains the installed and the second
553
- contains the not-installed standard packages that are available
554
- from the Sage repository.
555
-
556
- OUTPUT:
557
-
558
- - installed standard packages (as a list)
559
-
560
- - NOT installed standard packages (as a list)
561
-
562
- Run ``sage -i package_name`` from a shell to install a given
563
- package or ``sage -f package_name`` to re-install it.
564
-
565
- .. SEEALSO:: :func:`sage.misc.package.list_packages`
566
-
567
- EXAMPLES::
568
-
569
- sage: from sage.misc.package import standard_packages
570
- sage: installed, not_installed = standard_packages() # optional - sage_spkg
571
- doctest:...: DeprecationWarning: ...
572
- sage: 'numpy' in installed # optional - sage_spkg
573
- True
574
- """
575
- from sage .misc .superseded import deprecation
576
- deprecation (30747 ,
577
- 'the functions standard_packages, optional_packages, experimental_packages '
578
- 'are deprecated, use sage.features instead' )
579
- pkgs = list_packages ('standard' , local = True ).values ()
580
- return (sorted (pkg .name for pkg in pkgs if pkg .is_installed ()),
581
- sorted (pkg .name for pkg in pkgs if not pkg .is_installed ()))
582
-
583
-
584
- def optional_packages ():
585
- """
586
- Return two lists. The first contains the installed and the second
587
- contains the not-installed optional packages that are available
588
- from the Sage repository.
589
-
590
- OUTPUT:
591
-
592
- - installed optional packages (as a list)
593
-
594
- - NOT installed optional packages (as a list)
595
-
596
- Run ``sage -i package_name`` from a shell to install a given
597
- package or ``sage -f package_name`` to re-install it.
598
-
599
- .. SEEALSO:: :func:`sage.misc.package.list_packages`
600
-
601
- EXAMPLES::
602
-
603
- sage: # optional - sage_spkg
604
- sage: from sage.misc.package import optional_packages
605
- sage: installed, not_installed = optional_packages()
606
- doctest:...: DeprecationWarning: ...
607
- sage: 'biopython' in installed + not_installed
608
- True
609
- sage: 'biopython' in installed # optional - biopython
610
- True
611
- """
612
- from sage .misc .superseded import deprecation
613
- deprecation (30747 ,
614
- 'the functions standard_packages, optional_packages, experimental_packages '
615
- 'are deprecated, use sage.features instead' )
616
- pkgs = list_packages ('optional' , local = True )
617
- pkgs = pkgs .values ()
618
- return (sorted (pkg .name for pkg in pkgs if pkg .is_installed ()),
619
- sorted (pkg .name for pkg in pkgs if not pkg .is_installed ()))
620
-
621
-
622
- def experimental_packages ():
623
- """
624
- Return two lists. The first contains the installed and the second
625
- contains the not-installed experimental packages that are available
626
- from the Sage repository.
627
-
628
- OUTPUT:
629
-
630
- - installed experimental packages (as a list)
631
-
632
- - NOT installed experimental packages (as a list)
633
-
634
- Run ``sage -i package_name`` from a shell to install a given
635
- package or ``sage -f package_name`` to re-install it.
636
-
637
- .. SEEALSO:: :func:`sage.misc.package.list_packages`
638
-
639
- EXAMPLES::
640
-
641
- sage: from sage.misc.package import experimental_packages
642
- sage: installed, not_installed = experimental_packages() # optional - sage_spkg
643
- doctest:...: DeprecationWarning: ...
644
- """
645
- from sage .misc .superseded import deprecation
646
- deprecation (30747 ,
647
- 'the functions standard_packages, optional_packages, experimental_packages '
648
- 'are deprecated, use sage.features instead' )
649
- pkgs = list_packages ('experimental' , local = True ).values ()
650
- return (sorted (pkg .name for pkg in pkgs if pkg .is_installed ()),
651
- sorted (pkg .name for pkg in pkgs if not pkg .is_installed ()))
652
-
653
522
def package_manifest (package ):
654
523
"""
655
524
Return the manifest for ``package``.
@@ -691,68 +560,10 @@ def package_manifest(package):
691
560
pass
692
561
raise RuntimeError ('package manifest directory changed at runtime' )
693
562
694
- class PackageNotFoundError (RuntimeError ):
695
- """
696
- This class defines the exception that should be raised when a
697
- function, method, or class cannot detect a Sage package that it
698
- depends on.
699
-
700
- This exception should be raised with a single argument, namely
701
- the name of the package.
702
563
703
- When a ``PackageNotFoundError`` is raised, this means one of the
704
- following:
705
-
706
- - The required optional package is not installed.
707
-
708
- - The required optional package is installed, but the relevant
709
- interface to that package is unable to detect the package.
710
-
711
- Raising a ``PackageNotFoundError`` is deprecated. Use
712
- :class:`sage.features.FeatureNotPresentError` instead.
713
-
714
- User code can continue to catch ``PackageNotFoundError`` exceptions
715
- for compatibility with older versions of the Sage library.
716
- This does not cause deprecation warnings.
717
-
718
- EXAMPLES::
719
-
720
- sage: from sage.misc.package import PackageNotFoundError
721
- sage: try:
722
- ....: pass
723
- ....: except PackageNotFoundError:
724
- ....: pass
725
-
726
- """
727
-
728
- def __init__ (self , * args ):
729
- """
730
- TESTS::
731
-
732
- sage: from sage.misc.package import PackageNotFoundError
733
- sage: raise PackageNotFoundError("my_package")
734
- Traceback (most recent call last):
735
- ...
736
- PackageNotFoundError: the package 'my_package' was not found. You can install it by running 'sage -i my_package' in a shell
737
- """
738
- super ().__init__ (* args )
739
- # We do not deprecate the whole class because we want
740
- # to allow user code to handle this exception without causing
741
- # a deprecation warning.
742
- from sage .misc .superseded import deprecation
743
- deprecation (30607 , "Instead of raising PackageNotFoundError, raise sage.features.FeatureNotPresentError" )
744
-
745
- def __str__ (self ):
746
- """
747
- Return the actual error message.
748
-
749
- EXAMPLES::
750
-
751
- sage: from sage.misc.package import PackageNotFoundError
752
- sage: str(PackageNotFoundError("my_package"))
753
- doctest:warning...
754
- "the package 'my_package' was not found. You can install it by running 'sage -i my_package' in a shell"
755
- """
756
- return ("the package {0!r} was not found. "
757
- "You can install it by running 'sage -i {0}' in a shell"
758
- .format (self .args [0 ]))
564
+ # PackageNotFoundError used to be an exception class.
565
+ # It was deprecated in #30607 and removed afterwards.
566
+ # User code can continue to use PackageNotFoundError in
567
+ # try...except statements using this definition, which
568
+ # catches no exception.
569
+ PackageNotFoundError = ()
0 commit comments