Improve Dependency Management by removing packages not needed at runtime
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 24.4k
- Forks
- 2.3k
- Avg merge
- 2d 7h
- Merged PRs (30d)
- 13
Description
Dash runtime requirements inlcude some packages that are not needed at runtime.
Is your feature request related to a problem? Please describe.
Working in an enterprise setting there are strict requirements ragarding deploying secure software. Reducing the attack surface by installing only essential packages is key. As of now, dash requires some packages to be installed in the runtime environment which are not needed to run the app at all or not in particular / newer python versions.
Describe the solution you'd like
- Leverage PEP-518 which allows to remove
setuptoolsas a runtime dependency and add it as a build time dependency. importlib_metadatais sparsely used. Depending on the python version and features needed for this package, it is not required at all and can be replaced withimportlib.metdatawhich is inlcuded in the python stanrdard lib (at least for >3.8). Require it only for older python versions. You can handle if the version from the standard-lib or the installed packages should be used by checking the python version when the packages are imported. Add e.g.importlib-metadata ; python_version < 3.9to the respective requirements file.
import sys
if sys.version_info >= (3, 8):
from importlib.metadata import ...
else:
from importlib_metadata import ...
- I am pretty sure that the
typing_extensionspackage is not needed for newer python versions (>=3.10). If you do not leverage runtime type checking you can make it optional. For newer python versions the types can be imported from thetypingpackage. Additionally, you can leverage thetyping.TYPE_CHECKINGconstant. Again, require it only for older python versions and check the python version before importing the package.
Describe alternatives you've considered
No
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with requirements/install.txt, then search the repository for imports of importlib_metadata and typing_extensions and inspect the packaging configuration. Check the supported Python versions and where these dependencies are used. Done means runtime requirements contain only necessary packages while older Python versions and existing dependency-related tests continue to work.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- build-system
- Issue type
- Refactor
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 38/100