mirror of
https://github.com/kennethreitz/python-guide.git
synced 2026-06-05 23:00:18 +00:00
More typo, grammar, and style fixes
This commit is contained in:
+14
-14
@@ -23,7 +23,7 @@ Besides, end-user software should always be in an executable format. Files
|
||||
ending in ``.py`` are for software engineers and system administrators.
|
||||
|
||||
One disadvantage of freezing is that it will increase the size of your
|
||||
distribution by about 2–12MB. Also, you will be responsible for shipping
|
||||
distribution by about 2–12 MB. Also, you will be responsible for shipping
|
||||
updated versions of your application when security vulnerabilities to
|
||||
Python are patched.
|
||||
|
||||
@@ -60,12 +60,12 @@ py2app no no yes yes MIT no yes yes
|
||||
|
||||
.. note::
|
||||
Freezing Python code on Linux into a Windows executable was only once
|
||||
supported in PyInstaller `and later dropped.
|
||||
supported in PyInstaller `and later dropped
|
||||
<http://stackoverflow.com/questions/2950971/cross-compiling-a-python-script-on-linux-into-a-windows-executable#comment11890276_2951046>`_.
|
||||
|
||||
.. note::
|
||||
All solutions need MS Visual C++ dll to be installed on target machine, except py2app.
|
||||
Only Pyinstaller makes self-executable exe that bundles the dll when
|
||||
All solutions need a Microsoft Visual C++ to be installed on the target machine, except py2app.
|
||||
Only PyInstaller makes a self-executable exe that bundles the appropriate DLL when
|
||||
passing ``--onefile`` to :file:`Configure.py`.
|
||||
|
||||
|
||||
@@ -97,7 +97,7 @@ Prerequisite is to install :ref:`Python, Setuptools and pywin32 dependency on Wi
|
||||
.. note::
|
||||
|
||||
This will work for the most basic one file scripts. For more advanced freezing you will have to provide
|
||||
include and exclude paths like so
|
||||
include and exclude paths like so:
|
||||
|
||||
.. code-block:: python
|
||||
|
||||
@@ -109,8 +109,8 @@ Prerequisite is to install :ref:`Python, Setuptools and pywin32 dependency on Wi
|
||||
|
||||
freezer.setIcon('my_awesome_icon.ico')
|
||||
|
||||
4. Provide the Microsoft Visual C runtime DLL for the freezer. It might be possible to append your :code:`sys.path`
|
||||
with Microsoft Visual Studio path but I find it easier to drop :file:`msvcp90.dll` in the same folder where your script
|
||||
4. Provide the Microsoft Visual C++ runtime DLL for the freezer. It might be possible to append your :code:`sys.path`
|
||||
with the Microsoft Visual Studio path but I find it easier to drop :file:`msvcp90.dll` in the same folder where your script
|
||||
resides.
|
||||
|
||||
5. Freeze!
|
||||
@@ -122,7 +122,7 @@ resides.
|
||||
py2exe
|
||||
~~~~~~
|
||||
|
||||
Prerequisite is to install :ref:`Python on Windows <install-windows>`. The last release of py2exe is from the year 2014. There is not active development.
|
||||
Prerequisite is to install :ref:`Python on Windows <install-windows>`. The last release of py2exe is from the year 2014. There is not active development.
|
||||
|
||||
1. Download and install http://sourceforge.net/projects/py2exe/files/py2exe/
|
||||
|
||||
@@ -147,7 +147,7 @@ Prerequisite is to install :ref:`Python on Windows <install-windows>`. The last
|
||||
|
||||
$ python setup.py py2exe
|
||||
|
||||
6. Provide the Microsoft Visual C runtime DLL. Two options: `globally install dll on target machine <https://www.microsoft.com/en-us/download/details.aspx?id=29>`_ or `distribute dll alongside with .exe <http://www.py2exe.org/index.cgi/Tutorial#Step52>`_.
|
||||
6. Provide the Microsoft Visual C++ runtime DLL. Two options: `globally install dll on target machine <https://www.microsoft.com/en-us/download/details.aspx?id=29>`_ or `distribute dll alongside with .exe <http://www.py2exe.org/index.cgi/Tutorial#Step52>`_.
|
||||
|
||||
PyInstaller
|
||||
~~~~~~~~~~~
|
||||
@@ -183,19 +183,19 @@ To create a standard Unix executable, from say :code:`script.py`, use:
|
||||
|
||||
$ pyinstaller script.py
|
||||
|
||||
This creates,
|
||||
This creates:
|
||||
|
||||
- a :code:`script.spec` file, analogous to a :code:`make` file
|
||||
- a :code:`build` folder, that holds some log files
|
||||
- a :code:`dist` folder, that holds the main executable :code:`script`, and some dependent Python libraries,
|
||||
- a :code:`dist` folder, that holds the main executable :code:`script`, and some dependent Python libraries
|
||||
|
||||
all in the same folder as :code:`script.py`. PyInstaller puts all the Python libraries used in :code:`script.py` into the :code:`dist` folder, so when distributing the executable, distribute the whole :code:`dist` folder.
|
||||
|
||||
The :code:`script.spec` file can be edited to `customise the build <http://pythonhosted.org/PyInstaller/#spec-file-operation>`_, with options such as
|
||||
The :code:`script.spec` file can be edited to `customise the build <http://pythonhosted.org/PyInstaller/#spec-file-operation>`_, with options such as:
|
||||
|
||||
- bundling data files with the executable
|
||||
- including run-time libraries (:code:`.dll` or :code:`.so` files) that PyInstaller can't infer automatically
|
||||
- adding Python run-time options to the executable,
|
||||
- adding Python run-time options to the executable
|
||||
|
||||
Now :code:`script.spec` can be run with :code:`pyinstaller` (instead of using :code:`script.py` again):
|
||||
|
||||
@@ -203,7 +203,7 @@ Now :code:`script.spec` can be run with :code:`pyinstaller` (instead of using :c
|
||||
|
||||
$ pyinstaller script.spec
|
||||
|
||||
To create a standalone windowed OS X application, use the :code:`--windowed` option
|
||||
To create a standalone windowed OS X application, use the :code:`--windowed` option:
|
||||
|
||||
.. code-block:: console
|
||||
|
||||
|
||||
+15
-15
@@ -7,7 +7,7 @@ Packaging Your Code
|
||||
|
||||
.. image:: /_static/photos/36137234682_be6898bf57_k_d.jpg
|
||||
|
||||
Package your code to share it with other developers. For example
|
||||
Package your code to share it with other developers. For example,
|
||||
to share a library for other developers to use in their application,
|
||||
or for development tools like 'py.test'.
|
||||
|
||||
@@ -18,7 +18,7 @@ large, professional systems.
|
||||
|
||||
It is a well-established convention for Python code to be shared this way.
|
||||
If your code isn't packaged on PyPI, then it will be harder
|
||||
for other developers to find it, and to use it as part of their existing
|
||||
for other developers to find it and to use it as part of their existing
|
||||
process. They will regard such projects with substantial suspicion of being
|
||||
either badly managed or abandoned.
|
||||
|
||||
@@ -57,14 +57,14 @@ Pip vs. easy_install
|
||||
--------------------
|
||||
|
||||
Use `pip <http://pypi.python.org/pypi/pip>`_. More details
|
||||
`here <http://stackoverflow.com/questions/3220404/why-use-pip-over-easy-install>`_
|
||||
`here <http://stackoverflow.com/questions/3220404/why-use-pip-over-easy-install>`_.
|
||||
|
||||
|
||||
Personal PyPI
|
||||
-------------
|
||||
|
||||
If you want to install packages from a source other than PyPI, (say, if
|
||||
your packages are *proprietary*), you can do it by hosting a simple http
|
||||
If you want to install packages from a source other than PyPI (say, if
|
||||
your packages are *proprietary*), you can do it by hosting a simple HTTP
|
||||
server, running from the directory which holds those packages which need to be
|
||||
installed.
|
||||
|
||||
@@ -85,9 +85,9 @@ Go to your command prompt and type:
|
||||
$ cd archive
|
||||
$ python -m SimpleHTTPServer 9000
|
||||
|
||||
This runs a simple http server running on port 9000 and will list all packages
|
||||
This runs a simple HTTP server running on port 9000 and will list all packages
|
||||
(like **MyPackage**). Now you can install **MyPackage** using any Python
|
||||
package installer. Using Pip, you would do it like:
|
||||
package installer. Using pip, you would do it like:
|
||||
|
||||
.. code-block:: console
|
||||
|
||||
@@ -95,7 +95,7 @@ package installer. Using Pip, you would do it like:
|
||||
|
||||
Having a folder with the same name as the package name is **crucial** here.
|
||||
I got fooled by that, one time. But if you feel that creating a folder called
|
||||
:file:`MyPackage` and keeping :file:`MyPackage.tar.gz` inside that, is
|
||||
:file:`MyPackage` and keeping :file:`MyPackage.tar.gz` inside that is
|
||||
*redundant*, you can still install MyPackage using:
|
||||
|
||||
.. code-block:: console
|
||||
@@ -105,7 +105,7 @@ I got fooled by that, one time. But if you feel that creating a folder called
|
||||
pypiserver
|
||||
++++++++++
|
||||
|
||||
`Pypiserver <https://pypi.python.org/pypi/pypiserver>`_ is a minimal PyPI
|
||||
`pypiserver <https://pypi.python.org/pypi/pypiserver>`_ is a minimal PyPI
|
||||
compatible server. It can be used to serve a set of packages to easy_install
|
||||
or pip. It includes helpful features like an administrative command
|
||||
(``-U``) which will update all its packages to their latest versions
|
||||
@@ -115,7 +115,7 @@ found on PyPI.
|
||||
S3-Hosted PyPi
|
||||
++++++++++++++
|
||||
|
||||
One simple option for a personal PyPi server is to use Amazon S3. A
|
||||
One simple option for a personal PyPI server is to use Amazon S3. A
|
||||
prerequisite for this is that you have an Amazon AWS account with an S3 bucket.
|
||||
|
||||
1. **Install all your requirements from PyPi or another source**
|
||||
@@ -130,8 +130,8 @@ prerequisite for this is that you have an Amazon AWS account with an S3 bucket.
|
||||
|
||||
4. **Upload the new files**
|
||||
|
||||
* Use a client like Cyberduck to sync the entire :file:`packages` folder to your s3 bucket
|
||||
* Make sure you upload :code:`packages/simple/index.html` as well as all new files and directories
|
||||
* Use a client like Cyberduck to sync the entire :file:`packages` folder to your s3 bucket.
|
||||
* Make sure you upload :code:`packages/simple/index.html` as well as all new files and directories.
|
||||
|
||||
5. **Fix new file permissions**
|
||||
|
||||
@@ -141,7 +141,7 @@ prerequisite for this is that you have an Amazon AWS account with an S3 bucket.
|
||||
|
||||
6. **All done**
|
||||
|
||||
* You can now install your package with :code:`pip install --index-url=http://your-s3-bucket/packages/simple/ YourPackage`
|
||||
* You can now install your package with :code:`pip install --index-url=http://your-s3-bucket/packages/simple/ YourPackage`.
|
||||
|
||||
.. _packaging-for-linux-distributions-ref:
|
||||
|
||||
@@ -154,7 +154,7 @@ Creating a Linux distro package is arguably the "right way" to distribute code
|
||||
on Linux.
|
||||
|
||||
Because a distribution package doesn't include the Python interpreter, it
|
||||
makes the download and install about 2MB smaller than
|
||||
makes the download and install about 2-12 MB smaller than
|
||||
:ref:`freezing your application <freezing-your-code-ref>`.
|
||||
|
||||
Also, if a distribution releases a new security update for Python, then your
|
||||
@@ -165,7 +165,7 @@ for use by distributions like Red Hat or SuSE trivially easy.
|
||||
|
||||
However, creating and maintaining the different configurations required for
|
||||
each distribution's format (e.g. .deb for Debian/Ubuntu, .rpm for Red
|
||||
Hat/Fedora, etc) is a fair amount of work. If your code is an application that
|
||||
Hat/Fedora, etc.) is a fair amount of work. If your code is an application that
|
||||
you plan to distribute on other platforms, then you'll also have to create and
|
||||
maintain the separate config required to freeze your application for Windows
|
||||
and OS X. It would be much less work to simply create and maintain a single
|
||||
|
||||
Reference in New Issue
Block a user