Skip to content

Commit bd387fd

Browse files
author
Susan Vanderplas
committed
Write my own versionless requirements assembly code in py-deps, ensure py-system-pkgs is read only.
1 parent e25d471 commit bd387fd

File tree

3 files changed

+217
-101
lines changed

3 files changed

+217
-101
lines changed

py-deps

+37-1
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,46 @@
11
#!/bin/bash
2+
set_union () {
3+
sort $1 $2 | uniq
4+
}
5+
6+
set_intersection () {
7+
sort $1 $2 | uniq -d
8+
}
9+
10+
set_difference () {
11+
sort $1 $2 $2 | uniq -u
12+
}
13+
14+
set_symmetric_difference() {
15+
sort $1 $2 | uniq -u
16+
}
217

18+
FindRequirements() {
19+
grep -r "from .* import .*" --include "*.qmd" . | awk '{ match( $0, /:from ([A-z0-9]*).?.*? import .*$/, arr) ; if(arr[1] != "") print arr[1] } ' | sort | uniq > py-imports
20+
grep -r "import .* as .*" --include "*.qmd" . | awk '{ match( $0, /:import ([A-z0-9]*).?.*? as .*$/, arr) ; if(arr[1] != "") print arr[1] } ' | sort | uniq >> py-imports
21+
grep -r "import .*" --include "*.qmd" . | awk '{ match( $0, /:import ([A-z0-9]*).*$/, arr) ; if(arr[1] != "") print arr[1] } ' | sort | uniq >> py-imports
22+
# deduplicate
23+
cat requirements.txt >> py-imports
24+
cat py-imports | sort | uniq > py-imports-clean
25+
26+
# replace PIL with pillow... ugh python sucks
27+
sed -i -e 's/^PIL$/pillow/g' py-imports-clean
28+
# replace sklearn with scikit-learn
29+
sed -i -e 's/^sklearn$/scikit-learn/g' py-imports-clean
30+
31+
32+
set_difference py-imports-clean py-system-pkgs > py-imports-install
33+
34+
rm py-imports py-imports-clean
35+
mv py-imports-install requirements.txt
36+
}
337

438
SetRequirements() {
539
# Update dependencies required by the book
640
# pipdeptree -r -f --warn silence | grep -E '^[a-zA-Z0-9\-]+' > requirements.txt
7-
pip3 freeze > requirements.txt
41+
pip-chill --no-version > requirements.txt
42+
FindRequirements
43+
844
echo "Requirements file updated successfully!"
945
}
1046

py-system-pkgs

+159
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,159 @@
1+
2+
string
3+
re
4+
difflib
5+
textwrap
6+
unicodedata
7+
stringprep
8+
readline
9+
rlcompleter
10+
struct
11+
codecs
12+
datetime
13+
zoneinfo
14+
calendar
15+
collections
16+
heapq
17+
bisect
18+
array
19+
weakref
20+
types
21+
copy
22+
pprint
23+
reprlib
24+
enum
25+
graphlib
26+
numbers
27+
math
28+
cmath
29+
decimal
30+
fractions
31+
random
32+
statistics
33+
itertools
34+
functools
35+
operator
36+
pathlib
37+
os
38+
fileinput
39+
stat
40+
filecmp
41+
tempfile
42+
glob
43+
fnmatch
44+
linecache
45+
shutil
46+
pickle
47+
copyreg
48+
shelve
49+
marshal
50+
dbm
51+
sqlite3
52+
zlib
53+
gzip
54+
bz2
55+
lzma
56+
zipfile
57+
tarfile
58+
csv
59+
configparser
60+
tomllib
61+
netrc
62+
plist
63+
hashlib
64+
hmac
65+
secrets
66+
io
67+
time
68+
argparse
69+
getopt
70+
logging
71+
getpass
72+
curses
73+
platform
74+
errno
75+
ctypes
76+
threading
77+
multiprocessing
78+
concurrent
79+
subprocess
80+
sched
81+
queue
82+
contextvars
83+
asyncio
84+
socket
85+
ssl
86+
select
87+
selectors
88+
signal
89+
mmap
90+
email
91+
json
92+
mailbox
93+
mimetypes
94+
base64
95+
binascii
96+
quopri
97+
html
98+
urllib
99+
wsgiref
100+
webbrowser
101+
ftplib
102+
poplib
103+
imaplib
104+
smtplib
105+
uuid
106+
socketserver
107+
xmlrpc
108+
ipaddress
109+
wave
110+
colorsys
111+
gettext
112+
locale
113+
turtle
114+
cmd
115+
shlex
116+
tkinter
117+
typing
118+
pydoc
119+
doctest
120+
unittest
121+
test
122+
bdb
123+
faulthandler
124+
pdb
125+
timeit
126+
trace
127+
tracemalloc
128+
ensurepip
129+
venv
130+
zipapp
131+
sys
132+
sysconfig
133+
builtins
134+
warnings
135+
dataclasses
136+
contextlib
137+
abc
138+
atexit
139+
traceback
140+
gc
141+
inspect
142+
site
143+
code
144+
codeop
145+
zipimport
146+
pkgutil
147+
modulefinder
148+
runpy
149+
importlib
150+
ast
151+
symtable
152+
token
153+
keyword
154+
tokenize
155+
tabnanny
156+
pyclbr
157+
compileall
158+
dis
159+
pickletools

