40
40
import pkg_resources
41
41
42
42
BLINKA_LIBRARIES = [
43
- "adafruit_blinka " ,
44
- "adafruit_blinka_bleio " ,
45
- "adafruit_blinka_displayio " ,
46
- "adafruit_blinka_pyportal " ,
47
- "adafruit_python_extended_bus " ,
43
+ "adafruit-blinka " ,
44
+ "adafruit-blinka-bleio " ,
45
+ "adafruit-blinka-displayio " ,
46
+ "adafruit-blinka-pyportal " ,
47
+ "adafruit-python-extended-bus " ,
48
48
"numpy" ,
49
49
"pillow" ,
50
50
"pyasn1" ,
51
51
"pyserial" ,
52
52
"scipy" ,
53
+ "spidev" ,
53
54
]
54
55
55
56
def normalize_dist_name (name : str ) -> str :
56
- return name .lower ().replace ("-" , "_" )
57
+ """Return a normalized pip name"""
58
+ return name .lower ().replace ("_" , "-" )
57
59
58
60
def add_file (bundle , src_file , zip_name ):
59
61
bundle .write (src_file , zip_name )
@@ -70,7 +72,7 @@ def get_module_name(library_path):
70
72
repo = repo .stdout .decode ("utf-8" , errors = "ignore" ).strip ().lower ()
71
73
if repo [- 4 :] == ".git" :
72
74
repo = repo [:- 4 ]
73
- module_name = repo .split ("/" )[- 1 ]. replace ( "_" , "-" )
75
+ module_name = normalize_dist_name ( repo .split ("/" )[- 1 ])
74
76
75
77
# circuitpython org repos are deployed to pypi without "org" in the pypi name
76
78
module_name = re .sub (r"^circuitpython-org-" , "circuitpython-" , module_name )
@@ -83,8 +85,8 @@ def get_bundle_requirements(directory, package_list):
83
85
Return the list
84
86
"""
85
87
86
- pypi_reqs = [] # For multiple bundle dependency
87
- dependencies = [] # For intra-bundle dependency
88
+ pypi_reqs = set () # For multiple bundle dependency
89
+ dependencies = set () # For intra-bundle dependency
88
90
89
91
path = directory + "/requirements.txt"
90
92
if os .path .exists (path ):
@@ -97,15 +99,16 @@ def get_bundle_requirements(directory, package_list):
97
99
# skip comments
98
100
pass
99
101
else :
100
- if any (operators in line for operators in [">" , "<" , "=" ]):
101
- # Remove everything after any pip style version specifiers
102
- line = re .split ("[<|>|=|]" , line )[0 ]
103
- line = normalize_dist_name (line )
104
- if line not in dependencies and line in package_list :
105
- dependencies .append (package_list [line ]["module_name" ])
106
- elif line not in pypi_reqs and line not in BLINKA_LIBRARIES :
107
- pypi_reqs .append (line )
108
- return dependencies , pypi_reqs
102
+ # Remove any pip version and platform specifiers
103
+ original_name = re .split ("[<>=~[;]" , line )[0 ].strip ()
104
+ # Normalize to match the indexes in package_list
105
+ line = normalize_dist_name (original_name )
106
+ if line in package_list :
107
+ dependencies .add (package_list [line ]["module_name" ])
108
+ elif line not in BLINKA_LIBRARIES :
109
+ # add with the exact spelling from requirements.txt
110
+ pypi_reqs .add (original_name )
111
+ return sorted (dependencies ), sorted (pypi_reqs )
109
112
110
113
def build_bundle_json (libs , bundle_version , output_filename , package_folder_prefix ):
111
114
"""
@@ -137,7 +140,7 @@ def build_bundle_json(libs, bundle_version, output_filename, package_folder_pref
137
140
library ["dependencies" ], library ["external_dependencies" ] = get_bundle_requirements (packages [id ]["library_path" ], packages )
138
141
library_submodules [packages [id ]["module_name" ]] = library
139
142
out_file = open (output_filename , "w" )
140
- json .dump (library_submodules , out_file )
143
+ json .dump (library_submodules , out_file , sort_keys = True )
141
144
out_file .close ()
142
145
143
146
def build_bundle (libs , bundle_version , output_filename , package_folder_prefix ,
0 commit comments