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

Development dependencies are considered as actual dependencies when adding drf-nested-router package #267

Open
EarthModule opened this issue Jul 27, 2022 · 3 comments

Comments

@EarthModule
Copy link

The package requirements.txt only lists Django and DRF, however when installing this package, all the doc and testing packages and their version locks are installed as well. At least with Poetry, here is an example:

poetry add drf-nested-routers
Using version ^0.93.4 for drf-nested-routers

Updating dependencies
Resolving dependencies... (0.5s)

Writing lock file

Package operations: 15 installs, 23 updates, 0 removals

  • Updating markupsafe (2.1.1 -> 2.1.0)
  • Updating asgiref (3.5.2 -> 3.5.0)
  • Updating certifi (2022.6.15 -> 2021.10.8)
  • Updating charset-normalizer (2.1.0 -> 2.0.12)
  • Updating jinja2 (3.1.2 -> 3.0.3)
  • Updating pyparsing (3.0.9 -> 3.0.7)
  • Updating pytz (2022.1 -> 2021.3)
  • Updating urllib3 (1.26.10 -> 1.26.8)
  • Updating zipp (3.8.1 -> 3.7.0)
  • Installing alabaster (0.7.12)
  • Installing babel (2.9.1)
  • Updating distlib (0.3.5 -> 0.3.4)
  • Updating django (3.2.14 -> 3.2.12)
  • Installing docutils (0.17.1)
  • Updating filelock (3.7.1 -> 3.6.0)
  • Installing imagesize (1.3.0)
  • Updating importlib-metadata (4.12.0 -> 4.11.2)
  • Updating platformdirs (2.5.2 -> 2.5.1)
  • Updating pygments (2.12.0 -> 2.11.2)
  • Updating requests (2.28.1 -> 2.27.1)
  • Installing snowballstemmer (2.2.0)
  • Installing sphinxcontrib-applehelp (1.0.2)
  • Installing sphinxcontrib-devhelp (1.0.2)
  • Installing sphinxcontrib-htmlhelp (2.0.0)
  • Installing sphinxcontrib-jsmath (1.0.1)
  • Installing sphinxcontrib-qthelp (1.0.3)
  • Installing sphinxcontrib-serializinghtml (1.1.5)
  • Installing colorama (0.4.4)
  • Installing commonmark (0.9.1)
  • Updating pytest (7.1.2 -> 7.0.1)
  • Installing sphinx (4.4.0)
  • Updating virtualenv (20.15.1 -> 20.13.2)
  • Updating django-debug-toolbar (3.5.0 -> 3.2.4)
  • Updating django-extensions (3.2.0 -> 3.1.5)
  • Updating drf-yasg (1.21.0 -> 1.20.0)
  • Installing recommonmark (0.7.1)
  • Updating tox (3.25.1 -> 3.24.5)
  • Updating werkzeug (2.1.2 -> 2.0.3)

I think the setup.py function get_packages dynamically includes the development dependencies as part of the installation process.

Expected behavior would be that Django and DRF are the only packages to consider when installing drf-nested-router.

Really love drf-nested-routers package, but this issue prevents me from using it in any real-world projects.

@alanjds
Copy link
Owner

alanjds commented Jul 27, 2022

Hi, @EarthModule. Thanks for reaching out.

This situation with Poetry sounds odd. I personally have no projects using Poetry, so no experience with it, but my other projects are not installing the test dependencies 🤔.

Do you have a clue on what would be a fix for your issue?

@EarthModule
Copy link
Author

Hi @alanjds

If you want, you can quickly replicate the issue following these steps:
1. Install pipx. pipx is system-wide python application manager that isolates different tools to their own virtualenvs.
2. Install poetry with pipx: pipx install poetry
3. In empty folder, run poetry init, reply no for interactive definition of dependencies.
I could not replicate the issue into clean Poetry environment, which makes me doubt if this is just my project virtualenv. Hope not, would feel really silly. I did get the same result in same virtualenv on different weeks though. Might be some weird corner case bug with Poetry as well.

I think the fix could be to not use custom find_packages function, but instead use setuptools find_packages with excluding tests. Example how I would try to fix the issue (not tested), '...' denotes code in between:

#!/usr/bin/env python
# -*- coding: utf-8 -*-
...
from setuptools import setup, find_packages
...
def get_version(package):
    """
    Return package version as listed in `__version__` in `init.py`.
    """
    init_py = open(os.path.join(package, '__init__.py')).read()
    return re.search("^__version__ = ['\"]([^'\"]+)['\"]",
                     init_py, re.MULTILINE).group(1)

# removed get_packages function here
...
setup(
  ...
    packages=find_packages(exclude=["tests*", "docs*"]),
    package_data=get_package_data(package),
    install_requires=[
        'djangorestframework>=3.6.0',
        'Django>=1.11',
    ],
...
)

@maiksprenger
Copy link

As a data point, I installed drf-nested-routers with Poetry in my existing project, and it did not add any further dependencies.

image

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

No branches or pull requests

3 participants