# Finding a writable directory location for installing Python modules

**URL:** https://discourse.cmake.org/t/finding-a-writable-directory-location-for-installing-python-modules/1590
**Category:** Usage
**Created:** [July 20, 2020, 2:10pm UTC](https://discourse.cmake.org/t/finding-a-writable-directory-location-for-installing-python-modules/1590 "2020-07-20T14:10:11Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![EosPengwern](https://discourse.cmake.org/user_avatar/discourse.cmake.org/eospengwern/32/3904_2.png) [@EosPengwern](https://discourse.cmake.org/u/EosPengwern)
#### Post date: [July 20, 2020, 2:10pm UTC](https://discourse.cmake.org/t/finding-a-writable-directory-location-for-installing-python-modules/1590/1 "2020-07-20T14:10:11Z")

</div>

Does CMake / CPack provide a generic way of identifying the %APPDATA% library on a user’s machine during installation?

I ask because I’m trying to install a large scriptable application which provides various standard Python 2.7 modules with .py files as interfaces to them.

Most of the application is in C++, so of course the executables, DLLs and so on will typically go into C:\Program Files. But I can’t put the .py files in there, since when they’re opened Python immediately compiles them into .pyc files and tries to put them alongside the .py source files [N.B. the location for the .pyc files can in fact be specified for Python 3, but not Python 2]. Therefore the .py files need to be put in a writable location, for example C:\Program Data or (preferably) C:\Users\<username\>\AppData\Local.

But I can’t figure out how to point CMake at this directory, when I don’t know what the name of the user who ultimately does the installing will be. I don’t want to have to install the whole application, .exe and .dll files and all, in a writable location since that defeats the whole security philosophy of having executables installed in non-writable locations.

---

<div class="post-metadata">

### Author: ![marc.chevrier](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/m/ecb155/32.png) [@marc.chevrier](https://discourse.cmake.org/u/marc.chevrier)
#### Post date: [July 20, 2020, 2:17pm UTC](https://discourse.cmake.org/t/finding-a-writable-directory-location-for-installing-python-modules/1590/2 "2020-07-20T14:17:31Z")

</div>

You can retrieve environment variable values using syntax `$ENV{var}`. For example `$ENV{APPDATA}`.

For more information, see [Variable References](https://cmake.org/cmake/help/latest/manual/cmake-language.7.html#id23).

---

<div class="post-metadata">

### Author: ![EosPengwern](https://discourse.cmake.org/user_avatar/discourse.cmake.org/eospengwern/32/3904_2.png) [@EosPengwern](https://discourse.cmake.org/u/EosPengwern)
#### Post date: [July 20, 2020, 3:13pm UTC](https://discourse.cmake.org/t/finding-a-writable-directory-location-for-installing-python-modules/1590/3 "2020-07-20T15:13:28Z")

</div>

Ah, thank you. Exactly what I needed.
