... | ... | @@ -16,7 +16,7 @@ python setup.py <command> [opts] |
|
|
python setup.py install
|
|
|
# Install the package in a way that lets you edit the sources
|
|
|
python setup.py develop
|
|
|
# Upload your last revision to \texttt{PyPi} repository
|
|
|
# Upload your last revision to *PyPi* repository
|
|
|
python setup.py upload
|
|
|
```
|
|
|
|
... | ... | @@ -37,19 +37,20 @@ from setuptools import setup, find_packages |
|
|
...
|
|
|
```
|
|
|
|
|
|
### Exercise 2
|
|
|
### Exercise
|
|
|
1. Open the *setup.py* script and look at the *setup* function arguments.
|
|
|
|
|
|
#### Package dependency
|
|
|
|
|
|
Instead of writing in a *README* file explaining which packages are required by
|
|
|
your project, those packages can be automatically installed with *setuptools*.
|
|
|
Dependencies should be listed using *install_requires* parameter. In the example below, *argparse* dependency will be installed with the package.
|
|
|
Dependencies should be listed using *install_requires* parameter. In the
|
|
|
example below, *argparse* dependency will be installed with the package.
|
|
|
|
|
|
```
|
|
|
setup(
|
|
|
...,
|
|
|
install_requires=[’argparse’],
|
|
|
install_requires=['argparse'],
|
|
|
)
|
|
|
```
|
|
|
|
... | ... | @@ -58,13 +59,14 @@ Depending on your needs, you can specify the version with ==, <, != operators. |
|
|
#### Note
|
|
|
|
|
|
By default *setuptools* uses *PyPi* to find packages but can be configured to
|
|
|
install from many places, like an existing git repository or an [http url](http://python-packaging.readthedocs.io/en/latest/dependencies.html).
|
|
|
install third parties from many places, like an existing git repository or an
|
|
|
[http url](http://python-packaging.readthedocs.io/en/latest/dependencies.html).
|
|
|
|
|
|
#### Package version
|
|
|
|
|
|
Python package version is usually accessible at `package_name.__version__` should
|
|
|
be consistent with the version in *setup.py*. Importing the package in *setup.py*
|
|
|
script is a source of import and code coverage errors (cf. [Don’t
|
|
|
Python package version is usually accessible at `package_name.__version__`
|
|
|
should be consistent with the version in *setup.py*. Importing the package in
|
|
|
*setup.py* script is a source of import and code coverage errors (cf. [Do not
|
|
|
import your package in setup.py](https://stackoverflow.com/q/11279096/395687)).
|
|
|
To prevent that, package `__init__.py` file can be read and parsed manually
|
|
|
to find the version.
|
... | ... | @@ -73,14 +75,15 @@ Package version can be obtained using : |
|
|
python setup.py --version
|
|
|
```
|
|
|
|
|
|
### Exercise 3
|
|
|
### Exercise
|
|
|
1. Find where the version is stored and how it is retrieved in the *setup.py*
|
|
|
script.
|
|
|
|
|
|
## Semantic versioning
|
|
|
|
|
|
Versioning should help users follow features addition and know when incompatible changes have been introduced. Semantic Versioning gives you simple rules
|
|
|
for changing your version numbers.
|
|
|
Versioning should help users follow features addition and know when
|
|
|
incompatible changes have been introduced. Semantic Versioning gives you simple
|
|
|
rules for changing your version numbers.
|
|
|
|
|
|
From [http://semver.org/](http://semver.org/) summary : Given a version number MAJOR.MINOR.PATCH,
|
|
|
increment the :
|
... | ... | |