Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
A
AlekSIS-Core
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Terraform modules
Monitor
Service Desk
Analyze
Contributor analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
AlekSIS®
Official
AlekSIS-Core
Commits
f3d54ed0
Verified
Commit
f3d54ed0
authored
3 years ago
by
Nik | Klampfradler
Browse files
Options
Downloads
Patches
Plain Diff
Use importlib instead of pkg_resources to discover dist
parent
2280f3b7
No related branches found
No related tags found
1 merge request
!642
Use importlib instead of pkg_resources to discover dist
Pipeline
#14320
passed
3 years ago
Stage: test
Stage: build
Stage: publish
Stage: docker
Stage: deploy
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
aleksis/core/__init__.py
+2
-2
2 additions, 2 deletions
aleksis/core/__init__.py
aleksis/core/util/apps.py
+5
-5
5 additions, 5 deletions
aleksis/core/util/apps.py
with
7 additions
and
7 deletions
aleksis/core/__init__.py
+
2
−
2
View file @
f3d54ed0
import
pkg_resources
from
import
lib
import
metadata
try
:
from
.celery
import
app
as
celery_app
...
...
@@ -7,7 +7,7 @@ except ModuleNotFoundError:
celery_app
=
None
try
:
__version__
=
pkg_resources
.
get_
distribution
(
"
AlekSIS-Core
"
).
version
__version__
=
metadata
.
distribution
(
"
AlekSIS-Core
"
).
version
except
Exception
:
__version__
=
"
unknown
"
...
...
This diff is collapsed.
Click to expand it.
aleksis/core/util/apps.py
+
5
−
5
View file @
f3d54ed0
from
importlib
import
metadata
from
typing
import
Any
,
Optional
,
Sequence
import
django.apps
...
...
@@ -5,7 +6,6 @@ from django.contrib.auth.signals import user_logged_in, user_logged_out
from
django.db.models.signals
import
post_migrate
,
pre_migrate
from
django.http
import
HttpRequest
import
pkg_resources
from
dynamic_preferences.signals
import
preference_updated
from
license_expression
import
Licensing
from
spdx_license_list
import
LICENSES
...
...
@@ -32,7 +32,7 @@ class AppConfig(django.apps.AppConfig):
self
.
preference_updated
(
self
)
def
get_distribution_name
(
self
):
"""
Get
pkg_resources
distribution name of application package.
"""
"""
Get distribution name of application package.
"""
if
hasattr
(
self
,
"
dist_name
"
):
return
self
.
dist_name
elif
self
.
name
.
lower
().
startswith
(
"
aleksis.apps.
"
):
...
...
@@ -41,12 +41,12 @@ class AppConfig(django.apps.AppConfig):
return
None
def
get_distribution
(
self
):
"""
Get
pkg_resources
distribution of application package.
"""
"""
Get distribution of application package.
"""
dist_name
=
self
.
get_distribution_name
()
if
dist_name
:
try
:
dist
=
pkg_resources
.
get_
distribution
(
dist_name
)
except
pkg_resources
.
Distribution
NotFound
:
dist
=
metadata
.
distribution
(
dist_name
)
except
Package
NotFound
Error
:
return
None
return
dist
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment