Skip to content

Commit 1ca260b

Browse files
committed
Improve package manager tests
Backports a number of updates/improvements to the package manager integration tests found while working on the tests for uv.
1 parent ee0a9eb commit 1ca260b

File tree

12 files changed

+98
-52
lines changed

12 files changed

+98
-52
lines changed
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,3 @@
1+
# Note: This test has to use Python 3.12 until we work around the
2+
# Pipenv editable VCS dependency cache invalidation bug.
13
3.12

spec/fixtures/pipenv_editable/Pipfile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ verify_ssl = true
44
name = "pypi"
55

66
[packages]
7+
gunicorn = {git = "git+https://github.com/benoitc/gunicorn", ref = "20.1.0", editable = true}
78
local-package-pyproject-toml = {file = "packages/local_package_pyproject_toml", editable = true}
89
local-package-setup-py = {file = "packages/local_package_setup_py", editable = true}
9-
gunicorn = {git = "git+https://github.com/benoitc/gunicorn", ref = "20.1.0", editable = true}
10+
pipenv-editable = {file = ".", editable = true}

spec/fixtures/pipenv_editable/Pipfile.lock

Lines changed: 8 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

spec/fixtures/pipenv_editable/pipenv_editable/__init__.py

Whitespace-only changes.
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
[project]
2+
name = "pipenv-editable"
3+
version = "0.0.0"
4+
requires-python = ">=3.12"
5+
6+
[build-system]
7+
requires = ["hatchling"]
8+
build-backend = "hatchling.build"

spec/fixtures/poetry_editable/bin/test-entrypoints.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ set -euo pipefail
44

55
cd .heroku/python/lib/python*/site-packages/
66

7-
# List any path like strings in .pth, and finder files in site-packages.
7+
# List any path like strings in the .pth and finder files in site-packages.
88
grep --extended-regexp --only-matching -- '/\S+' *.pth __editable___*_finder.py | sort
99
echo
1010

spec/fixtures/poetry_editable/poetry.lock

Lines changed: 21 additions & 25 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

spec/fixtures/poetry_editable/pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ authors = []
66

77
[tool.poetry.dependencies]
88
python = "^3.13"
9-
gunicorn = { git = "https://github.com/benoitc/gunicorn.git", tag = "20.1.0", develop = true }
9+
gunicorn = { git = "https://github.com/benoitc/gunicorn.git", develop = true }
1010
local-package-pyproject-toml = { path = "packages/local_package_pyproject_toml", develop = true }
1111
local-package-setup-py = { path = "packages/local_package_setup_py", develop = true }
1212

spec/hatchet/ci_spec.rb

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
it 'installs both normal and test dependencies and uses cache on subsequent runs' do
1212
app.run_ci do |test_run|
13-
expect(test_run.output).to match(Regexp.new(<<~REGEX, Regexp::MULTILINE))
13+
expect(clean_output(test_run.output)).to match(Regexp.new(<<~REGEX, Regexp::MULTILINE))
1414
-----> Python app detected
1515
-----> Using Python #{DEFAULT_PYTHON_MAJOR_VERSION} specified in .python-version
1616
-----> Installing Python #{DEFAULT_PYTHON_FULL_VERSION}
@@ -62,7 +62,7 @@
6262
REGEX
6363

6464
test_run.run_again
65-
expect(test_run.output).to include(<<~OUTPUT)
65+
expect(clean_output(test_run.output)).to include(<<~OUTPUT)
6666
-----> Python app detected
6767
-----> Using Python #{DEFAULT_PYTHON_MAJOR_VERSION} specified in .python-version
6868
-----> Restoring cache
@@ -81,7 +81,7 @@
8181

8282
it 'installs both normal and test dependencies and uses cache on subsequent runs' do
8383
app.run_ci do |test_run|
84-
expect(test_run.output).to match(Regexp.new(<<~REGEX))
84+
expect(clean_output(test_run.output)).to match(Regexp.new(<<~REGEX))
8585
-----> Python app detected
8686
-----> Using Python #{DEFAULT_PYTHON_MAJOR_VERSION} specified in .python-version
8787
-----> Installing Python #{DEFAULT_PYTHON_FULL_VERSION}
@@ -134,7 +134,7 @@
134134
REGEX
135135

136136
test_run.run_again
137-
expect(test_run.output).to match(Regexp.new(<<~REGEX))
137+
expect(clean_output(test_run.output)).to match(Regexp.new(<<~REGEX))
138138
-----> Python app detected
139139
-----> Using Python #{DEFAULT_PYTHON_MAJOR_VERSION} specified in .python-version
140140
-----> Restoring cache
@@ -156,7 +156,7 @@
156156

157157
it 'installs both normal and test dependencies and uses cache on subsequent runs' do
158158
app.run_ci do |test_run|
159-
expect(test_run.output).to match(Regexp.new(<<~REGEX))
159+
expect(clean_output(test_run.output)).to match(Regexp.new(<<~REGEX))
160160
-----> Python app detected
161161
-----> Using Python #{DEFAULT_PYTHON_MAJOR_VERSION} specified in .python-version
162162
-----> Installing Python #{DEFAULT_PYTHON_FULL_VERSION}
@@ -217,7 +217,7 @@
217217
REGEX
218218

219219
test_run.run_again
220-
expect(test_run.output).to include(<<~OUTPUT)
220+
expect(clean_output(test_run.output)).to include(<<~OUTPUT)
221221
-----> Python app detected
222222
-----> Using Python #{DEFAULT_PYTHON_MAJOR_VERSION} specified in .python-version
223223
-----> Restoring cache

spec/hatchet/pip_spec.rb

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,8 @@
9191
end
9292

9393
# This test intentionally uses Python 3.12, so that we test rewriting using older globally installed
94-
# setuptools. The Poetry equivalent of this test covers the PEP-517/518 setuptools case.
94+
# setuptools (which causes .egg-link files to be created too). The Pipenv and Poetry equivalents of
95+
# this test covers the PEP-517/518 setuptools case.
9596
context 'when requirements.txt contains editable requirements (both VCS and local package)' do
9697
let(:buildpacks) { [:default, 'heroku-community/inline'] }
9798
let(:app) { Hatchet::Runner.new('spec/fixtures/pip_editable', buildpacks:) }
@@ -159,6 +160,8 @@
159160
remote: Running entrypoint for the setup.py-based local package: Hello setup.py!
160161
remote: Running entrypoint for the VCS package: gunicorn \\(version 20.1.0\\)
161162
REGEX
163+
# Test that the VCS repo checkout was cached correctly.
164+
expect(app.output).to include('Updating /app/.heroku/python/src/gunicorn clone (to revision 20.1.0)')
162165
end
163166
end
164167
end

spec/hatchet/pipenv_spec.rb

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@
4747
remote: typing_extensions 4.12.2
4848
remote: virtualenv .+
4949
remote:
50-
remote: \\<module 'typing_extensions' from '/app/.heroku/python/lib/python3.13/site-packages/typing_extensions.py'\\>
50+
remote: <module 'typing_extensions' from '/app/.heroku/python/lib/python3.13/site-packages/typing_extensions.py'>
5151
REGEX
5252
app.commit!
5353
app.push!
@@ -348,19 +348,24 @@
348348
end
349349
end
350350

351+
# Note: This test has to use Python 3.12 until we work around the Pipenv editable VCS dependency
352+
# cache invalidation bug when using pyproject.toml / PEP517 based installs.
351353
context 'when Pipfile contains editable requirements' do
352354
let(:buildpacks) { [:default, 'heroku-community/inline'] }
353355
let(:app) { Hatchet::Runner.new('spec/fixtures/pipenv_editable', buildpacks:) }
354356

