Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/jupyterlab/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@
"codemirror": "^5.65.0"
},
"devDependencies": {
"@jupyterlab/builder": "^3.1.0",
"@jupyterlab/builder": "^4.4.3",
"@tsconfig/svelte": "^3.0.0",
"@types/codemirror": "^5.60.5",
"@types/node": "^17.0.7",
Expand Down
20 changes: 12 additions & 8 deletions yuuno/autodiscover.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,18 @@
#
# You should have received a copy of the GNU Lesser General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
import pkg_resources

try:
import importlib.metadata as importlib_metadata
except ImportError:
import importlib_metadata

def discover_environments(module_dict):
all_exts = []
for ep in pkg_resources.iter_entry_points('yuuno.environments'):
entry_points = importlib_metadata.entry_points()
for ep in entry_points.select(group='yuuno.environments'):
module_dict[ep.name] = ep.load()
all_exts.append(ep.name)

# This makes yuuno_ipython work easier in development environments.
if "load_ipython_extension" not in module_dict:
import yuuno_ipython.ipython.environment as ipy_env
Expand All @@ -34,18 +37,19 @@ def discover_environments(module_dict):

return all_exts


def discover_extensions():
for ep in pkg_resources.iter_entry_points('yuuno.extensions'):
entry_points = importlib_metadata.entry_points()
for ep in entry_points.select(group='yuuno.extensions'):
extension = ep.load()
if not hasattr(extension, '_name'):
extension._name = ep.name
yield extension


def discover_commands():
commands = {}
for ep in pkg_resources.iter_entry_points('yuuno.commands'):
entry_points = importlib_metadata.entry_points()
for ep in entry_points.select(group='yuuno.commands'):
command = ep.load()
commands[ep.name] = command
return commands

16 changes: 11 additions & 5 deletions yuuno_ipython/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,18 @@
from pathlib import Path

try:
from pkg_resources import resource_filename
import importlib.resources as importlib_resources
except ImportError:
def resource_filename(_: str, name: str):
this_dir, this_filename = os.path.split(__file__)
path = os.path.join(this_dir, '..', name)
return path
import importlib_resources
def resource_filename(package: str, name: str):
"""
Return the file system path to a resource inside a package.
"""
try:
return str(importlib_resources.files(package).joinpath(name))
except AttributeError:
with importlib_resources.path(package, name) as resource_path:
return str(resource_path)


def get_data_file(name) -> Path:
Expand Down