Skip to content
Snippets Groups Projects
Commit 13a0b2cf authored by Paul McCarthy's avatar Paul McCarthy :mountain_bicyclist:
Browse files

Convert structuring_projects packager example to use pyproject.toml

parent 98078b3c
No related branches found
No related tags found
1 merge request!39Update "structuring projects" practical to recommend `pyproject.toml`
Example project
===============
# Example project
This is an example project, used to demonstrate the basics of how to structure
......
#!/usr/bin/env python
import sys
def myfunction(a, b):
return a * b
def main():
if len(sys.argv) != 3:
print(f'Usage: myscript a b')
sys.exit(1)
a = float(sys.argv[1])
b = float(sys.argv[2])
print(myfunction(a, b))
[project]
name = "example-project"
dynamic = ["version"]
description = "Example Python project for PyTreat"
readme = {file = "README.md", content-type="text/markdown"}
license = {text = "Apache License Version 2.0"}
requires-python = ">=3.8"
authors = [{name = "Paul McCarthy", email = "pauldmccarthy@gmail.com"}]
dependencies = [
"numpy",
"nibabel",
"scipy"
]
[project.urls]
Repository = "https://git.fmrib.ox.ac.uk/fsl/win-pytreat/"
# The "mypackage.mymodule.main" function is installed
# as a command-line program called "myscript".
[project.scripts]
myscript = "mypackage.mymodule:main"
# Use setuptools to build this package
[build-system]
requires = ["setuptools"]
build-backend = "setuptools.build_meta"
# Specify which Python packages to include
[tool.setuptools.packages.find]
include = ["mypackage*"]
# The version number is inside mypackage/__init__.py
[tool.setuptools.dynamic]
version = {attr = "mypackage.__version__"}
\ No newline at end of file
numpy==1.*
#!/usr/bin/env python
from setuptools import setup
from setuptools import find_packages
# Import version number from
# the project package (see
# the section on versioning).
from mypackage import __version__
# Read in requirements from
# the requirements.txt file.
with open('requirements.txt', 'rt') as f:
requirements = [l.strip() for l in f.readlines()]
# Generate a list of all of the
# packages that are in your project.
packages = find_packages()
setup(
name='Example project',
description='Example Python project for PyTreat',
url='https://git.fmrib.ox.ac.uk/fsl/pytreat-practicals-2020/',
author='Paul McCarthy',
author_email='pauldmccarthy@gmail.com',
license='Apache License Version 2.0',
packages=packages,
version=__version__,
install_requires=requirements,
classifiers=[
'Development Status :: 3 - Alpha',
'Intended Audience :: Developers',
'License :: OSI Approved :: Apache Software License',
'Programming Language :: Python :: 2.7',
'Programming Language :: Python :: 3.4',
'Programming Language :: Python :: 3.5',
'Programming Language :: Python :: 3.6',
'Topic :: Software Development :: Libraries :: Python Modules'],
)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment