... | ... |
@@ -27,8 +27,7 @@ works with Python 2](https://github.com/cmarquardt/miniver2) |
27 | 27 |
[versioneer]: https://github.com/warner/python-versioneer |
28 | 28 |
[cc0]: http://creativecommons.org/publicdomain/zero/1.0/ |
29 | 29 |
[pypi]: https://pypi.org/project/miniver/ |
30 |
-[travis]: https://travis-ci.org/jbweston/miniver |
|
31 |
-[appveyor]: https://ci.appveyor.com/project/jbweston/miniver |
|
30 |
+[ci]: https://github.com/jbweston/miniver/actions?query=workflow%3Atest |
|
32 | 31 |
|
33 | 32 |
## Usage |
34 | 33 |
The simplest way to use Miniver is to run the following in your project root: |
... | ... |
@@ -1,8 +1,8 @@ |
1 | 1 |
# Miniver |
2 | 2 |
[![license: CC0-1.0](https://img.shields.io/pypi/l/miniver.svg)][cc0] |
3 | 3 |
[![PyPI version](https://img.shields.io/pypi/v/miniver.svg)][pypi] |
4 |
-[![Travis build](https://travis-ci.org/jbweston/miniver.svg)][travis] |
|
5 |
-[![Appveyor build](https://ci.appveyor.com/api/projects/status/v9q0hmjfm9qxdsi4?svg=true)][appveyor] |
|
4 |
+[![CI status](https://github.com/jbweston/miniver/workflows/test/badge.svg)][ci] |
|
5 |
+ |
|
6 | 6 |
|
7 | 7 |
**Like [versioneer][versioneer], but smaller** |
8 | 8 |
|
... | ... |
@@ -17,9 +17,7 @@ version strings everywhere. |
17 | 17 |
|
18 | 18 |
This is the same problem that Versioneer solves, but Miniver is less |
19 | 19 |
than 200 lines of code, whereas Versioneer is over 2000. The tradeoff |
20 |
-is that Miniver only works with Git and Python 3.5 (or above), and has only been |
|
21 |
-tested on Debian Linux and Mac OSX (automated with Travis) and for Windows |
|
22 |
-on Appveyor. |
|
20 |
+is that Miniver only works with Git and Python 3.5 (or above). |
|
23 | 21 |
|
24 | 22 |
Support for Python 2 is not a goal, as Python 2 is fast approaching its |
25 | 23 |
end of life (2020), and we want to encourage people to use Python 3! |
... | ... |
@@ -35,7 +35,7 @@ works with Python 2](https://github.com/cmarquardt/miniver2) |
35 | 35 |
## Usage |
36 | 36 |
The simplest way to use Miniver is to run the following in your project root: |
37 | 37 |
``` |
38 |
-curl https://raw.githubusercontent.com/jbweston/miniver/master/install-miniver | python - <your_package_directory> |
|
38 |
+curl https://raw.githubusercontent.com/jbweston/miniver/master/bin/miniver | python - install <your_package_directory> |
|
39 | 39 |
``` |
40 | 40 |
This will grab the latest files from GitHub and set up Miniver for your project. |
41 | 41 |
|
... | ... |
@@ -52,10 +52,10 @@ curl https://raw.githubusercontent.com/jbweston/miniver/master/unannotated-tags. |
52 | 52 |
``` |
53 | 53 |
|
54 | 54 |
### I don't want to type that URL every time I use this |
55 |
-You can `pip install miniver`, which will give you the `install-miniver` script. |
|
55 |
+You can `pip install miniver`, which will give you the `miniver` command. |
|
56 | 56 |
Then you can simply run the following from your project root to use Miniver: |
57 | 57 |
``` |
58 |
-install-miniver <your_package_directory> |
|
58 |
+miniver install <your_package_directory> |
|
59 | 59 |
``` |
60 | 60 |
|
61 | 61 |
### Can I use this without executing random code from the internet? |
... | ... |
@@ -1,6 +1,8 @@ |
1 | 1 |
# Miniver |
2 | 2 |
[![license: CC0-1.0](https://img.shields.io/pypi/l/miniver.svg)][cc0] |
3 | 3 |
[![PyPI version](https://img.shields.io/pypi/v/miniver.svg)][pypi] |
4 |
+[![Travis build](https://travis-ci.org/jbweston/miniver.svg)][travis] |
|
5 |
+[![Appveyor build](https://ci.appveyor.com/api/projects/status/v9q0hmjfm9qxdsi4?svg=true)][appveyor] |
|
4 | 6 |
|
5 | 7 |
**Like [versioneer][versioneer], but smaller** |
6 | 8 |
|
... | ... |
@@ -27,6 +29,8 @@ works with Python 2](https://github.com/cmarquardt/miniver2) |
27 | 29 |
[versioneer]: https://github.com/warner/python-versioneer |
28 | 30 |
[cc0]: http://creativecommons.org/publicdomain/zero/1.0/ |
29 | 31 |
[pypi]: https://pypi.org/project/miniver/ |
32 |
+[travis]: https://travis-ci.org/jbweston/miniver |
|
33 |
+[appveyor]: https://ci.appveyor.com/project/jbweston/miniver |
|
30 | 34 |
|
31 | 35 |
## Usage |
32 | 36 |
The simplest way to use Miniver is to run the following in your project root: |
... | ... |
@@ -5,8 +5,8 @@ |
5 | 5 |
**Like [versioneer][versioneer], but smaller** |
6 | 6 |
|
7 | 7 |
Miniver is a **mini**mal **ver**sioning tool that serves the same purpose |
8 |
-as [Versioneer][versioneer], except that it is not designed to be |
|
9 |
-cross platform, and only works with Git. |
|
8 |
+as [Versioneer][versioneer], except that it only works with Git and |
|
9 |
+multiplatform support is still experimental. |
|
10 | 10 |
|
11 | 11 |
#### Why would I use this? |
12 | 12 |
If you are developing a Python package inside a Git repository and |
... | ... |
@@ -16,7 +16,8 @@ version strings everywhere. |
16 | 16 |
This is the same problem that Versioneer solves, but Miniver is less |
17 | 17 |
than 200 lines of code, whereas Versioneer is over 2000. The tradeoff |
18 | 18 |
is that Miniver only works with Git and Python 3.5 (or above), and has only been |
19 |
-tested on Debian Linux and Mac OSX (so far). |
|
19 |
+tested on Debian Linux and Mac OSX (automated with Travis) and for Windows |
|
20 |
+on Appveyor. |
|
20 | 21 |
|
21 | 22 |
Support for Python 2 is not a goal, as Python 2 is fast approaching its |
22 | 23 |
end of life (2020), and we want to encourage people to use Python 3! |
We also add a patch that can be directly applied to '_version.py'
to make this change. This patch will need to be kept in sync
with '_version.py'.
... | ... |
@@ -34,6 +34,18 @@ curl https://raw.githubusercontent.com/jbweston/miniver/master/install-miniver | |
34 | 34 |
``` |
35 | 35 |
This will grab the latest files from GitHub and set up Miniver for your project. |
36 | 36 |
|
37 |
+### I get an `unknown` version! |
|
38 |
+The version is reported as `unknown` (plus the current git hash) when there are no valid tags |
|
39 |
+in the git history. You should create an [*annotated tag*](https://git-scm.com/book/en/v2/Git-Basics-Tagging) |
|
40 |
+so that Miniver reports a reasonable version. |
|
41 |
+ |
|
42 |
+If your project uses *unannotated tags* for versioning (though this is not the |
|
43 |
+[recommended way](https://stackoverflow.com/questions/11514075/what-is-the-difference-between-an-annotated-and-unannotated-tag)) |
|
44 |
+then you'll need to run the following in order to modify Miniver's behaviour: |
|
45 |
+``` |
|
46 |
+curl https://raw.githubusercontent.com/jbweston/miniver/master/unannotated-tags.patch | patch <your_package_directory>/_version.py |
|
47 |
+``` |
|
48 |
+ |
|
37 | 49 |
### I don't want to type that URL every time I use this |
38 | 50 |
You can `pip install miniver`, which will give you the `install-miniver` script. |
39 | 51 |
Then you can simply run the following from your project root to use Miniver: |
... | ... |
@@ -21,7 +21,7 @@ tested on Debian Linux and Mac OSX (so far). |
21 | 21 |
Support for Python 2 is not a goal, as Python 2 is fast approaching its |
22 | 22 |
end of life (2020), and we want to encourage people to use Python 3! |
23 | 23 |
That being said, Christian Marquardt has a [fork that also |
24 |
-works with Python 2](https://github.com/cmarquardt/miniver) |
|
24 |
+works with Python 2](https://github.com/cmarquardt/miniver2) |
|
25 | 25 |
|
26 | 26 |
[versioneer]: https://github.com/warner/python-versioneer |
27 | 27 |
[cc0]: http://creativecommons.org/publicdomain/zero/1.0/ |
... | ... |
@@ -15,9 +15,13 @@ version strings everywhere. |
15 | 15 |
|
16 | 16 |
This is the same problem that Versioneer solves, but Miniver is less |
17 | 17 |
than 200 lines of code, whereas Versioneer is over 2000. The tradeoff |
18 |
-is that Miniver only works with Git, and has not been tested across |
|
19 |
-different platforms and Python versions (yet). |
|
18 |
+is that Miniver only works with Git and Python 3.5 (or above), and has only been |
|
19 |
+tested on Debian Linux and Mac OSX (so far). |
|
20 | 20 |
|
21 |
+Support for Python 2 is not a goal, as Python 2 is fast approaching its |
|
22 |
+end of life (2020), and we want to encourage people to use Python 3! |
|
23 |
+That being said, Christian Marquardt has a [fork that also |
|
24 |
+works with Python 2](https://github.com/cmarquardt/miniver) |
|
21 | 25 |
|
22 | 26 |
[versioneer]: https://github.com/warner/python-versioneer |
23 | 27 |
[cc0]: http://creativecommons.org/publicdomain/zero/1.0/ |
Also update README and setup.py to accomodate it.
Joseph Weston authored on 26/02/2018 23:54:00... | ... |
@@ -24,10 +24,23 @@ different platforms and Python versions (yet). |
24 | 24 |
[pypi]: https://pypi.org/project/miniver/ |
25 | 25 |
|
26 | 26 |
## Usage |
27 |
-Copy the contents of the `miniver` directory (in this repository) into your |
|
28 |
-project's main package directory. |
|
27 |
+The simplest way to use Miniver is to run the following in your project root: |
|
28 |
+``` |
|
29 |
+curl https://raw.githubusercontent.com/jbweston/miniver/master/install-miniver | python - <your_package_directory> |
|
30 |
+``` |
|
31 |
+This will grab the latest files from GitHub and set up Miniver for your project. |
|
29 | 32 |
|
30 |
-Then copy the following snippets into the appropriate files: |
|
33 |
+### I don't want to type that URL every time I use this |
|
34 |
+You can `pip install miniver`, which will give you the `install-miniver` script. |
|
35 |
+Then you can simply run the following from your project root to use Miniver: |
|
36 |
+``` |
|
37 |
+install-miniver <your_package_directory> |
|
38 |
+``` |
|
39 |
+ |
|
40 |
+### Can I use this without executing random code from the internet? |
|
41 |
+Sure! Copy `miniver/_version.py` and `miniver/_static_version.py` from this |
|
42 |
+repository into your package directory, then copy the following snippets into |
|
43 |
+the appropriate files: |
|
31 | 44 |
|
32 | 45 |
```python |
33 | 46 |
# Your package's __init__.py |
... | ... |
@@ -69,11 +82,5 @@ which you copied the contents of `miniver`). |
69 | 82 |
|
70 | 83 |
That's it! |
71 | 84 |
|
72 |
-**PROTIP**: When starting a new project you can just [download minver][zip] |
|
73 |
-and use that as the starting point! You will still need to add |
|
74 |
-`your_package/_static_version.py export-subst` to your `.gitattributes`. |
|
75 |
- |
|
76 |
-[zip]: https://github.com/jbweston/miniver/archive/master.zip |
|
77 |
- |
|
78 | 85 |
## License |
79 | 86 |
Miniver is in the public domain under a CC0 license. |
Change 'version.py' to '_version.py' and make the 'version'
module attribute '__version__' instead.
... | ... |
@@ -31,23 +31,22 @@ Then copy the following snippets into the appropriate files: |
31 | 31 |
|
32 | 32 |
```python |
33 | 33 |
# Your package's __init__.py |
34 |
-from . import version |
|
35 |
-__version__ = version.version |
|
36 |
-del version |
|
34 |
+from ._version import __version__ |
|
35 |
+del _version |
|
37 | 36 |
``` |
38 | 37 |
|
39 | 38 |
```python |
40 | 39 |
# Your project's setup.py |
41 | 40 |
|
42 |
-# Loads version.py module without importing the whole package. |
|
41 |
+# Loads _version.py module without importing the whole package. |
|
43 | 42 |
def get_version_and_cmdclass(package_name): |
44 | 43 |
import os |
45 | 44 |
from importlib.util import module_from_spec, spec_from_file_location |
46 | 45 |
spec = spec_from_file_location('version', |
47 |
- os.path.join(package_name, 'version.py')) |
|
46 |
+ os.path.join(package_name, '_version.py')) |
|
48 | 47 |
module = module_from_spec(spec) |
49 | 48 |
spec.loader.exec_module(module) |
50 |
- return module.version, module.cmdclass |
|
49 |
+ return module.__version__, module.cmdclass |
|
51 | 50 |
|
52 | 51 |
|
53 | 52 |
version, cmdclass = get_version_and_cmdclass('my_package') |
... | ... |
@@ -44,7 +44,7 @@ def get_version_and_cmdclass(package_name): |
44 | 44 |
import os |
45 | 45 |
from importlib.util import module_from_spec, spec_from_file_location |
46 | 46 |
spec = spec_from_file_location('version', |
47 |
- os.path.join(package_name, 'miniver.py')) |
|
47 |
+ os.path.join(package_name, 'version.py')) |
|
48 | 48 |
module = module_from_spec(spec) |
49 | 49 |
spec.loader.exec_module(module) |
50 | 50 |
return module.version, module.cmdclass |
... | ... |
@@ -70,5 +70,11 @@ which you copied the contents of `miniver`). |
70 | 70 |
|
71 | 71 |
That's it! |
72 | 72 |
|
73 |
+**PROTIP**: When starting a new project you can just [download minver][zip] |
|
74 |
+and use that as the starting point! You will still need to add |
|
75 |
+`your_package/_static_version.py export-subst` to your `.gitattributes`. |
|
76 |
+ |
|
77 |
+[zip]: https://github.com/jbweston/miniver/archive/master.zip |
|
78 |
+ |
|
73 | 79 |
## License |
74 | 80 |
Miniver is in the public domain under a CC0 license. |
... | ... |
@@ -1,5 +1,6 @@ |
1 | 1 |
# Miniver |
2 |
-[![License: CC0-1.0][cc0_badge]][cc0] |
|
2 |
+[![license: CC0-1.0](https://img.shields.io/pypi/l/miniver.svg)][cc0] |
|
3 |
+[![PyPI version](https://img.shields.io/pypi/v/miniver.svg)][pypi] |
|
3 | 4 |
|
4 | 5 |
**Like [versioneer][versioneer], but smaller** |
5 | 6 |
|
... | ... |
@@ -19,8 +20,8 @@ different platforms and Python versions (yet). |
19 | 20 |
|
20 | 21 |
|
21 | 22 |
[versioneer]: https://github.com/warner/python-versioneer |
22 |
-[cc0_badge]: https://licensebuttons.net/l/zero/1.0/88x31.png |
|
23 | 23 |
[cc0]: http://creativecommons.org/publicdomain/zero/1.0/ |
24 |
+[pypi]: https://pypi.org/project/miniver/ |
|
24 | 25 |
|
25 | 26 |
## Usage |
26 | 27 |
Copy the contents of the `miniver` directory (in this repository) into your |
... | ... |
@@ -3,7 +3,7 @@ |
3 | 3 |
|
4 | 4 |
**Like [versioneer][versioneer], but smaller** |
5 | 5 |
|
6 |
-Miniver is a **min**imal **ver**sioning tool that serves the same purpose |
|
6 |
+Miniver is a **mini**mal **ver**sioning tool that serves the same purpose |
|
7 | 7 |
as [Versioneer][versioneer], except that it is not designed to be |
8 | 8 |
cross platform, and only works with Git. |
9 | 9 |
|
1 | 1 |
new file mode 100644 |
... | ... |
@@ -0,0 +1,73 @@ |
1 |
+# Miniver |
|
2 |
+[![License: CC0-1.0][cc0_badge]][cc0] |
|
3 |
+ |
|
4 |
+**Like [versioneer][versioneer], but smaller** |
|
5 |
+ |
|
6 |
+Miniver is a **min**imal **ver**sioning tool that serves the same purpose |
|
7 |
+as [Versioneer][versioneer], except that it is not designed to be |
|
8 |
+cross platform, and only works with Git. |
|
9 |
+ |
|
10 |
+#### Why would I use this? |
|
11 |
+If you are developing a Python package inside a Git repository and |
|
12 |
+want to get the version directly from Git tags, rather than hard-coding |
|
13 |
+version strings everywhere. |
|
14 |
+ |
|
15 |
+This is the same problem that Versioneer solves, but Miniver is less |
|
16 |
+than 200 lines of code, whereas Versioneer is over 2000. The tradeoff |
|
17 |
+is that Miniver only works with Git, and has not been tested across |
|
18 |
+different platforms and Python versions (yet). |
|
19 |
+ |
|
20 |
+ |
|
21 |
+[versioneer]: https://github.com/warner/python-versioneer |
|
22 |
+[cc0_badge]: https://licensebuttons.net/l/zero/1.0/88x31.png |
|
23 |
+[cc0]: http://creativecommons.org/publicdomain/zero/1.0/ |
|
24 |
+ |
|
25 |
+## Usage |
|
26 |
+Copy the contents of the `miniver` directory (in this repository) into your |
|
27 |
+project's main package directory. |
|
28 |
+ |
|
29 |
+Then copy the following snippets into the appropriate files: |
|
30 |
+ |
|
31 |
+```python |
|
32 |
+# Your package's __init__.py |
|
33 |
+from . import version |
|
34 |
+__version__ = version.version |
|
35 |
+del version |
|
36 |
+``` |
|
37 |
+ |
|
38 |
+```python |
|
39 |
+# Your project's setup.py |
|
40 |
+ |
|
41 |
+# Loads version.py module without importing the whole package. |
|
42 |
+def get_version_and_cmdclass(package_name): |
|
43 |
+ import os |
|
44 |
+ from importlib.util import module_from_spec, spec_from_file_location |
|
45 |
+ spec = spec_from_file_location('version', |
|
46 |
+ os.path.join(package_name, 'miniver.py')) |
|
47 |
+ module = module_from_spec(spec) |
|
48 |
+ spec.loader.exec_module(module) |
|
49 |
+ return module.version, module.cmdclass |
|
50 |
+ |
|
51 |
+ |
|
52 |
+version, cmdclass = get_version_and_cmdclass('my_package') |
|
53 |
+ |
|
54 |
+setup( |
|
55 |
+ name='my_package', |
|
56 |
+ version=version, |
|
57 |
+ cmdclass=cmdclass, |
|
58 |
+) |
|
59 |
+``` |
|
60 |
+ |
|
61 |
+``` |
|
62 |
+# Your project's .gitattributes |
|
63 |
+my_package/_static_version.py export-subst |
|
64 |
+``` |
|
65 |
+ |
|
66 |
+replacing `'my_package'` in the above with the name of your package |
|
67 |
+(this should be the same as the name of the directory into |
|
68 |
+which you copied the contents of `miniver`). |
|
69 |
+ |
|
70 |
+That's it! |
|
71 |
+ |
|
72 |
+## License |
|
73 |
+Miniver is in the public domain under a CC0 license. |