diff --git a/.gitignore b/.gitignore
index 52e4e61140d1226f5ba80676d1973baa298d3b23..820ef3628459e8107a44669ff8fa8fa796e15d9d 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,2 +1,7 @@
 *.pyc
 *.pyo
+dist/
+build/
+MANIFEST
+*.egg-info/
+scapy/VERSION
diff --git a/MANIFEST.in b/MANIFEST.in
index 7c33aff5294273cbf414c418d66b075a02901b9d..880a3f51ab8dfaa70fca921d696ad56ed36157c8 100644
--- a/MANIFEST.in
+++ b/MANIFEST.in
@@ -3,3 +3,4 @@ include run_scapy
 recursive-include bin *
 recursive-include doc *
 recursive-include test *
+include scapy/VERSION
diff --git a/README b/README
new file mode 120000
index 0000000000000000000000000000000000000000..42061c01a1c70097d1e4579f29a5adf40abdec95
--- /dev/null
+++ b/README
@@ -0,0 +1 @@
+README.md
\ No newline at end of file
diff --git a/scapy/__init__.py b/scapy/__init__.py
index 443b36753f7f543c88564c4b8abe0f9bd5fd84ad..2be2f82d216b0ec66aacdfe9bfaa9036428f664d 100644
--- a/scapy/__init__.py
+++ b/scapy/__init__.py
@@ -3,6 +3,8 @@
 ## Copyright (C) Philippe Biondi <phil@secdev.org>
 ## This program is published under a GPLv2 license
 
+from __future__ import with_statement
+
 """
 Scapy: create, send, sniff, dissect and manipulate network packets.
 
@@ -10,6 +12,71 @@ Usable either from an interactive console or as a Python library.
 http://www.secdev.org/projects/scapy
 """
 
+import os
+import re
+import subprocess
+
+
+_SCAPY_PKG_DIR = os.path.dirname(__file__)
+
+def _version_from_git_describe():
+    """
+    Read the version from ``git describe``. It returns the latest tag with an
+    optional suffix if the current directory is not exactly on the tag.
+
+    Example::
+
+        $ git describe --always
+        v2.3.2-346-g164a52c075c8
+
+    The tag prefix (``v``) and the git commit sha1 (``-g164a52c075c8``) are
+    removed if present.
+
+    If the current directory is not exactly on the tag, a ``.devN`` suffix is
+    appended where N is the number of commits made after the last tag.
+
+    Example::
+
+        >>> _version_from_git_describe()
+        '2.3.2.dev346'
+    """
+    p = subprocess.Popen(['git', 'describe', '--always'], cwd=_SCAPY_PKG_DIR,
+                         stdout=subprocess.PIPE, stderr=subprocess.PIPE)
+
+    out, err = p.communicate()
+
+    if p.returncode == 0:
+        tag = out.strip()
+        match = re.match(r'^v?(.+?)-(\d+)-g[a-f0-9]+$', tag)
+        if match:
+            # remove the 'v' prefix and add a '.devN' suffix
+            return '%s.dev%s' % (match.group(1), match.group(2))
+        else:
+            # just remove the 'v' prefix
+            return re.sub(r'^v', '', tag)
+    else:
+        raise subprocess.CalledProcessError(p.returncode, err)
+
+def _version():
+    version_file = os.path.join(_SCAPY_PKG_DIR, 'VERSION')
+    try:
+        tag = _version_from_git_describe()
+        # successfully read the tag from git, write it in VERSION for
+        # installation and/or archive generation.
+        with open(version_file, 'w') as f:
+            f.write(tag)
+        return tag
+    except:
+        # failed to read the tag from git, try to read it from a VERSION file
+        try:
+            with open(version_file, 'r') as f:
+                tag = f.read()
+            return tag
+        except:
+            return 'unknown.version'
+
+VERSION = _version()
+
 if __name__ == "__main__":
     from scapy.main import interact
     interact()
diff --git a/scapy/config.py b/scapy/config.py
index 9160a88e8eea52d4871783b081991466b4f4a60a..f11bcc560f60d5df814bc602c1be4a7d27fcb70d 100755
--- a/scapy/config.py
+++ b/scapy/config.py
@@ -9,6 +9,7 @@ Implementation for of the configuration object.
 
 import os,time,socket,sys
 
+from scapy import VERSION
 from scapy.data import *
 from scapy import base_classes
 from scapy import themes
@@ -319,7 +320,7 @@ noenum    : holds list of enum fields for which conversion to string should NOT
 AS_resolver: choose the AS resolver class to use
 extensions_paths: path or list of paths where extensions are to be looked for
 """
-    version = "2.3.2-dev"
+    version = VERSION
     session = ""
     interactive = False
     interactive_shell = ""
diff --git a/setup.cfg b/setup.cfg
index b88034e414bc7b80d686e3c94d516305348053ea..609d6dfa9b03b8bde5e94b3201feb96f22579052 100644
--- a/setup.cfg
+++ b/setup.cfg
@@ -1,2 +1,7 @@
 [metadata]
 description-file = README.md
+
+[sdist]
+formats=gztar
+owner=root
+group=root
diff --git a/setup.py b/setup.py
index f6771427ed9aad771d781ab5b07fd1a869e9f535..53bf808d313ddc0c44c0a146056d99aa23bc6533 100755
--- a/setup.py
+++ b/setup.py
@@ -47,7 +47,7 @@ if os.name == "nt":
 
 setup(
     name='scapy',
-    version='2.3.2-dev',
+    version=__import__('scapy').VERSION,
     packages=[
         'scapy',
         'scapy/arch',
@@ -62,6 +62,9 @@ setup(
     ],
     scripts=SCRIPTS,
     data_files=[('share/man/man1', ["doc/scapy.1.gz"])],
+    package_data={
+        'scapy': ['VERSION'],
+    },
 
     # Metadata
     author='Philippe BIONDI',