Checklist
What is the idea?
Consolidate hardcoded file and directory names used across the codebase into a central constants module. Currently, the same file names are repeated as string literals in multiple modules, making them prone to typos and harder to maintain.
Why is this needed?
- Maintainability: Changing a file name requires finding and updating multiple locations
- Consistency: Reduces risk of typos or inconsistent naming across modules
- Discoverability: New contributors can understand the file structure from one place
- Refactoring safety: Constants make it easier to rename paths without missing occurrences
What should happen?
Possibly a central location (e.g., constructor/paths.py or a section in utils.py) where we define constants for commonly used file and directory names. These constants would then be imported where needed.
Additional Context
I ran an analysis with an AI Tool of locating all of these and count the occurrences, now, with this list below I'm not saying all of these have to be replaced, but can be used for context when working on this issue. I ran this including the MSI feature branch.
Analysis of hardcoded file/directory names in the codebase:
Directory names
| Name |
Occurrences |
Modules |
conda-meta |
~25 |
main.py, shar.py, preconda.py, winexe.py, header.sh, run_installation.sh |
pkgs |
~15 |
shar.py, preconda.py, winexe.py, osxpkg.py, utils.py |
envs |
~10 |
shar.py, preconda.py, winexe.py, header.sh, run_installation.sh |
cache |
~4 |
shar.py, winexe.py |
Files within conda-meta/
| Name |
Occurrences |
Modules |
history |
~12 |
shar.py, preconda.py, winexe.py, osx/*.sh |
initial-state.explicit.txt |
~10 |
preconda.py, winexe.py, shar.py, header.sh, run_installation.sh |
frozen |
~8 |
main.py, shar.py, preconda.py, winexe.py |
Files within pkgs/
| Name |
Occurrences |
Modules |
urls.txt |
~4 |
preconda.py, winexe.py |
urls |
~3 |
preconda.py, winexe.py |
shortcuts.txt |
~3 |
shar.py, preconda.py |
repodata_record.json |
~4 |
shar.py, preconda.py, winexe.py |
Config files
| Name |
Occurrences |
Modules |
.condarc |
~8 |
winexe.py, utils.py, osx/run_installation.sh |
User-provided install scripts
| Name |
Occurrences |
Modules |
pre_install.bat / pre_install.sh |
~8 |
winexe.py, shar.py, header.sh |
post_install.bat / post_install.sh |
~8 |
winexe.py, shar.py, header.sh |
pre_uninstall.bat |
~4 |
winexe.py, briefcase.py |
Internal install scripts (MSI/PKG)
| Name |
Occurrences |
Modules |
user_pre_install.bat / user_pre_install |
~5 |
briefcase.py, osxpkg.py, run_installation.bat |
user_post_install.bat / user_post_install |
~5 |
briefcase.py, osxpkg.py, run_installation.bat |
user_pre_uninstall.bat |
~3 |
briefcase.py, pre_uninstall.bat |
run_installation.sh / run_installation.bat |
~6 |
osxpkg.py, briefcase.py |
prepare_installation.sh |
~4 |
osxpkg.py |
checks_before_install.sh |
~2 |
osxpkg.py |
Template scripts (macOS PKG)
| Name |
Occurrences |
Modules |
run_user_script.sh |
~2 |
osxpkg.py |
check_shortcuts.sh |
~1 |
osxpkg.py |
run_conda_init.sh |
~1 |
osxpkg.py |
clean_cache.sh |
~1 |
osxpkg.py |
Note: Shell template files (header.sh, run_installation.sh, etc.) would need these values passed as Jinja template variables rather than importing Python constants directly.
Checklist
What is the idea?
Consolidate hardcoded file and directory names used across the codebase into a central constants module. Currently, the same file names are repeated as string literals in multiple modules, making them prone to typos and harder to maintain.
Why is this needed?
What should happen?
Possibly a central location (e.g.,
constructor/paths.pyor a section inutils.py) where we define constants for commonly used file and directory names. These constants would then be imported where needed.Additional Context
I ran an analysis with an AI Tool of locating all of these and count the occurrences, now, with this list below I'm not saying all of these have to be replaced, but can be used for context when working on this issue. I ran this including the
MSIfeature branch.Analysis of hardcoded file/directory names in the codebase:
Directory names
conda-metamain.py,shar.py,preconda.py,winexe.py,header.sh,run_installation.shpkgsshar.py,preconda.py,winexe.py,osxpkg.py,utils.pyenvsshar.py,preconda.py,winexe.py,header.sh,run_installation.shcacheshar.py,winexe.pyFiles within
conda-meta/historyshar.py,preconda.py,winexe.py,osx/*.shinitial-state.explicit.txtpreconda.py,winexe.py,shar.py,header.sh,run_installation.shfrozenmain.py,shar.py,preconda.py,winexe.pyFiles within
pkgs/urls.txtpreconda.py,winexe.pyurlspreconda.py,winexe.pyshortcuts.txtshar.py,preconda.pyrepodata_record.jsonshar.py,preconda.py,winexe.pyConfig files
.condarcwinexe.py,utils.py,osx/run_installation.shUser-provided install scripts
pre_install.bat/pre_install.shwinexe.py,shar.py,header.shpost_install.bat/post_install.shwinexe.py,shar.py,header.shpre_uninstall.batwinexe.py,briefcase.pyInternal install scripts (MSI/PKG)
user_pre_install.bat/user_pre_installbriefcase.py,osxpkg.py,run_installation.batuser_post_install.bat/user_post_installbriefcase.py,osxpkg.py,run_installation.batuser_pre_uninstall.batbriefcase.py,pre_uninstall.batrun_installation.sh/run_installation.batosxpkg.py,briefcase.pyprepare_installation.shosxpkg.pychecks_before_install.shosxpkg.pyTemplate scripts (macOS PKG)
run_user_script.shosxpkg.pycheck_shortcuts.shosxpkg.pyrun_conda_init.shosxpkg.pyclean_cache.shosxpkg.pyNote: Shell template files (
header.sh,run_installation.sh, etc.) would need these values passed as Jinja template variables rather than importing Python constants directly.