Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Don't depend on pkg_resources #185

Open
ataylor32 opened this issue Apr 28, 2024 · 1 comment
Open

Don't depend on pkg_resources #185

ataylor32 opened this issue Apr 28, 2024 · 1 comment

Comments

@ataylor32
Copy link
Contributor

Expected Behavior

I should be able to run a command like python manage.py shell without any errors.

Current Behavior

[ERROR] management_commands File "/var/www/example.com/manage.py", line 33: Management command error: manage.py shell
Traceback (most recent call last):
  File "/var/www/example.com/manage.py", line 31, in main
    execute_from_command_line(sys.argv)
  File "/var/www/example.com/venv/lib/python3.12/site-packages/django/core/management/__init__.py", line 442, in execute_from_command_line
    utility.execute()
  File "/var/www/example.com/venv/lib/python3.12/site-packages/django/core/management/__init__.py", line 416, in execute
    django.setup()
  File "/var/www/example.com/venv/lib/python3.12/site-packages/django/__init__.py", line 24, in setup
    apps.populate(settings.INSTALLED_APPS)
  File "/var/www/example.com/venv/lib/python3.12/site-packages/django/apps/registry.py", line 91, in populate
    app_config = AppConfig.create(entry)
                 ^^^^^^^^^^^^^^^^^^^^^^^
  File "/var/www/example.com/venv/lib/python3.12/site-packages/django/apps/config.py", line 193, in create
    import_module(entry)
  File "/usr/lib/python3.12/importlib/__init__.py", line 90, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "<frozen importlib._bootstrap>", line 1387, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1360, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1331, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 935, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 995, in exec_module
  File "<frozen importlib._bootstrap>", line 488, in _call_with_frames_removed
  File "/var/www/example.com/venv/lib/python3.12/site-packages/user_sessions/__init__.py", line 1, in <module>
    from pkg_resources import DistributionNotFound, get_distribution
ModuleNotFoundError: No module named 'pkg_resources'

Your Environment

  • Python version: 3.12.3
  • Django version: 4.2.11
  • django-user-sessions version: 2.0.0

Relevant: python/cpython#95299

@WhyNotHugo
Copy link
Member

WhyNotHugo commented May 15, 2024

pkg_resources is used to read the current package version.

We should probably write the version into a file at build time instead with something like:

[build-system]
requires = ["setuptools>=45", "wheel", "setuptools_scm>=6.2"]

[tool.setuptools_scm]
write_to = "user_sessions/version.py"
version_scheme = "no-guess-dev"

init.py can then use:

from . import version

__version__ = version.version

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants