wagtail-longclaw/setup.py

140 wiersze
4.0 KiB
Python

2017-02-03 10:04:57 +00:00
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import os
import re
import sys
2017-02-10 09:18:37 +00:00
import subprocess
2017-02-03 10:04:57 +00:00
2017-02-10 09:18:37 +00:00
from setuptools import setup
from setuptools.command.sdist import sdist as base_sdist
class sdist(base_sdist):
2017-10-01 10:19:37 +00:00
"""
2017-02-10 09:19:42 +00:00
Regular sdist class plus compilation of front end assets
2017-10-01 10:19:37 +00:00
"""
2017-02-10 09:18:37 +00:00
def compile_assets(self):
2017-10-01 10:19:37 +00:00
"""
2017-02-10 09:18:37 +00:00
Compile the front end assets
2017-10-01 10:19:37 +00:00
"""
2017-02-10 09:18:37 +00:00
try:
2017-02-10 18:43:22 +00:00
# Move into client dir
curdir = os.path.abspath(os.curdir)
client_path = os.path.join(os.path.dirname(__file__), 'longclaw', 'client')
os.chdir(client_path)
subprocess.check_call(['npm', 'install'])
2017-02-10 18:43:22 +00:00
subprocess.check_call(['npm', 'run', 'build'])
os.chdir(curdir)
2017-02-10 09:18:37 +00:00
except (OSError, subprocess.CalledProcessError) as err:
print('Error compiling assets: {}'.format(err))
raise SystemExit(1)
def run(self):
self.compile_assets()
base_sdist.run(self)
2017-02-03 10:04:57 +00:00
def get_version(*file_paths):
"""Retrieves the version from longclaw/__init__.py"""
filename = os.path.join(os.path.dirname(__file__), *file_paths)
version_file = open(filename).read()
version_match = re.search(r"^__version__ = ['\"]([^'\"]*)['\"]",
version_file, re.M)
if version_match:
return version_match.group(1)
raise RuntimeError('Unable to find version string.')
version = get_version("longclaw", "__init__.py")
if sys.argv[-1] == 'publish':
try:
import wheel
print("Wheel version: ", wheel.__version__)
except ImportError:
print('Wheel library missing. Please run "pip install wheel"')
sys.exit()
2019-02-03 09:53:53 +00:00
os.system('python setup.py sdist bdist_wheel')
2019-03-28 19:13:58 +00:00
os.system('python -m twine upload --verbose dist/*')
2017-02-03 10:04:57 +00:00
sys.exit()
if sys.argv[-1] == 'tag':
print("Tagging the version on git:")
os.system("git tag -a %s -m 'version %s'" % (version, version))
os.system("git push --tags")
sys.exit()
2017-02-06 08:34:23 +00:00
try:
readme = open('README.rst').read()
history = open('CHANGELOG.rst').read().replace('.. :changelog:', '')
2017-02-07 09:23:23 +00:00
except IOError:
2017-02-10 09:19:42 +00:00
# Protects against running python from a different dir to setup.py,
2017-02-06 08:34:23 +00:00
# e.g. on travis
readme = ''
history = ''
2017-02-03 10:04:57 +00:00
setup(
name='longclaw',
version=version,
description="""A shop for wagtail cms""",
long_description=readme + '\n\n' + history,
author='James Ramm',
author_email='jamessramm@gmail.com',
url='https://github.com/JamesRamm/longclaw',
packages=[
'longclaw',
],
include_package_data=True,
install_requires=[
'django>=2.2,<3.0',
'wagtail>=2.11,<2.14',
2019-09-22 10:33:34 +00:00
'django-countries==5.5',
'django-extensions==2.2.1',
'djangorestframework==3.11.2',
Issue 219 calculated rates base class (#230) * add test for get_shipping_cost with a basket rate * add fields to allow us to tie shipping rate to a basket & address * add test for testing specified address and basket * add migration for new shipping rate fields * add missing import * fix name errors * add shipping possibilities based on shipping address and basket id * test basket, shipping address, & basket+shipping address rate assignment * return correct rates for basket and address rate cases * rename shipping rate address for clarity (origin/destination) * send basket modified signal when basket is modified via api endpoints * test address only rate * remove basket rates when the basket_modified signal is sent * show response content on error * print response content on failure for more tests and include more 200 statuses for put * getting different status codes back from our endpoints, check success * clear shipping rates based on destination address when address modified * allow get params * return cost and rate options for more cases (test not complete) * fix mock * return applicable shipping options and test some combinations * stub the rate processor interface * add fk from rate to processor that created it * set rate basket and destination * shipping processor instance can apply to more than one country * run processor get_rates if configured * let child models handle assignment * add some initial testing for processor * rename _get_rates() to process_rates() * allow disabling the success check * test country shipping option with processor requires destination * test that the endpoint calls get_rate on the processor * test that multiple processors are called once * add shipping_origin fk to site settings * add default cache key based on origin, destination, & basket items * test a trivial rate processor implementation is used * test cost endpoint returns the processed rate * pin version requirement * fix wagtail version * start vagrant config * get tox to run * install nvm for vagrant user * add instructions to move npm deps off shared folder for speed * compact into a shell script for ease of use * add some more examples as temporary documentation * tests require dev reqs * clean this up a little * add migrations for productrequest app to fix test runner * raise exception on error instead of returning error response * test exception raised when country and country code specified * test for destination address does not exist * test exception when country and country code are not supplied * set request.site as it is expected * test get_shipping_cost_kwargs with only country code * check the basket id and the settings * value passed for country is supposed to be PK * test with country specified * write test so we can test with iso as string of known value * tes destination is respected * test with destination and country code * test shipping_rate_name is set as name * move models * rename models.py * rename to be consistent with rates being plural * move serializers * move models * ignore private vagrant subdir * move code around to fix circular imports to allow top level imports * move address serializer import to top level * ws * ws
2019-11-06 12:46:07 +00:00
'django-ipware==2.1.0',
'django-polymorphic==2.0.3',
],
extras_require={
"testing": [
"bumpversion==0.6.0",
"wheel==0.38.1",
"setuptools==65.5.1",
"coverage>=4.5.2",
"mock==2.0.0",
"flake8>=3.6.0",
"tox>=3.5.3",
"codecov>=2.0.15",
"# Additional test requirements go here",
"factory_boy>=2.11.1",
"wagtail-factories>=1.1.0",
],
},
2017-02-03 10:04:57 +00:00
license="MIT",
zip_safe=False,
keywords='longclaw',
classifiers=[
'Development Status :: 3 - Alpha',
'Framework :: Django',
'Framework :: Django :: 2.0',
'Framework :: Wagtail',
'Framework :: Wagtail :: 2',
2017-02-03 10:04:57 +00:00
'Intended Audience :: Developers',
'License :: OSI Approved :: BSD License',
'Natural Language :: English',
'Programming Language :: Python :: 3',
'Programming Language :: Python :: 3.7'
'Programming Language :: Python :: 3.8'
'Programming Language :: Python :: 3.9'
'Programming Language :: Python :: 3.10'
2017-02-03 10:04:57 +00:00
],
2017-10-01 10:19:37 +00:00
entry_points="""
2017-02-27 22:09:50 +00:00
[console_scripts]
longclaw=longclaw.bin.longclaw:main
2017-10-01 10:19:37 +00:00
""",
2017-02-10 09:18:37 +00:00
cmdclass={
'sdist': sdist
}
2017-02-03 10:04:57 +00:00
)