Mercurial > cpython-lru_cache-weakref
annotate Lib/packaging/create.py @ 70817:dd775b1561ba
Fix markup.
| author | Georg Brandl <georg@python.org> |
|---|---|
| date | Tue, 14 Jun 2011 21:09:55 +0200 |
| parents | 79f7ad26829e |
| children | f937da5f3101 |
| rev | line source |
|---|---|
|
70194
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
1 """Interactive helper used to create a setup.cfg file. |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
2 |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
3 This script will generate a packaging configuration file by looking at |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
4 the current directory and asking the user questions. It is intended to |
|
70671
b0e11220a6bf
Improve a few docstrings in packaging.
Éric Araujo <merwok@netwok.org>
parents:
70246
diff
changeset
|
5 be called as *pysetup create*. |
|
70194
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
6 """ |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
7 |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
8 # Original code by Sean Reifschneider <jafo@tummy.com> |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
9 |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
10 # Original TODO list: |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
11 # Look for a license file and automatically add the category. |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
12 # When a .c file is found during the walk, can we add it as an extension? |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
13 # Ask if there is a maintainer different that the author |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
14 # Ask for the platform (can we detect this via "import win32" or something?) |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
15 # Ask for the dependencies. |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
16 # Ask for the Requires-Dist |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
17 # Ask for the Provides-Dist |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
18 # Ask for a description |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
19 # Detect scripts (not sure how. #! outside of package?) |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
20 |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
21 import os |
|
70671
b0e11220a6bf
Improve a few docstrings in packaging.
Éric Araujo <merwok@netwok.org>
parents:
70246
diff
changeset
|
22 import re |
|
70194
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
23 import imp |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
24 import sys |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
25 import glob |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
26 import shutil |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
27 import sysconfig |
|
70210
a636cb1b7f84
Issue #12112: fix the encoding of setup.py in the packaging module
Victor Stinner <victor.stinner@haypocalc.com>
parents:
70206
diff
changeset
|
28 import tokenize |
|
70671
b0e11220a6bf
Improve a few docstrings in packaging.
Éric Araujo <merwok@netwok.org>
parents:
70246
diff
changeset
|
29 from hashlib import md5 |
|
70194
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
30 from textwrap import dedent |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
31 from functools import cmp_to_key |
|
70671
b0e11220a6bf
Improve a few docstrings in packaging.
Éric Araujo <merwok@netwok.org>
parents:
70246
diff
changeset
|
32 from configparser import RawConfigParser |
|
70194
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
33 # importing this with an underscore as it should be replaced by the |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
34 # dict form or another structures for all purposes |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
35 from packaging._trove import all_classifiers as _CLASSIFIERS_LIST |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
36 from packaging.version import is_valid_version |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
37 |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
38 _FILENAME = 'setup.cfg' |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
39 _DEFAULT_CFG = '.pypkgcreate' |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
40 |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
41 _helptext = { |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
42 'name': ''' |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
43 The name of the program to be packaged, usually a single word composed |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
44 of lower-case characters such as "python", "sqlalchemy", or "CherryPy". |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
45 ''', |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
46 'version': ''' |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
47 Version number of the software, typically 2 or 3 numbers separated by dots |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
48 such as "1.00", "0.6", or "3.02.01". "0.1.0" is recommended for initial |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
49 development. |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
50 ''', |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
51 'summary': ''' |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
52 A one-line summary of what this project is or does, typically a sentence 80 |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
53 characters or less in length. |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
54 ''', |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
55 'author': ''' |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
56 The full name of the author (typically you). |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
57 ''', |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
58 'author_email': ''' |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
59 E-mail address of the project author (typically you). |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
60 ''', |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
61 'do_classifier': ''' |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
62 Trove classifiers are optional identifiers that allow you to specify the |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
63 intended audience by saying things like "Beta software with a text UI |
|
70675
33f680ed54ac
Improve consistency in questions asked by packaging.create.
Éric Araujo <merwok@netwok.org>
parents:
70674
diff
changeset
|
64 for Linux under the PSF license". However, this can be a somewhat involved |
|
70194
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
65 process. |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
66 ''', |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
67 'packages': ''' |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
68 You can provide a package name contained in your project. |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
69 ''', |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
70 'modules': ''' |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
71 You can provide a python module contained in your project. |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
72 ''', |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
73 'extra_files': ''' |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
74 You can provide extra files/dirs contained in your project. |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
75 It has to follow the template syntax. XXX add help here. |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
76 ''', |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
77 |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
78 'home_page': ''' |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
79 The home page for the project, typically starting with "http://". |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
80 ''', |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
81 'trove_license': ''' |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
82 Optionally you can specify a license. Type a string that identifies a common |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
83 license, and then you can select a list of license specifiers. |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
84 ''', |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
85 'trove_generic': ''' |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
86 Optionally, you can set other trove identifiers for things such as the |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
87 human language, programming language, user interface, etc... |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
88 ''', |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
89 'setup.py found': ''' |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
90 The setup.py script will be executed to retrieve the metadata. |
|
70675
33f680ed54ac
Improve consistency in questions asked by packaging.create.
Éric Araujo <merwok@netwok.org>
parents:
70674
diff
changeset
|
91 An interactive helper will be run if you answer "n", |
|
70194
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
92 ''', |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
93 } |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
94 |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
95 PROJECT_MATURITY = ['Development Status :: 1 - Planning', |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
96 'Development Status :: 2 - Pre-Alpha', |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
97 'Development Status :: 3 - Alpha', |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
98 'Development Status :: 4 - Beta', |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
99 'Development Status :: 5 - Production/Stable', |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
100 'Development Status :: 6 - Mature', |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
101 'Development Status :: 7 - Inactive'] |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
102 |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
103 # XXX everything needs docstrings and tests (both low-level tests of various |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
104 # methods and functional tests of running the script) |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
105 |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
106 |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
107 def load_setup(): |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
108 """run the setup script (i.e the setup.py file) |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
109 |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
110 This function load the setup file in all cases (even if it have already |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
111 been loaded before, because we are monkey patching its setup function with |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
112 a particular one""" |
|
70210
a636cb1b7f84
Issue #12112: fix the encoding of setup.py in the packaging module
Victor Stinner <victor.stinner@haypocalc.com>
parents:
70206
diff
changeset
|
113 with open("setup.py", "rb") as f: |
|
a636cb1b7f84
Issue #12112: fix the encoding of setup.py in the packaging module
Victor Stinner <victor.stinner@haypocalc.com>
parents:
70206
diff
changeset
|
114 encoding, lines = tokenize.detect_encoding(f.readline) |
|
a636cb1b7f84
Issue #12112: fix the encoding of setup.py in the packaging module
Victor Stinner <victor.stinner@haypocalc.com>
parents:
70206
diff
changeset
|
115 with open("setup.py", encoding=encoding) as f: |
|
70194
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
116 imp.load_module("setup", f, "setup.py", (".py", "r", imp.PY_SOURCE)) |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
117 |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
118 |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
119 def ask_yn(question, default=None, helptext=None): |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
120 question += ' (y/n)' |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
121 while True: |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
122 answer = ask(question, default, helptext, required=True) |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
123 if answer and answer[0].lower() in 'yn': |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
124 return answer[0].lower() |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
125 |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
126 print('\nERROR: You must select "Y" or "N".\n') |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
127 |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
128 |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
129 def ask(question, default=None, helptext=None, required=True, |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
130 lengthy=False, multiline=False): |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
131 prompt = '%s: ' % (question,) |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
132 if default: |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
133 prompt = '%s [%s]: ' % (question, default) |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
134 if default and len(question) + len(default) > 70: |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
135 prompt = '%s\n [%s]: ' % (question, default) |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
136 if lengthy or multiline: |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
137 prompt += '\n > ' |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
138 |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
139 if not helptext: |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
140 helptext = 'No additional help available.' |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
141 |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
142 helptext = helptext.strip("\n") |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
143 |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
144 while True: |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
145 sys.stdout.write(prompt) |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
146 sys.stdout.flush() |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
147 |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
148 line = sys.stdin.readline().strip() |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
149 if line == '?': |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
150 print('=' * 70) |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
151 print(helptext) |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
152 print('=' * 70) |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
153 continue |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
154 if default and not line: |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
155 return default |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
156 if not line and required: |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
157 print('*' * 70) |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
158 print('This value cannot be empty.') |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
159 print('===========================') |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
160 if helptext: |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
161 print(helptext) |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
162 print('*' * 70) |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
163 continue |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
164 return line |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
165 |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
166 |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
167 def convert_yn_to_bool(yn, yes=True, no=False): |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
168 """Convert a y/yes or n/no to a boolean value.""" |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
169 if yn.lower().startswith('y'): |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
170 return yes |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
171 else: |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
172 return no |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
173 |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
174 |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
175 def _build_classifiers_dict(classifiers): |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
176 d = {} |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
177 for key in classifiers: |
|
70725
79f7ad26829e
Style change in packaging: use “not in” over “not x in”.
Éric Araujo <merwok@netwok.org>
parents:
70675
diff
changeset
|
178 subdict = d |
|
70194
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
179 for subkey in key.split(' :: '): |
|
70725
79f7ad26829e
Style change in packaging: use “not in” over “not x in”.
Éric Araujo <merwok@netwok.org>
parents:
70675
diff
changeset
|
180 if subkey not in subdict: |
|
79f7ad26829e
Style change in packaging: use “not in” over “not x in”.
Éric Araujo <merwok@netwok.org>
parents:
70675
diff
changeset
|
181 subdict[subkey] = {} |
|
79f7ad26829e
Style change in packaging: use “not in” over “not x in”.
Éric Araujo <merwok@netwok.org>
parents:
70675
diff
changeset
|
182 subdict = subdict[subkey] |
|
70194
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
183 return d |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
184 |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
185 CLASSIFIERS = _build_classifiers_dict(_CLASSIFIERS_LIST) |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
186 |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
187 |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
188 def _build_licences(classifiers): |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
189 res = [] |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
190 for index, item in enumerate(classifiers): |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
191 if not item.startswith('License :: '): |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
192 continue |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
193 res.append((index, item.split(' :: ')[-1].lower())) |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
194 return res |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
195 |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
196 LICENCES = _build_licences(_CLASSIFIERS_LIST) |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
197 |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
198 |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
199 class MainProgram: |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
200 """Make a project setup configuration file (setup.cfg).""" |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
201 |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
202 def __init__(self): |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
203 self.configparser = None |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
204 self.classifiers = set() |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
205 self.data = {'name': '', |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
206 'version': '1.0.0', |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
207 'classifier': self.classifiers, |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
208 'packages': [], |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
209 'modules': [], |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
210 'platform': [], |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
211 'resources': [], |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
212 'extra_files': [], |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
213 'scripts': [], |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
214 } |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
215 self._load_defaults() |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
216 |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
217 def __call__(self): |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
218 setupcfg_defined = False |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
219 if self.has_setup_py() and self._prompt_user_for_conversion(): |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
220 setupcfg_defined = self.convert_py_to_cfg() |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
221 if not setupcfg_defined: |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
222 self.define_cfg_values() |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
223 self._write_cfg() |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
224 |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
225 def has_setup_py(self): |
|
70671
b0e11220a6bf
Improve a few docstrings in packaging.
Éric Araujo <merwok@netwok.org>
parents:
70246
diff
changeset
|
226 """Test for the existence of a setup.py file.""" |
|
70194
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
227 return os.path.exists('setup.py') |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
228 |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
229 def define_cfg_values(self): |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
230 self.inspect() |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
231 self.query_user() |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
232 |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
233 def _lookup_option(self, key): |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
234 if not self.configparser.has_option('DEFAULT', key): |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
235 return None |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
236 return self.configparser.get('DEFAULT', key) |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
237 |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
238 def _load_defaults(self): |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
239 # Load default values from a user configuration file |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
240 self.configparser = RawConfigParser() |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
241 # TODO replace with section in distutils config file |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
242 default_cfg = os.path.expanduser(os.path.join('~', _DEFAULT_CFG)) |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
243 self.configparser.read(default_cfg) |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
244 self.data['author'] = self._lookup_option('author') |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
245 self.data['author_email'] = self._lookup_option('author_email') |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
246 |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
247 def _prompt_user_for_conversion(self): |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
248 # Prompt the user about whether they would like to use the setup.py |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
249 # conversion utility to generate a setup.cfg or generate the setup.cfg |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
250 # from scratch |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
251 answer = ask_yn(('A legacy setup.py has been found.\n' |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
252 'Would you like to convert it to a setup.cfg?'), |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
253 default="y", |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
254 helptext=_helptext['setup.py found']) |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
255 return convert_yn_to_bool(answer) |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
256 |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
257 def _dotted_packages(self, data): |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
258 packages = sorted(data) |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
259 modified_pkgs = [] |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
260 for pkg in packages: |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
261 pkg = pkg.lstrip('./') |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
262 pkg = pkg.replace('/', '.') |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
263 modified_pkgs.append(pkg) |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
264 return modified_pkgs |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
265 |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
266 def _write_cfg(self): |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
267 if os.path.exists(_FILENAME): |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
268 if os.path.exists('%s.old' % _FILENAME): |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
269 print("ERROR: %(name)s.old backup exists, please check that " |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
270 "current %(name)s is correct and remove %(name)s.old" % |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
271 {'name': _FILENAME}) |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
272 return |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
273 shutil.move(_FILENAME, '%s.old' % _FILENAME) |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
274 |
|
70204
fe740c1cee02
Issue #12112: packaging reads and writes setup.cfg using UTF-8
Victor Stinner <victor.stinner@haypocalc.com>
parents:
70198
diff
changeset
|
275 with open(_FILENAME, 'w', encoding='utf-8') as fp: |
|
70194
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
276 fp.write('[metadata]\n') |
|
70674
50b9fc2451f0
Clean up packaging.create and add TODO notes for future cleanups
Éric Araujo <merwok@netwok.org>
parents:
70671
diff
changeset
|
277 # TODO use metadata module instead of hard-coding field-specific |
|
50b9fc2451f0
Clean up packaging.create and add TODO notes for future cleanups
Éric Araujo <merwok@netwok.org>
parents:
70671
diff
changeset
|
278 # behavior here |
|
50b9fc2451f0
Clean up packaging.create and add TODO notes for future cleanups
Éric Araujo <merwok@netwok.org>
parents:
70671
diff
changeset
|
279 |
|
70194
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
280 # simple string entries |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
281 for name in ('name', 'version', 'summary', 'download_url'): |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
282 fp.write('%s = %s\n' % (name, self.data.get(name, 'UNKNOWN'))) |
|
70674
50b9fc2451f0
Clean up packaging.create and add TODO notes for future cleanups
Éric Araujo <merwok@netwok.org>
parents:
70671
diff
changeset
|
283 |
|
70194
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
284 # optional string entries |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
285 if 'keywords' in self.data and self.data['keywords']: |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
286 fp.write('keywords = %s\n' % ' '.join(self.data['keywords'])) |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
287 for name in ('home_page', 'author', 'author_email', |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
288 'maintainer', 'maintainer_email', 'description-file'): |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
289 if name in self.data and self.data[name]: |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
290 fp.write('%s = %s\n' % (name, self.data[name])) |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
291 if 'description' in self.data: |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
292 fp.write( |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
293 'description = %s\n' |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
294 % '\n |'.join(self.data['description'].split('\n'))) |
|
70674
50b9fc2451f0
Clean up packaging.create and add TODO notes for future cleanups
Éric Araujo <merwok@netwok.org>
parents:
70671
diff
changeset
|
295 |
|
70194
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
296 # multiple use string entries |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
297 for name in ('platform', 'supported-platform', 'classifier', |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
298 'requires-dist', 'provides-dist', 'obsoletes-dist', |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
299 'requires-external'): |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
300 if not(name in self.data and self.data[name]): |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
301 continue |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
302 fp.write('%s = ' % name) |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
303 fp.write(''.join(' %s\n' % val |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
304 for val in self.data[name]).lstrip()) |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
305 fp.write('\n[files]\n') |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
306 for name in ('packages', 'modules', 'scripts', |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
307 'package_data', 'extra_files'): |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
308 if not(name in self.data and self.data[name]): |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
309 continue |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
310 fp.write('%s = %s\n' |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
311 % (name, '\n '.join(self.data[name]).strip())) |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
312 fp.write('\nresources =\n') |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
313 for src, dest in self.data['resources']: |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
314 fp.write(' %s = %s\n' % (src, dest)) |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
315 fp.write('\n') |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
316 |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
317 os.chmod(_FILENAME, 0o644) |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
318 print('Wrote "%s".' % _FILENAME) |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
319 |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
320 def convert_py_to_cfg(self): |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
321 """Generate a setup.cfg from an existing setup.py. |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
322 |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
323 It only exports the distutils metadata (setuptools specific metadata |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
324 is not currently supported). |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
325 """ |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
326 data = self.data |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
327 |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
328 def setup_mock(**attrs): |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
329 """Mock the setup(**attrs) in order to retrieve metadata.""" |
|
70674
50b9fc2451f0
Clean up packaging.create and add TODO notes for future cleanups
Éric Araujo <merwok@netwok.org>
parents:
70671
diff
changeset
|
330 |
|
50b9fc2451f0
Clean up packaging.create and add TODO notes for future cleanups
Éric Araujo <merwok@netwok.org>
parents:
70671
diff
changeset
|
331 # TODO use config and metadata instead of Distribution |
|
70194
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
332 from distutils.dist import Distribution |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
333 dist = Distribution(attrs) |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
334 dist.parse_config_files() |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
335 |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
336 # 1. retrieve metadata fields that are quite similar in |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
337 # PEP 314 and PEP 345 |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
338 labels = (('name',) * 2, |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
339 ('version',) * 2, |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
340 ('author',) * 2, |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
341 ('author_email',) * 2, |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
342 ('maintainer',) * 2, |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
343 ('maintainer_email',) * 2, |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
344 ('description', 'summary'), |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
345 ('long_description', 'description'), |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
346 ('url', 'home_page'), |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
347 ('platforms', 'platform'), |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
348 # backport only for 2.5+ |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
349 ('provides', 'provides-dist'), |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
350 ('obsoletes', 'obsoletes-dist'), |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
351 ('requires', 'requires-dist')) |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
352 |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
353 get = lambda lab: getattr(dist.metadata, lab.replace('-', '_')) |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
354 data.update((new, get(old)) for old, new in labels if get(old)) |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
355 |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
356 # 2. retrieve data that requires special processing |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
357 data['classifier'].update(dist.get_classifiers() or []) |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
358 data['scripts'].extend(dist.scripts or []) |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
359 data['packages'].extend(dist.packages or []) |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
360 data['modules'].extend(dist.py_modules or []) |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
361 # 2.1 data_files -> resources |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
362 if dist.data_files: |
|
70674
50b9fc2451f0
Clean up packaging.create and add TODO notes for future cleanups
Éric Araujo <merwok@netwok.org>
parents:
70671
diff
changeset
|
363 if (len(dist.data_files) < 2 or |
|
50b9fc2451f0
Clean up packaging.create and add TODO notes for future cleanups
Éric Araujo <merwok@netwok.org>
parents:
70671
diff
changeset
|
364 isinstance(dist.data_files[1], str)): |
|
70194
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
365 dist.data_files = [('', dist.data_files)] |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
366 # add tokens in the destination paths |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
367 vars = {'distribution.name': data['name']} |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
368 path_tokens = list(sysconfig.get_paths(vars=vars).items()) |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
369 |
|
70674
50b9fc2451f0
Clean up packaging.create and add TODO notes for future cleanups
Éric Araujo <merwok@netwok.org>
parents:
70671
diff
changeset
|
370 # TODO replace this with a key function |
|
70194
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
371 def length_comparison(x, y): |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
372 len_x = len(x[1]) |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
373 len_y = len(y[1]) |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
374 if len_x == len_y: |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
375 return 0 |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
376 elif len_x < len_y: |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
377 return -1 |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
378 else: |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
379 return 1 |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
380 |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
381 # sort tokens to use the longest one first |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
382 path_tokens.sort(key=cmp_to_key(length_comparison)) |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
383 for dest, srcs in (dist.data_files or []): |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
384 dest = os.path.join(sys.prefix, dest) |
|
70246
3854d17ab407
we want to generate /-separated paths setup.cfg files even under win32
Tarek Ziade <tarek@ziade.org>
parents:
70210
diff
changeset
|
385 dest = dest.replace(os.path.sep, '/') |
|
70194
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
386 for tok, path in path_tokens: |
|
70246
3854d17ab407
we want to generate /-separated paths setup.cfg files even under win32
Tarek Ziade <tarek@ziade.org>
parents:
70210
diff
changeset
|
387 path = path.replace(os.path.sep, '/') |
|
3854d17ab407
we want to generate /-separated paths setup.cfg files even under win32
Tarek Ziade <tarek@ziade.org>
parents:
70210
diff
changeset
|
388 if not dest.startswith(path): |
|
70194
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
389 continue |
|
70246
3854d17ab407
we want to generate /-separated paths setup.cfg files even under win32
Tarek Ziade <tarek@ziade.org>
parents:
70210
diff
changeset
|
390 |
|
3854d17ab407
we want to generate /-separated paths setup.cfg files even under win32
Tarek Ziade <tarek@ziade.org>
parents:
70210
diff
changeset
|
391 dest = ('{%s}' % tok) + dest[len(path):] |
|
3854d17ab407
we want to generate /-separated paths setup.cfg files even under win32
Tarek Ziade <tarek@ziade.org>
parents:
70210
diff
changeset
|
392 files = [('/ '.join(src.rsplit('/', 1)), dest) |
|
70674
50b9fc2451f0
Clean up packaging.create and add TODO notes for future cleanups
Éric Araujo <merwok@netwok.org>
parents:
70671
diff
changeset
|
393 for src in srcs] |
|
70246
3854d17ab407
we want to generate /-separated paths setup.cfg files even under win32
Tarek Ziade <tarek@ziade.org>
parents:
70210
diff
changeset
|
394 data['resources'].extend(files) |
|
3854d17ab407
we want to generate /-separated paths setup.cfg files even under win32
Tarek Ziade <tarek@ziade.org>
parents:
70210
diff
changeset
|
395 |
|
70194
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
396 # 2.2 package_data -> extra_files |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
397 package_dirs = dist.package_dir or {} |
|
70674
50b9fc2451f0
Clean up packaging.create and add TODO notes for future cleanups
Éric Araujo <merwok@netwok.org>
parents:
70671
diff
changeset
|
398 for package, extras in dist.package_data.items() or []: |
|
70194
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
399 package_dir = package_dirs.get(package, package) |
|
70246
3854d17ab407
we want to generate /-separated paths setup.cfg files even under win32
Tarek Ziade <tarek@ziade.org>
parents:
70210
diff
changeset
|
400 for file_ in extras: |
|
3854d17ab407
we want to generate /-separated paths setup.cfg files even under win32
Tarek Ziade <tarek@ziade.org>
parents:
70210
diff
changeset
|
401 if package_dir: |
|
3854d17ab407
we want to generate /-separated paths setup.cfg files even under win32
Tarek Ziade <tarek@ziade.org>
parents:
70210
diff
changeset
|
402 file_ = package_dir + '/' + file_ |
|
3854d17ab407
we want to generate /-separated paths setup.cfg files even under win32
Tarek Ziade <tarek@ziade.org>
parents:
70210
diff
changeset
|
403 data['extra_files'].append(file_) |
|
70194
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
404 |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
405 # Use README file if its content is the desciption |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
406 if "description" in data: |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
407 ref = md5(re.sub('\s', '', |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
408 self.data['description']).lower().encode()) |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
409 ref = ref.digest() |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
410 for readme in glob.glob('README*'): |
|
70198
47c0ab9ab3aa
packaging: don't use locale encoding to compute MD5 checksums
Victor Stinner <victor.stinner@haypocalc.com>
parents:
70194
diff
changeset
|
411 with open(readme, encoding='utf-8') as fp: |
|
70194
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
412 contents = fp.read() |
|
70198
47c0ab9ab3aa
packaging: don't use locale encoding to compute MD5 checksums
Victor Stinner <victor.stinner@haypocalc.com>
parents:
70194
diff
changeset
|
413 contents = re.sub('\s', '', contents.lower()).encode() |
|
47c0ab9ab3aa
packaging: don't use locale encoding to compute MD5 checksums
Victor Stinner <victor.stinner@haypocalc.com>
parents:
70194
diff
changeset
|
414 val = md5(contents).digest() |
|
70194
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
415 if val == ref: |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
416 del data['description'] |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
417 data['description-file'] = readme |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
418 break |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
419 |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
420 # apply monkey patch to distutils (v1) and setuptools (if needed) |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
421 # (abort the feature if distutils v1 has been killed) |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
422 try: |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
423 from distutils import core |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
424 core.setup # make sure it's not d2 maskerading as d1 |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
425 except (ImportError, AttributeError): |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
426 return |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
427 saved_setups = [(core, core.setup)] |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
428 core.setup = setup_mock |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
429 try: |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
430 import setuptools |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
431 except ImportError: |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
432 pass |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
433 else: |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
434 saved_setups.append((setuptools, setuptools.setup)) |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
435 setuptools.setup = setup_mock |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
436 # get metadata by executing the setup.py with the patched setup(...) |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
437 success = False # for python < 2.4 |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
438 try: |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
439 load_setup() |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
440 success = True |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
441 finally: # revert monkey patches |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
442 for patched_module, original_setup in saved_setups: |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
443 patched_module.setup = original_setup |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
444 if not self.data: |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
445 raise ValueError('Unable to load metadata from setup.py') |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
446 return success |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
447 |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
448 def inspect(self): |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
449 """Inspect the current working diretory for a name and version. |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
450 |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
451 This information is harvested in where the directory is named |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
452 like [name]-[version]. |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
453 """ |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
454 dir_name = os.path.basename(os.getcwd()) |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
455 self.data['name'] = dir_name |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
456 match = re.match(r'(.*)-(\d.+)', dir_name) |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
457 if match: |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
458 self.data['name'] = match.group(1) |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
459 self.data['version'] = match.group(2) |
|
70674
50b9fc2451f0
Clean up packaging.create and add TODO notes for future cleanups
Éric Araujo <merwok@netwok.org>
parents:
70671
diff
changeset
|
460 # TODO needs testing! |
|
70194
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
461 if not is_valid_version(self.data['version']): |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
462 msg = "Invalid version discovered: %s" % self.data['version'] |
|
70674
50b9fc2451f0
Clean up packaging.create and add TODO notes for future cleanups
Éric Araujo <merwok@netwok.org>
parents:
70671
diff
changeset
|
463 raise ValueError(msg) |
|
70194
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
464 |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
465 def query_user(self): |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
466 self.data['name'] = ask('Project name', self.data['name'], |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
467 _helptext['name']) |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
468 |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
469 self.data['version'] = ask('Current version number', |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
470 self.data.get('version'), _helptext['version']) |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
471 self.data['summary'] = ask('Package summary', |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
472 self.data.get('summary'), _helptext['summary'], |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
473 lengthy=True) |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
474 self.data['author'] = ask('Author name', |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
475 self.data.get('author'), _helptext['author']) |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
476 self.data['author_email'] = ask('Author e-mail address', |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
477 self.data.get('author_email'), _helptext['author_email']) |
|
70675
33f680ed54ac
Improve consistency in questions asked by packaging.create.
Éric Araujo <merwok@netwok.org>
parents:
70674
diff
changeset
|
478 self.data['home_page'] = ask('Project home page', |
|
70194
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
479 self.data.get('home_page'), _helptext['home_page'], |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
480 required=False) |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
481 |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
482 if ask_yn('Do you want me to automatically build the file list ' |
|
70675
33f680ed54ac
Improve consistency in questions asked by packaging.create.
Éric Araujo <merwok@netwok.org>
parents:
70674
diff
changeset
|
483 'with everything I can find in the current directory? ' |
|
70194
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
484 'If you say no, you will have to define them manually.') == 'y': |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
485 self._find_files() |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
486 else: |
|
70675
33f680ed54ac
Improve consistency in questions asked by packaging.create.
Éric Araujo <merwok@netwok.org>
parents:
70674
diff
changeset
|
487 while ask_yn('Do you want to add a single module?' |
|
70194
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
488 ' (you will be able to add full packages next)', |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
489 helptext=_helptext['modules']) == 'y': |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
490 self._set_multi('Module name', 'modules') |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
491 |
|
70675
33f680ed54ac
Improve consistency in questions asked by packaging.create.
Éric Araujo <merwok@netwok.org>
parents:
70674
diff
changeset
|
492 while ask_yn('Do you want to add a package?', |
|
70194
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
493 helptext=_helptext['packages']) == 'y': |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
494 self._set_multi('Package name', 'packages') |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
495 |
|
70675
33f680ed54ac
Improve consistency in questions asked by packaging.create.
Éric Araujo <merwok@netwok.org>
parents:
70674
diff
changeset
|
496 while ask_yn('Do you want to add an extra file?', |
|
70194
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
497 helptext=_helptext['extra_files']) == 'y': |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
498 self._set_multi('Extra file/dir name', 'extra_files') |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
499 |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
500 if ask_yn('Do you want to set Trove classifiers?', |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
501 helptext=_helptext['do_classifier']) == 'y': |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
502 self.set_classifier() |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
503 |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
504 def _find_files(self): |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
505 # we are looking for python modules and packages, |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
506 # other stuff are added as regular files |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
507 pkgs = self.data['packages'] |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
508 modules = self.data['modules'] |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
509 extra_files = self.data['extra_files'] |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
510 |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
511 def is_package(path): |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
512 return os.path.exists(os.path.join(path, '__init__.py')) |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
513 |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
514 curdir = os.getcwd() |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
515 scanned = [] |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
516 _pref = ['lib', 'include', 'dist', 'build', '.', '~'] |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
517 _suf = ['.pyc'] |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
518 |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
519 def to_skip(path): |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
520 path = relative(path) |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
521 |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
522 for pref in _pref: |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
523 if path.startswith(pref): |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
524 return True |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
525 |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
526 for suf in _suf: |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
527 if path.endswith(suf): |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
528 return True |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
529 |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
530 return False |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
531 |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
532 def relative(path): |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
533 return path[len(curdir) + 1:] |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
534 |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
535 def dotted(path): |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
536 res = relative(path).replace(os.path.sep, '.') |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
537 if res.endswith('.py'): |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
538 res = res[:-len('.py')] |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
539 return res |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
540 |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
541 # first pass: packages |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
542 for root, dirs, files in os.walk(curdir): |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
543 if to_skip(root): |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
544 continue |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
545 for dir_ in sorted(dirs): |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
546 if to_skip(dir_): |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
547 continue |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
548 fullpath = os.path.join(root, dir_) |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
549 dotted_name = dotted(fullpath) |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
550 if is_package(fullpath) and dotted_name not in pkgs: |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
551 pkgs.append(dotted_name) |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
552 scanned.append(fullpath) |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
553 |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
554 # modules and extra files |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
555 for root, dirs, files in os.walk(curdir): |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
556 if to_skip(root): |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
557 continue |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
558 |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
559 if any(root.startswith(path) for path in scanned): |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
560 continue |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
561 |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
562 for file in sorted(files): |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
563 fullpath = os.path.join(root, file) |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
564 if to_skip(fullpath): |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
565 continue |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
566 # single module? |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
567 if os.path.splitext(file)[-1] == '.py': |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
568 modules.append(dotted(fullpath)) |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
569 else: |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
570 extra_files.append(relative(fullpath)) |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
571 |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
572 def _set_multi(self, question, name): |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
573 existing_values = self.data[name] |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
574 value = ask(question, helptext=_helptext[name]).strip() |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
575 if value not in existing_values: |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
576 existing_values.append(value) |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
577 |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
578 def set_classifier(self): |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
579 self.set_maturity_status(self.classifiers) |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
580 self.set_license(self.classifiers) |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
581 self.set_other_classifier(self.classifiers) |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
582 |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
583 def set_other_classifier(self, classifiers): |
|
70675
33f680ed54ac
Improve consistency in questions asked by packaging.create.
Éric Araujo <merwok@netwok.org>
parents:
70674
diff
changeset
|
584 if ask_yn('Do you want to set other trove identifiers?', 'n', |
|
70194
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
585 _helptext['trove_generic']) != 'y': |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
586 return |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
587 self.walk_classifiers(classifiers, [CLASSIFIERS], '') |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
588 |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
589 def walk_classifiers(self, classifiers, trovepath, desc): |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
590 trove = trovepath[-1] |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
591 |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
592 if not trove: |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
593 return |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
594 |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
595 for key in sorted(trove): |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
596 if len(trove[key]) == 0: |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
597 if ask_yn('Add "%s"' % desc[4:] + ' :: ' + key, 'n') == 'y': |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
598 classifiers.add(desc[4:] + ' :: ' + key) |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
599 continue |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
600 |
|
70675
33f680ed54ac
Improve consistency in questions asked by packaging.create.
Éric Araujo <merwok@netwok.org>
parents:
70674
diff
changeset
|
601 if ask_yn('Do you want to set items under\n "%s" (%d sub-items)?' |
|
70194
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
602 % (key, len(trove[key])), 'n', |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
603 _helptext['trove_generic']) == 'y': |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
604 self.walk_classifiers(classifiers, trovepath + [trove[key]], |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
605 desc + ' :: ' + key) |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
606 |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
607 def set_license(self, classifiers): |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
608 while True: |
|
70675
33f680ed54ac
Improve consistency in questions asked by packaging.create.
Éric Araujo <merwok@netwok.org>
parents:
70674
diff
changeset
|
609 license = ask('What license do you use?', |
|
70194
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
610 helptext=_helptext['trove_license'], required=False) |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
611 if not license: |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
612 return |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
613 |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
614 license_words = license.lower().split(' ') |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
615 found_list = [] |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
616 |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
617 for index, licence in LICENCES: |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
618 for word in license_words: |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
619 if word in licence: |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
620 found_list.append(index) |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
621 break |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
622 |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
623 if len(found_list) == 0: |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
624 print('ERROR: Could not find a matching license for "%s"' % |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
625 license) |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
626 continue |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
627 |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
628 question = 'Matching licenses:\n\n' |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
629 |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
630 for index, list_index in enumerate(found_list): |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
631 question += ' %s) %s\n' % (index + 1, |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
632 _CLASSIFIERS_LIST[list_index]) |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
633 |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
634 question += ('\nType the number of the license you wish to use or ' |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
635 '? to try again:') |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
636 choice = ask(question, required=False) |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
637 |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
638 if choice == '?': |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
639 continue |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
640 if choice == '': |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
641 return |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
642 |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
643 try: |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
644 index = found_list[int(choice) - 1] |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
645 except ValueError: |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
646 print("ERROR: Invalid selection, type a number from the list " |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
647 "above.") |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
648 |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
649 classifiers.add(_CLASSIFIERS_LIST[index]) |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
650 |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
651 def set_maturity_status(self, classifiers): |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
652 maturity_name = lambda mat: mat.split('- ')[-1] |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
653 maturity_question = '''\ |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
654 Please select the project status: |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
655 |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
656 %s |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
657 |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
658 Status''' % '\n'.join('%s - %s' % (i, maturity_name(n)) |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
659 for i, n in enumerate(PROJECT_MATURITY)) |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
660 while True: |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
661 choice = ask(dedent(maturity_question), required=False) |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
662 |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
663 if choice: |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
664 try: |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
665 choice = int(choice) - 1 |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
666 key = PROJECT_MATURITY[choice] |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
667 classifiers.add(key) |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
668 return |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
669 except (IndexError, ValueError): |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
670 print("ERROR: Invalid selection, type a single digit " |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
671 "number.") |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
672 |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
673 |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
674 def main(): |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
675 """Main entry point.""" |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
676 program = MainProgram() |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
677 # # uncomment when implemented |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
678 # if not program.load_existing_setup_script(): |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
679 # program.inspect_directory() |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
680 # program.query_user() |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
681 # program.update_config_file() |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
682 # program.write_setup_script() |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
683 # packaging.util.cfg_to_args() |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
684 program() |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
685 |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
686 |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
687 if __name__ == '__main__': |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
688 main() |
