Reputation: 41
I am looking for a way to distribute an in-house python library among coworkers. We have a lot of functions dealing with downloading and processing files from a server. These files need to be downloaded on a local machine in a specific folder location, chosen by each programmer. Something like "/Users/me/path/to/downloads". Obviously this would be slightly different on a windows computer.
Before we gathered all the code into a package, we had a constants file which we had to modify on our local machines with the paths we were choosing for the download location. This, obviously, was not an ideal solution because it was error prone, time consuming and just not pretty.
We are now distributing our code via pip (we use pip install git+our/project/path). The problem is that now we cannot modify the constants file containing the paths for the download location. My question is - is the a way in which to specify at install time where you would like this download location for the files to be? I am thinking somewhere along the lines of:
Or is there a better way of distributing this kind of code? Any help would be appreciated!
Upvotes: 1
Views: 341
Reputation: 36
Since the Python program executed will be run from the path that the .py file is contained in. Maybe you can try to change all the "/path" variable in the .py file that you have with os.getcwd(). Therefore when you clone your git repository using the command:
git clone [your program repository] [the path where you want to install on your computer]
the path that you choose to install your program will also be the directory where the files will be downloaded. If you want to modify the path a little bit from where the program (.py) is running, you can use a combination of:
os.chdir(os.path.join(os.getcwd(), some_fix_folder_name))
for each of the programs so that it fixs the topic.
Upvotes: 0