Start a makefile
This commit is contained in:
parent
b716a2d9d9
commit
a6ff67d077
|
@ -0,0 +1,126 @@
|
|||
SHELL := /bin/bash
|
||||
|
||||
# If specified, open pdb on uncaught exception
|
||||
DEBUG?=
|
||||
# If specified, run a linter
|
||||
LINT?=
|
||||
# If specified, use a different python command
|
||||
PY?=python3
|
||||
# Unless specified otherwise, install python modules as user
|
||||
USER_FLAG?=--user
|
||||
# If specified, use a different command for pip
|
||||
PIP?=$(PY) -m pip
|
||||
# If specified, perform type-checking
|
||||
MYPY?=true
|
||||
|
||||
ifneq ($(MYPY),true)
|
||||
LINT=less
|
||||
endif
|
||||
|
||||
ifeq ($(LINT),false)
|
||||
pytest_args?= -vl --benchmark-min-time=0.05 --benchmark-sort=fullname --benchmark-group-by=fullfunc --benchmark-verbose
|
||||
else
|
||||
ifeq ($(LINT),true)
|
||||
pytest_args?= -vl --mypy --mypy-ignore-missing-imports --flake8 --isort -k 'not test_problem and not test_is_prime and not test_groupwise'
|
||||
else
|
||||
ifeq ($(LINT),less)
|
||||
pytest_args?= -vl --flake8 --isort --benchmark-min-time=0.05 --benchmark-sort=fullname --benchmark-group-by=fullfunc --benchmark-verbose
|
||||
else
|
||||
pytest_args?= -vl --mypy --mypy-ignore-missing-imports --flake8 --isort --benchmark-min-time=0.05 --benchmark-group-by=fullfunc --benchmark-sort=fullname --benchmark-verbose
|
||||
endif
|
||||
endif
|
||||
endif
|
||||
|
||||
ifneq ($(https_proxy), )
|
||||
PROXY_ARG=--proxy=$(https_proxy)
|
||||
else
|
||||
ifneq ($(http_proxy), )
|
||||
PROXY_ARG=--proxy=$(http_proxy)
|
||||
else
|
||||
PROXY_ARG=
|
||||
endif
|
||||
endif
|
||||
|
||||
.PHONY: test
|
||||
# Run tests sequentially
|
||||
test: dependencies _test
|
||||
|
||||
.PHONY: test_%
|
||||
# Run tests with a given number of parallel runners
|
||||
test_%:
|
||||
@$(MAKE) test pytest_args="$(pytest_args) -n$*" $(MFLAGS)
|
||||
|
||||
.PHONY: _test
|
||||
_test:
|
||||
@$(PY) -m pytest src $(pytest_args)
|
||||
|
||||
.PHONY: dependencies
|
||||
ifeq ($(MYPY),true)
|
||||
# Load dependencies from pypi
|
||||
dependencies:
|
||||
@$(PIP) install -r requirements.txt $(USER_FLAG) $(PROXY_ARG)
|
||||
else
|
||||
dependencies:
|
||||
@cat requirements.txt | grep -v "mypy" > .requirements.txt
|
||||
@$(PIP) install -r .requirements.txt $(USER_FLAG) $(PROXY_ARG)
|
||||
endif
|
||||
|
||||
.PHONY: run_%
|
||||
# Run a specific account
|
||||
run_%: LICENSE dependencies
|
||||
@source env_$*.sh && $(PY) -m src
|
||||
|
||||
.PHONY: run
|
||||
# Run all known accounts
|
||||
run:
|
||||
@$(MAKE) run_bot run_personal $(MFLAGS)
|
||||
|
||||
.PHONY: daemon
|
||||
# Run all known accounts in a loop
|
||||
daemon:
|
||||
@./daemon.sh
|
||||
|
||||
.PHONY: quiet_daemon
|
||||
# Run all known accounts in a loop (quietly)
|
||||
quiet_daemon:
|
||||
@while [ 1 ]; do\
|
||||
$(MAKE) run $(MFLAGS);\
|
||||
sleep 1800;\
|
||||
done;
|
||||
|
||||
.PHONY: build
|
||||
# (TODO) Build a package
|
||||
build: dependencies clean LICENSE
|
||||
@$(PY) setup.py bdist_wheel --universal
|
||||
@$(PY) setup.py sdist
|
||||
|
||||
.PHONY: clean
|
||||
# Clean up after a build
|
||||
clean:
|
||||
@mkdir -p build dist
|
||||
@rm -r build dist
|
||||
|
||||
.PHONY: publish
|
||||
# (TODO) Publish new version to pypi
|
||||
publish: build
|
||||
@$(PY) -m twine upload -u gappleto97 -s --sign-with gpg2 dist/*
|
||||
|
||||
.PHONY: graph
|
||||
# Build a dependency graph of this package
|
||||
graph: dependencies
|
||||
@$(PIP) install pydeps
|
||||
@PYTHONPATH=${PYTHONPATH}:./src/PyManifold $(PY) -m pydeps --noshow --cluster --max-bacon 100 src
|
||||
|
||||
.PHONY: import_%
|
||||
# Create one or more markets from example.json and add them to the specified account
|
||||
import_%: LICENSE dependencies
|
||||
@$(PY) example_json.py
|
||||
|
||||
.PHONY: help
|
||||
# Show this help.
|
||||
help:
|
||||
@echo Variables:
|
||||
@awk '/^#/{c=substr($$0,3);next}c&&/^[[:alpha:]][[:alnum:]_]+\??=/{print substr($$1,1,index($$1,"?")),c}1{c=0}' $(MAKEFILE_LIST) | column -s? -t
|
||||
@echo
|
||||
@echo Commands:
|
||||
@awk '/^#/{c=substr($$0,3);next}c&&/^[[:alpha:]][[:alnum:]_%%-]+:/{print substr($$1,1,index($$1,":")),c}1{c=0}' $(MAKEFILE_LIST) | column -s: -t
|
|
@ -99,8 +99,8 @@ The goal of this project is to make a Manifold agent that can manage various for
|
|||
|
||||
1. First, make sure you are running Python >= 3.7
|
||||
2. Load the submodules
|
||||
3. Run `pip install -r requirements.txt`
|
||||
4. Make a file called `env.sh`. It should contain 5 exports
|
||||
3. Run `make dependencies`
|
||||
4. Make a file called `env_<name>.sh`. It should contain 6 exports
|
||||
1. `GithubAPIKey`: The API key for reading GitHub issues and pull requests. Strictly speaking not needed, so long as you don't use GitHub rules, but the underlying script will check that this exists.
|
||||
2. `ManifoldAPIKey`: The API key for managing your Manifold markets. See [here](https://docs.manifold.markets/api) for instructions on how to retrieve it.
|
||||
3. `TelegramAPIKey`: The API key for your Telegram bot. For more info, see [here](https://github.com/python-telegram-bot/python-telegram-bot/wiki/Introduction-to-the-API)
|
||||
|
@ -108,7 +108,7 @@ The goal of this project is to make a Manifold agent that can manage various for
|
|||
5. `DBName`: The name of your database file
|
||||
6. `LogFile`: The name of a logfile to use
|
||||
5. Add your first markets using the arguments provided in `src/__main__.py`. Each market needs at least one DoResolveRule and at least one ResolveToRule. The simplest ResolveToRule is `--round` or `--current`. The simplest DoResolve rule is `--rel-date`. More complicated markets may need to have rules constructed manually.
|
||||
6. When you've added all your markets, modify the polling frequency in `daemon.sh`, then run it
|
||||
6. When you've added all your markets, modify the polling frequency in `daemon.sh`, then run `make daemon`
|
||||
|
||||
## JSON Examples
|
||||
|
||||
|
|
Loading…
Reference in New Issue