Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit4268d36

Browse files
committed
add setup.py to README.md, JPYN and PDF
1 parentaeb15f1 commit4268d36

File tree

5 files changed

+91
-5
lines changed

5 files changed

+91
-5
lines changed

‎README.md‎

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -194,6 +194,7 @@ All contributions are welcome:
194194
-[Writing your own contextmanager using generator syntax](#writing-your-own-contextmanager-using-generator-syntax)
195195
-[`__main__` Top-level script environment](#main-top-level-script-environment)
196196
-[Advantages](#advantages)
197+
-[setup.py](#setuppy)
197198
-[Virtual Environment](#virtual-environment)
198199
-[virtualenv](#virtualenv)
199200
-[pipenv](#pipenv)
@@ -4404,6 +4405,37 @@ For example we are developing script which is designed to be used as module, we
44044405

44054406
[*Return to the Top*](#python-cheatsheet)
44064407

4408+
## setup.py
4409+
4410+
The setup scriptis the centre ofall activityin building, distributing,and installing modules using the Distutils. The main purpose of the setup scriptis to describe your module distribution to the Distutils, so that the various commands that operate on your modules do the right thing.
4411+
4412+
The`setup.py`fileis at the heart of a Python project. It describesall of the metadata about your project. There a quite a few fields you can add to a project to give it a richset of metadata describing the project. However, there are only three required fields: name, version,and packages. The name field must be uniqueif you wish to publish your package on the Python Package Index (PyPI). The version field keeps track of different releases of the project. The packages field describes where you’ve put the Python source code within your project.
4413+
4414+
This allows you to easily install Python packages. Often it's enough to write:
4415+
4416+
```bash
4417+
python setup.py install
4418+
```
4419+
4420+
and module will install itself.
4421+
4422+
Our initial setup.py will also include information about thelicenseand will re-use theREADME.txtfilefor the long_description field. This will look like:
4423+
4424+
```python
4425+
>>>from distutils.coreimport setup
4426+
>>> setup(
4427+
...name='pythonCheatsheet',
4428+
...version='0.1',
4429+
...packages=['pipenv',],
4430+
...license='MIT',
4431+
...long_description=open('README.txt').read(),
4432+
... )
4433+
```
4434+
4435+
Find more information visit [http://docs.python.org/install/index.html](http://docs.python.org/install/index.html).
4436+
4437+
[*Return to the Top*](#python-cheatsheet)
4438+
44074439
## Virtual Environment
44084440

44094441
The use of a Virtual Environmentis to test python codein encapsulated environmentsand to also avoid filling the base Python installationwith libraries we might usefor only one project.

‎blog_files/index.md‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,4 +19,5 @@
1919
-[args and kwargs](#args-and-kwargs)
2020
-[Context Manager](#context-manager)
2121
-[`__main__` Top-level script environment](#main-top-level-script-environment)
22+
-[setup.py](#setup.py)
2223
-[Virtual Environment](#virtual-environment)

‎blog_files/pysheet.md‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3915,8 +3915,8 @@ The `setup.py` file is at the heart of a Python project. It describes all of the
39153915

39163916
This allows you to easily install Python packages. Often it's enough to write:
39173917

3918-
```
3919-
$python setup.py install
3918+
```bash
3919+
python setup.py install
39203920
```
39213921

39223922
and module will install itself.
@@ -3934,7 +3934,7 @@ Our initial setup.py will also include information about the license and will re
39343934
... )
39353935
```
39363936

3937-
Find more information visit http://docs.python.org/install/index.html.
3937+
Find more information visit[http://docs.python.org/install/index.html](http://docs.python.org/install/index.html).
39383938

39393939
## Virtual Environment
39403940

‎python_cheat_sheet.ipynb‎

Lines changed: 55 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -198,8 +198,9 @@
198198
"- [Context Manager](#context-manager)\n",
199199
" - [with statement](#with-statement)\n",
200200
" - [Writing your own contextmanager using generator syntax](#writing-your-own-contextmanager-using-generator-syntax)\n",
201-
"- [__main__ Top-level script environment](#main-top-level-script-environment)\n",
201+
"- [`__main__` Top-level script environment](#main-top-level-script-environment)\n",
202202
" - [Advantages](#advantages)\n",
203+
"- [setup.py](#setuppy)\n",
203204
"- [Virtual Environment](#virtual-environment)\n",
204205
" - [virtualenv](#virtualenv)\n",
205206
" - [pipenv](#pipenv)\n",
@@ -7450,7 +7451,7 @@
74507451
"source": [
74517452
"[*Return to the Top*](#python-cheatsheet)\n",
74527453
"\n",
7453-
"## __main__ Top-level script environment\n",
7454+
"##`__main__` Top-level script environment\n",
74547455
"\n",
74557456
"`__main__` is the name of the scope in which top-level code executes.\n",
74567457
"A module’s __name__ is set equal to `__main__` when read from standard input, a script, or from an interactive prompt.\n",
@@ -7513,6 +7514,58 @@
75137514
"\n",
75147515
"[*Return to the Top*](#python-cheatsheet)\n",
75157516
"\n",
7517+
"## setup.py\n",
7518+
"\n",
7519+
"The setup script is the centre of all activity in building, distributing, and installing modules using the Distutils. The main purpose of the setup script is to describe your module distribution to the Distutils, so that the various commands that operate on your modules do the right thing.\n",
7520+
"\n",
7521+
"The `setup.py` file is at the heart of a Python project. It describes all of the metadata about your project. There a quite a few fields you can add to a project to give it a rich set of metadata describing the project. However, there are only three required fields: name, version, and packages. The name field must be unique if you wish to publish your package on the Python Package Index (PyPI). The version field keeps track of different releases of the project. The packages field describes where you’ve put the Python source code within your project.\n",
7522+
"\n",
7523+
"This allows you to easily install Python packages. Often it's enough to write:"
7524+
]
7525+
},
7526+
{
7527+
"cell_type":"code",
7528+
"execution_count":null,
7529+
"metadata": {},
7530+
"outputs": [],
7531+
"source": [
7532+
"%%bash\n",
7533+
"python setup.py install"
7534+
]
7535+
},
7536+
{
7537+
"cell_type":"markdown",
7538+
"metadata": {},
7539+
"source": [
7540+
"and module will install itself.\n",
7541+
"\n",
7542+
"Our initial setup.py will also include information about the license and will re-use the README.txt file for the long_description field. This will look like:"
7543+
]
7544+
},
7545+
{
7546+
"cell_type":"code",
7547+
"execution_count":null,
7548+
"metadata": {},
7549+
"outputs": [],
7550+
"source": [
7551+
">>> from distutils.core import setup\n",
7552+
">>> setup(\n",
7553+
"... name='pythonCheatsheet',\n",
7554+
"... version='0.1',\n",
7555+
"... packages=['pipenv',],\n",
7556+
"... license='MIT',\n",
7557+
"... long_description=open('README.txt').read(),\n",
7558+
"... )"
7559+
]
7560+
},
7561+
{
7562+
"cell_type":"markdown",
7563+
"metadata": {},
7564+
"source": [
7565+
"Find more information visit [http://docs.python.org/install/index.html](http://docs.python.org/install/index.html).\n",
7566+
"\n",
7567+
"[*Return to the Top*](#python-cheatsheet)\n",
7568+
"\n",
75167569
"## Virtual Environment\n",
75177570
"\n",
75187571
"The use of a Virtual Environment is to test python code in encapsulated environments and to also avoid filling the base Python installation with libraries we might use for only one project.\n",

‎python_cheat_sheet.pdf‎

3.37 KB
Binary file not shown.

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp