Fix Broken Links
This commit is contained in:
@@ -10,8 +10,8 @@ focus of this section is on some general code organization principles
|
||||
that will prove useful no matter what tools you later use to give code
|
||||
away or manage dependencies.
|
||||
|
||||
* [9.1 Packages](01_Packages)
|
||||
* [9.2 Third Party Modules](02_Third_party)
|
||||
* [9.3 Giving your code to others](03_Distribution)
|
||||
* [9.1 Packages](01_Packages.md)
|
||||
* [9.2 Third Party Modules](02_Third_party.md)
|
||||
* [9.3 Giving your code to others](03_Distribution.md)
|
||||
|
||||
[Contents](../Contents)
|
||||
[Contents](../Contents.md)
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
[Contents](../Contents) \| [Previous (8.3 Debugging)](../08_Testing_debugging/03_Debugging) \| [Next (9.2 Third Party Packages)](02_Third_party)
|
||||
[Contents](../Contents.md) \| [Previous (8.3 Debugging)](../08_Testing_debugging/03_Debugging) \| [Next (9.2 Third Party Packages)](02_Third_party.md)
|
||||
|
||||
# 9.1 Packages
|
||||
|
||||
@@ -119,7 +119,7 @@ import fileparse # BREAKS. fileparse not found
|
||||
|
||||
### Relative Imports
|
||||
|
||||
Instead of directly using the package name,
|
||||
Instead of directly using the package name,
|
||||
you can use `.` to refer to the current package.
|
||||
|
||||
```python
|
||||
@@ -204,7 +204,7 @@ import sys
|
||||
porty.pcost.main(sys.argv)
|
||||
```
|
||||
|
||||
This script lives *outside* the package. For example, looking at the directory
|
||||
This script lives *outside* the package. For example, looking at the directory
|
||||
structure:
|
||||
|
||||
```
|
||||
@@ -375,7 +375,7 @@ Try running some of your prior scripts as a main program:
|
||||
shell % cd porty-app
|
||||
shell % python3 -m porty.report portfolio.csv prices.csv txt
|
||||
Name Shares Price Change
|
||||
---------- ---------- ---------- ----------
|
||||
---------- ---------- ---------- ----------
|
||||
AA 100 9.22 -22.98
|
||||
IBM 50 106.28 15.18
|
||||
CAT 150 35.46 -47.98
|
||||
@@ -408,7 +408,7 @@ can run it in that location:
|
||||
shell % cd porty-app
|
||||
shell % python3 print-report.py portfolio.csv prices.csv txt
|
||||
Name Shares Price Change
|
||||
---------- ---------- ---------- ----------
|
||||
---------- ---------- ---------- ----------
|
||||
AA 100 9.22 -22.98
|
||||
IBM 50 106.28 15.18
|
||||
CAT 150 35.46 -47.98
|
||||
@@ -441,4 +441,4 @@ porty-app/
|
||||
typedproperty.py
|
||||
```
|
||||
|
||||
[Contents](../Contents) \| [Previous (8.3 Debugging)](../08_Testing_debugging/03_Debugging) \| [Next (9.2 Third Party Packages)](02_Third_party)
|
||||
[Contents](../Contents.md) \| [Previous (8.3 Debugging)](../08_Testing_debugging/03_Debugging) \| [Next (9.2 Third Party Packages)](02_Third_party.md)
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
[Contents](../Contents) \| [Previous (9.1 Packages)](01_Packages) \| [Next (9.3 Distribution)](03_Distribution)
|
||||
[Contents](../Contents.md) \| [Previous (9.1 Packages)](01_Packages) \| [Next (9.3 Distribution)](03_Distribution)
|
||||
|
||||
# 9.2 Third Party Modules
|
||||
|
||||
Python has a large library of built-in modules (*batteries included*).
|
||||
|
||||
There are even more third party modules. Check them in the [Python Package Index](https://pypi.org/) or PyPi.
|
||||
There are even more third party modules. Check them in the [Python Package Index](https://pypi.org/) or PyPi.
|
||||
Or just do a Google search for a specific topic.
|
||||
|
||||
How to handle third-party dependencies is an ever-evolving topic with
|
||||
How to handle third-party dependencies is an ever-evolving topic with
|
||||
Python. This section merely covers the basics to help you wrap
|
||||
your brain around how it works.
|
||||
|
||||
@@ -24,7 +24,7 @@ checked by the `import` statement. Look at it:
|
||||
```
|
||||
|
||||
If you import something and it's not located in one of those
|
||||
directories, you will get an `ImportError` exception.
|
||||
directories, you will get an `ImportError` exception.
|
||||
|
||||
### Standard Library Modules
|
||||
|
||||
@@ -39,19 +39,19 @@ by trying a short test:
|
||||
>>>
|
||||
```
|
||||
|
||||
Simply looking at a module in the REPL is a good debugging tip
|
||||
Simply looking at a module in the REPL is a good debugging tip
|
||||
to know about. It will show you the location of the file.
|
||||
|
||||
### Third-party Modules
|
||||
|
||||
Third party modules are usually located in a dedicated
|
||||
Third party modules are usually located in a dedicated
|
||||
`site-packages` directory. You'll see it if you perform
|
||||
the same steps as above:
|
||||
|
||||
```python
|
||||
>>> import numpy
|
||||
<module 'numpy' from '/usr/local/lib/python3.6/site-packages/numpy/__init__.py'>
|
||||
>>>
|
||||
>>>
|
||||
```
|
||||
|
||||
Again, looking at a module is a good debugging tip if you're
|
||||
@@ -114,7 +114,7 @@ For example:
|
||||
For the purposes of experimenting and trying out different
|
||||
packages, a virtual environment will usually work fine. If,
|
||||
on the other hand, you're creating an application and it
|
||||
has specific package dependencies, that is a slightly
|
||||
has specific package dependencies, that is a slightly
|
||||
different problem.
|
||||
|
||||
### Handling Third-Party Dependencies in Your Application
|
||||
@@ -135,7 +135,7 @@ I refer you to the [Python Packaging User Guide](https://packaging.python.org).
|
||||
See if you can recreate the steps of making a virtual environment and installing
|
||||
pandas into it as shown above.
|
||||
|
||||
[Contents](../Contents) \| [Previous (9.1 Packages)](01_Packages) \| [Next (9.3 Distribution)](03_Distribution)
|
||||
[Contents](../Contents.md) \| [Previous (9.1 Packages)](01_Packages) \| [Next (9.3 Distribution)](03_Distribution)
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
[Contents](../Contents) \| [Previous (9.2 Third Party Packages)](02_Third_party) \| [Next (The End)](TheEnd)
|
||||
[Contents](../Contents.md) \| [Previous (9.2 Third Party Packages)](02_Third_party.md) \| [Next (The End)](TheEnd.md)
|
||||
|
||||
# 9.3 Distribution
|
||||
|
||||
@@ -8,7 +8,7 @@ information, you'll need to consult the [Python Packaging User Guide](https://pa
|
||||
|
||||
### Creating a setup.py file
|
||||
|
||||
Add a `setup.py` file to the top-level of your project directory.
|
||||
Add a `setup.py` file to the top-level of your project directory.
|
||||
|
||||
```python
|
||||
# setup.py
|
||||
@@ -20,7 +20,7 @@ setuptools.setup(
|
||||
author="Your Name",
|
||||
author_email="you@example.com",
|
||||
description="Practical Python Code",
|
||||
packages=setuptools.find_packages(),
|
||||
packages=setuptools.find_packages(),
|
||||
)
|
||||
```
|
||||
|
||||
@@ -45,7 +45,7 @@ bash % python setup.py sdist
|
||||
```
|
||||
|
||||
This will create a `.tar.gz` or `.zip` file in the directory `dist/`. That file is something
|
||||
that you can now give away to others.
|
||||
that you can now give away to others.
|
||||
|
||||
### Installing your code
|
||||
|
||||
@@ -72,13 +72,13 @@ this course. We've only taken a tiny first step.
|
||||
|
||||
Take the `porty-app/` code you created for Exercise 9.3 and see if you
|
||||
can recreate the steps described here. Specifically, add a `setup.py`
|
||||
file and a `MANIFEST.in` file to the top-level directory.
|
||||
file and a `MANIFEST.in` file to the top-level directory.
|
||||
Create a source distribution file by running `python setup.py sdist`.
|
||||
|
||||
As a final step, see if you can install your package into a Python
|
||||
virtual environment.
|
||||
|
||||
[Contents](../Contents) \| [Previous (9.2 Third Party Packages)](02_Third_party) \| [Next (The End)](TheEnd)
|
||||
[Contents](../Contents.md) \| [Previous (9.2 Third Party Packages)](02_Third_party.md) \| [Next (The End)](TheEnd.md)
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -6,5 +6,5 @@ May your future Python hacking be fun and productive!
|
||||
I'm always happy to get feedback. You can find me at [https://dabeaz.com](https://dabeaz.com)
|
||||
or on Twitter at [@dabeaz](https://twitter.com/dabeaz). - David Beazley.
|
||||
|
||||
[Contents](../Contents) \| [Home](../..)
|
||||
[Contents](../Contents.md) \| [Home](../..)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user