Skip to content

Commit 3458cde

Browse files
authored
Merge pull request #4732 from stsewd/extend-install-option
Extend install option from config file (v2, schema only)
2 parents c38efc8 + 970e583 commit 3458cde

File tree

2 files changed

+38
-46
lines changed

2 files changed

+38
-46
lines changed

readthedocs/rtd_tests/fixtures/spec/v2/schema.yml

+18-10
Original file line numberDiff line numberDiff line change
@@ -53,22 +53,30 @@ python:
5353
# Default: '3'
5454
version: enum('2', '2.7', '3', '3.3', '3.4', '3.5', '3.6', required=False)
5555

56+
# Give the virtual environment access to the global site-packages dir
57+
# Default: false | project config
58+
system_packages: bool(required=False)
59+
60+
# Installation of packages and requiremens
61+
install: list(any(include('python-install-requirements'), include('python-install')), required=False)
62+
63+
python-install-requirements:
5664
# The path to the requirements file from the root of the project
57-
# Default: null | project config
58-
requirements: path(required=False)
65+
requirements: path()
5966

60-
# Install the project using python setup.py install or pip
61-
# Default: null | project config
62-
install: enum('pip', 'setup.py', required=False)
67+
python-install:
68+
# The path to the project to be installed
69+
path: path()
6370

64-
# Extra requirements sections to install in addition to the package dependencies
71+
# Install using python setup.py install or pip
72+
# Default: pip
73+
method: enum('pip', 'setuptools', required=False)
74+
75+
# Extra requirements sections to install in addition to the package dependencies.
76+
# Only valid when `method` is `pip`.
6577
# Default: []
6678
extra_requirements: list(str(), required=False)
6779

68-
# Give the virtual environment access to the global site-packages dir
69-
# Default: false | project config
70-
system_packages: bool(required=False)
71-
7280
sphinx:
7381
# The builder type for the sphinx documentation
7482
# Default: 'html'

readthedocs/rtd_tests/tests/test_build_config.py

+20-36
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ def assertInvalidConfig(tmpdir, content, msgs=()):
7474
with pytest.raises(ValueError) as excinfo:
7575
validate_schema(file)
7676
for msg in msgs:
77-
msg in str(excinfo.value)
77+
assert msg in str(excinfo.value)
7878

7979

8080
def test_minimal_config(tmpdir):
@@ -250,16 +250,18 @@ def test_python_requirements(tmpdir):
250250
content = '''
251251
version: "2"
252252
python:
253-
requirements: docs/requirements.txt
253+
install:
254+
- requirements: docs/requirements.txt
254255
'''
255256
assertValidConfig(tmpdir, content)
256257

257258

258-
def test_python_requirements_invalid(tmpdir):
259+
def test_python_install_requirements(tmpdir):
259260
content = '''
260261
version: "2"
261262
python:
262-
requirements: 23
263+
install:
264+
- requirements: 23
263265
'''
264266
assertInvalidConfig(
265267
tmpdir,
@@ -268,22 +270,15 @@ def test_python_requirements_invalid(tmpdir):
268270
)
269271

270272

271-
def test_python_requirements_null(tmpdir):
272-
content = '''
273-
version: "2"
274-
python:
275-
requirements: null
276-
'''
277-
assertValidConfig(tmpdir, content)
278-
279-
280-
@pytest.mark.parametrize('value', ['pip', 'setup.py'])
273+
@pytest.mark.parametrize('value', ['pip', 'setuptools'])
281274
def test_python_install(tmpdir, value):
282275
content = '''
283276
version: "2"
284277
python:
285278
version: "3.6"
286-
install: {value}
279+
install:
280+
- path: .
281+
method: {value}
287282
'''
288283
assertValidConfig(tmpdir, content.format(value=value))
289284

@@ -297,7 +292,7 @@ def test_python_install_invalid(tmpdir):
297292
assertInvalidConfig(
298293
tmpdir,
299294
content,
300-
["python.install: 'guido' not in"]
295+
["python.install: 'guido' is not a list"]
301296
)
302297

303298

@@ -310,38 +305,27 @@ def test_python_install_null(tmpdir):
310305
assertValidConfig(tmpdir, content)
311306

312307

313-
def test_python_extra_requirements(tmpdir):
308+
def test_python_install_extra_requirements(tmpdir):
314309
content = '''
315310
version: "2"
316311
python:
317-
extra_requirements:
318-
- test
319-
- dev
312+
install:
313+
- path: .
314+
extra_requirements:
315+
- test
316+
- dev
320317
'''
321318
assertValidConfig(tmpdir, content)
322319

323320

324-
def test_python_extra_requirements_invalid(tmpdir):
325-
content = '''
326-
version: "2"
327-
python:
328-
extra_requirements:
329-
- 1
330-
- dev
331-
'''
332-
assertInvalidConfig(
333-
tmpdir,
334-
content,
335-
["'1' is not a str"]
336-
)
337-
338-
339321
@pytest.mark.parametrize('value', ['', 'null', '[]'])
340322
def test_python_extra_requirements_empty(tmpdir, value):
341323
content = '''
342324
version: "2"
343325
python:
344-
extra_requirements: {value}
326+
install:
327+
- path: .
328+
extra_requirements: {value}
345329
'''
346330
assertValidConfig(tmpdir, content.format(value=value))
347331

0 commit comments

Comments
 (0)