@@ -2,7 +2,7 @@ A Simple Python Project Skeleton
2
2
================================
3
3
This repo attempts to standardize our python repositories using modern python
4
4
packaging and configuration techniques. Using this `blog post `_ as inspiration, this
5
- repository will serve as the base for all new python projects and will be adopted to all
5
+ repository will serve as the base for all new python projects and will be adopted to all
6
6
our existing ones as well.
7
7
8
8
.. _blog post : https://blog.jaraco.com/a-project-skeleton-for-python-projects/
@@ -33,18 +33,148 @@ Update an existing project
33
33
34
34
This is also the workflow to use when updating the skeleton files in any given repository.
35
35
36
-
37
36
Customizing
38
37
-----------
39
38
40
39
You typically want to perform these customizations:
41
40
42
41
- remove or update the src/README.rst and tests/README.rst files
42
+ - set project info and dependencies in setup.cfg
43
43
- check the configure and configure.bat defaults
44
44
45
+ Initializing a project
46
+ ----------------------
47
+
48
+ All projects using the skeleton will be expected to pull all of it dependencies
49
+ from thirdparty.aboutcode.org/pypi or the local thirdparty directory, using
50
+ requirements.txt and/or requirements-dev.txt to determine what version of a
51
+ package to collect. By default, PyPI will not be used to find and collect
52
+ packages from.
53
+
54
+ In the case where we are starting a new project where we do not have
55
+ requirements.txt and requirements-dev.txt and whose dependencies are not yet on
56
+ thirdparty.aboutcode.org/pypi, we run the following command after adding and
57
+ customizing the skeleton files to your project:
58
+
59
+ .. code-block :: bash
60
+
61
+ ./configure --init
62
+
63
+ This will initialize the virtual environment for the project, pull in the
64
+ dependencies from PyPI and add them to the virtual environment.
65
+
66
+ Generating requirements.txt and requirements-dev.txt
67
+ ----------------------------------------------------
68
+
69
+ After the project has been initialized, we can generate the requirements.txt and
70
+ requirements-dev.txt files.
71
+
72
+ Ensure the virtual environment is enabled.
73
+
74
+ .. code-block :: bash
75
+
76
+ source venv/bin/activate
77
+
78
+ To generate requirements.txt:
79
+
80
+ .. code-block :: bash
81
+
82
+ python etc/scripts/gen_requirements.py -s venv/lib/python< version> /site-packages/
83
+
84
+ Replace \< version\> with the version number of the Python being used, for example: ``venv/lib/python3.6/site-packages/ ``
85
+
86
+ To generate requirements-dev.txt after requirements.txt has been generated:
87
+
88
+ .. code-block :: bash
89
+ ./configure --init --dev
90
+ python etc/scripts/gen_requirements_dev.py -s venv/lib/python< version> /site-packages/
91
+
92
+ Note: on Windows, the ``site-packages `` directory is located at ``venv\Lib\site-packages\ ``
93
+
94
+ .. code-block :: bash
95
+
96
+ python .\\ etc\\ scripts\\ gen_requirements.py -s .\\ venv\\ Lib\\ site-packages\\
97
+ .\c onfigure --init --dev
98
+ python .\\ etc\\ scripts\\ gen_requirements_dev.py -s .\\ venv\\ Lib\\ site-packages\\
99
+
100
+ Collecting and generating ABOUT files for dependencies
101
+ ------------------------------------------------------
102
+
103
+ Ensure that the dependencies used by ``etc/scripts/bootstrap.py `` are installed:
104
+
105
+ .. code-block :: bash
106
+
107
+ pip install -r etc/scripts/requirements.txt
108
+
109
+ Once we have requirements.txt and requirements-dev.txt, we can fetch the project
110
+ dependencies as wheels and generate ABOUT files for them:
111
+
112
+ .. code-block :: bash
113
+
114
+ python etc/scripts/bootstrap.py -r requirements.txt -r requirements-dev.txt --with-deps
115
+
116
+ There may be issues with the generated ABOUT files, which will have to be
117
+ corrected. You can check to see if your corrections are valid by running:
118
+
119
+ .. code-block :: bash
120
+
121
+ python etc/scripts/check_thirdparty.py -d thirdparty
122
+
123
+ Once the wheels are collected and the ABOUT files are generated and correct,
124
+ upload them to thirdparty.aboutcode.org/pypi by placing the wheels and ABOUT
125
+ files from the thirdparty directory to the pypi directory at
126
+ https://github.com/nexB/thirdparty-packages
127
+
128
+
129
+ Usage after project initialization
130
+ ----------------------------------
131
+
132
+ Once the ``requirements.txt `` and ``requirements-dev.txt `` have been generated
133
+ and the project dependencies and their ABOUT files have been uploaded to
134
+ thirdparty.aboutcode.org/pypi, you can configure the project without using the
135
+ ``--init `` option.
136
+
137
+ If the virtual env for the project becomes polluted, or you would like to remove
138
+ it, use the ``--clean `` option:
139
+
140
+ .. code-block :: bash
141
+
142
+ ./configure --clean
143
+
144
+ Then you can run ``./configure `` again to set up the project virtual environment.
145
+
146
+ To set up the project for development use:
147
+
148
+ .. code-block :: bash
149
+
150
+ ./configure --dev
151
+
152
+ To update the project dependencies (adding, removing, updating packages, etc.),
153
+ update the dependencies in ``setup.cfg ``, then run:
154
+
155
+ .. code-block :: bash
156
+
157
+ ./configure --clean # Remove existing virtual environment
158
+ ./configure --init # Create project virtual environment, pull in new dependencies
159
+ source venv/bin/activate # Ensure virtual environment is activated
160
+ python etc/scripts/gen_requirements.py -s venv/lib/python< version> /site-packages/ # Regenerate requirements.txt
161
+ python etc/scripts/gen_requirements_dev.py -s venv/lib/python< version> /site-packages/ # Regenerate requirements-dev.txt
162
+ pip install -r etc/scripts/requirements.txt # Install dependencies needed by etc/scripts/bootstrap.py
163
+ python etc/scripts/bootstrap.py -r requirements.txt -r requirements-dev.txt --with-deps # Collect dependency wheels and their ABOUT files
164
+
165
+ Ensure that the generated ABOUT files are valid, then take the dependency wheels
166
+ and ABOUT files and upload them to thirdparty.aboutcode.org/pypi.
45
167
46
168
Release Notes
47
- -------------
169
+ =============
170
+
171
+ - 2021-09-03:
172
+ - ``configure `` now requires pinned dependencies via the use of ``requirements.txt `` and ``requirements-dev.txt ``
173
+ - ``configure `` can now accept multiple options at once
174
+ - Add utility scripts from scancode-toolkit/etc/release/ for use in generating project files
175
+ - Rename virtual environment directory from ``tmp `` to ``venv ``
176
+ - Update README.rst with instructions for generating ``requirements.txt `` and ``requirements-dev.txt ``,
177
+ as well as collecting dependencies as wheels and generating ABOUT files for them.
48
178
49
- - 2021-05-11: adopt new configure scripts from ScanCode TK that allows correct
50
- configuration of which Python version is used.
179
+ - 2021-05-11:
180
+ - Adopt new configure scripts from ScanCode TK that allows correct configuration of which Python version is used.
0 commit comments