-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Improve how we manage which PDM to use
Move our PDM version pin to a separate file. This both makes it easier to manage updates to the same and also allows the pinned version to be usable outside of the venv_sync script. Add a simple script to update version pins in this file. Teach venv_upgrade to use this to update the PDM version pin in addition to updating the PDM lock file. Also, modify venv_sync to tell PDM to not complain about newer versions.
- Loading branch information
1 parent
f164831
commit 3a05c50
Showing
4 changed files
with
80 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
# This file describes does NOT describe the requirements for Drake itself, but | ||
# for setting up the Python virtual environment that Drake will manage. It is | ||
# used by Drake's @python, and also when preparing a virtual environment to | ||
# support a Drake installation. | ||
# | ||
# Specific version pins in this file are updated automatically by | ||
# tools/workspace/python/venv_upgrade. | ||
|
||
# TODO(jeremy.nimmer) Ideally, we also would pin all of the dependencies of | ||
# PDM here, but it's not obvious to me how to do that in a way which is easy to | ||
# upgrade/re-pin over time. | ||
pdm==2.22.0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
#!/usr/bin/env python3 | ||
|
||
import json | ||
import sys | ||
import urllib.request | ||
|
||
|
||
def get_latest_version(name): | ||
r = urllib.request.urlopen(f'https://pypi.org/pypi/{name}/json') | ||
d = json.loads(r.read()) | ||
return d['info']['version'] | ||
|
||
|
||
def update_requirements(requirements_path): | ||
updated = False | ||
|
||
lines = [] | ||
with open(requirements_path, 'r') as f: | ||
for line in f: | ||
line = line.strip() | ||
|
||
if not line.startswith('#') and '==' in line: | ||
name, current = line.split('==') | ||
latest = get_latest_version(name) | ||
if latest != current: | ||
line = f'{name}=={latest}' | ||
updated = True | ||
|
||
lines.append(line) | ||
|
||
if updated: | ||
with open(requirements_path, 'w') as f: | ||
f.write('\n'.join(lines)) | ||
print(requirements_path) | ||
|
||
|
||
def main(args): | ||
for p in args: | ||
update_requirements(p) | ||
|
||
|
||
if __name__ == '__main__': | ||
main(sys.argv[1:]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters