Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace pipenv with poetry #567

Open
wants to merge 12 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .github/workflows/shared-build-deploy.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,14 @@ on: push
jobs:
backend-check:
name: "Backend Check"
uses: pennlabs/shared-actions/.github/workflows/django.yaml@8785a7d7b9158d8d5705a0202f5695db2c0beb97
uses: pennlabs/shared-actions/.github/workflows/django.yaml@7b67c73ced6fa70043451f6816c706a003642828
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

having to pin like this sucks because its pretty opaque :(

with:
projectName: PennCourses
path: backend
flake: true
black: true
pythonVersion: 3.10-buster
dependencyManager: poetry

publish-backend:
uses: pennlabs/shared-actions/.github/workflows/[email protected]
Expand Down
11 changes: 0 additions & 11 deletions Pipfile

This file was deleted.

8 changes: 5 additions & 3 deletions backend/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
FROM pennlabs/django-base:9c4f31bf1af44219d0f9019271a0033a222291c2-3.10.1
FROM pennlabs/django-base:281d2f6446bb5381e1a2ecf39f6689b648d92ee6-3.10.1

LABEL maintainer="Penn Labs"

# Copy project dependencies
COPY Pipfile* /app/
COPY pyproject.toml /app/
COPY poetry.lock /app/

# Install project dependencies
RUN pipenv install --system --deploy
RUN poetry config virtualenvs.create false
RUN poetry install --no-root

# Copy project files
COPY . /app/
Expand Down
7 changes: 4 additions & 3 deletions backend/Dockerfile.dev
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
FROM pennlabs/django-base:f0f05216db7c23c1dbb5b95c3bc9e8a2603bf2fd
FROM pennlabs/django-base:281d2f6446bb5381e1a2ecf39f6689b648d92ee6-3.10.1

LABEL maintainer="Penn Labs"

WORKDIR /backend

# Copy project dependencies
COPY Pipfile* ./
COPY pyproject.toml ./
COPY poetry.lock ./

# Install backend dependencies
RUN pipenv install --dev
RUN poetry install --no-root

# Alias runserver command
RUN echo 'alias runserver="python manage.py runserver 0.0.0.0:8000"' >> ~/.bashrc
68 changes: 0 additions & 68 deletions backend/Pipfile

This file was deleted.

2,505 changes: 0 additions & 2,505 deletions backend/Pipfile.lock

This file was deleted.

20 changes: 10 additions & 10 deletions backend/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,13 @@ cd backend
2. Run shell inside the container
```sh
[sudo] docker-compose run --service-ports development /bin/bash # launch shell inside container
pipenv shell # activate shell with python packages
poetry shell # activate shell with python packages
python manage.py makemigrations
python manage.py migrate # database migrations
python manage.py test # run tests
python manage.py test tests.review.test_api.OneReviewTestCase.test_course # re-run a specific test
runserver # optionally, run the server from within the shell
exit # leave pipenv shell
exit # leave poetry shell
exit # leave docker shell
```
3. Run the server on `127.0.0.1:8000` (use `CTRL+C` to stop running this)
Expand Down Expand Up @@ -58,14 +58,14 @@ If you are in Penn Labs, reach out to a Penn Courses team lead for a .env file t
put in your `backend` directory. This will contain some sensitive credentials (which is why the file contents are not
pasted in this public README). If you are not in Penn Labs, see the "Loading Course Data on Demand" section below for instructions on how to get your own credentials.

NOTE: when using `pipenv`, environment variables are only refreshed when you exit your shell and rerun `pipenv shell` (this is a common source of confusing behavior, so it's good to know about).
NOTE: when using `poetry`, environment variables are only refreshed when you exit your shell and rerun `poetry shell` (this is a common source of confusing behavior, so it's good to know about).

## Linting

We use `black`, `flake8`, and 'isort' to lint our code. Once you are in the `backend` directory, you can run the following commands to lint:
1. `pipenv run black`
2. `pipenv run isort`
3. `pipenv run flake8`
1. `poetry run black`
2. `poetry run isort`
3. `poetry run flake8`

## Loading Courses Data

Expand Down Expand Up @@ -115,7 +115,7 @@ For example, you can try out: `https://3scale-public-prod-open-data.apps.k8s.upe
To load in course data for a certain semester, set the environment variables
`OPEN_DATA_CLIENT_ID` and `OPEN_DATA_OIDC_SECRET` to the corresponding credentials you
receive from the OpenData API. These credentials are already included in the .env file you should receive from a team lead if you are in Labs. Otherwise, you can register for prod OpenData API credentials [here](https://hosted.apps.upenn.edu/PennOpenshiftCommandCenter_UI/PublicRestAccounts.aspx).
After your environment variables have been set (remember to refresh your pipenv shell), run
After your environment variables have been set (remember to refresh your poetry shell), run

`python manage.py registrarimport --semester=<semester> --query=<query>`

Expand Down Expand Up @@ -147,7 +147,7 @@ If you don't want to use docker alone, you can also set up and run the dev envir

### Prerequisites
- Python 3.10 ([`pyenv`](https://github.com/pyenv/pyenv) is recommended)
- [`pipenv`](https://pipenv.pypa.io/en/latest/)
- [`poetry`](https://python-poetry.org/docs/)
- [`docker` and `docker-compose`](https://docs.docker.com/get-docker/)

`psql` is required to load data into the db, but it should be installed when you install `postgres`/`psycopg2`.
Expand Down Expand Up @@ -178,8 +178,8 @@ If you don't want to use docker alone, you can also set up and run the dev envir

4. Setting up your Penn Courses development environment

1. `pipenv install --dev`
2. `pipenv shell`
1. `poetry install --no-root`
2. `poetry shell`
3. `python manage.py migrate`

5. Loading test data (if you are a member of Penn Labs). If you are not a member of Penn Labs, you can skip this section and load in course data from the registrar, as explained below.
Expand Down
2 changes: 1 addition & 1 deletion backend/courses/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ def get_current_semester(allow_not_found=False):
"option by running the command "
"'python manage.py setoption SEMESTER 2020C', "
"replacing 2020C with the current semester, in the backend directory (remember "
"to run 'pipenv shell' before running this command, though)."
"to run 'poetry shell' before running this command, though)."
)
cache.set("SEMESTER", retrieved_val, timeout=90000) # cache expires every 25 hours
return retrieved_val
Expand Down
2 changes: 1 addition & 1 deletion backend/docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,4 @@ services:
environment:
- REDIS_URL=redis://redis:6379/1
- DATABASE_URL=postgres://penn-courses:postgres@db:5432/postgres
command: pipenv run python manage.py runserver 0.0.0.0:8000
command: poetry run python manage.py runserver 0.0.0.0:8000
Loading
Loading