Skip to content
This repository was archived by the owner on Oct 7, 2022. It is now read-only.

Commit 0430a0a

Browse files
authored
Test pypi upload (#357)
* Implement test script to see if generated distributions can be installed * Add deployment script * Make sure old build artifacts are deleted before deploying
1 parent 255b575 commit 0430a0a

File tree

9 files changed

+269
-46
lines changed

9 files changed

+269
-46
lines changed

.gitignore

Lines changed: 1 addition & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -3,47 +3,6 @@
33
/.coverage
44
/build
55
/deploy_rsa
6-
/examples/*.txt
7-
/examples/aiohttp
8-
/examples/aiohttp.nix
9-
/examples/aiohttp_override.nix
10-
/examples/awscli_and_requests
11-
/examples/awscli_and_requests.nix
12-
/examples/connexion
13-
/examples/connexion.nix
14-
/examples/empy
15-
/examples/empy.nix
16-
/examples/empy_override.nix
17-
/examples/flake8
18-
/examples/flake8-includes
19-
/examples/flake8-includes.nix
20-
/examples/flake8-includes_override.nix
21-
/examples/flake8.nix
22-
/examples/flake8_override.nix
23-
/examples/ldap
24-
/examples/ldap.nix
25-
/examples/lektor
26-
/examples/lektor
27-
/examples/lektor.nix
28-
/examples/lektor.nix
29-
/examples/mercurial
30-
/examples/mercurial.nix
31-
/examples/mercurial_override.nix
32-
/examples/pillow
33-
/examples/pillow
34-
/examples/pillow.nix
35-
/examples/pillow.nix
36-
/examples/pillow_override.nix
37-
/examples/pillow_override.nix
38-
/examples/pypi2nix
39-
/examples/rss2email
40-
/examples/rss2email.nix
41-
/examples/rss2email_override.nix
42-
/examples/scipy
43-
/examples/scipy.nix
44-
/examples/tornado
45-
/examples/tornado.nix
46-
/examples/tornado_override.nix
476
/out/
487
/result*
498
/src/pypi2nix.egg-info/
@@ -62,4 +21,4 @@
6221
/dist/
6322
*.egg-info
6423
**/.eggs/**
65-
.mypy_cache
24+
.mypy_cache

.travis.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,3 +53,11 @@ jobs:
5353
- nix build
5454
- result/bin/pypi2nix --version
5555
- nix-shell --command 'pytest unittests/'
56+
- stage: package tests
57+
name: package installation
58+
os: linux
59+
env:
60+
- NIX_PATH=nixpkgs=https://github.com/NixOS/nixpkgs-channels/archive/nixos-unstable.tar.gz
61+
62+
script:
63+
- nix-shell --command 'install_test.py'

default.nix

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,9 @@ in python.mkDerivation {
4545
dontUseSetuptoolsShellHook = true;
4646
checkPhase = if doCheck then ''
4747
echo "Running black ..."
48-
black --check --diff -v setup.py src/ unittests/ mypy/ ${maybeIntegrationTestsDir}
48+
black --check --diff -v setup.py src/ unittests/ mypy/ ${maybeIntegrationTestsDir} scripts/
4949
echo "Running flake8 ..."
50-
flake8 -v setup.py src/ ${maybeIntegrationTestsDir} unittests/
50+
flake8 -v setup.py src/ ${maybeIntegrationTestsDir} unittests/ scripts/
5151
mypy --config-file setup.cfg src/
5252
mypy \
5353
--config-file setup.cfg \

requirements-dev.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,9 @@ attrs
1414
# develop
1515
pdbpp
1616

17+
# packaging
18+
twine
19+
1720
# setup requires
1821
pytest-runner
1922
setuptools-scm

requirements.nix

Lines changed: 129 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,25 @@ let
148148
};
149149
};
150150

151+
"bleach" = python.mkDerivation {
152+
name = "bleach-3.1.0";
153+
src = pkgs.fetchurl {
154+
url = "https://files.pythonhosted.org/packages/78/5a/0df03e8735cd9c75167528299c738702437589b9c71a849489d00ffa82e8/bleach-3.1.0.tar.gz";
155+
sha256 = "3fdf7f77adcf649c9911387df51254b813185e32b2c6619f690b593a617e19fa";
156+
};
157+
doCheck = commonDoCheck;
158+
buildInputs = commonBuildInputs ++ [ ];
159+
propagatedBuildInputs = [
160+
self."six"
161+
self."webencodings"
162+
];
163+
meta = with pkgs.stdenv.lib; {
164+
homepage = "https://github.com/mozilla/bleach";
165+
license = licenses.asl20;
166+
description = "An easy safelist-based HTML-sanitizing tool.";
167+
};
168+
};
169+
151170
"certifi" = python.mkDerivation {
152171
name = "certifi-2019.9.11";
153172
src = pkgs.fetchurl {
@@ -614,6 +633,22 @@ let
614633
};
615634
};
616635

636+
"pkginfo" = python.mkDerivation {
637+
name = "pkginfo-1.5.0.1";
638+
src = pkgs.fetchurl {
639+
url = "https://files.pythonhosted.org/packages/6c/04/fd6683d24581894be8b25bc8c68ac7a0a73bf0c4d74b888ac5fe9a28e77f/pkginfo-1.5.0.1.tar.gz";
640+
sha256 = "7424f2c8511c186cd5424bbf31045b77435b37a8d604990b79d4e70d741148bb";
641+
};
642+
doCheck = commonDoCheck;
643+
buildInputs = commonBuildInputs ++ [ ];
644+
propagatedBuildInputs = [ ];
645+
meta = with pkgs.stdenv.lib; {
646+
homepage = "https://code.launchpad.net/~tseaver/pkginfo/trunk";
647+
license = licenses.mit;
648+
description = "Query metadatdata from sdists / bdists / installed packages.";
649+
};
650+
};
651+
617652
"pluggy" = python.mkDerivation {
618653
name = "pluggy-0.13.0";
619654
src = pkgs.fetchurl {
@@ -800,6 +835,27 @@ let
800835
};
801836
};
802837

838+
"readme-renderer" = python.mkDerivation {
839+
name = "readme-renderer-24.0";
840+
src = pkgs.fetchurl {
841+
url = "https://files.pythonhosted.org/packages/44/de/a567140b13a0fc8d3b04d85a510b5a7d9869b44b2939fa8ac07c5e421485/readme_renderer-24.0.tar.gz";
842+
sha256 = "bb16f55b259f27f75f640acf5e00cf897845a8b3e4731b5c1a436e4b8529202f";
843+
};
844+
doCheck = commonDoCheck;
845+
buildInputs = commonBuildInputs ++ [ ];
846+
propagatedBuildInputs = [
847+
self."bleach"
848+
self."docutils"
849+
self."pygments"
850+
self."six"
851+
];
852+
meta = with pkgs.stdenv.lib; {
853+
homepage = "https://github.com/pypa/readme_renderer";
854+
license = licenses.asl20;
855+
description = "readme_renderer is a library for rendering \"readme\" descriptions for Warehouse";
856+
};
857+
};
858+
803859
"requests" = python.mkDerivation {
804860
name = "requests-2.22.0";
805861
src = pkgs.fetchurl {
@@ -821,6 +877,24 @@ let
821877
};
822878
};
823879

880+
"requests-toolbelt" = python.mkDerivation {
881+
name = "requests-toolbelt-0.9.1";
882+
src = pkgs.fetchurl {
883+
url = "https://files.pythonhosted.org/packages/28/30/7bf7e5071081f761766d46820e52f4b16c8a08fef02d2eb4682ca7534310/requests-toolbelt-0.9.1.tar.gz";
884+
sha256 = "968089d4584ad4ad7c171454f0a5c6dac23971e9472521ea3b6d49d610aa6fc0";
885+
};
886+
doCheck = commonDoCheck;
887+
buildInputs = commonBuildInputs ++ [ ];
888+
propagatedBuildInputs = [
889+
self."requests"
890+
];
891+
meta = with pkgs.stdenv.lib; {
892+
homepage = "https://toolbelt.readthedocs.org";
893+
license = licenses.asl20;
894+
description = "A utility belt for advanced users of python-requests";
895+
};
896+
};
897+
824898
"setuptools" = python.mkDerivation {
825899
name = "setuptools-41.4.0";
826900
src = pkgs.fetchurl {
@@ -885,6 +959,45 @@ let
885959
};
886960
};
887961

962+
"tqdm" = python.mkDerivation {
963+
name = "tqdm-4.36.1";
964+
src = pkgs.fetchurl {
965+
url = "https://files.pythonhosted.org/packages/80/b3/6ca4806441b730782fc4613c6aa2070412295c5521f33ae151988e448929/tqdm-4.36.1.tar.gz";
966+
sha256 = "abc25d0ce2397d070ef07d8c7e706aede7920da163c64997585d42d3537ece3d";
967+
};
968+
doCheck = commonDoCheck;
969+
buildInputs = commonBuildInputs ++ [ ];
970+
propagatedBuildInputs = [ ];
971+
meta = with pkgs.stdenv.lib; {
972+
homepage = "https://github.com/tqdm/tqdm";
973+
license = licenses.mit;
974+
description = "Fast, Extensible Progress Meter";
975+
};
976+
};
977+
978+
"twine" = python.mkDerivation {
979+
name = "twine-2.0.0";
980+
src = pkgs.fetchurl {
981+
url = "https://files.pythonhosted.org/packages/91/82/32c68749d10ae30dd126699ee471b8885d9a9ae326a0f25dac42bb6a3f28/twine-2.0.0.tar.gz";
982+
sha256 = "9fe7091715c7576df166df8ef6654e61bada39571783f2fd415bdcba867c6993";
983+
};
984+
doCheck = commonDoCheck;
985+
buildInputs = commonBuildInputs ++ [ ];
986+
propagatedBuildInputs = [
987+
self."pkginfo"
988+
self."readme-renderer"
989+
self."requests"
990+
self."requests-toolbelt"
991+
self."setuptools"
992+
self."tqdm"
993+
];
994+
meta = with pkgs.stdenv.lib; {
995+
homepage = "https://twine.readthedocs.io/";
996+
license = licenses.asl20;
997+
description = "Collection of utilities for publishing packages on PyPI";
998+
};
999+
};
1000+
8881001
"typed-ast" = python.mkDerivation {
8891002
name = "typed-ast-1.4.0";
8901003
src = pkgs.fetchurl {
@@ -949,6 +1062,22 @@ let
9491062
};
9501063
};
9511064

1065+
"webencodings" = python.mkDerivation {
1066+
name = "webencodings-0.5.1";
1067+
src = pkgs.fetchurl {
1068+
url = "https://files.pythonhosted.org/packages/0b/02/ae6ceac1baeda530866a85075641cec12989bd8d31af6d5ab4a3e8c92f47/webencodings-0.5.1.tar.gz";
1069+
sha256 = "b36a1c245f2d304965eb4e0a82848379241dc04b865afcc4aab16748587e1923";
1070+
};
1071+
doCheck = commonDoCheck;
1072+
buildInputs = commonBuildInputs ++ [ ];
1073+
propagatedBuildInputs = [ ];
1074+
meta = with pkgs.stdenv.lib; {
1075+
homepage = "https://github.com/SimonSapin/python-webencodings";
1076+
license = licenses.bsdOriginal;
1077+
description = "Character encoding aliases for legacy web content";
1078+
};
1079+
};
1080+
9521081
"wheel" = python.mkDerivation {
9531082
name = "wheel-0.33.6";
9541083
src = pkgs.fetchurl {

requirements_frozen.txt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ appdirs==1.4.3
22
atomicwrites==1.3.0
33
attrs==19.3.0
44
black==19.3b0
5+
bleach==3.1.0
56
certifi==2019.9.11
67
chardet==3.0.4
78
Click==7.0
@@ -28,6 +29,7 @@ nix-prefetch-github==2.3.1
2829
packaging==19.2
2930
Parsley==1.3
3031
pdbpp==0.10.2
32+
pkginfo==1.5.0.1
3133
pluggy==0.13.0
3234
py==1.8.0
3335
pycodestyle==2.5.0
@@ -38,13 +40,18 @@ pytest==5.2.2
3840
pytest-cov==2.8.1
3941
pytest-runner==5.1
4042
pytoml==0.1.21
43+
readme-renderer==24.0
4144
requests==2.22.0
45+
requests-toolbelt==0.9.1
4246
setuptools-scm==3.3.3
4347
six==1.12.0
4448
toml==0.10.0
49+
tqdm==4.36.1
50+
twine==2.0.0
4551
typed-ast==1.4.0
4652
typing-extensions==3.7.4
4753
urllib3==1.25.6
4854
wcwidth==0.1.7
55+
webencodings==0.5.1
4956
wmctrl==0.3
5057
zipp==0.6.0

scripts/deploy_to_pypi.py

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
#!/usr/bin/env python
2+
import argparse
3+
import os
4+
import shutil
5+
import subprocess
6+
7+
from pypi2nix.version import pypi2nix_version
8+
9+
10+
def main():
11+
set_up_environment()
12+
args = parse_args()
13+
pypi_name = get_pypi_name_from_args(args)
14+
remove_old_build_artifacts()
15+
deploy_to(pypi_name)
16+
17+
18+
def set_up_environment():
19+
os.putenv("SOURCE_DATE_EPOCH", "315532800")
20+
21+
22+
def parse_args():
23+
parser = argparse.ArgumentParser(description="Deploy pypi2nix to pypi")
24+
parser.add_argument("--production", action="store_true", default=False)
25+
return parser.parse_args()
26+
27+
28+
def get_pypi_name_from_args(args):
29+
return "pypi" if args.production else "test-pypi"
30+
31+
32+
def remove_old_build_artifacts():
33+
shutil.rmtree("src/pypi2nix.egg-info", ignore_errors=True)
34+
35+
36+
def deploy_to(pypi_name):
37+
subprocess.run(["python", "setup.py", "sdist", "bdist_wheel"], check=True)
38+
distribution_paths = [
39+
f"dist/pypi2nix-{pypi2nix_version}.tar.gz",
40+
f"dist/pypi2nix-{pypi2nix_version}-py3-none-any.whl",
41+
]
42+
subprocess.run(
43+
["twine", "upload", "-r", pypi_name] + distribution_paths, check=True
44+
)
45+
46+
47+
if __name__ == "__main__":
48+
main()

0 commit comments

Comments
 (0)