355357
it 'rewrites .pth, .egg-link and finder paths correctly for hooks, later buildpacks, runtime and cached builds' do
356358
app.deploy do |app|
357359
expect(clean_output(app.output)).to match(Regexp.new(<<~REGEX))
360+
remote: -----> Installing dependencies using 'pipenv install --deploy'
361+
remote: Installing dependencies from Pipfile.lock \\(.+\\)...
358362
remote: -----> Running bin/post_compile hook
359363
remote: easy-install.pth:/tmp/build_.+/.heroku/python/src/gunicorn
360364
remote: easy-install.pth:/tmp/build_.+/packages/local_package_setup_py
361365
remote: __editable___local_package_pyproject_toml_0_0_1_finder.py:/tmp/build_.+/packages/local_package_pyproject_toml/local_package_pyproject_toml'}
362366
remote: gunicorn.egg-link:/tmp/build_.+/.heroku/python/src/gunicorn
363367
remote: local-package-setup-py.egg-link:/tmp/build_.+/packages/local_package_setup_py
368+
remote: _pipenv_editable.pth:/tmp/build_.+
364369
remote:
365370
remote: Running entrypoint for the pyproject.toml-based local package: Hello pyproject.toml!
366371
remote: Running entrypoint for the setup.py-based local package: Hello setup.py!
@@ -371,6 +376,7 @@
371376
remote: __editable___local_package_pyproject_toml_0_0_1_finder.py:/tmp/build_.+/packages/local_package_pyproject_toml/local_package_pyproject_toml'}
372377
remote: gunicorn.egg-link:/tmp/build_.+/.heroku/python/src/gunicorn
373378
remote: local-package-setup-py.egg-link:/tmp/build_.+/packages/local_package_setup_py
379+
remote: _pipenv_editable.pth:/tmp/build_.+
374380
remote:
375381
remote: Running entrypoint for the pyproject.toml-based local package: Hello pyproject.toml!
376382
remote: Running entrypoint for the setup.py-based local package: Hello setup.py!
@@ -384,6 +390,7 @@
384390
__editable___local_package_pyproject_toml_0_0_1_finder.py:/app/packages/local_package_pyproject_toml/local_package_pyproject_toml'}
385391
gunicorn.egg-link:/app/.heroku/python/src/gunicorn
386392
local-package-setup-py.egg-link:/app/packages/local_package_setup_py
393+
_pipenv_editable.pth:/app
387394
388395
Running entrypoint for the pyproject.toml-based local package: Hello pyproject.toml!
389396
Running entrypoint for the setup.py-based local package: Hello setup.py!
@@ -394,12 +401,15 @@
394401
app.commit!
395402
app.push!
396403
expect(clean_output(app.output)).to match(Regexp.new(<<~REGEX))
404+
remote: -----> Installing dependencies using 'pipenv install --deploy'
405+
remote: Installing dependencies from Pipfile.lock \\(.+\\)...
397406
remote: -----> Running bin/post_compile hook
398407
remote: easy-install.pth:/tmp/build_.+/.heroku/python/src/gunicorn
399408
remote: easy-install.pth:/tmp/build_.+/packages/local_package_setup_py
400409
remote: __editable___local_package_pyproject_toml_0_0_1_finder.py:/tmp/build_.+/packages/local_package_pyproject_toml/local_package_pyproject_toml'}
401410
remote: gunicorn.egg-link:/tmp/build_.+/.heroku/python/src/gunicorn
402411
remote: local-package-setup-py.egg-link:/tmp/build_.+/packages/local_package_setup_py
412+
remote: _pipenv_editable.pth:/tmp/build_.+
403413
remote:
404414
remote: Running entrypoint for the pyproject.toml-based local package: Hello pyproject.toml!
405415
remote: Running entrypoint for the setup.py-based local package: Hello setup.py!
@@ -410,6 +420,7 @@
410420
remote: __editable___local_package_pyproject_toml_0_0_1_finder.py:/tmp/build_.+/packages/local_package_pyproject_toml/local_package_pyproject_toml'}
411421
remote: gunicorn.egg-link:/tmp/build_.+/.heroku/python/src/gunicorn
412422
remote: local-package-setup-py.egg-link:/tmp/build_.+/packages/local_package_setup_py
423+
remote: _pipenv_editable.pth:/tmp/build_.+
413424
remote:
414425
remote: Running entrypoint for the pyproject.toml-based local package: Hello pyproject.toml!
415426
remote: Running entrypoint for the setup.py-based local package: Hello setup.py!

0 commit comments

Comments
 (0)