Skip to content

Commit b0fa355

Browse files
authored
Merge pull request #1630 from carver/pretest-packaging
Add `make package` target to test packaged release
2 parents eb6e9c6 + 1e02eb3 commit b0fa355

File tree

3 files changed

+94
-10
lines changed

3 files changed

+94
-10
lines changed

Makefile

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,10 @@ docs: build-docs
5151
linux-docs: build-docs
5252
readlink -f docs/_build/html/index.html
5353

54+
package: clean
55+
python setup.py sdist bdist_wheel
56+
python scripts/release/test_package.py
57+
5458
release: clean
5559
CURRENT_SIGN_SETTING=$(git config commit.gpgSign)
5660
git config commit.gpgSign true

docs/contributing.rst

Lines changed: 37 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,9 @@ GitHub interface and make sure all tests are passing. In general pull requests t
9191
Releasing
9292
~~~~~~~~~
9393

94+
One time setup
95+
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
96+
9497
Pandoc is required for transforming the markdown README to the proper
9598
format to render correctly on pypi.
9699

@@ -106,30 +109,54 @@ Or on OSX:
106109
107110
brew install pandoc
108111
109-
To release a new version:
112+
Final test before each release
113+
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
114+
115+
Before releasing a new version, build and test the package that will be released:
116+
117+
.. code:: sh
118+
119+
git checkout master && git pull
120+
121+
make package
122+
123+
# in another shell, navigate to the virtualenv mentioned in output of ^
124+
125+
# load the virtualenv with the packaged trinity release
126+
source package-smoke-test/bin/activate
127+
128+
# smoke test the release
129+
trinity --ropsten
130+
131+
Push the release to github & pypi
132+
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
133+
134+
After confirming that the release package looks okay, release a new version:
110135

111136
.. code:: sh
112137
113-
bumpversion $$VERSION_PART_TO_BUMP$$
114-
git push && git push --tags
115-
make release
138+
make release bump=$$VERSION_PART_TO_BUMP$$
139+
140+
# While trinity and py-evm are colocated,
141+
# manually change trinity & py-evm version in setup_trinity.py
142+
make release-trinity
116143
117-
How to bumpversion
118-
^^^^^^^^^^^^^^^^^^
144+
Which version part to bump
145+
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
119146

120147
The version format for this repo is ``{major}.{minor}.{patch}`` for
121148
stable, and ``{major}.{minor}.{patch}-{stage}.{devnum}`` for unstable
122149
(``stage`` can be alpha or beta).
123150

124-
To issue the next version in line, use bumpversion and specify which
125-
part to bump, like ``bumpversion minor`` or ``bumpversion devnum``.
151+
During a release, specify which part to bump, like
152+
``make release bump=minor`` or ``make release bump=devnum``.
126153

127-
If you are in a beta version, ``bumpversion stage`` will switch to a
154+
If you are in a beta version, ``make release bump=stage`` will switch to a
128155
stable.
129156

130157
To issue an unstable version when the current version is stable, specify
131158
the new version explicitly, like
132-
``bumpversion --new-version 4.0.0-alpha.1 devnum``
159+
``make release bump="--new-version 4.0.0-alpha.1 devnum"``
133160

134161

135162
How to release docker images

scripts/release/test_package.py

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
from pathlib import Path
2+
import subprocess
3+
from tempfile import TemporaryDirectory
4+
import venv
5+
6+
7+
def create_venv(parent_path):
8+
venv_path = parent_path / 'package-smoke-test'
9+
venv.create(venv_path, with_pip=True)
10+
subprocess.run([venv_path / 'bin' / 'pip', 'install', '-U', 'pip', 'setuptools'], check=True)
11+
return venv_path
12+
13+
14+
def find_wheel(project_path):
15+
wheels = list(project_path.glob('dist/*.whl'))
16+
17+
if len(wheels) != 1:
18+
raise Exception(
19+
f"Expected one wheel. Instead found: {wheels} in project {project_path.absolute()}"
20+
)
21+
22+
return wheels[0]
23+
24+
25+
def install_wheel(venv_path, wheel_path, extras=tuple()):
26+
if extras:
27+
extra_suffix = f"[{','.join(extras)}]"
28+
else:
29+
extra_suffix = ""
30+
31+
subprocess.run(
32+
[
33+
venv_path / 'bin' / 'pip',
34+
'install',
35+
f"{wheel_path}{extra_suffix}"
36+
],
37+
check=True,
38+
)
39+
40+
41+
def test_install_local_wheel():
42+
temporary_dir = TemporaryDirectory()
43+
venv_path = create_venv(Path(temporary_dir.name))
44+
wheel_path = find_wheel(Path('.'))
45+
install_wheel(venv_path, wheel_path, extras=['p2p', 'trinity'])
46+
print("Installed", wheel_path.absolute(), "to", venv_path)
47+
print(f"Activate with `source {venv_path}/bin/activate`")
48+
input("Press enter when the test has completed. The directory will be deleted.")
49+
temporary_dir.cleanup()
50+
51+
52+
if __name__ == '__main__':
53+
test_install_local_wheel()

0 commit comments

Comments
 (0)