Skip to content

Commit eb1bc61

Browse files
author
James Campbell
committed
updates for uv management
1 parent cbf6d93 commit eb1bc61

File tree

8 files changed

+2064
-2607
lines changed

8 files changed

+2064
-2607
lines changed
Lines changed: 4 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,9 @@
1-
# For most projects, this workflow file will not need changing; you simply need
2-
# to commit it to your repository.
3-
#
4-
# You may wish to alter this file to override the set of languages analyzed,
5-
# or to provide custom queries or build logic.
6-
#
7-
# ******** NOTE ********
8-
# We have attempted to detect the languages in your repository. Please check
9-
# the `language` matrix defined below to confirm you have the correct set of
10-
# supported CodeQL languages.
11-
#
121
name: "CodeQL"
132

143
on:
154
push:
165
branches: [ "master" ]
176
pull_request:
18-
# The branches below must be a subset of the branches above
197
branches: [ "master" ]
208
schedule:
219
- cron: '38 22 * * 5'
@@ -33,40 +21,18 @@ jobs:
3321
fail-fast: false
3422
matrix:
3523
language: [ 'python' ]
36-
# CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python', 'ruby' ]
37-
# Learn more about CodeQL language support at https://aka.ms/codeql-docs/language-support
3824

3925
steps:
4026
- name: Checkout repository
41-
uses: actions/checkout@v3
27+
uses: actions/checkout@v4
4228

43-
# Initializes the CodeQL tools for scanning.
4429
- name: Initialize CodeQL
45-
uses: github/codeql-action/init@v2
30+
uses: github/codeql-action/init@v3
4631
with:
4732
languages: ${{ matrix.language }}
48-
# If you wish to specify custom queries, you can do so here or in a config file.
49-
# By default, queries listed here will override any specified in a config file.
50-
# Prefix the list here with "+" to use these queries and those in the config file.
51-
52-
# Details on CodeQL's query packs refer to : https://docs.github.com/en/code-security/code-scanning/automatically-scanning-your-code-for-vulnerabilities-and-errors/configuring-code-scanning#using-queries-in-ql-packs
53-
# queries: security-extended,security-and-quality
5433

55-
56-
# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
57-
# If this step fails, then you should remove it and run the build manually (see below)
5834
- name: Autobuild
59-
uses: github/codeql-action/autobuild@v2
60-
61-
# ℹ️ Command-line programs to run using the OS shell.
62-
# 📚 See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun
63-
64-
# If the Autobuild fails above, remove it and uncomment the following three lines.
65-
# modify them (or add more) to build your code if your project, please refer to the EXAMPLE below for guidance.
66-
67-
# - run: |
68-
# echo "Run, Build Application using script"
69-
# ./location_of_script_within_repo/buildscript.sh
35+
uses: github/codeql-action/autobuild@v3
7036

7137
- name: Perform CodeQL Analysis
72-
uses: github/codeql-action/analyze@v2
38+
uses: github/codeql-action/analyze@v3

.github/workflows/test.yml

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
name: Tests
2+
3+
on:
4+
push:
5+
branches: [ main, master ]
6+
pull_request:
7+
branches: [ main, master ]
8+
9+
jobs:
10+
test:
11+
runs-on: ubuntu-latest
12+
strategy:
13+
matrix:
14+
python-version: ["3.12", "3.11"]
15+
16+
steps:
17+
- uses: actions/checkout@v4
18+
19+
- name: Install uv
20+
uses: astral-sh/setup-uv@v3
21+
with:
22+
version: "latest"
23+
24+
- name: Set up Python ${{ matrix.python-version }}
25+
uses: actions/setup-python@v5
26+
with:
27+
python-version: ${{ matrix.python-version }}
28+
29+
- name: Install dependencies
30+
run: uv sync --dev
31+
32+
- name: Run tests
33+
run: uv run pytest
34+
35+
- name: Lint with flake8
36+
run: |
37+
uv run flake8 --count --select=E9,F63,F7,F82 --show-source --statistics
38+
uv run flake8 --count --exit-zero --max-complexity=10 --max-line-length=100 --statistics

.travis.yml

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

README.md

Lines changed: 76 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,61 @@
11
# python-examples
22

3-
<a href='https://travis-ci.org/jamesacampbell/python-examples'>![travis build status](https://travis-ci.org/jamesacampbell/python-examples.svg)</a>
4-
[![CircleCI](https://circleci.com/gh/jamesacampbell/python-examples/tree/master.svg?style=svg)](https://circleci.com/gh/jamesacampbell/python-examples/tree/master)
3+
[![CI](https://github.com/james-see/python-examples/workflows/Tests/badge.svg)](https://github.com/james-see/python-examples/actions)
4+
[![CodeQL](https://github.com/james-see/python-examples/workflows/CodeQL/badge.svg)](https://github.com/james-see/python-examples/actions)
55

66
This is a collection of python examples I created for some key libraries in Python that I use all the time.
77

88
It is a way for me to remember and hopefully get others started.
99

1010
Start your Python journey in Python 3. Onward and upward.
1111

12+
## 🚀 Quick Start
13+
14+
This project uses [uv](https://github.com/astral-sh/uv) for modern Python package management.
15+
16+
### Prerequisites
17+
18+
- Python 3.12 or higher
19+
- uv package manager (install via `curl -LsSf https://astral.sh/uv/install.sh | sh`)
20+
21+
### Installation
22+
23+
```bash
24+
# Clone the repository
25+
git clone https://github.com/james-see/python-examples.git
26+
cd python-examples
27+
28+
# Install dependencies
29+
uv sync --dev
30+
31+
# Run tests
32+
uv run pytest
33+
34+
# Run linting
35+
uv run flake8
36+
```
37+
38+
### Development
39+
40+
```bash
41+
# Add new dependencies
42+
uv add package-name
43+
44+
# Run a specific example
45+
uv run python example-name.py
46+
47+
# Format code
48+
uv run black .
49+
uv run isort .
50+
```
51+
52+
## 🛠️ Project Structure
53+
54+
- **python-examples/**: Main package containing all example scripts
55+
- **assets/**: Sample data files for examples
56+
- **tests/**: Test files
57+
- **.github/workflows/**: GitHub Actions for CI/CD
58+
1259
**urllib** (built-in to python3)
1360

1461
1. [access foursquare API](#foursquare-api-example)
@@ -19,36 +66,36 @@ Start your Python journey in Python 3. Onward and upward.
1966

2067
1. [http example](#http-example)
2168

22-
**pdfquery** (install by `pip3 install pdfquery --upgrade`)
69+
**pdfquery** (install by `uv add pdfquery`)
2370

2471
1. [pdfquery example](#pdfquery-example)
2572

26-
**PyPDF2** (install by `pip3 install PyPDF2 --upgrade`)
73+
**PyPDF2** (install by `uv add PyPDF2`)
2774

2875
1. [pdf merge example](#pdf-merge-example)
2976

30-
**argparse** (install by `pip3 install argparse --upgrade`)
77+
**argparse** (built-in to python3)
3178

3279
1. [argparse example](#argparse-example)
3380

34-
**bs4** ([package download link](http://www.crummy.com/software/BeautifulSoup/bs4/download/))
81+
**bs4** (install via `uv add beautifulsoup4`)
3582

3683
1. [html to text parser](#html-to-text-example)
3784
2. [email parser](#email-parser-example)
3885

39-
**fuzzywuzzy** (install by `pip3 install fuzzywuzzy --upgrade`)
86+
**fuzzywuzzy** (install by `uv add fuzzywuzzy`)
4087

4188
1. [fuzzywuzzy](#fuzzywuzzy-example)
4289

43-
**rethinkdb** (install by `pip3 install rethinkdb --upgrade`)
90+
**rethinkdb** (install by `uv add rethinkdb`)
4491

4592
1. [rethinkdb example](#rethinkdb-example)
4693

47-
**quandl** (install by `pip3 install quandl --upgrade`)
94+
**quandl** (install by `uv add quandl`)
4895

4996
1. [quandl api access example](#quandl-example)
5097

51-
**hug** (install by `pip3 install hug --upgrade`)
98+
**hug** (install by `uv add hug`)
5299

53100
1. [hug api access example](#hug-example)
54101

@@ -64,45 +111,45 @@ Start your Python journey in Python 3. Onward and upward.
64111

65112
1. [sha 256 hash example](#sha-example)
66113

67-
**nltk** (package download via pip3 install nltk)
114+
**nltk** (install via `uv add nltk`)
68115

69116
1. [sentiment analysis example](#sentiment-example)
70117

71-
**exifread** (package download via pip3 install exifread)
118+
**exifread** (install via `uv add exifread`)
72119

73120
1. [read exif example](#exifread-example)
74121

75-
**json** (package download via pip3 install json)
122+
**json** (built-in to python3)
76123

77124
1. [json to python object example](#json-to-python-object-example)
78125

79-
**urllib3** (package download via pip3 install urllib3 from homebrew osx brew install python3)
126+
**urllib3** (install via `uv add urllib3`)
80127

81128
1. [google mask search example](#google-mask-example)
82129
2. [urllib3 proxymanager example](#proxymanager-example)
83130

84-
**blockchain** (package download via pip3 install blockchain)
131+
**blockchain** (install via `uv add blockchain`)
85132

86133
1. [wallet query example](#bitcoin-wallet-example)
87134

88135
**PySocks** ([package download link](https://github.com/Anorov/PySocks))
89136

90137
1. [connect to tor and print .onion site](#tor-connect-example)
91138

92-
**shodan** (package download via pip install shodan)
139+
**shodan** (install via `uv add shodan`)
93140

94141
1. [shodan count example](#shodan-count-example)
95142
2. [google lat/long and shodan enrichment geo search example](#google-geo-and-shodan-example)
96143

97-
**websockify** (package download via pip(3) install websockify)
144+
**websockify** (install via `uv add websockify`)
98145

99146
1. [websockify example](#websockify-example)
100147

101148
**scrapy** ([package download link](http://scrapy.org/download/))
102149

103150
1. [crawl all internal links for a domain](#scrapy-spider-example)
104151

105-
**iptcinfo3** (download via pip3 install iptcinfo3)
152+
**iptcinfo3** (install via `uv add iptcinfo3`)
106153

107154
1. [iptcinfo3 example](#iptcinfo3-example)
108155

@@ -116,8 +163,8 @@ This example runs a web server to http://127.0.0.1:8000. Go to http://127.0.0.1:
116163

117164
#### Run the example
118165

119-
```python3
120-
python3 example-http-server.py
166+
```bash
167+
uv run python example-http-server.py
121168
```
122169

123170
This will output that it is running on port 8000.
@@ -128,8 +175,8 @@ This example takes in the first argument the name of the pdf you want to get tex
128175

129176
### Run the example
130177

131-
```python3
132-
python3 pdfquery-example.py mypdf.pdf
178+
```bash
179+
uv run python pdfquery-example.py mypdf.pdf
133180
```
134181

135182
This will output the text of the pdf to stdout if it contains any.
@@ -142,14 +189,14 @@ This example reads in a list of pdfs, you can specify the prefix of the list of
142189

143190
To get the help file:
144191

145-
```python3
146-
python3 merge-pdfs-example.py -h
192+
```bash
193+
uv run python merge-pdfs-example.py -h
147194
```
148195

149196
To run it on a list of pdfs with prefix `test` and output `final.pdf`:
150197

151-
```python3
152-
python3 merge-pdfs-example.py -p test -o final.pdf
198+
```bash
199+
uv run python merge-pdfs-example.py -p test -o final.pdf
153200
```
154201

155202
## Pattern Twitter Search Example
@@ -236,10 +283,10 @@ This will output a html string that is encoded into base64.
236283
## Html to Text Example
237284

238285
Beautiful Soup is a great library to parse and select html or iterate through the DOM.
239-
For this example to work you need to install Beautiful Soup via pip:
286+
For this example to work you need to install Beautiful Soup:
240287

241-
```python3
242-
pip install bs4
288+
```bash
289+
uv add beautifulsoup4
243290
```
244291

245292
### Run the Example

0 commit comments

Comments
 (0)