requirements.txt

+21-100
Original file line numberDiff line numberDiff line change
@@ -1,100 +1,21 @@
1-
annotated-types==0.7.0
2-
anyio==4.4.0
3-
asttokens==2.4.1
4-
attrs==24.2.0
5-
beartype==0.18.5
6-
beautifulsoup4==4.12.3
7-
bs4==0.0.2
8-
certifi==2024.8.30
9-
charset-normalizer==3.3.2
10-
click==8.1.7
11-
colorama==0.4.6
12-
comm==0.2.2
13-
contourpy==1.3.0
14-
cycler==0.12.1
15-
DateTime==5.5
16-
debugpy==1.8.5
17-
decorator==5.1.1
18-
distro==1.9.0
19-
executing==2.1.0
20-
fonttools==4.53.1
21-
griffe==1.3.1
22-
h11==0.14.0
23-
httpcore==1.0.5
24-
httpx==0.27.2
25-
idna==3.10
26-
importlib_metadata==8.5.0
27-
importlib_resources==6.4.5
28-
ipykernel==6.29.5
29-
ipython==8.27.0
30-
jedi==0.19.1
31-
jiter==0.5.0
32-
jsonschema==4.23.0
33-
jsonschema-specifications==2023.12.1
34-
jupyter_client==8.6.3
35-
jupyter_core==5.7.2
36-
kiwisolver==1.4.7
37-
markdown-it-py==3.0.0
38-
matplotlib==3.9.2
39-
matplotlib-inline==0.1.7
40-
mdurl==0.1.2
41-
mizani==0.12.2
42-
nest-asyncio==1.6.0
43-
numpy==2.1.1
44-
openai==1.45.1
45-
packaging==24.1
46-
palmerpenguins==0.1.4
47-
pandas==2.2.2
48-
parso==0.8.4
49-
pathlib==1.0.1
50-
patsy==0.5.6
51-
pexpect==4.9.0
52-
pillow==10.4.0
53-
pipdeptree==2.23.3
54-
platformdirs==4.3.3
55-
plotly==5.24.1
56-
plotnine==0.13.6
57-
plum-dispatch==2.5.2
58-
polars==1.7.1
59-
prompt_toolkit==3.0.47
60-
psutil==6.0.0
61-
ptyprocess==0.7.0
62-
pure_eval==0.2.3
63-
pyarrow==17.0.0
64-
pydantic==2.9.1
65-
pydantic_core==2.23.4
66-
Pygments==2.18.0
67-
pyparsing==3.1.4
68-
pyreadr==0.5.2
69-
python-dateutil==2.9.0.post0
70-
python-dotenv==1.0.1
71-
pytz==2024.2
72-
PyYAML==6.0.2
73-
pyzmq==26.2.0
74-
quartodoc==0.7.6
75-
referencing==0.35.1
76-
requests==2.32.3
77-
rich==13.8.1
78-
rpds-py==0.20.0
79-
scipy==1.14.1
80-
seaborn==0.13.2
81-
six==1.16.0
82-
skimpy==0.0.15
83-
sniffio==1.3.1
84-
soupsieve==2.6
85-
sphobjinv==2.3.1.1
86-
stack-data==0.6.3
87-
statsmodels==0.14.3
88-
tabulate==0.9.0
89-
tenacity==9.0.0
90-
tornado==6.4.1
91-
tqdm==4.66.5
92-
traitlets==5.14.3
93-
typeguard==4.3.0
94-
typing_extensions==4.12.2
95-
tzdata==2024.1
96-
urllib3==2.2.3
97-
watchdog==5.0.2
98-
wcwidth==0.2.13
99-
zipp==3.20.2
100-
zope.interface==7.0.3
1+
astropy
2+
babel
3+
bs4
4+
gspread
5+
IPython
6+
matplotlib
7+
numpy
8+
nycflights13
9+
palmerpenguins
10+
pandas
11+
pandas_access
12+
pillow
13+
plotly
14+
plotnine
15+
polars
16+
pyreadr
17+
requests
18+
seaborn
19+
skimpy
20+
statsmodels
21+
tabulate

0 commit comments

Comments
 (0)