/
Transcript_of_installation_and_testing.txt
144 lines (109 loc) · 5.92 KB
/
Transcript_of_installation_and_testing.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
# cd into development directory
% pwd
/path/to/demo-package-sample-data-with-code
# create virtual environment in development directory and activate it
% python3 -m venv venv
% source venv/bin/activate
# upgrade pip within virtual environment
(venv) % python -m pip install --upgrade pip
Requirement already satisfied: pip in ./venv/lib/python3.9/site-packages (22.0.4)
# pip list shows that only pip and setuptools are loaded into virtual environment
(venv) % pip list
Package Version
---------- -------
pip 22.0.4
setuptools 60.10.0
# LOCAL install for development purposes
# install the package contained in the current directory (“.”) in “editable/development mode”
(venv) % pip install -e .
Obtaining file:///path/to/demo-package-sample-data-with-code
…
Installing collected packages: demo-package-sample-data-with-code
Running setup.py develop for demo-package-sample-data-with-code
Successfully installed demo-package-sample-data-with-code-0.0.1
# Use pip list to confirm that our package is now loaded
(venv) % pip list
Package Version Editable project location
---------------------------------- ------- ----------------------------------------------------------------------------------------
demo-package-sample-data-with-code 0.0.1 /path/to/demo-package-sample-data-with-code/src
pip 22.0.4
setuptools 60.10.0
# Test the package by invoking it with python -m
(venv) % python -m demo_package_sample_data_with_code
I am here, in __main__.py.
# # # # # # # # # # # # # # #
π: 3.14159265358979323846
e: 2.71828182845904523536
Oops! The data file «meaning_of_life.txt» wasn’t found at this location:
»» /path/to/demo-package-sample-data-with-code/src/demo_package_sample_data_with_code/sample_data/meaning_of_life.txt.
[Errno 2] No such file or directory: '/path/to/demo-package-sample-data-with-code/src/demo_package_sample_data_with_code/sample_data/meaning_of_life.txt'
Meaning of life: I have no clue 🤪
* * * * * * * * * * * * * * *
# The above was the expected/desired/correct output (including the “Oops!”, which was a deliberate exception).
# Prepare for PyPI
# Install `build` into virtual environment
(venv) % python -m pip install --upgrade build
Successfully installed build-0.7.0 packaging-21.3 pep517-0.12.0 pyparsing-3.0.8 tomli-2.0.1
# Build the package to be uploaded to PyPI
(venv) % python -m build
# NOTE: If your MANIFEST.in file isn’t correct, you might be asking for sample-data files that can’t be found.
# So be on the lookout for the following kind of warnings in the output to “% python -m build”:
warning: no files found matching 'src/demo_package_and_read_data_files/sample_data_pi.txt'
warning: no files found matching 'src/demo_package_and_read_data_files/sample_data/sample_data_e.txt'
(venv) % python -m build
…
Successfully built demo-package-sample-data-with-code-0.0.1.tar.gz and demo_package_sample_data_with_code-0.0.1-py39-none-any.whl
# Install twine in virtual environment
(venv) % python -m pip install --upgrade twine
# Use `twine` to check the distribution files
% twine check dist/*
Checking dist/demo_package_and_read_data_files-0.0.1-py39-none-any.whl: PASSED
Checking dist/demo_package_and_read_data_files-0.0.1.tar.gz: PASSED
# Upload the distribution packages in dist/ to TestPyPI using twine
(venv) % python -m twine upload --repository testpypi dist/*
Uploading distributions to https://test.pypi.org/legacy/
Enter your username: myusername
Enter your password:
Uploading demo_package_sample_data_with_code-0.0.1-py39-none-any.whl
100% ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 52.6/52.6 kB • 00:00 • 51.6 MB/s
Uploading demo-package-sample-data-with-code-0.0.1.tar.gz
100% ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 71.3/71.3 kB • 00:00 • 34.1 MB/s
View at:
https://test.pypi.org/project/demo-package-sample-data-with-code/0.0.1/
# Deactivate the current virtual environment
(venv) % deactivate
# Create new directory in which to test the TestPyPI package.
% cd /some/new/path/
% mkdir testbed
# Enter the new test-bed directory
% cd /some/new/path/testbed
#Create new virtual environment
% python3 -m venv venv
% source venv/bin/activate
(venv) % python -m pip install --upgrade pip
Requirement already satisfied: pip in ./venv/lib/python3.9/site-packages (22.0.4)
# Install project from TestPyPI using link provided on project homepage
(venv) % pip install -i https://test.pypi.org/simple/ demo-package-sample-data-with-code==0.0.1
Looking in indexes: https://test.pypi.org/simple/
Collecting demo-package-sample-data-with-code==0.0.1
Downloading https://test-files.pythonhosted.org/packages/cd/e5/ … /demo_package_sample_data_with_code-0.0.1-py39-none-any.whl (17 kB)
Installing collected packages: demo-package-sample-data-with-code
Successfully installed demo-package-sample-data-with-code-0.0.1
# Confirm it’s installed
(venv) % pip list
Package Version
---------------------------------- -------
demo-package-sample-data-with-code 0.0.1
pip 22.0.4
setuptools 60.10.0
# Test the package by invoking it with python -m
(venv) % python -m demo_package_sample_data_with_code
I am here, in __main__.py.
# # # # # # # # # # # # # # #
π: 3.14159265358979323846
e: 2.71828182845904523536
Oops! The data file «meaning_of_life.txt» wasn’t found at this location:
»» /path/to/test_bed_demo-package-sample-data-with-code/venv/lib/python3.9/site-packages/demo_package_sample_data_with_code/sample_data/meaning_of_life.txt.
[Errno 2] No such file or directory: '/path/to/test_bed_demo-package-sample-data-with-code/venv/lib/python3.9/site-packages/demo_package_sample_data_with_code/sample_data/meaning_of_life.txt'
Meaning of life: I have no clue 🤪
* * * * * * * * * * * * * * *