Skip to content

Commit

Permalink
refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
jgtvares committed Dec 27, 2021
1 parent fec427d commit 620eb2d
Show file tree
Hide file tree
Showing 7 changed files with 31 additions and 35 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ test.js

example/.vercel/

__pycache__



Expand Down
4 changes: 2 additions & 2 deletions build-utils/index.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
const log = require('./log');
const pip = require('./pip');
const python = require('./python');
const apt = require('./apt');
const linux = require('./linux');

module.exports = {
log,
pip,
python,
apt,
linux,
};
File renamed without changes.
19 changes: 7 additions & 12 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,7 @@ const download = require('@vercel/build-utils/fs/download'); // eslint-disable-l
const glob = require('@vercel/build-utils/fs/glob'); // eslint-disable-line import/no-extraneous-dependencies
const { createLambda } = require('@vercel/build-utils/lambda'); // eslint-disable-line import/no-extraneous-dependencies

const {
log,
pip,
python,
apt,
} = require('./build-utils');
const { log, pip, python, linux } = require('./build-utils');


exports.config = {
Expand All @@ -19,7 +14,7 @@ exports.config = {


exports.build = async ({ files, entrypoint, config }) => {
log.info(`Files: ${files}`);
log.info(`Files: ${JSON.parse(files)}`);
log.title('Starting build');
const systemReleaseContents = await readFile(
path.join('/etc', 'system-release'),
Expand Down Expand Up @@ -53,9 +48,9 @@ exports.build = async ({ files, entrypoint, config }) => {
await pip.install(pipPath, srcDir, __dirname);

log.heading('Running setup script');
let setupPath = apt.findRequirements(entrypoint, files);
let setupPath = linux.findRequirements(entrypoint, files);
if (setupPath) {
await apt.install(setupPath);
await linux.install(setupPath);
}

log.heading('Running pip script');
Expand All @@ -65,16 +60,16 @@ exports.build = async ({ files, entrypoint, config }) => {
}

log.heading('Running post script');
setupPath = apt.findPostRequirements(entrypoint, files);
setupPath = linux.findPostRequirements(entrypoint, files);
if (setupPath) {
await apt.install(setupPath);
await linux.install(setupPath);
}

log.heading('Preparing lambda bundle');

const lambda = await createLambda({
files: await glob('**', srcDir),
handler: 'pyvercel.vercel_handler',
handler: 'lambda.handler',
runtime: `${config.runtime || 'python3.8'}`,
environment: {
WSGI_APPLICATION: `${wsgiApplication}`,
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion pyvercel/handler.py → lambda/handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
from io import BytesIO
from werkzeug._internal import _wsgi_encoding_dance, _to_bytes

from urllib.parse import urlparse, unquote, urlencode
from urllib.parse import urlparse, unquote

# Set up logging
root = logging.getLogger()
Expand Down
40 changes: 20 additions & 20 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,24 +1,24 @@
#! /usr/bin/env python
import json
# #! /usr/bin/env python
# import json

from setuptools import setup
# from setuptools import setup


with open('package.json') as f:
package_data = json.loads(f.read())
version = package_data['version']
# with open('package.json') as f:
# package_data = json.loads(f.read())
# version = package_data['version']

# py-vercel
"""A barebones setup for tests
"""
setup(
name='py-vercel',
version=version,
packages=[
'pyvercel'
],
install_requires=[
'Werkzeug',
'py-exceptions'
]
)
# # py-vercel
# """A barebones setup for tests
# """
# setup(
# name='py-vercel',
# version=version,
# packages=[
# 'pyvercel'
# ],
# install_requires=[
# 'Werkzeug',
# 'py-exceptions'
# ]
# )

0 comments on commit 620eb2d

Please sign in to comment.