Skip to content

Commit a039856

Browse files
updating rendered version
1 parent 0ac1f21 commit a039856

File tree

3 files changed

+80
-12
lines changed

3 files changed

+80
-12
lines changed

_sources/where_to_put_your_code.rst.txt

Lines changed: 37 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ Many scientists and engineers that do a little coding find they have a collectio
2929
Options for Handling Your Code Collection:
3030
------------------------------------------
3131

32-
1) Keep your code in one place, and copy and paste the functions y ou need into each new project.
32+
1) Keep your code in one place, and copy and paste the functions you need into each new project.
3333

3434

3535
DON'T DO THAT!
@@ -39,21 +39,53 @@ REALLY!
3939
.......
4040

4141

42-
It is really NOT a good idea to simply copy and paste these around for use with each project -- you will regret that!
42+
It is really NOT a good idea to simply copy and paste code around for use with each project. You will end up with multiple versions scattered all over the place -- **you will regret that!**
4343

44-
It is also not a good idea to use the ``PYTHONPATH`` environment variable to set up a directory in which to dump stuff. (Google a bit if you want to know why).
44+
2) Put your code in a single directory and add it to the ``PYTHONPATH`` environment variable
45+
46+
47+
DON'T DO THAT!
48+
..............
49+
50+
51+
REALLY!
52+
.......
53+
54+
``PTYHONPATH`` is shared by all installs of Python. What with Python2, Python3, virtual environments, etc -- it's really not a good idea.
55+
56+
If you don't believe me: **Google It**
57+
58+
59+
What you should do is make a "package"
60+
--------------------------------------
4561

4662
The best way to do this with Python is to use the Python package mechanism.
4763

4864
A Python "package" is a collection of modules and scripts -- we usually think of these as something carefully developed for a particular purpose and distributed to a wide audience for re-use -- the packages you can install with pip.
4965

5066
Indeed that is the case, but the "collection of modules and scripts" part can be used for your own code that no one else is ever going to touch, and the overhead is small if you use it only this way.
5167

68+
Why Don't People Tend to figure this out for themselves?
69+
........................................................
70+
71+
The Packaging Documentation is mostly about Making a "proper" package for distribution to a wide audience.
72+
73+
So newbies tend to either:
74+
75+
* Think: "I don't want/need to do all that", and then move on and copy and past their code around like they have already done.
76+
77+
or
78+
79+
* Go ahead and follow the instructions, and end up putting their tiny little not-useful-to-anyone-else package up on PyPi.
80+
81+
5282
The challenge is that most of the documentation about python packaging is focused on creating a package of a library that you want to distribute to the community. In that case, it's very important to have full and proper meta data, tests, documentation, etc. As a result, the packaging documentation makes the whole process seem complicated and cumbersome.
5383

54-
But making a simple package for your own use can be very simple, and very useful.
84+
Making a simple package just for your own use can be very simple, and very useful.
85+
..................................................................................
86+
5587

56-
Step by step:
88+
Step by Step:
5789
-------------
5890

5991
1) Create a directory in your user (or home, or ... ) dir for your code. Let's call it "my_code".

0 commit comments

Comments
 (0)