Skip to content

Commit 007edd4

Browse files
committed
Upgraded conda to uv.
1 parent 8f6666e commit 007edd4

File tree

8 files changed

+46
-109
lines changed

8 files changed

+46
-109
lines changed

.github/workflows/ns.py-test.yml

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,23 @@ jobs:
1515
runs-on: ubuntu-latest
1616

1717
steps:
18-
- uses: actions/checkout@v2
18+
- uses: actions/checkout@v5
1919

20-
- name: Install dependencies
21-
run: |
22-
sudo apt install -y python3-pip git
23-
pip3 install -r requirements.txt --upgrade
24-
pip3 install .
20+
- name: Install uv
21+
uses: astral-sh/setup-uv@v3
22+
with:
23+
version: "latest"
24+
25+
- name: Set up Python
26+
id: setup-python
27+
uses: actions/setup-python@v5
28+
with:
29+
python-version: "3.13"
30+
31+
- name: Sync dependencies
32+
run: uv sync --python 3.13
2533

2634
- name: Running the examples
2735
run: |
2836
cd examples
29-
find . -name '*.py' -exec python {} \;
37+
find . -name '*.py' -exec uv run python {} \;

.github/workflows/pypi_publish.yml

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
1-
# This workflows will upload a Python Package using Twine when a release is created.
1+
# This workflow uploads the ns.py Python package using uv when a release is created.
22

33
name: Upload the ns.py Python Package to PyPI
4+
permissions:
5+
contents: read
6+
pull-requests: read
47

58
on:
69
release:
@@ -13,23 +16,20 @@ jobs:
1316

1417
steps:
1518
- name: Checkout repository
16-
uses: actions/checkout@v2
19+
uses: actions/checkout@v5
1720

18-
- name: Set up Python
19-
uses: actions/setup-python@v2
21+
- name: Install uv
22+
uses: astral-sh/setup-uv@v3
2023
with:
21-
python-version: 3.x
24+
version: "latest"
2225

23-
- name: Install dependencies
24-
run: |
25-
python -m pip install --upgrade pip
26-
pip install setuptools wheel twine
26+
- name: Set up Python
27+
uses: actions/setup-python@v5
28+
with:
29+
python-version: "3.13"
2730

2831
- name: Build package
29-
run: python setup.py sdist bdist_wheel
32+
run: uv build
3033

3134
- name: Publish package to PyPI
32-
uses: pypa/gh-action-pypi-publish@release/v1
33-
with:
34-
user: __token__
35-
password: ${{ secrets.PYPI_API_TOKEN }}
35+
run: uv publish --token ${{ secrets.PYPI_API_TOKEN }}

.gitignore

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -81,9 +81,6 @@ target/
8181
profile_default/
8282
ipython_config.py
8383

84-
# pyenv
85-
.python-version
86-
8784
# pipenv
8885
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
8986
# However, in case of collaboration, if having platform-specific dependencies or dependencies

README.md

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -4,25 +4,28 @@ This discrete-event network simulator is based on [`simpy`](https://simpy.readth
44

55
## Installation
66

7-
First, launch the terminal and create a new `conda` environment (say, called `ns.py`):
7+
### From PyPI
88

99
```shell
10-
$ conda update conda
11-
$ conda create -n ns.py python=3.9
12-
$ conda activate ns.py
10+
pip install ns.py
1311
```
1412

15-
Then, install `ns.py` using `pip`:
13+
### Local development with uv
1614

17-
```shell
18-
$ pip install ns.py
19-
```
15+
1. Install [uv](https://docs.astral.sh/uv/getting-started/installation/) if it's not already on your machine.
16+
2. Sync the project and provision a Python 3.13 virtual environment:
2017

21-
That's it! You can now try to run some examples in the `examples/` directory. To upgrade Python packages in the current environment, run the command:
18+
```shell
19+
uv sync
20+
```
2221

23-
```shell
24-
$ python upgrade_packages.py
25-
```
22+
3. Run commands through `uv run` so they pick up the synced environment. For example:
23+
24+
```shell
25+
uv run examples/basic.py
26+
```
27+
28+
`uv sync` installs `ns.py` in editable mode along with its dependencies, so subsequent `uv run …` invocations (tests, builds, examples) share the exact same interpreter and packages.
2629

2730
## Current network components
2831

@@ -90,8 +93,6 @@ The network components that have already been implemented include:
9093

9194
## Current examples (in increasing levels of complexity)
9295

93-
Some of these examples requires installing `matplotlib`. It has not been included in the list of dependencies in `ns.py`, and needs to be installed separately in the current Python environment.
94-
9596
* `basic.py`: A basic example that connects two packet generators to a network wire with a propagation delay distribution, and then to a packet sink. It showcases `DistPacketGenerator`, `PacketSink`, and `Wire`.
9697

9798
* `overloaded_switch.py`: an example that contains a packet generator connected to a downstream switch port, which is then connected to a packet sink. It showcases `DistPacketGenerator`, `PacketSink`, and `Port`.
@@ -126,7 +127,7 @@ Similar to the emulation mode in the ns-3 simulator, `ns.py` supports an *emulat
126127
<img src="https://github.com/TL-System/ns.py/blob/main/docs/emulation/emulation_mode.svg" alt="High-level overview of ns.py's emulation mode"/>
127128
</p>
128129

129-
`examples/real_traffic/proxy.py` has been provided as an example that shows how a real-world client and server can communicate using a simulated network environment as the proxy, and how `ProxyPacketGenerator` and `ProxySink` are to be used to achieve this objective.
130+
`examples/real_traffic/proxy.py` has been provided as an example that shows how a real-world client and server can communicate using a simulated network environment as the proxy, and how `ProxyPacketGenerator` and `ProxySink` are to be used to achieve this objective.
130131

131132
### Testing the emulation mode with simple TCP and UDP echo servers
132133

@@ -285,4 +286,3 @@ self.deficit[flow_id] += self.quantum[flow_id]
285286
```
286287

287288
Most often, the mapping between flow IDs and per-flow parameters, such as weights in a Weighted Fair Queueing scheduler or priorities in a Static Priority scheduler, need to be stored in a dictionary, and then used to initialized these schedulers. An optional (but not recommended) style is to assign consecutive integers as flow IDs to the flows throughout the entire network, and then use simple lists of per-flow parameters to initialize the schedulers. In this case, flow IDs will be directly used as indices to look up these lists to find the parameter values.
288-

ns/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
__version__ = "0.4.3"
1+
__version__ = "0.4.4"

requirements.txt

Lines changed: 0 additions & 3 deletions
This file was deleted.

setup.py

Lines changed: 0 additions & 59 deletions
This file was deleted.

upgrade_packages.py

Lines changed: 0 additions & 6 deletions
This file was deleted.

0 commit comments

Comments
 (0)